vm_shepherd 3.6.0 → 3.6.1

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: 756d9a70d96ccda7ec70f94f6696609f891ca919
4
- data.tar.gz: 8de386223858e604289442480c2afc2ec13b1a2b
3
+ metadata.gz: b60886b794bcc80be233a697303896117ba30bd8
4
+ data.tar.gz: 9c19f82ea6a62127b8622a847c6253f925dd80c1
5
5
  SHA512:
6
- metadata.gz: aeca796706b5cadc48fef207c01f27025dc53d7a042caa1d2e02d5734ac41f6b179c171be2ac107262989390ab58f0f786933fa0f6ad23795686fec4718bf787
7
- data.tar.gz: ba4b1dc89e6bf841b0081722120e39a23672e17a2c687383e283d4069ae59c9335c4afbd92a2eb82d93048e97565f653b0b380b9f29d6dd0fa6c0c491f12c166
6
+ metadata.gz: 9a16267362a30cd6b1fc2697cbd475dff8cd49591fa4b363a4a22b21b5d629405070fdab4ae302094fb74f4f39d24b963dc1f785a62812b2371fe5261101c891
7
+ data.tar.gz: 97cb4e3d2d8040b40ce1f226b738091e832738813e1d06e57702e3100426861265e0420bbe9b6de2b2b716264e145be5898063b5e795cd0b4da0f3fcdd5edc8f
@@ -1,3 +1,3 @@
1
1
  module VmShepherd
2
- VERSION = '3.6.0'.freeze
2
+ VERSION = '3.6.1'.freeze
3
3
  end
@@ -105,18 +105,23 @@ module VmShepherd
105
105
  end
106
106
 
107
107
  def create_network_mappings(ovf_file_path, vsphere_config)
108
- ovf = Nokogiri::XML(File.read(ovf_file_path))
109
- ovf.remove_namespaces!
108
+ ovf = parse_ovf(ovf_file_path)
110
109
  networks = ovf.xpath('//NetworkSection/Network').map { |x| x['name'] }
111
110
  Hash[networks.map { |ovf_network| [ovf_network, network(vsphere_config)] }]
112
111
  end
113
112
 
113
+ def parse_ovf(ovf_file_path)
114
+ ovf = Nokogiri::XML(File.read(ovf_file_path))
115
+ ovf.remove_namespaces!
116
+ ovf
117
+ end
118
+
114
119
  def boot_vm(ovf_file_path, vm_config, vsphere_config)
115
120
  ensure_folder_exists(vsphere_config[:folder])
116
121
  template = deploy_ovf_template(ovf_file_path, vsphere_config)
117
122
  vm = create_vm_from_template(template, vm_config, vsphere_config)
118
123
 
119
- reconfigure_vm(vm, vm_config)
124
+ reconfigure_vm(vm, vm_config, ovf_file_path)
120
125
  power_on_vm(vm)
121
126
  end
122
127
 
@@ -233,8 +238,8 @@ module VmShepherd
233
238
  }
234
239
  end
235
240
 
236
- def reconfigure_vm(vm, vm_config)
237
- virtual_machine_config_spec = create_virtual_machine_config_spec(vm_config)
241
+ def reconfigure_vm(vm, vm_config, ovf_file_path)
242
+ virtual_machine_config_spec = create_virtual_machine_config_spec(vm_config, ovf_file_path)
238
243
  logger.info("BEGIN reconfigure_vm_task virtual_machine_config_spec=#{virtual_machine_config_spec.inspect}")
239
244
  vm.ReconfigVM_Task(
240
245
  spec: virtual_machine_config_spec
@@ -243,12 +248,12 @@ module VmShepherd
243
248
  }
244
249
  end
245
250
 
246
- def create_virtual_machine_config_spec(vm_config)
251
+ def create_virtual_machine_config_spec(vm_config, ovf_file_path)
247
252
  logger.info('BEGIN VmConfigSpec creation')
248
253
  vm_config_spec =
249
254
  RbVmomi::VIM::VmConfigSpec.new.tap do |vcs|
250
255
  vcs.ovfEnvironmentTransport = ['com.vmware.guestInfo']
251
- vcs.property = create_vapp_property_specs(vm_config)
256
+ vcs.property = create_vapp_property_specs(vm_config, ovf_file_path)
252
257
  end
253
258
  logger.info("END VmConfigSpec creation: #{vm_config_spec.inspect}")
254
259
 
@@ -259,57 +264,36 @@ module VmShepherd
259
264
  end
260
265
  end
261
266
 
262
- def create_vapp_property_specs(vm_config)
263
- ip_configuration = {
264
- 'ip0' => vm_config[:ip],
265
- 'netmask0' => vm_config[:netmask],
266
- 'gateway' => vm_config[:gateway],
267
- 'DNS' => vm_config[:dns],
267
+ def create_vapp_property_specs(vm_config, ovf_file_path)
268
+ property_value_map = {
269
+ 'ip0' => vm_config[:ip],
270
+ 'netmask0' => vm_config[:netmask],
271
+ 'gateway' => vm_config[:gateway],
272
+ 'DNS' => vm_config[:dns],
268
273
  'ntp_servers' => vm_config[:ntp_servers],
274
+ 'admin_password' => vm_config[:vm_password],
275
+ 'public_ssh_key' => vm_config[:public_ssh_key],
276
+ 'custom_hostname' => vm_config[:custom_hostname],
269
277
  }
270
278
 
271
279
  vapp_property_specs = []
272
280
 
273
- logger.info("BEGIN VAppPropertySpec creation configuration=#{ip_configuration.inspect}")
274
- # IP Configuration key order must match OVF template property order
275
- ip_configuration.each_with_index do |(key, value), i|
281
+ logger.info("BEGIN VAppPropertySpec creation configuration=#{property_value_map.inspect}")
282
+
283
+ # VAppPropertySpec order must match OVF template property order
284
+ ovf = parse_ovf(ovf_file_path)
285
+ ovf.xpath('//ProductSection/Property').each_with_index do |property, index|
286
+ label = property.attribute('key').value
276
287
  vapp_property_specs << RbVmomi::VIM::VAppPropertySpec.new.tap do |spec|
277
288
  spec.operation = 'edit'
278
289
  spec.info = RbVmomi::VIM::VAppPropertyInfo.new.tap do |p|
279
- p.key = i
280
- p.label = key
281
- p.value = value
290
+ p.key = index
291
+ p.label = label
292
+ p.value = property_value_map[label]
282
293
  end
283
294
  end
284
295
  end
285
296
 
286
- vapp_property_specs << RbVmomi::VIM::VAppPropertySpec.new.tap do |spec|
287
- spec.operation = 'edit'
288
- spec.info = RbVmomi::VIM::VAppPropertyInfo.new.tap do |p|
289
- p.key = 5 # this needs to be 5th to match the ovf template property order.
290
- p.label = 'admin_password'
291
- p.value = vm_config[:vm_password]
292
- end
293
- end
294
-
295
- vapp_property_specs << RbVmomi::VIM::VAppPropertySpec.new.tap do |spec|
296
- spec.operation = 'edit'
297
- spec.info = RbVmomi::VIM::VAppPropertyInfo.new.tap do |p|
298
- p.key = 6 # ditto. see above. it makes me sad, too.
299
- p.label = 'public_ssh_key'
300
- p.value = vm_config[:public_ssh_key]
301
- end
302
- end
303
-
304
- vapp_property_specs << RbVmomi::VIM::VAppPropertySpec.new.tap do |spec|
305
- spec.operation = 'edit'
306
- spec.info = RbVmomi::VIM::VAppPropertyInfo.new.tap do |p|
307
- p.key = 7 # ditto. see above. it makes me sad, too.
308
- p.label = 'custom_hostname'
309
- p.value = vm_config[:custom_hostname]
310
- end
311
- end unless vm_config[:custom_hostname].nil?
312
-
313
297
  logger.info("END VAppPropertySpec creation vapp_property_specs=#{vapp_property_specs.inspect}")
314
298
  vapp_property_specs
315
299
  end
@@ -0,0 +1,136 @@
1
+ <?xml version="1.0"?>
2
+ <Envelope ovf:version="1.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xml:lang="en-US" xmlns="http://schemas.dmtf.org/ovf/envelope/1"
5
+ xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
6
+ xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
7
+ xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
8
+ xmlns:vmw="http://www.vmware.com/schema/ovf">
9
+
10
+ <References>
11
+ <File ovf:href="pivotal-ops-manager-disk1.vmdk" ovf:size="4243996160" ovf:id="file1"/>
12
+ </References>
13
+
14
+ <DiskSection>
15
+ <Info>List of the virtual disks used in the package</Info>
16
+ <Disk ovf:capacity="171798603879"
17
+ ovf:diskId="vmdisk1"
18
+ ovf:fileRef="file1"
19
+ ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
20
+ </DiskSection>
21
+
22
+ <NetworkSection>
23
+ <Info>Logical networks used in the package</Info>
24
+ <Network ovf:name="Network 1">
25
+ <Description>Logical network used by this appliance.</Description>
26
+ </Network>
27
+ </NetworkSection>
28
+
29
+ <vmw:IpAssignmentSection ovf:required="false" vmw:protocols="IPv4" vmw:schemes="">
30
+ <Info>Supported IP assignment schemes</Info>
31
+ </vmw:IpAssignmentSection>
32
+
33
+ <VirtualSystem ovf:id="FAKE_FILENAME">
34
+ <Info>A virtual machine</Info>
35
+
36
+ <ProductSection>
37
+ <Info/>
38
+ <Product>Ops Manager</Product>
39
+ <Vendor>Pivotal</Vendor>
40
+ <Version>2.3-build.203</Version>
41
+ <Property ovf:key="ip0" ovf:userConfigurable="true" ovf:type="string">
42
+ <Label>IP Address</Label>
43
+ <Description>The IP address for the Ops Manager. Leave blank if DHCP is desired.</Description>
44
+ </Property>
45
+ <Property ovf:key="netmask0" ovf:userConfigurable="true" ovf:type="string">
46
+ <Label>Netmask</Label>
47
+ <Description>The netmask for the Ops Manager's network. Leave blank if DHCP is desired.</Description>
48
+ </Property>
49
+ <Property ovf:key="gateway" ovf:userConfigurable="true" ovf:type="string">
50
+ <Label>Default Gateway</Label>
51
+ <Description>The default gateway address for the Ops Manager's network. Leave blank if DHCP is desired.</Description>
52
+ </Property>
53
+ <Property ovf:key="DNS" ovf:userConfigurable="true" ovf:type="string">
54
+ <Label>DNS</Label>
55
+ <Description>The domain name servers for the Ops Manager (comma separated). Leave blank if DHCP is desired.</Description>
56
+ </Property>
57
+ <Property ovf:key="ntp_servers" ovf:userConfigurable="true" ovf:type="string">
58
+ <Label>NTP Servers</Label>
59
+ <Description>Comma-delimited list of NTP servers</Description>
60
+ </Property>
61
+ <Property ovf:key="admin_password" ovf:userConfigurable="true" ovf:type="password">
62
+ <Label>Admin Password</Label>
63
+ <Description>This password is used to SSH into the Ops Manager. The username is 'ubuntu'. One or both of Admin Password and SSH Key is required.</Description>
64
+ </Property>
65
+ <Property ovf:key="public_ssh_key" ovf:userConfigurable="true" ovf:type="string">
66
+ <Label>Public SSH Key</Label>
67
+ <Description>The Public SSH Key is used to allow SSHing into the Ops Manager with your private ssh key. The username is 'ubuntu'. One or both of Admin Password and SSH Key is required.</Description>
68
+ </Property>
69
+ <Property ovf:key="custom_hostname" ovf:userConfigurable="true" ovf:type="string">
70
+ <Label>Custom Hostname</Label>
71
+ <Description>This will be set as the hostname on the VM. Default: 'pivotal-ops-manager'.</Description>
72
+ </Property>
73
+ </ProductSection>
74
+
75
+ <AnnotationSection>
76
+ <Info/>
77
+ <Annotation>Ops Manager for Pivotal Cloud Foundry
78
+ installs and manages PCF products and services.</Annotation>
79
+ </AnnotationSection>
80
+
81
+ <VirtualHardwareSection ovf:required="false" ovf:transport="com.vmware.guestInfo">
82
+ <Info>Virtual hardware requirements for a virtual machine</Info>
83
+ <System>
84
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
85
+ <vssd:InstanceID>0</vssd:InstanceID>
86
+ <vssd:VirtualSystemIdentifier>FAKE_FILENAME</vssd:VirtualSystemIdentifier>
87
+ <vssd:VirtualSystemType>vmx-09</vssd:VirtualSystemType>
88
+ </System>
89
+ <Item>
90
+ <rasd:Caption>1 virtual CPU</rasd:Caption>
91
+ <rasd:Description>Number of virtual CPUs</rasd:Description>
92
+ <rasd:ElementName>1 virtual CPU</rasd:ElementName>
93
+ <rasd:InstanceID>1</rasd:InstanceID>
94
+ <rasd:ResourceType>3</rasd:ResourceType>
95
+ <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
96
+ </Item>
97
+ <Item>
98
+ <rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
99
+ <rasd:Caption>8192 MB of memory</rasd:Caption>
100
+ <rasd:Description>Memory Size</rasd:Description>
101
+ <rasd:ElementName>8192 MB of memory</rasd:ElementName>
102
+ <rasd:InstanceID>2</rasd:InstanceID>
103
+ <rasd:ResourceType>4</rasd:ResourceType>
104
+ <rasd:VirtualQuantity>8192</rasd:VirtualQuantity>
105
+ </Item>
106
+ <Item>
107
+ <rasd:Address>0</rasd:Address>
108
+ <rasd:Caption>scsiController0</rasd:Caption>
109
+ <rasd:Description>SCSI Controller</rasd:Description>
110
+ <rasd:ElementName>scsiController0</rasd:ElementName>
111
+ <rasd:InstanceID>3</rasd:InstanceID>
112
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
113
+ <rasd:ResourceType>6</rasd:ResourceType>
114
+ </Item>
115
+ <Item>
116
+ <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
117
+ <rasd:Caption>Ethernet adapter on 'Network 1'</rasd:Caption>
118
+ <rasd:Connection>Network 1</rasd:Connection>
119
+ <rasd:ElementName>Ethernet adapter on 'Network 1'</rasd:ElementName>
120
+ <rasd:InstanceID>4</rasd:InstanceID>
121
+ <rasd:ResourceSubType>E1000</rasd:ResourceSubType>
122
+ <rasd:ResourceType>10</rasd:ResourceType>
123
+ </Item>
124
+ <Item>
125
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
126
+ <rasd:Caption>disk1</rasd:Caption>
127
+ <rasd:Description>Disk Image</rasd:Description>
128
+ <rasd:ElementName>disk1</rasd:ElementName>
129
+ <rasd:HostResource>/disk/vmdisk1</rasd:HostResource>
130
+ <rasd:InstanceID>5</rasd:InstanceID>
131
+ <rasd:Parent>3</rasd:Parent>
132
+ <rasd:ResourceType>17</rasd:ResourceType>
133
+ </Item>
134
+ </VirtualHardwareSection>
135
+ </VirtualSystem>
136
+ </Envelope>
@@ -0,0 +1,132 @@
1
+ <?xml version="1.0"?>
2
+ <Envelope ovf:version="1.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xml:lang="en-US" xmlns="http://schemas.dmtf.org/ovf/envelope/1"
5
+ xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
6
+ xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
7
+ xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
8
+ xmlns:vmw="http://www.vmware.com/schema/ovf">
9
+
10
+ <References>
11
+ <File ovf:href="pivotal-ops-manager-disk1.vmdk" ovf:size="4223308288" ovf:id="file1"/>
12
+ </References>
13
+
14
+ <DiskSection>
15
+ <Info>List of the virtual disks used in the package</Info>
16
+ <Disk ovf:capacity="171798603879"
17
+ ovf:diskId="vmdisk1"
18
+ ovf:fileRef="file1"
19
+ ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
20
+ </DiskSection>
21
+
22
+ <NetworkSection>
23
+ <Info>Logical networks used in the package</Info>
24
+ <Network ovf:name="Network 1">
25
+ <Description>Logical network used by this appliance.</Description>
26
+ </Network>
27
+ </NetworkSection>
28
+
29
+ <vmw:IpAssignmentSection ovf:required="false" vmw:protocols="IPv4" vmw:schemes="">
30
+ <Info>Supported IP assignment schemes</Info>
31
+ </vmw:IpAssignmentSection>
32
+
33
+ <VirtualSystem ovf:id="FAKE_FILENAME">
34
+ <Info>A virtual machine</Info>
35
+
36
+ <ProductSection>
37
+ <Info/>
38
+ <Product>Ops Manager</Product>
39
+ <Vendor>Pivotal</Vendor>
40
+ <Version>2.2-build.365</Version>
41
+ <Property ovf:key="ip0" ovf:userConfigurable="true" ovf:type="string">
42
+ <Label>IP Address</Label>
43
+ <Description>The IP address for the Ops Manager. Leave blank if DHCP is desired.</Description>
44
+ </Property>
45
+ <Property ovf:key="netmask0" ovf:userConfigurable="true" ovf:type="string">
46
+ <Label>Netmask</Label>
47
+ <Description>The netmask for the Ops Manager's network. Leave blank if DHCP is desired.</Description>
48
+ </Property>
49
+ <Property ovf:key="gateway" ovf:userConfigurable="true" ovf:type="string">
50
+ <Label>Default Gateway</Label>
51
+ <Description>The default gateway address for the Ops Manager's network. Leave blank if DHCP is desired.</Description>
52
+ </Property>
53
+ <Property ovf:key="DNS" ovf:userConfigurable="true" ovf:type="string">
54
+ <Label>DNS</Label>
55
+ <Description>The domain name servers for the Ops Manager (comma separated). Leave blank if DHCP is desired.</Description>
56
+ </Property>
57
+ <Property ovf:key="ntp_servers" ovf:userConfigurable="true" ovf:type="string">
58
+ <Label>NTP Servers</Label>
59
+ <Description>Comma-delimited list of NTP servers</Description>
60
+ </Property>
61
+ <Property ovf:key="admin_password" ovf:required="true" ovf:userConfigurable="true" ovf:type="password">
62
+ <Label>Admin Password</Label>
63
+ <Description>This password is used to SSH into the Ops Manager. The username is 'ubuntu'.</Description>
64
+ </Property>
65
+ <Property ovf:key="custom_hostname" ovf:userConfigurable="true" ovf:type="string">
66
+ <Label>Custom Hostname</Label>
67
+ <Description>This will be set as the hostname on the VM. Default: 'pivotal-ops-manager'.</Description>
68
+ </Property>
69
+ </ProductSection>
70
+
71
+ <AnnotationSection>
72
+ <Info/>
73
+ <Annotation>Ops Manager for Pivotal Cloud Foundry
74
+ installs and manages PCF products and services.</Annotation>
75
+ </AnnotationSection>
76
+
77
+ <VirtualHardwareSection ovf:required="false" ovf:transport="com.vmware.guestInfo">
78
+ <Info>Virtual hardware requirements for a virtual machine</Info>
79
+ <System>
80
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
81
+ <vssd:InstanceID>0</vssd:InstanceID>
82
+ <vssd:VirtualSystemIdentifier>FAKE_FILENAME</vssd:VirtualSystemIdentifier>
83
+ <vssd:VirtualSystemType>vmx-09</vssd:VirtualSystemType>
84
+ </System>
85
+ <Item>
86
+ <rasd:Caption>1 virtual CPU</rasd:Caption>
87
+ <rasd:Description>Number of virtual CPUs</rasd:Description>
88
+ <rasd:ElementName>1 virtual CPU</rasd:ElementName>
89
+ <rasd:InstanceID>1</rasd:InstanceID>
90
+ <rasd:ResourceType>3</rasd:ResourceType>
91
+ <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
92
+ </Item>
93
+ <Item>
94
+ <rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
95
+ <rasd:Caption>8192 MB of memory</rasd:Caption>
96
+ <rasd:Description>Memory Size</rasd:Description>
97
+ <rasd:ElementName>8192 MB of memory</rasd:ElementName>
98
+ <rasd:InstanceID>2</rasd:InstanceID>
99
+ <rasd:ResourceType>4</rasd:ResourceType>
100
+ <rasd:VirtualQuantity>8192</rasd:VirtualQuantity>
101
+ </Item>
102
+ <Item>
103
+ <rasd:Address>0</rasd:Address>
104
+ <rasd:Caption>scsiController0</rasd:Caption>
105
+ <rasd:Description>SCSI Controller</rasd:Description>
106
+ <rasd:ElementName>scsiController0</rasd:ElementName>
107
+ <rasd:InstanceID>3</rasd:InstanceID>
108
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
109
+ <rasd:ResourceType>6</rasd:ResourceType>
110
+ </Item>
111
+ <Item>
112
+ <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
113
+ <rasd:Caption>Ethernet adapter on 'Network 1'</rasd:Caption>
114
+ <rasd:Connection>Network 1</rasd:Connection>
115
+ <rasd:ElementName>Ethernet adapter on 'Network 1'</rasd:ElementName>
116
+ <rasd:InstanceID>4</rasd:InstanceID>
117
+ <rasd:ResourceSubType>E1000</rasd:ResourceSubType>
118
+ <rasd:ResourceType>10</rasd:ResourceType>
119
+ </Item>
120
+ <Item>
121
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
122
+ <rasd:Caption>disk1</rasd:Caption>
123
+ <rasd:Description>Disk Image</rasd:Description>
124
+ <rasd:ElementName>disk1</rasd:ElementName>
125
+ <rasd:HostResource>/disk/vmdisk1</rasd:HostResource>
126
+ <rasd:InstanceID>5</rasd:InstanceID>
127
+ <rasd:Parent>3</rasd:Parent>
128
+ <rasd:ResourceType>17</rasd:ResourceType>
129
+ </Item>
130
+ </VirtualHardwareSection>
131
+ </VirtualSystem>
132
+ </Envelope>
@@ -48,18 +48,20 @@ module VmShepherd
48
48
  let(:ovf_template) { instance_double(RbVmomi::VIM::VirtualMachine, name: 'vm_name', add_delta_disk_layer_on_all_disks: nil, MarkAsTemplate: nil) }
49
49
  let(:vsphere_config) { { folder: folder_name, datastore: datastore_name } }
50
50
  let(:vm_config) { {ip: '10.0.0.1'} }
51
+ let(:ovf_path) { 'spec/fixtures/ova_manager/default.ovf' }
51
52
 
52
53
  before do
53
54
  allow(vsphere_manager).to receive(:system).with("nc -z -w 1 #{vm_config[:ip]} 443").and_return(false)
54
55
  allow(vsphere_manager).to receive(:system).with(/tar xfv/).and_return(true)
55
- allow(Dir).to receive(:[]).and_return(['foo.ovf'])
56
+ allow(Dir).to receive(:[]).and_return([ovf_path])
57
+ allow(FileUtils).to receive(:remove_entry_secure)
56
58
  allow(vsphere_manager).to receive(:datacenter).and_return(datacenter)
57
59
  allow(vsphere_manager).to receive(:connection).and_return(connection)
58
60
  allow(ovf_manager).to receive(:deployOVF).and_return(ovf_template)
59
61
  allow(vsphere_manager).to receive(:ovf_template_options).and_return({})
60
62
  end
61
63
 
62
- context 'When custom hostname is not set' do
64
+ context 'When a property value is not set' do
63
65
  it 'verifies the value of custom hostname is nil' do
64
66
  expect(vsphere_manager).to receive(:create_vm_from_template).and_return(vm1)
65
67
  allow(subject).to receive(:power_on_vm)
@@ -69,7 +71,34 @@ module VmShepherd
69
71
  custom_hostname_property = options[:spec].vAppConfig.property.find do |prop|
70
72
  prop.instance_variable_get(:@props)[:info].instance_variable_get(:@props)[:label] == 'custom_hostname'
71
73
  end
74
+ expect(custom_hostname_property.info.value).to be_nil
75
+ task
76
+ end
77
+
78
+ subject.deploy(ova_path, vm_config, vsphere_config)
79
+ end
80
+ end
81
+
82
+ context 'When the ovf does not contain a public_ssh_key property' do
83
+ let(:ovf_path) { 'spec/fixtures/ova_manager/without_public_ssh_key.ovf' }
84
+ let(:vm_config) { {ip: '10.0.0.1', custom_hostname: 'meow' } }
85
+
86
+ it 'does not create a property spec' do
87
+ expect(vsphere_manager).to receive(:create_vm_from_template).and_return(vm1)
88
+ allow(subject).to receive(:power_on_vm)
89
+ allow(task).to receive(:wait_for_completion)
90
+
91
+ expect(vm1).to receive(:ReconfigVM_Task) do |options|
92
+ custom_hostname_property = options[:spec].vAppConfig.property.find do |prop|
93
+ prop.instance_variable_get(:@props)[:info].instance_variable_get(:@props)[:label] == 'custom_hostname'
94
+ end
95
+ expect(custom_hostname_property.info.key).to eq(6)
96
+
97
+ custom_hostname_property = options[:spec].vAppConfig.property.find do |prop|
98
+ prop.instance_variable_get(:@props)[:info].instance_variable_get(:@props)[:label] == 'public_ssh_key'
99
+ end
72
100
  expect(custom_hostname_property).to be_nil
101
+
73
102
  task
74
103
  end
75
104
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vm_shepherd
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ops Manager Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-23 00:00:00.000000000 Z
11
+ date: 2018-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-v1
@@ -167,7 +167,9 @@ files:
167
167
  - lib/vm_shepherd/version.rb
168
168
  - lib/vm_shepherd/vsphere_manager.rb
169
169
  - spec/backport_refinements_spec.rb
170
+ - spec/fixtures/ova_manager/default.ovf
170
171
  - spec/fixtures/ova_manager/foo.ova
172
+ - spec/fixtures/ova_manager/without_public_ssh_key.ovf
171
173
  - spec/fixtures/shepherd/aws-no-elb.yml
172
174
  - spec/fixtures/shepherd/aws.yml
173
175
  - spec/fixtures/shepherd/openstack.yml
@@ -213,7 +215,9 @@ specification_version: 4
213
215
  summary: A tool for booting and tearing down Ops Manager VMs on various Infrastructures.
214
216
  test_files:
215
217
  - spec/backport_refinements_spec.rb
218
+ - spec/fixtures/ova_manager/default.ovf
216
219
  - spec/fixtures/ova_manager/foo.ova
220
+ - spec/fixtures/ova_manager/without_public_ssh_key.ovf
217
221
  - spec/fixtures/shepherd/aws-no-elb.yml
218
222
  - spec/fixtures/shepherd/aws.yml
219
223
  - spec/fixtures/shepherd/openstack.yml