Class: Fog::Compute::ProfitBricks::Nic
Instance Attribute Summary collapse
Instance Method Summary
collapse
#flatten
#failed?, #ready?, #request_status, #wait_for
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
37
38
39
|
# File 'lib/fog/profitbricks/models/compute/nic.rb', line 37
def options
@options
end
|
Instance Method Details
#delete ⇒ Object
74
75
76
77
78
|
# File 'lib/fog/profitbricks/models/compute/nic.rb', line 74
def delete
requires :datacenter_id, :server_id, :id
service.delete_nic(datacenter_id, server_id, id)
true
end
|
#get_firewall_rules(firewall_rules) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/fog/profitbricks/models/compute/nic.rb', line 96
def get_firewall_rules(firewall_rules)
items = []
firewall_rules.each do |firewall_rule|
item = {}
item[:name] = firewall_rule[:name] if firewall_rule.key?(:name)
item[:protocol] = firewall_rule[:protocol] if firewall_rule.key?(:protocol)
item[:sourceMac] = firewall_rule[:source_mac] if firewall_rule.key?(:source_mac)
item[:sourceIp] = firewall_rule[:source_ip] if firewall_rule.key?(:source_ip)
item[:targetIp] = firewall_rule[:target_ip] if firewall_rule.key?(:target_ip)
item[:portRangeStart] = firewall_rule[:port_range_start] if firewall_rule.key?(:port_range_start)
item[:portRangeEnd] = firewall_rule[:port_range_end] if firewall_rule.key?(:port_range_end)
item[:icmpType] = firewall_rule[:icmp_type] if firewall_rule.key?(:icmp_type)
item[:icmpCode] = firewall_rule[:icmp_code] if firewall_rule.key?(:icmp_code)
items << { :properties => item }
end
{ :items => items }
end
|
#reload ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/fog/profitbricks/models/compute/nic.rb', line 80
def reload
requires :datacenter_id, :server_id, :id
data = begin
collection.get(datacenter_id, server_id, id)
rescue Excon::Errors::SocketError
nil
end
return unless data
new_attributes = data.attributes
merge_attributes(new_attributes)
self
end
|
#save ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/fog/profitbricks/models/compute/nic.rb', line 39
def save
requires :datacenter_id, :server_id, :lan
properties = {}
properties[:name] = name if name
properties[:ips] = ips if ips
properties[:dhcp] = dhcp if dhcp
properties[:lan] = lan if lan
properties[:nat] = nat if nat
properties[:firewallActive] = firewall_active if firewall_active
entities = {}
if firewall_rules
properties[:firewallActive] = true
entities[:firewallrules] = get_firewall_rules(firewall_rules)
end
data = service.create_nic(datacenter_id, server_id, properties, entities)
merge_attributes(flatten(data.body))
end
|
#update ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/fog/profitbricks/models/compute/nic.rb', line 60
def update
requires :datacenter_id, :server_id, :id
properties = {}
properties[:name] = name if name
properties[:ips] = ips if ips
properties[:dhcp] = dhcp if dhcp
properties[:lan] = lan if lan
properties[:nat] = nat if nat
data = service.update_nic(datacenter_id, server_id, id, properties)
merge_attributes(data.body)
end
|