Class: Vcloud::Core::EdgeGateway
- Inherits:
-
Object
- Object
- Vcloud::Core::EdgeGateway
- Defined in:
- lib/vcloud/core/edge_gateway.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #href ⇒ Object
-
#initialize(id) ⇒ EdgeGateway
constructor
A new instance of EdgeGateway.
- #interfaces ⇒ Object
- #name ⇒ Object
- #update_configuration(config) ⇒ Object
- #vcloud_attributes ⇒ Object
- #vcloud_gateway_interface_by_id(gateway_interface_id) ⇒ Object
Constructor Details
#initialize(id) ⇒ EdgeGateway
Returns a new instance of EdgeGateway.
7 8 9 10 11 12 |
# File 'lib/vcloud/core/edge_gateway.rb', line 7 def initialize(id) unless id =~ /^[-0-9a-f]+$/ raise "EdgeGateway id : #{id} is not in correct format" end @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/vcloud/core/edge_gateway.rb', line 5 def id @id end |
Class Method Details
.get_by_name(name) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/vcloud/core/edge_gateway.rb', line 37 def self.get_by_name(name) ids = self.get_ids_by_name(name) raise "edgeGateway #{name} not found" if ids.size == 0 raise "edgeGateway #{name} is not unique" if ids.size > 1 return self.new(ids.first) end |
.get_ids_by_name(name) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/vcloud/core/edge_gateway.rb', line 14 def self.get_ids_by_name(name) q = Vcloud::Core::QueryRunner.new query_results = q.run('edgeGateway', :filter => "name==#{name}") raise "Error finding edgeGateway by name #{name}" unless query_results query_results.collect do |record| record[:href].split('/').last if record.key?(:href) end end |
Instance Method Details
#href ⇒ Object
49 50 51 |
# File 'lib/vcloud/core/edge_gateway.rb', line 49 def href vcloud_attributes[:href] end |
#interfaces ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/vcloud/core/edge_gateway.rb', line 57 def interfaces gateway_config = vcloud_attributes[:Configuration] return [] unless gateway_config[:GatewayInterfaces] gateway_interfaces = gateway_config[:GatewayInterfaces][:GatewayInterface] return [] unless gateway_interfaces gateway_interfaces.map do |vcloud_gateway_interface_hash| EdgeGatewayInterface.new(vcloud_gateway_interface_hash) end end |
#name ⇒ Object
53 54 55 |
# File 'lib/vcloud/core/edge_gateway.rb', line 53 def name vcloud_attributes[:name] end |
#update_configuration(config) ⇒ Object
23 24 25 26 |
# File 'lib/vcloud/core/edge_gateway.rb', line 23 def update_configuration(config) fsi = Vcloud::Fog::ServiceInterface.new fsi.post_configure_edge_gateway_services(id, config) end |
#vcloud_attributes ⇒ Object
44 45 46 47 |
# File 'lib/vcloud/core/edge_gateway.rb', line 44 def vcloud_attributes fsi = Vcloud::Fog::ServiceInterface.new fsi.get_edge_gateway(id) end |
#vcloud_gateway_interface_by_id(gateway_interface_id) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/vcloud/core/edge_gateway.rb', line 28 def vcloud_gateway_interface_by_id gateway_interface_id gateway_interfaces = vcloud_attributes[:Configuration][:GatewayInterfaces][:GatewayInterface] unless gateway_interfaces.empty? return gateway_interfaces.find{ |interface| interface[:Network][:href].split('/').last == gateway_interface_id } end end |