Class: Fog::Vsphere::Compute::Rule

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/vsphere/models/compute/rule.rb

Overview

ClusterRuleInfo

Instance Method Summary collapse

Instance Method Details

#destroyObject



40
41
42
# File 'lib/fog/vsphere/models/compute/rule.rb', line 40

def destroy
  service.destroy_rule(attributes)
end

#saveObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/vsphere/models/compute/rule.rb', line 27

def save
  requires :datacenter, :cluster, :name, :enabled, :type, :vm_ids
  if vm_ids.length < 2
    raise ArgumentError, 'A rule must have at least 2 VMs'
  end
  if persisted?
    raise 'Update is not supported yet'
  else
    self.key = service.create_rule(attributes)
  end
  reload
end

#vmsObject



19
20
21
# File 'lib/fog/vsphere/models/compute/rule.rb', line 19

def vms
  vm_ids.map { |id| service.servers.get(id, datacenter) }
end

#vms=(vms) ⇒ Object



23
24
25
# File 'lib/fog/vsphere/models/compute/rule.rb', line 23

def vms=(vms)
  self.vm_ids = vms.map(&:instance_uuid)
end