Sha256: c0f2e1c2e435a60dbf78a5ac2cf4a86a3eb75fc57acbb9300fdd62e3799d1c4b

Contents?: true

Size: 1.32 KB

Versions: 29

Compression:

Stored size: 1.32 KB

Contents

module Fog
  module Compute
    class Vsphere
      class Real
        def list_rules(filters = {})
          cluster = get_raw_cluster(filters[:cluster], filters[:datacenter])
          cluster.configurationEx.rule.map {|r| rule_attributes r, filters}
        end

        protected

        def rule_attributes(rule, filters)
          attributes = {}
          attributes[:datacenter] = filters[:datacenter]
          attributes[:cluster] = filters[:cluster]
          attributes[:key] = rule[:key]
          attributes[:name] = rule[:name]
          attributes[:enabled] = rule[:enabled]
          attributes[:type] = rule.class
          if rule.class.to_s == 'ClusterAntiAffinityRuleSpec' || rule.class.to_s == 'ClusterAffinityRuleSpec'
            attributes[:vm_ids] = rule[:vm].map {|vm| vm.config.instanceUuid}
          elsif rule.class.to_s == 'ClusterVmHostRuleInfo'
            attributes[:mandatory] = rule[:mandatory]
            attributes[:vmGroupName] = rule[:vmGroupName]
            attributes[:affineHostGroupName] = rule[:affineHostGroupName]
          end
          return attributes
        end
      end
      class Mock
        def list_rules(filters = {})
          self.data[:rules].values.select {|r| r[:datacenter] == filters[:datacenter] && r[:cluster] == filters[:cluster]}
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
fog-vsphere-1.7.0.1 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-2.1.1 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-2.1.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-2.0.1 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-2.0.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.13.1 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.13.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.12.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.11.3 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.11.2 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.11.1 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.11.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.10.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.9.2 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.9.1 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.9.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.8.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.7.1 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.7.0 lib/fog/vsphere/requests/compute/list_rules.rb
fog-vsphere-1.6.0 lib/fog/vsphere/requests/compute/list_rules.rb