fog-vsphere 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5703036b88d40352d297136ef8ccb16d37002d0
|
4
|
+
data.tar.gz: 288684548ab71c5ea0034fb242b210be18626d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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>
|
@@ -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
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
data/lib/fog/vsphere/version.rb
CHANGED
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
|
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-
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|