mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-14 19:24:10 +03:00
feature #1977: Fix Attach/Detach and PCI set functionality
This commit is contained in:
parent
1e500f0ec0
commit
9c75891fe9
@ -47,6 +47,8 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
string guestOS = "";
|
||||
string pciBridge = "";
|
||||
|
||||
const VectorAttribute * features;
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VectorAttribute * context;
|
||||
|
||||
@ -182,6 +184,29 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Features
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
num = vm->get_template_attribute("FEATURES",attrs);
|
||||
|
||||
if ( num > 0 )
|
||||
{
|
||||
features = dynamic_cast<const VectorAttribute *>(attrs[0]);
|
||||
|
||||
if ( features != 0 )
|
||||
{
|
||||
pciBridge = features->vector_value("PCIBRIDGE");
|
||||
|
||||
if (!pciBridge.empty())
|
||||
{
|
||||
metadata << "<pcibridge>" << pciBridge << "</pcibridge>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attrs.clear();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Disks
|
||||
// ------------------------------------------------------------------------
|
||||
@ -435,17 +460,6 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
|
||||
file << "\t</devices>" << endl;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Special Attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
vm->get_template_attribute("PCIBRIDGE",pciBridge);
|
||||
|
||||
if (!pciBridge.empty())
|
||||
{
|
||||
metadata << "<pcibridge>" << pciBridge.c_str() << "</pcibridge>";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Raw VMware attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -26,6 +26,5 @@
|
||||
#VCPU = 1
|
||||
|
||||
OS = [ ARCH = i686 ]
|
||||
PCIBRIDGE = "YES"
|
||||
#DISK = [ DRIVER = file ]
|
||||
|
||||
|
@ -39,4 +39,4 @@ VIDriver::initialize(host, false)
|
||||
|
||||
vivm = VIDriver::VIVm.new(deploy_id, nil)
|
||||
|
||||
puts vivm.attach_nic(bridge, model, mac)
|
||||
puts vivm.attach_nic(bridge, mac, model)
|
||||
|
@ -33,6 +33,6 @@ require 'vi_driver'
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
vi_drv = VIDriver.new(host)
|
||||
VIDriver::initialize(host)
|
||||
|
||||
puts vi_drv.poll_vm(deploy_id)
|
||||
puts VIDriver::poll_vm(deploy_id)
|
||||
|
@ -157,9 +157,9 @@ class VIVm
|
||||
return if (pciBridge.nil? || pciBridge.empty? )
|
||||
|
||||
if pciBridge.downcase == "yes"
|
||||
spec = { :key => "pciBridge0.present", :value => "TRUE" }
|
||||
spec = [ :key => "pciBridge0.present", :value => "TRUE" ]
|
||||
else
|
||||
spec = { :key => "pciBridge0.present", :value => "FALSE" }
|
||||
spec = [ :key => "pciBridge0.present", :value => "FALSE" ]
|
||||
end
|
||||
|
||||
vmspec = RbVmomi::VIM.VirtualMachineConfigSpec(:extraConfig => spec)
|
||||
@ -170,7 +170,7 @@ class VIVm
|
||||
########################################################################
|
||||
#
|
||||
########################################################################
|
||||
def attach_nic(bridge, model, mac)
|
||||
def attach_nic(bridge, mac, model='default')
|
||||
return if bridge.empty? || mac.empty?
|
||||
|
||||
card_num = 1 # start in one, we want the next avaiable id
|
||||
@ -213,21 +213,18 @@ class VIVm
|
||||
# Initialize the vm monitor information
|
||||
########################################################################
|
||||
def detach_nic(mac)
|
||||
nic_to_detach = nil
|
||||
|
||||
@vm.config.hardware.device.each{ |dv|
|
||||
if dv.class.ancestors[1] == RbVmomi::VIM::VirtualEthernetCard
|
||||
nic_to_detach = dv if dv.macAddress == mac
|
||||
break
|
||||
end
|
||||
eth = @vm.config.hardware.device.find { |d|
|
||||
(d.class.ancestors[1] == RbVmomi::VIM::VirtualEthernetCard) &&
|
||||
(d.macAddress == mac)
|
||||
}
|
||||
|
||||
return -1 if !nic_to_detach
|
||||
return -1 if eth.nil?
|
||||
|
||||
spec = {
|
||||
:deviceChange => [
|
||||
:operation => :remove,
|
||||
:device => nic_to_detach
|
||||
:device => eth
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user