Class: Puppet::Provider::Junos::SSH_auth_key

Inherits:
Puppet::Provider::Junos
  • Object
show all
Defined in:
lib/junos-ez/system/user_ssh_keys.rb

Instance Method Summary collapse

Instance Method Details

#get_junos_configObject



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 81

def get_junos_config
  
  @ndev_res ||= NetdevJunos::Resource.new( self, 'system/login', 'user' )   
  @ndev_res[:unmanaged_active] = true
  
  return nil unless (ndev_config = @ndev_res.getconfig)    
  return nil unless auth_config = ndev_config.xpath("//user/authentication/ssh-rsa")[0]                  
  @ndev_res.set_active_state( auth_config )        
  
  return auth_config        
end

#netdev_res_exists?Boolean


triggered by provider #exists?


Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 43

def netdev_res_exists?     
  
  # cannot manage the 'active' parameter from the puppet manifest since the
  # type definition is compiled on the server, and doesn't include this :-(
  # so fake it here, set to true always.  this way if someone deactivated
  # it apriori, then this puppet-run will make it active again.

  return false unless (auth = get_junos_config)

  got_key = auth.text.strip
  got_key_skip = got_key.index(' ') + 1
  got_key = got_key[ got_key_skip .. -1 ]
  
  @ndev_res[:key] = got_key
  @ndev_res[:user] = resource[:user]
  @ndev_res[:type] = resource[:type]
  @ndev_res[:target] = resource[:target]
  @ndev_res[:options] = resource[:options]
  
  return true    
end

#netdev_resxml_top(xml) ⇒ Object


—> override parent method <—-




69
70
71
72
73
74
75
76
77
78
79
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 69

def netdev_resxml_top( xml )
  xml.user {
    xml.name resource[:user]
    xml.authentication {
      xml.send(:'ssh-rsa') {
        xml.name 'ssh-rsa ' + resource[:key]
        return xml
      }
    }
  }    
end

#xml_change_key(xml) ⇒ Object



101
102
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 101

def xml_change_key( xml )
end

#xml_change_options(xml) ⇒ Object



110
111
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 110

def xml_change_options( xml )
end

#xml_change_target(xml) ⇒ Object



107
108
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 107

def xml_change_target( xml ) 
end

#xml_change_type(xml) ⇒ Object


XML builder routines, one for each property




98
99
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 98

def xml_change_type( xml ) 
end

#xml_change_user(xml) ⇒ Object



104
105
# File 'lib/junos-ez/system/user_ssh_keys.rb', line 104

def xml_change_user( xml )
end