src/vsphere_cpi/lib/cloud/vsphere/drs_rules/vm_group.rb
def add_vm_to_vm_group(vm, vm_group_name)
      DrsLock.new(@vm_attribute_manager, DRS_LOCK_VMGROUP ).with_drs_lock do
        vm_group = find_vm_group(vm_group_name)
        logger.debug("VmGroup: #{vm_group_name} already exists") unless vm_group.nil?

        vm_group_spec = VimSdk::Vim::Cluster::VmGroup.new
        vm_group_spec.vm = vm_group ? vm_group.vm.concat([vm]) : [vm]
        vm_group_spec.name = vm_group_name

        group_spec = VimSdk::Vim::Cluster::GroupSpec.new
        group_spec.info = vm_group_spec

        group_spec.operation = vm_group ? VimSdk::Vim::Option::ArrayUpdateSpec::Operation::EDIT : VimSdk::Vim::Option::ArrayUpdateSpec::Operation::ADD

        config_spec = VimSdk::Vim::Cluster::ConfigSpecEx.new
        config_spec.group_spec = [group_spec]

        logger.debug("Adding VM to VM group: #{vm_group_name}")
        reconfigure_cluster(config_spec)
      end
    end
# Adds VM to given VM Group
# @param [Vim::VirtualMachine] vm
# @params [String] vm_group_name
Adds VM to given VM Group
Adds VM to given VM Group
def add_vm_to_vm_group(vm, vm_group_name)
      DrsLock.new(@vm_attribute_manager, DRS_LOCK_VMGROUP ).with_drs_lock do
        vm_group = find_vm_group(vm_group_name)
        logger.debug("VmGroup: #{vm_group_name} already exists") unless vm_group.nil?
        vm_group_spec = VimSdk::Vim::Cluster::VmGroup.new
        vm_group_spec.vm = vm_group ? vm_group.vm.concat([vm]) : [vm]
        vm_group_spec.name = vm_group_name
        group_spec = VimSdk::Vim::Cluster::GroupSpec.new
        group_spec.info = vm_group_spec
        group_spec.operation = vm_group ? VimSdk::Vim::Option::ArrayUpdateSpec::Operation::EDIT : VimSdk::Vim::Option::ArrayUpdateSpec::Operation::ADD
        config_spec = VimSdk::Vim::Cluster::ConfigSpecEx.new
        config_spec.group_spec = [group_spec]
        logger.debug("Adding VM to VM group: #{vm_group_name}")
        reconfigure_cluster(config_spec)
      end
    end
def add_vm_to_vm_group ( vm , vm_group_name ) DrsLock . new ( @vm_attribute_manager , DRS_LOCK_VMGROUP ) . with_drs_lock do vm_group = find_vm_group ( vm_group_name ) logger . debug ( "VmGroup: #{vm_group_name} already exists" ) unless vm_group . nil? vm_group_spec = VimSdk :: Vim :: Cluster :: VmGroup . new vm_group_spec . vm = vm_group ? vm_group . vm . concat ( [ vm ] ) : [ vm ] vm_group_spec . name = vm_group_name group_spec = VimSdk :: Vim :: Cluster :: GroupSpec . new group_spec . info = vm_group_spec group_spec . operation = vm_group ? VimSdk :: Vim :: Option :: ArrayUpdateSpec :: Operation :: EDIT : VimSdk :: Vim :: Option :: ArrayUpdateSpec :: Operation :: ADD config_spec = VimSdk :: Vim :: Cluster :: ConfigSpecEx . new config_spec . group_spec = [ group_spec ] logger . debug ( "Adding VM to VM group: #{vm_group_name}" ) reconfigure_cluster ( config_spec ) end end
Adds VM to given VM Group
Adds VM to given VM Group
vm
vm_group_name
None
params
None