chef-metal-vsphere 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8ea8bc26ba359b811ea19cfa5876b688437362b
4
+ data.tar.gz: 3e37abdd15aed60c1b5ff549ee55b06aaaaac116
5
+ SHA512:
6
+ metadata.gz: 5c67f07c76d42ba8804f369651b7ba88a60d9ac14584cd79ebfc8df25138597606872a9150fb8edd3a6cf055162d4937baf629797f204cd98009885f75d9af47
7
+ data.tar.gz: cd75aac3d3273599f7499e4603155d6cdea53b4135d047c20fa07f9188b36854eb4ad9b93096f35d5d4b4ee18a3ab9e508f808aa8d7e1235399dbec24c5a4eeb
data/README.md CHANGED
@@ -26,13 +26,14 @@ Create or obtain a unix/linux VM template. The VM template must:
26
26
  vsphere_password: 'your_mothers_maiden_name' # consider using a chef-vault
27
27
 
28
28
  with_provisioner_options('bootstrap_options' => {
29
- datacenter: 'datacenter_name',
30
- cluster: 'cluster_name',
31
- resource_pool: 'resource_pool_name', # often the same as the cluster_name
32
- datastore: 'datastore_name',
33
- template_name: 'name_of_template_vm', # may be a VM or a VM Template
34
- template_folder: 'folder_containing_template_vm',
35
- vm_folder: 'folder_to_clone_vms_into',
29
+ datacenter: 'datacenter_name',
30
+ cluster: 'cluster_name',
31
+ resource_pool: 'resource_pool_name', # often the same as the cluster_name
32
+ datastore: 'datastore_name',
33
+ template_name: 'name_of_template_vm', # may be a VM or a VM Template
34
+ template_folder: 'folder_containing_template_vm',
35
+ vm_folder: 'folder_to_clone_vms_into',
36
+ customization_spec: 'standard-config', # optional
36
37
 
37
38
  ssh: { # net-ssh start() options
38
39
  user: 'username_on_vm', # must have nopasswd sudo
@@ -49,6 +50,13 @@ Create or obtain a unix/linux VM template. The VM template must:
49
50
  1.upto 2 do |n|
50
51
  machine "metal_#{n}" do
51
52
  action [:create]
53
+
54
+ ## optionally add options per-machine customizations
55
+ add_provisioner_options('bootstrap_options' => {
56
+ num_cpus: n,
57
+ memory_mb: 1024 * n,
58
+ annotation: "metal_#{n} created by chef-metal-vsphere"
59
+ })
52
60
  end
53
61
 
54
62
  machine_file "/tmp/metal_#{n}.txt" do
@@ -1,3 +1,3 @@
1
1
  module ChefMetalVsphere
2
- VERSION = '0.1.4'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -4,15 +4,15 @@ module ChefMetalVsphere
4
4
  def vim
5
5
  # reconnect on every call - connections may silently timeout during long operations (e.g. cloning)
6
6
  conn_opts = {
7
- :host => connect_options['vsphere_host'],
8
- :port => connect_options['vsphere_port'],
9
- :path => connect_options['vshere_path'],
10
- :use_ssl => connect_options['vsphere_ssl'],
11
- :insecure => connect_options['vsphere_insecure'],
12
- :proxyHost => connect_options['proxy_host'],
13
- :proxyPort => connect_options['proxy_port'],
14
- :user => connect_options['vsphere_user'],
15
- :password => connect_options['vsphere_password']
7
+ :host => connect_options['vsphere_host'],
8
+ :port => connect_options['vsphere_port'],
9
+ :path => connect_options['vshere_path'],
10
+ :use_ssl => connect_options['vsphere_ssl'],
11
+ :insecure => connect_options['vsphere_insecure'],
12
+ :proxyHost => connect_options['proxy_host'],
13
+ :proxyPort => connect_options['proxy_port'],
14
+ :user => connect_options['vsphere_user'],
15
+ :password => connect_options['vsphere_password']
16
16
  }
17
17
 
18
18
  vim = RbVmomi::VIM.connect conn_opts
@@ -107,13 +107,31 @@ module ChefMetalVsphere
107
107
  location: RbVmomi::VIM.VirtualMachineRelocateSpec(pool: pool),
108
108
  powerOn: false,
109
109
  template: false
110
- )
110
+ )
111
+
112
+ clone_spec.config = RbVmomi::VIM.VirtualMachineConfigSpec(:deviceChange => Array.new)
113
+
114
+ unless options['customization_spec'].to_s.empty?
115
+ clone_spec.customization = find_customization_spec(options['customization_spec'])
116
+ end
117
+
118
+ unless options['annotation'].to_s.nil?
119
+ clone_spec.config.annotation = options['annotation']
120
+ end
121
+
122
+ unless options['num_cpus'].to_s.nil?
123
+ clone_spec.config.numCPUs = options['num_cpus']
124
+ end
125
+
126
+ unless options['memory_mb'].to_s.nil?
127
+ clone_spec.config.memoryMB = options['memory_mb']
128
+ end
111
129
 
112
130
  vm_template.CloneVM_Task(
113
131
  name: vm_name,
114
132
  folder: find_folder(dc_name, options['vm_folder']),
115
133
  spec: clone_spec
116
- ).wait_for_completion
134
+ ).wait_for_completion
117
135
  end
118
136
 
119
137
  def find_pool(dc, pool_name)
@@ -138,5 +156,13 @@ module ChefMetalVsphere
138
156
  baseEntity = baseEntity.resourcePool if not baseEntity.is_a?(RbVmomi::VIM::ResourcePool) and baseEntity.respond_to?(:resourcePool)
139
157
  baseEntity
140
158
  end
159
+
160
+ def find_customization_spec(customization_spec)
161
+ csm = vim.serviceContent.customizationSpecManager
162
+ csi = csm.GetCustomizationSpec(:name => customization_spec)
163
+ spec = csi.spec
164
+ raise "Customization Spec not found [#{customization_spec}]" if spec.nil?
165
+ spec
166
+ end
141
167
  end
142
168
  end
@@ -215,6 +215,7 @@ module ChefMetalVsphere
215
215
  datacenter = bootstrap_options['datacenter']
216
216
  template_folder = bootstrap_options['template_folder']
217
217
  template_name = bootstrap_options['template_name']
218
+
218
219
  vm_template = find_vm(datacenter, template_folder, template_name) or raise("vSphere VM Template not found [#{template_folder}/#{template_name}]")
219
220
 
220
221
  vm = do_vm_clone(datacenter, vm_template, vm_name, bootstrap_options)
@@ -305,6 +306,5 @@ module ChefMetalVsphere
305
306
  end
306
307
  ] : h
307
308
  end
308
-
309
309
  end
310
- end
310
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-metal-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rally Software Development Corp
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-05-10 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: chef
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rbvmomi
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -83,43 +74,36 @@ extra_rdoc_files:
83
74
  - README.md
84
75
  - LICENSE
85
76
  files:
86
- - Rakefile
87
77
  - LICENSE
88
78
  - README.md
79
+ - Rakefile
89
80
  - lib/chef_metal/provisioner_init/vsphere_init.rb
81
+ - lib/chef_metal_vsphere.rb
90
82
  - lib/chef_metal_vsphere/version.rb
91
83
  - lib/chef_metal_vsphere/vsphere_helpers.rb
92
84
  - lib/chef_metal_vsphere/vsphere_provisioner.rb
93
- - lib/chef_metal_vsphere.rb
94
85
  homepage: https://github.com/RallySoftware-cookbooks/chef-metal-vsphere
95
86
  licenses:
96
87
  - MIT
88
+ metadata: {}
97
89
  post_install_message:
98
90
  rdoc_options: []
99
91
  require_paths:
100
92
  - lib
101
93
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
94
  requirements:
104
95
  - - ! '>='
105
96
  - !ruby/object:Gem::Version
106
97
  version: '0'
107
- segments:
108
- - 0
109
- hash: -1936715573261494371
110
98
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
99
  requirements:
113
100
  - - ! '>='
114
101
  - !ruby/object:Gem::Version
115
102
  version: '0'
116
- segments:
117
- - 0
118
- hash: -1936715573261494371
119
103
  requirements: []
120
104
  rubyforge_project:
121
- rubygems_version: 1.8.28
105
+ rubygems_version: 2.2.2
122
106
  signing_key:
123
- specification_version: 3
107
+ specification_version: 4
124
108
  summary: Provisioner for creating vSphere VM instances in Chef Metal.
125
109
  test_files: []