mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-28 17:47:03 +03:00
* B #4990 retrieve vlanID query * B #4990: parse vlanid * B #4990 ask for integer values
This commit is contained in:
parent
069d995b98
commit
36cb9acb33
@ -351,7 +351,7 @@ class DatacenterFolder
|
||||
result = pc.RetrieveProperties(:specSet => [filterSpec])
|
||||
|
||||
networks = {}
|
||||
result.each do |r|
|
||||
result.each do |r|
|
||||
networks[r.obj._ref] = r.to_hash if r.obj.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) || r.obj.is_a?(RbVmomi::VIM::Network)
|
||||
networks[r.obj._ref][:network_type] = r.obj.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) ? "Distributed Port Group" : "Port Group"
|
||||
end
|
||||
|
@ -651,6 +651,21 @@ def self.import_networks(con_ops, options)
|
||||
next if STDIN.gets.strip.downcase != 'y'
|
||||
end
|
||||
|
||||
# we try to retrieve once we know the desired net
|
||||
net = VCenterDriver::Network.new_from_ref(n[:vcenter_net_ref], vi_client)
|
||||
vid = VCenterDriver::Network.retrieve_vlanid(net.item) if net
|
||||
|
||||
if vid
|
||||
vlanid = VCenterDriver::Network.vlanid(vid)
|
||||
|
||||
# we have vlan id
|
||||
if /\A\d+\z/.match(vlanid)
|
||||
n[:one] << "VCENTER_VLAN_ID=\"#{vlanid}\"\n"
|
||||
STDOUT.print " - vcenter vlan id = #{vlanid}\n"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
size="255"
|
||||
ar_type="e"
|
||||
first_ip=nil
|
||||
|
@ -66,7 +66,30 @@ class Network
|
||||
!device.class.ancestors.index(RbVmomi::VIM::VirtualEthernetCard).nil?
|
||||
end
|
||||
|
||||
def self.vlanid(vid)
|
||||
case vid
|
||||
when -1
|
||||
"error"
|
||||
when 0
|
||||
"disabled"
|
||||
when 4095
|
||||
"VGT"
|
||||
else
|
||||
"#{vid}"
|
||||
end
|
||||
end
|
||||
|
||||
def self.retrieve_vlanid(network)
|
||||
begin
|
||||
name = network.name
|
||||
id = network.host.first.configManager.networkSystem.networkConfig.portgroup.select{|p|
|
||||
p.spec.name == name
|
||||
}.first.spec.vlanId
|
||||
rescue
|
||||
id = -1
|
||||
end
|
||||
return id
|
||||
end
|
||||
|
||||
def self.to_one_template(network_name, network_ref, network_type,
|
||||
ccr_ref, ccr_name, vcenter_uuid,
|
||||
@ -94,6 +117,7 @@ class Network
|
||||
one_tmp[:cluster_location] = cluster_location
|
||||
one_tmp[:vcenter_ccr_ref] = ccr_ref
|
||||
one_tmp[:one_cluster_id] = cluster_id
|
||||
one_tmp[:vcenter_net_ref] = network_ref
|
||||
|
||||
one_tmp[:one] = to_one(network_import_name, network_name, network_ref, network_type,
|
||||
ccr_ref, vcenter_uuid, unmanaged, template_ref, dc_ref, template_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user