fog-vsphere 1.1.0 → 1.2.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: e5703036b88d40352d297136ef8ccb16d37002d0
4
- data.tar.gz: 288684548ab71c5ea0034fb242b210be18626d3b
3
+ metadata.gz: a8f624e20813963c149bbc3431f915c5a64253ca
4
+ data.tar.gz: bd06d1bf3e396c00ee9c440b4d4f6fa513845dda
5
5
  SHA512:
6
- metadata.gz: 57e7615da7c6f5ca65c555f217fc972bdfaf1433936373798f139b0ca33a64fbeebc2161656d22f6ef6e1b8c0b8a49551c0953b20032b72d42d3a44cfb8bd61a
7
- data.tar.gz: 24eff7e37397f64cd72ae14e453a81eae8e785281e68ac5bcc98092409233389cebf23b457245159303b7111aeece237a9fe5822ba1ff8d7d7682c69a81df34f
6
+ metadata.gz: 60bddac43701180f347749259cc99346ad6b1f9b6d5345829ead5bcee5142bbb10ffdee03422726096545d2a69c50737ef07d725cac7e4bc0353a306835d3ebf
7
+ data.tar.gz: 419b957fc118175d7f60b54cbfae755ebca6c8802923105a748b79e30730f2227259489a7036c3488adcebff420943d74c7040cf537283cdaa3dce7eef12e68c
@@ -112,6 +112,10 @@ module Fog
112
112
  request :list_rules
113
113
  request :destroy_rule
114
114
  request :list_hosts
115
+ request :create_group
116
+ request :list_groups
117
+ request :destroy_group
118
+ request :get_host
115
119
 
116
120
  module Shared
117
121
  attr_reader :vsphere_is_vcenter
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def create_group(attributes={})
6
+ cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])
7
+ group = cluster.configurationEx.group.find {|n| n[:name] == attributes[:name]}
8
+ if group
9
+ raise ArgumentError, "Group #{attributes[:name]} already exists!"
10
+ end
11
+ spec = get_spec attributes
12
+ cluster_spec = RbVmomi::VIM.ClusterConfigSpecEx(groupSpec: [
13
+ RbVmomi::VIM.ClusterGroupSpec(
14
+ operation: RbVmomi::VIM.ArrayUpdateOperation('add'),
15
+ info: spec
16
+ )
17
+ ])
18
+ cluster.ReconfigureComputeResource_Task(spec: cluster_spec, modify: true).wait_for_completion
19
+ group = cluster.configurationEx.group.find {|n| n[:name] == attributes[:name]}
20
+ if group
21
+ return group[:name]
22
+ else
23
+ raise Fog::Vsphere::Errors::ServiceError, "Unknown error creating group #{attributes[:name]}"
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def get_spec(attributes={})
30
+ if attributes[:type].to_s == 'ClusterVmGroup'
31
+ vms = attributes[:vm_ids].to_a.map {|id| get_vm_ref(id, attributes[:datacenter])}
32
+ attributes[:type].new(
33
+ name: attributes[:name],
34
+ vm: vms
35
+ )
36
+ elsif attributes[:type].to_s == 'ClusterHostGroup'
37
+ attributes[:type].new(
38
+ name: attributes[:name],
39
+ host: attributes[:host_refs]
40
+ )
41
+ end
42
+ end
43
+ end
44
+
45
+ class Mock
46
+ def create_group(attributes={})
47
+ self.data[:groups][attributes[:name]] = attributes
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def destroy_group(attributes = {})
6
+ cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])
7
+ group = cluster.configurationEx.group.find {|g| g.name == attributes[:name]}
8
+ raise Fog::Vsphere::Error::NotFound, "group #{attributes[:name]} not found" unless group
9
+ delete_spec = RbVmomi::VIM.ClusterConfigSpecEx(groupSpec: [
10
+ RbVmomi::VIM.ClusterGroupSpec(
11
+ operation: RbVmomi::VIM.ArrayUpdateOperation('remove'),
12
+ removeKey: group.name
13
+ )
14
+ ])
15
+ cluster.ReconfigureComputeResource_Task(spec: delete_spec, modify: true).wait_for_completion
16
+ end
17
+ end
18
+ class Mock
19
+ def destroy_group(attributes = {})
20
+ group = self.data[:groups][attributes[:name]]
21
+ raise Fog::Vsphere::Error::NotFound unless group
22
+ self.data[:groups].delete(attributes[:name])
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,6 +3,10 @@ module Fog
3
3
  class Vsphere
4
4
  class Real
5
5
 
6
+ def get_host(name, cluster_name, datacenter_name)
7
+ get_raw_host(name, cluster_name, datacenter_name)
8
+ end
9
+
6
10
  protected
7
11
 
8
12
  def get_raw_host(name, cluster_name, datacenter_name)
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def list_groups(filters = {})
6
+ cluster = get_raw_cluster(filters[:cluster], filters[:datacenter])
7
+ cluster.configurationEx.group.map {|g| group_attributes g, filters}
8
+ end
9
+
10
+ protected
11
+
12
+ def group_attributes(group, filters)
13
+ attributes = {}
14
+ attributes[:datacenter] = filters[:datacenter]
15
+ attributes[:cluster] = filters[:cluster]
16
+ attributes[:name] = group[:name]
17
+ attributes[:type] = group.class
18
+ if group.class.to_s == 'ClusterVmGroup' then attributes[:vm_ids] = group[:vm].map {|vm| vm.config.instanceUuid} end
19
+ if group.class.to_s == 'ClusterHostGroup' then attributes[:hosts] = group[:host].map {|host| host.name} end
20
+ return attributes
21
+ end
22
+ end
23
+ class Mock
24
+ def list_groups(filters = {})
25
+ self.data[:groups].values.select {|g| g[:datacenter] == filters[:datacenter] && g[:cluster] == filters[:cluster]}
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.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.1.0
4
+ version: 1.2.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-09-16 00:00:00.000000000 Z
11
+ date: 2016-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -186,9 +186,11 @@ files:
186
186
  - lib/fog/vsphere/models/compute/volumes.rb
187
187
  - lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb
188
188
  - lib/fog/vsphere/requests/compute/create_folder.rb
189
+ - lib/fog/vsphere/requests/compute/create_group.rb
189
190
  - lib/fog/vsphere/requests/compute/create_rule.rb
190
191
  - lib/fog/vsphere/requests/compute/create_vm.rb
191
192
  - lib/fog/vsphere/requests/compute/current_time.rb
193
+ - lib/fog/vsphere/requests/compute/destroy_group.rb
192
194
  - lib/fog/vsphere/requests/compute/destroy_rule.rb
193
195
  - lib/fog/vsphere/requests/compute/folder_destroy.rb
194
196
  - lib/fog/vsphere/requests/compute/get_cluster.rb
@@ -212,6 +214,7 @@ files:
212
214
  - lib/fog/vsphere/requests/compute/list_datacenters.rb
213
215
  - lib/fog/vsphere/requests/compute/list_datastores.rb
214
216
  - lib/fog/vsphere/requests/compute/list_folders.rb
217
+ - lib/fog/vsphere/requests/compute/list_groups.rb
215
218
  - lib/fog/vsphere/requests/compute/list_hosts.rb
216
219
  - lib/fog/vsphere/requests/compute/list_interface_types.rb
217
220
  - lib/fog/vsphere/requests/compute/list_networks.rb