knife-vsphere 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,42 @@
1
+ #r# Author:: Ezra Pagel (<ezra@cpan.org>)
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'chef/knife'
17
+ require 'chef/knife/VsphereBaseCommand'
18
+
19
+ class Chef
20
+ class Knife
21
+ class VsphereCustomizationList < VsphereBaseCommand
22
+
23
+ banner "knife vsphere customization list"
24
+
25
+ get_common_options
26
+
27
+ def run
28
+
29
+ $stdout.sync = true
30
+
31
+ vim = get_vim_connection
32
+
33
+ csm = vim.serviceContent.customizationSpecManager
34
+ csm.info.each do |c|
35
+ puts "#{ui.color("Customization Name", :cyan)}: #{c.name}"
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -36,6 +36,10 @@ class Chef
36
36
  :long => "--vmname VMNAME",
37
37
  :description => "The name for the new virtual machine"
38
38
 
39
+ option :customization_spec,
40
+ :long => "--cspec CUSTOMIZATION_SPEC",
41
+ :description => "The name of any customization specification to apply"
42
+
39
43
  def run
40
44
 
41
45
  $stdout.sync = true
@@ -55,10 +59,18 @@ class Chef
55
59
  abort "VM/Template not found"
56
60
 
57
61
  rspec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => rp)
62
+
63
+
58
64
  spec = RbVmomi::VIM.VirtualMachineCloneSpec(:location => rspec,
59
65
  :powerOn => false,
60
66
  :template => false)
61
67
 
68
+ if config[:customization_spec]
69
+ cs = find_customization(vim, config[:customization_spec]) or
70
+ abort "failed to find customization specification named #{config[:customization_spec]}"
71
+ spec.customization = cs.spec
72
+ end
73
+
62
74
  task = src_vm.CloneVM_Task(:folder => src_vm.parent, :name => vmname, :spec => spec)
63
75
  puts "Cloning template #{template} to new VM #{vmname}"
64
76
  task.wait_for_completion
@@ -66,6 +78,12 @@ class Chef
66
78
 
67
79
  end
68
80
 
81
+ def find_customization(vim, name)
82
+ csm = vim.serviceContent.customizationSpecManager
83
+ csm.GetCustomizationSpec(:name => name)
84
+ end
85
+
86
+
69
87
  end
70
88
  end
71
89
  end
@@ -1,4 +1,4 @@
1
1
  module KnifeVsphere
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ezra Pagel
@@ -50,7 +50,7 @@ dependencies:
50
50
  version: 1.2.3
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
- description: VMware Vsphere Support for Chef's Knife Command
53
+ description: VMware vSphere Support for Chef's Knife Command
54
54
  email: ezra@cpan.org
55
55
  executables: []
56
56
 
@@ -59,6 +59,7 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
 
61
61
  files:
62
+ - lib/chef/knife/vsphere_customization_list.rb
62
63
  - lib/chef/knife/vsphere_template_list.rb
63
64
  - lib/chef/knife/vsphere_vm_clone.rb
64
65
  - lib/chef/knife/vsphere_vm_delete.rb
@@ -98,6 +99,6 @@ rubyforge_project:
98
99
  rubygems_version: 1.6.2
99
100
  signing_key:
100
101
  specification_version: 3
101
- summary: VSphere Support for Knife
102
+ summary: vSphere Support for Knife
102
103
  test_files: []
103
104