Class: Azure::Vnet

Inherits:
Object
  • Object
show all
Defined in:
lib/azure/vnet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Vnet

Returns a new instance of Vnet.



60
61
62
# File 'lib/azure/vnet.rb', line 60

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#affinity_groupObject

Returns the value of attribute affinity_group.



58
59
60
# File 'lib/azure/vnet.rb', line 58

def affinity_group
  @affinity_group
end

#nameObject

Returns the value of attribute name.



58
59
60
# File 'lib/azure/vnet.rb', line 58

def name
  @name
end

#stateObject

Returns the value of attribute state.



58
59
60
# File 'lib/azure/vnet.rb', line 58

def state
  @state
end

Instance Method Details

#create(params) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/azure/vnet.rb', line 71

def create(params)
  response = @connection.query_azure('networking/media')
  vnets = response.css('VirtualNetworkSite')
  vnet = nil
  vnets.each { |vn| vnet = vn if vn['name'] == params[:azure_vnet_name] }
  add = vnet.nil?
  vnet = Nokogiri::XML::Node.new('VirtualNetworkSite', response) if add
  vnet['name'] = params[:azure_vnet_name]
  vnet['AffinityGroup'] = params[:azure_ag_name]
  addr_space = Nokogiri::XML::Node.new('AddressSpace', response)
  addr_prefix = Nokogiri::XML::Node.new('AddressPrefix', response)
  addr_prefix.content = params[:azure_address_space]
  addr_space.children = addr_prefix
  vnet.children = addr_space
  vnets.last.add_next_sibling(vnet) if add
  @connection.query_azure('networking/media', 'put', response.to_xml)
end

#parse(image) ⇒ Object



64
65
66
67
68
69
# File 'lib/azure/vnet.rb', line 64

def parse(image)
  @name = image.at_css('Name').content
  @affinity_group = image.at_css('AffinityGroup').content
  @state = image.at_css('State').content
  self
end