fog-vsphere 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6484c578c8862f6daabfc08133d6ce75e9115d19
4
- data.tar.gz: 2350426ea93ab74418b4a83a036bdc9cb334de5f
3
+ metadata.gz: e5703036b88d40352d297136ef8ccb16d37002d0
4
+ data.tar.gz: 288684548ab71c5ea0034fb242b210be18626d3b
5
5
  SHA512:
6
- metadata.gz: 1e97ddb8418174a55e6c09e3daae4d200eae177ed91058d512f5721a176afa5739a1aba9e187e0498e319d2c0c1e65e4f182b68ba67cee8db302814ecc4276b1
7
- data.tar.gz: 826dbf47f157dc8667904ede7cc5fa29006f1e042816d4b60376ee628ab7a17325e78ca033a98240cb511eb6da2a1fbbb6df96a838f4dfc788f0d53cb58e0049
6
+ metadata.gz: 57e7615da7c6f5ca65c555f217fc972bdfaf1433936373798f139b0ca33a64fbeebc2161656d22f6ef6e1b8c0b8a49551c0953b20032b72d42d3a44cfb8bd61a
7
+ data.tar.gz: 24eff7e37397f64cd72ae14e453a81eae8e785281e68ac5bcc98092409233389cebf23b457245159303b7111aeece237a9fe5822ba1ff8d7d7682c69a81df34f
data/CONTRIBUTORS.md CHANGED
@@ -61,6 +61,7 @@
61
61
  * Wesley Beary <geemus@gmail.com>
62
62
  * Xavier Fontrodona <xavier.fontrodona@safelayer.com>
63
63
  * alan <asebastian2@gmail.com>
64
+ * c0puga <c0puga@walmart.com>
64
65
  * endzyme <nick.huanca@gmail.com>
65
66
  * geemus <geemus@gmail.com>
66
67
  * karmab <karimboumedhel@gmail.com>
@@ -12,6 +12,7 @@ module Fog
12
12
  # Type should be a class - either
13
13
  # - RbVmomi::VIM::ClusterAntiAffinityRuleSpec
14
14
  # - RbVmomi::VIM::ClusterAffinityRuleSpec
15
+ # - RbVmomi::VIM::ClusterVmHostRuleInfo
15
16
  attribute :type
16
17
  attribute :vm_ids
17
18
 
@@ -4,25 +4,17 @@ module Fog
4
4
  class Real
5
5
  def create_rule(attributes={})
6
6
  cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])
7
- # Check if it already exists and blow up if it does
8
- # (otherwise ESX just happily accepts it and then considers it a conflict)
9
7
  rule = cluster.configurationEx.rule.find {|n| n[:name] == attributes[:name]}
10
8
  if rule
11
9
  raise ArgumentError, "Rule #{attributes[:name]} already exists!"
12
10
  end
13
- # First, create the rulespec
14
- vms = attributes[:vm_ids].to_a.map {|id| get_vm_ref(id, attributes[:datacenter])}
15
- spec = attributes[:type].new(
16
- name: attributes[:name],
17
- enabled: attributes[:enabled],
18
- vm: vms
19
- )
11
+ spec = get_spec attributes
20
12
  # Now, attach it to the cluster
21
13
  cluster_spec = RbVmomi::VIM.ClusterConfigSpecEx(rulesSpec: [
22
- RbVmomi::VIM.ClusterRuleSpec(
23
- operation: RbVmomi::VIM.ArrayUpdateOperation('add'),
24
- info: spec
25
- )
14
+ RbVmomi::VIM.ClusterRuleSpec(
15
+ operation: RbVmomi::VIM.ArrayUpdateOperation('add'),
16
+ info: spec
17
+ )
26
18
  ])
27
19
  ret = cluster.ReconfigureComputeResource_Task(spec: cluster_spec, modify: true).wait_for_completion
28
20
  rule = cluster.configurationEx.rule.find {|n| n[:name] == attributes[:name]}
@@ -32,8 +24,29 @@ module Fog
32
24
  raise Fog::Vsphere::Errors::ServiceError, "Unknown error creating rule #{attributes[:name]}"
33
25
  end
34
26
  end
35
-
27
+
28
+ private
29
+
30
+ def get_spec(attributes={})
31
+ if (attributes[:type].to_s == 'ClusterAntiAffinityRuleSpec' || attributes[:type].to_s == 'ClusterAffinityRuleSpec')
32
+ vms = attributes[:vm_ids].to_a.map {|id| get_vm_ref(id, attributes[:datacenter])}
33
+ attributes[:type].new(
34
+ name: attributes[:name],
35
+ enabled: attributes[:enabled],
36
+ vm: vms
37
+ )
38
+ elsif attributes[:type].to_s == 'ClusterVmHostRuleInfo'
39
+ attributes[:type].new(
40
+ name: attributes[:name],
41
+ enabled: attributes[:enabled],
42
+ mandatory: attributes[:mandatory],
43
+ vmGroupName: attributes[:vmGroupName],
44
+ affineHostGroupName: attributes[:affineHostGroupName]
45
+ )
46
+ end
47
+ end
36
48
  end
49
+
37
50
  class Mock
38
51
  def create_rule(attributes={})
39
52
  attributes[:key] = rand(9999)
@@ -8,17 +8,23 @@ module Fog
8
8
  end
9
9
 
10
10
  protected
11
-
11
+
12
12
  def rule_attributes(rule, filters)
13
- {
14
- datacenter: filters[:datacenter],
15
- cluster: filters[:cluster],
16
- key: rule[:key],
17
- name: rule[:name],
18
- enabled: rule[:enabled],
19
- type: rule.class,
20
- vm_ids: rule[:vm].map {|vm| vm.config.instanceUuid }
21
- }
13
+ attributes = {}
14
+ attributes[:datacenter] = filters[:datacenter]
15
+ attributes[:cluster] = filters[:cluster]
16
+ attributes[:key] = rule[:key]
17
+ attributes[:name] = rule[:name]
18
+ attributes[:enabled] = rule[:enabled]
19
+ attributes[:type] = rule.class
20
+ if rule.class.to_s == 'ClusterAntiAffinityRuleSpec' || rule.class.to_s == 'ClusterAffinityRuleSpec'
21
+ attributes[:vm_ids] = rule[:vm].map {|vm| vm.config.instanceUuid}
22
+ elsif rule.class.to_s == 'ClusterVmHostRuleInfo'
23
+ attributes[:mandatory] = rule[:mandatory]
24
+ attributes[:vmGroupName] = rule[:vmGroupName]
25
+ attributes[:affineHostGroupName] = rule[:affineHostGroupName]
26
+ end
27
+ return attributes
22
28
  end
23
29
  end
24
30
  class Mock
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.R. Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core