Class: Staypuft::Deployment::NeutronService::Cisconexus

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Serializers::JSON, ActiveModel::Validations
Defined in:
app/models/staypuft/deployment/neutron_service/cisconexus.rb

Defined Under Namespace

Modules: Hostname, Ip, Login, Password, PortMap, SshPort Classes: IpValueValidator, PortMapValueValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Cisconexus

Returns a new instance of Cisconexus.



70
71
72
73
74
75
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 70

def initialize(attrs = {})
  @errors = ActiveModel::Errors.new(self)
  # Default ssh port to 22, but let args override
  self.ssh_port = 22
  self.attributes = attrs
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 9

def errors
  @errors
end

#hostnameObject

Returns the value of attribute hostname.



8
9
10
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 8

def hostname
  @hostname
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 8

def id
  @id
end

#ipObject

Returns the value of attribute ip.



8
9
10
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 8

def ip
  @ip
end

#loginObject

Returns the value of attribute login.



8
9
10
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 8

def 
  @login
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 8

def password
  @password
end

#port_mapObject

Returns the value of attribute port_map.



8
9
10
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 8

def port_map
  @port_map
end

#ssh_portObject

Returns the value of attribute ssh_port.



8
9
10
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 8

def ssh_port
  @ssh_port
end

Class Method Details

.human_attribute_name(attr, options = {}) ⇒ Object



77
78
79
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 77

def self.human_attribute_name(attr, options = {})
  attr
end

.lookup_ancestorsObject



81
82
83
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 81

def self.lookup_ancestors
  [self]
end

Instance Method Details

#attributesObject



97
98
99
100
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 97

def attributes
  { 'hostname' => nil, 'ip' => nil, 'login' => nil, 'password' => nil,
    'port_map' => nil, 'ssh_port' => nil }
end

#attributes=(attrs) ⇒ Object



102
103
104
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 102

def attributes=(attrs)
  attrs.each { |attr, value| send "#{attr}=", value } unless attrs.nil?
end

#config_hashObject



85
86
87
88
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 85

def config_hash
  { "ip_address" => ip, "username" => , "password" => password,
    "ssh_port" => ssh_port, "servers" => port_map_hash }
end

#port_map_hashObject



90
91
92
93
94
95
# File 'app/models/staypuft/deployment/neutron_service/cisconexus.rb', line 90

def port_map_hash
  Hash[port_map.each_line.map do |line|
    server = line.split(':')
    [ server.first.strip, server.last.strip ]
  end]
end