Class: Vcloud::Core::OrgVdcNetwork
- Inherits:
-
Object
- Object
- Vcloud::Core::OrgVdcNetwork
- Defined in:
- lib/vcloud/core/org_vdc_network.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #href ⇒ Object
-
#initialize(id) ⇒ OrgVdcNetwork
constructor
A new instance of OrgVdcNetwork.
- #name ⇒ Object
- #vcloud_attributes ⇒ Object
Constructor Details
#initialize(id) ⇒ OrgVdcNetwork
Returns a new instance of OrgVdcNetwork.
7 8 9 10 11 12 |
# File 'lib/vcloud/core/org_vdc_network.rb', line 7 def initialize(id) unless id =~ /^[-0-9a-f]+$/ raise "orgVdcNetwork 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/org_vdc_network.rb', line 5 def id @id end |
Class Method Details
.provision(config) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vcloud/core/org_vdc_network.rb', line 14 def self.provision(config) raise "Must specify a name" unless name = config[:name] raise "Must specify a vdc_name" unless vdc_name = config[:vdc_name] unless config[:fence_mode] == 'isolated' || config[:fence_mode] == 'natRouted' raise "fence_mode #{config[:fence_mode]} not supported. Must be 'isolated' or 'natRouted'" end config[:is_shared] = false unless config[:is_shared] if config[:fence_mode] == 'natRouted' raise "Must specify an edge_gateway to connect to" unless config.key?(:edge_gateway) edgegw = Vcloud::Core::EdgeGateway.get_by_name(config[:edge_gateway]) end vdc = Vcloud::Core::Vdc.get_by_name(vdc_name) = (config) [:EdgeGateway] = { :href => edgegw.href } if edgegw begin Vcloud::Core.logger.info("Provisioning new OrgVdcNetwork #{name} in vDC '#{vdc_name}'") attrs = Vcloud::Fog::ServiceInterface.new.post_create_org_vdc_network(vdc.id, name, ) rescue RuntimeError => e Vcloud::Core.logger.error("Could not provision orgVdcNetwork: #{e.}") end raise "Did not successfully create orgVdcNetwork" unless attrs && attrs.key?(:href) self.new(attrs[:href].split('/').last) end |
Instance Method Details
#delete ⇒ Object
58 59 60 |
# File 'lib/vcloud/core/org_vdc_network.rb', line 58 def delete Vcloud::Fog::ServiceInterface.new.delete_network(id) end |
#href ⇒ Object
54 55 56 |
# File 'lib/vcloud/core/org_vdc_network.rb', line 54 def href vcloud_attributes[:href] end |
#name ⇒ Object
50 51 52 |
# File 'lib/vcloud/core/org_vdc_network.rb', line 50 def name vcloud_attributes[:name] end |
#vcloud_attributes ⇒ Object
46 47 48 |
# File 'lib/vcloud/core/org_vdc_network.rb', line 46 def vcloud_attributes Vcloud::Fog::ServiceInterface.new.get_network(id) end |