Sha256: 0b813f5f1410564b1f864eda939e755e9939fa196ed26e9d783c6f02feb53838
Contents?: true
Size: 1.96 KB
Versions: 23
Compression:
Stored size: 1.96 KB
Contents
module Fog module Vsphere class Compute class Real def create_group(attributes = {}) cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter]) group = cluster.configurationEx.group.find { |n| n[:name] == attributes[:name] } if group raise ArgumentError, "Group #{attributes[:name]} already exists!" end spec = get_group_spec attributes cluster_spec = RbVmomi::VIM.ClusterConfigSpecEx(groupSpec: [ RbVmomi::VIM.ClusterGroupSpec( operation: RbVmomi::VIM.ArrayUpdateOperation('add'), info: spec ) ]) cluster.ReconfigureComputeResource_Task(spec: cluster_spec, modify: true).wait_for_completion group = cluster.configurationEx.group.find { |n| n[:name] == attributes[:name] } if group return group[:name] else raise Fog::Vsphere::Errors::ServiceError, "Unknown error creating group #{attributes[:name]}" end end private def get_group_spec(attributes = {}) if attributes[:type].to_s == 'ClusterVmGroup' vms = attributes[:vm_ids].to_a.map { |id| get_vm_ref(id, attributes[:datacenter]) } attributes[:type].new( name: attributes[:name], vm: vms ) elsif attributes[:type].to_s == 'ClusterHostGroup' attributes[:type].new( name: attributes[:name], host: attributes[:host_refs] ) end end end class Mock def create_group(attributes = {}) data[:groups][attributes[:name]] = attributes end end end end end
Version data entries
23 entries across 23 versions & 1 rubygems