Class: InstanceAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/deltacloud/models/instance_address.rb

Overview

Model to store the hardware profile applied to an instance together with any instance-specific overrides

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, opts = {}) ⇒ InstanceAddress

Returns a new instance of InstanceAddress.



24
25
26
27
28
29
# File 'lib/deltacloud/models/instance_address.rb', line 24

def initialize(address, opts={})
  self.address = address
  self.port = opts[:port] if opts[:port]
  self.address_type = opts[:type] || :ipv4
  self
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



20
21
22
# File 'lib/deltacloud/models/instance_address.rb', line 20

def address
  @address
end

#address_typeObject

Returns the value of attribute address_type.



22
23
24
# File 'lib/deltacloud/models/instance_address.rb', line 22

def address_type
  @address_type
end

#portObject

Returns the value of attribute port.



21
22
23
# File 'lib/deltacloud/models/instance_address.rb', line 21

def port
  @port
end

Instance Method Details

#is_hostname?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/deltacloud/models/instance_address.rb', line 61

def is_hostname?
  address_type == :hostname
end

#is_ipv4?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/deltacloud/models/instance_address.rb', line 53

def is_ipv4?
  address_type == :ipv4
end

#is_ipv6?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/deltacloud/models/instance_address.rb', line 57

def is_ipv6?
  address_type == :ipv6
end

#is_mac?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/deltacloud/models/instance_address.rb', line 49

def is_mac?
  address_type == :mac
end

#is_vnc?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/deltacloud/models/instance_address.rb', line 65

def is_vnc?
  address_type == :vnc
end

#to_hash(context) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/deltacloud/models/instance_address.rb', line 40

def to_hash(context)
  r = {
    :address => address,
    :type => address_type
  }
  r.merge!(:port => port) if !port.nil?
  r
end

#to_sObject



35
36
37
38
# File 'lib/deltacloud/models/instance_address.rb', line 35

def to_s
  return ['VNC', address, port].join(':') if is_vnc?
  address
end