knife-vsphere 2.1.1 → 2.1.3
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 +5 -5
- data/lib/chef/knife/base_vsphere_command.rb +69 -70
- data/lib/chef/knife/customization_helper.rb +4 -4
- data/lib/chef/knife/search_helper.rb +16 -7
- data/lib/chef/knife/vsphere_cluster_list.rb +8 -8
- data/lib/chef/knife/vsphere_cpu_ratio.rb +4 -4
- data/lib/chef/knife/vsphere_customization_list.rb +3 -3
- data/lib/chef/knife/vsphere_datastore_file.rb +17 -17
- data/lib/chef/knife/vsphere_datastore_list.rb +11 -11
- data/lib/chef/knife/vsphere_datastore_maxfree.rb +14 -14
- data/lib/chef/knife/vsphere_datastorecluster_list.rb +7 -7
- data/lib/chef/knife/vsphere_datastorecluster_maxfree.rb +10 -10
- data/lib/chef/knife/vsphere_folder_list.rb +4 -4
- data/lib/chef/knife/vsphere_hosts_list.rb +10 -10
- data/lib/chef/knife/vsphere_pool_list.rb +5 -5
- data/lib/chef/knife/vsphere_pool_query.rb +7 -7
- data/lib/chef/knife/vsphere_pool_show.rb +8 -8
- data/lib/chef/knife/vsphere_template_list.rb +7 -7
- data/lib/chef/knife/vsphere_vlan_create.rb +8 -8
- data/lib/chef/knife/vsphere_vlan_list.rb +3 -3
- data/lib/chef/knife/vsphere_vm_cdrom.rb +27 -27
- data/lib/chef/knife/vsphere_vm_clone.rb +224 -214
- data/lib/chef/knife/vsphere_vm_config.rb +6 -6
- data/lib/chef/knife/vsphere_vm_delete.rb +17 -17
- data/lib/chef/knife/vsphere_vm_disk_extend.rb +11 -11
- data/lib/chef/knife/vsphere_vm_disk_list.rb +6 -6
- data/lib/chef/knife/vsphere_vm_execute.rb +14 -14
- data/lib/chef/knife/vsphere_vm_find.rb +87 -87
- data/lib/chef/knife/vsphere_vm_list.rb +12 -12
- data/lib/chef/knife/vsphere_vm_markastemplate.rb +5 -5
- data/lib/chef/knife/vsphere_vm_migrate.rb +20 -25
- data/lib/chef/knife/vsphere_vm_move.rb +17 -17
- data/lib/chef/knife/vsphere_vm_net.rb +8 -8
- data/lib/chef/knife/vsphere_vm_network_add.rb +22 -24
- data/lib/chef/knife/vsphere_vm_network_delete.rb +8 -8
- data/lib/chef/knife/vsphere_vm_network_list.rb +5 -5
- data/lib/chef/knife/vsphere_vm_network_set.rb +10 -10
- data/lib/chef/knife/vsphere_vm_property_get.rb +7 -7
- data/lib/chef/knife/vsphere_vm_property_set.rb +16 -16
- data/lib/chef/knife/vsphere_vm_show.rb +8 -8
- data/lib/chef/knife/vsphere_vm_snapshot.rb +35 -35
- data/lib/chef/knife/vsphere_vm_state.rb +31 -31
- data/lib/chef/knife/vsphere_vm_toolsconfig.rb +11 -11
- data/lib/chef/knife/vsphere_vm_vmdk_add.rb +32 -32
- data/lib/chef/knife/vsphere_vm_vnc_set.rb +15 -15
- data/lib/chef/knife/vsphere_vm_wait_sysprep.rb +10 -11
- data/lib/knife-vsphere/version.rb +1 -1
- metadata +5 -89
@@ -2,21 +2,21 @@
|
|
2
2
|
# Author:: Owen Groves (<omgroves@gmail.com>)
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "chef/knife"
|
6
|
+
require "chef/knife/base_vsphere_command"
|
7
|
+
require "chef/knife/search_helper"
|
8
8
|
|
9
9
|
# Changes network on a certain VM
|
10
10
|
# VsphereVmNetworkSet extends the BaseVspherecommand
|
11
11
|
class Chef::Knife::VsphereVmNetworkSet < Chef::Knife::BaseVsphereCommand
|
12
12
|
include SearchHelper
|
13
|
-
banner
|
13
|
+
banner "knife vsphere vm network set VMNAME NETWORKNAME"
|
14
14
|
|
15
15
|
common_options
|
16
16
|
|
17
17
|
option :nic,
|
18
|
-
long:
|
19
|
-
description:
|
18
|
+
long: "--nic INTEGER",
|
19
|
+
description: "Network interface to use when multiple NICs are present on the VM. (0,1..)",
|
20
20
|
default: 0
|
21
21
|
|
22
22
|
# The main run method for vm_network_set
|
@@ -27,11 +27,11 @@ class Chef::Knife::VsphereVmNetworkSet < Chef::Knife::BaseVsphereCommand
|
|
27
27
|
networkname = @name_args[1]
|
28
28
|
if vmname.nil?
|
29
29
|
show_usage
|
30
|
-
fatal_exit(
|
30
|
+
fatal_exit("You must specify a virtual machine name")
|
31
31
|
end
|
32
32
|
if networkname.nil?
|
33
33
|
show_usage
|
34
|
-
fatal_exit(
|
34
|
+
fatal_exit("You must specify a network name")
|
35
35
|
end
|
36
36
|
|
37
37
|
network = find_network(networkname)
|
@@ -43,9 +43,9 @@ class Chef::Knife::VsphereVmNetworkSet < Chef::Knife::BaseVsphereCommand
|
|
43
43
|
elsif network.is_a? RbVmomi::VIM::Network
|
44
44
|
nic.backing = RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(deviceName: network.name)
|
45
45
|
else
|
46
|
-
fatal_exit(
|
46
|
+
fatal_exit("Network type not recognized")
|
47
47
|
end
|
48
|
-
change_spec = RbVmomi::VIM.VirtualMachineConfigSpec(deviceChange: [RbVmomi::VIM.VirtualDeviceConfigSpec(device: nic, operation:
|
48
|
+
change_spec = RbVmomi::VIM.VirtualMachineConfigSpec(deviceChange: [RbVmomi::VIM.VirtualDeviceConfigSpec(device: nic, operation: "edit")])
|
49
49
|
vm.ReconfigVM_Task(spec: change_spec).wait_for_completion
|
50
50
|
end
|
51
51
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# Author:: Brian Dupras (<bdupras@rallydev.com>)
|
2
2
|
# License:: Apache License, Version 2.0
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
4
|
+
require "chef/knife"
|
5
|
+
require "chef/knife/base_vsphere_command"
|
6
|
+
require "chef/knife/search_helper"
|
7
7
|
|
8
8
|
# VsphereVMPropertyget extends the BaseVspherecommand
|
9
9
|
class Chef::Knife::VsphereVmPropertyGet < Chef::Knife::BaseVsphereCommand
|
10
10
|
include SearchHelper
|
11
|
-
banner
|
11
|
+
banner "knife vsphere vm property get VMNAME PROPERTY. Gets a vApp Property on VMNAME."
|
12
12
|
|
13
13
|
common_options
|
14
14
|
|
@@ -19,19 +19,19 @@ class Chef::Knife::VsphereVmPropertyGet < Chef::Knife::BaseVsphereCommand
|
|
19
19
|
vmname = @name_args[0]
|
20
20
|
if vmname.nil?
|
21
21
|
show_usage
|
22
|
-
fatal_exit(
|
22
|
+
fatal_exit("You must specify a virtual machine name")
|
23
23
|
end
|
24
24
|
|
25
25
|
property_name = @name_args[1]
|
26
26
|
if property_name.nil?
|
27
27
|
show_usage
|
28
|
-
fatal_exit(
|
28
|
+
fatal_exit("You must specify a PROPERTY name (e.g. annotation)")
|
29
29
|
end
|
30
30
|
property_name = property_name.to_sym
|
31
31
|
|
32
32
|
vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}")
|
33
33
|
|
34
|
-
existing_property = vm.config.vAppConfig.property.find { |p| p.props[:id] == property_name.to_s
|
34
|
+
existing_property = vm.config.vAppConfig.property.find { |p| p.props[:id] == property_name.to_s }
|
35
35
|
|
36
36
|
if existing_property
|
37
37
|
puts existing_property.props[:value]
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# Author:: Brian Dupras (<bdupras@rallydev.com>)
|
2
2
|
# License:: Apache License, Version 2.0
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
4
|
+
require "chef/knife"
|
5
|
+
require "chef/knife/base_vsphere_command"
|
6
|
+
require "chef/knife/search_helper"
|
7
7
|
|
8
8
|
# VsphereVMPropertySet extends Basevspherecommand
|
9
9
|
class Chef::Knife::VsphereVmPropertySet < Chef::Knife::BaseVsphereCommand
|
10
10
|
include SearchHelper
|
11
|
-
banner
|
11
|
+
banner "knife vsphere vm property set VMNAME PROPERTY VALUE. Sets a vApp Property on VMNAME."
|
12
12
|
|
13
13
|
common_options
|
14
14
|
|
15
15
|
option :ovf_environment_transport,
|
16
|
-
long:
|
17
|
-
description:
|
16
|
+
long: "--ovf-environment-transport STRING",
|
17
|
+
description: "Comma delimited string. Configures the transports to use for properties. Supported values are: iso and com.vmware.guestInfo."
|
18
18
|
|
19
19
|
# The main run method for vm_property_set
|
20
20
|
#
|
@@ -23,20 +23,20 @@ class Chef::Knife::VsphereVmPropertySet < Chef::Knife::BaseVsphereCommand
|
|
23
23
|
vmname = @name_args[0]
|
24
24
|
if vmname.nil?
|
25
25
|
show_usage
|
26
|
-
fatal_exit(
|
26
|
+
fatal_exit("You must specify a virtual machine name")
|
27
27
|
end
|
28
28
|
|
29
29
|
property_name = @name_args[1]
|
30
30
|
if property_name.nil?
|
31
31
|
show_usage
|
32
|
-
fatal_exit(
|
32
|
+
fatal_exit("You must specify a PROPERTY name (e.g. annotation)")
|
33
33
|
end
|
34
34
|
property_name = property_name.to_sym
|
35
35
|
|
36
36
|
property_value = @name_args[2]
|
37
37
|
if property_value.nil?
|
38
38
|
show_usage
|
39
|
-
fatal_exit(
|
39
|
+
fatal_exit("You must specify a PROPERTY value")
|
40
40
|
end
|
41
41
|
|
42
42
|
vim_connection
|
@@ -46,14 +46,14 @@ class Chef::Knife::VsphereVmPropertySet < Chef::Knife::BaseVsphereCommand
|
|
46
46
|
vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}")
|
47
47
|
|
48
48
|
if vm.config.vAppConfig && vm.config.vAppConfig.property
|
49
|
-
existing_property = vm.config.vAppConfig.property.find { |p| p.props[:id] == property_name.to_s
|
49
|
+
existing_property = vm.config.vAppConfig.property.find { |p| p.props[:id] == property_name.to_s }
|
50
50
|
end
|
51
51
|
|
52
52
|
if existing_property
|
53
|
-
operation =
|
53
|
+
operation = "edit"
|
54
54
|
property_key = existing_property.props[:key]
|
55
55
|
else
|
56
|
-
operation =
|
56
|
+
operation = "add"
|
57
57
|
property_key = property_name.object_id
|
58
58
|
end
|
59
59
|
|
@@ -65,9 +65,9 @@ class Chef::Knife::VsphereVmPropertySet < Chef::Knife::BaseVsphereCommand
|
|
65
65
|
info: {
|
66
66
|
key: property_key,
|
67
67
|
id: property_name.to_s,
|
68
|
-
type:
|
68
|
+
type: "string",
|
69
69
|
userConfigurable: true,
|
70
|
-
value: property_value
|
70
|
+
value: property_value,
|
71
71
|
}
|
72
72
|
)
|
73
73
|
]
|
@@ -75,8 +75,8 @@ class Chef::Knife::VsphereVmPropertySet < Chef::Knife::BaseVsphereCommand
|
|
75
75
|
)
|
76
76
|
|
77
77
|
unless config[:ovf_environment_transport].nil?
|
78
|
-
transport = config[:ovf_environment_transport].split(
|
79
|
-
transport = [
|
78
|
+
transport = config[:ovf_environment_transport].split(",")
|
79
|
+
transport = [""] if transport == [] ## because "".split returns [] and vmware wants [""]
|
80
80
|
vm_config_spec[:vAppConfig][:ovfEnvironmentTransport] = transport
|
81
81
|
end
|
82
82
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# Author:: Brian Dupras (<bdupras@rallydev.com>)
|
2
2
|
# License:: Apache License, Version 2.0
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
4
|
+
require "chef/knife"
|
5
|
+
require "chef/knife/base_vsphere_command"
|
6
|
+
require "chef/knife/search_helper"
|
7
7
|
|
8
8
|
# VsphereVmShow extends the BaseVspherecommand
|
9
9
|
class Chef::Knife::VsphereVmShow < Chef::Knife::BaseVsphereCommand
|
10
10
|
include SearchHelper
|
11
|
-
banner
|
11
|
+
banner 'knife vsphere vm show VMNAME QUERY. See "http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.VirtualMachine.html" for allowed QUERY values.'
|
12
12
|
|
13
13
|
common_options
|
14
14
|
|
@@ -19,19 +19,19 @@ class Chef::Knife::VsphereVmShow < Chef::Knife::BaseVsphereCommand
|
|
19
19
|
vmname = @name_args.shift
|
20
20
|
if vmname.nil?
|
21
21
|
show_usage
|
22
|
-
fatal_exit(
|
22
|
+
fatal_exit("You must specify a virtual machine name")
|
23
23
|
end
|
24
24
|
|
25
25
|
if @name_args.empty?
|
26
26
|
show_usage
|
27
|
-
fatal_exit(
|
27
|
+
fatal_exit("You must specify a QUERY value (e.g. guest.ipAddress or network[0].name)")
|
28
28
|
end
|
29
29
|
|
30
30
|
vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}")
|
31
31
|
|
32
32
|
out = @name_args.map do |query_string|
|
33
33
|
# split QUERY by dots, and walk the object model
|
34
|
-
query = query_string.split
|
34
|
+
query = query_string.split "."
|
35
35
|
result = vm
|
36
36
|
query.each do |part|
|
37
37
|
message, index = part.split(/[\[\]]/)
|
@@ -43,6 +43,6 @@ class Chef::Knife::VsphereVmShow < Chef::Knife::BaseVsphereCommand
|
|
43
43
|
|
44
44
|
{ query_string => result }
|
45
45
|
end
|
46
|
-
|
46
|
+
ui.output out
|
47
47
|
end
|
48
48
|
end
|
@@ -2,68 +2,68 @@
|
|
2
2
|
# License:: Apache License, Version 2.0
|
3
3
|
#
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "chef/knife"
|
6
|
+
require "chef/knife/base_vsphere_command"
|
7
|
+
require "chef/knife/search_helper"
|
8
8
|
|
9
9
|
# Manage snapshots of a virtual machine
|
10
10
|
class Chef::Knife::VsphereVmSnapshot < Chef::Knife::BaseVsphereCommand
|
11
11
|
include SearchHelper
|
12
|
-
banner
|
12
|
+
banner "knife vsphere vm snapshot VMNAME (options)"
|
13
13
|
|
14
14
|
common_options
|
15
15
|
|
16
16
|
option :list,
|
17
|
-
long:
|
18
|
-
description:
|
17
|
+
long: "--list",
|
18
|
+
description: "The current tree of snapshots"
|
19
19
|
|
20
20
|
option :create_new_snapshot,
|
21
|
-
long:
|
22
|
-
description:
|
21
|
+
long: "--create SNAPSHOT",
|
22
|
+
description: "Create a new snapshot off of the current snapshot."
|
23
23
|
|
24
24
|
option :remove_named_snapshot,
|
25
|
-
long:
|
26
|
-
description:
|
25
|
+
long: "--remove SNAPSHOT",
|
26
|
+
description: "Remove a named snapshot."
|
27
27
|
|
28
28
|
option :revert_snapshot,
|
29
|
-
long:
|
30
|
-
description:
|
29
|
+
long: "--revert SNAPSHOT",
|
30
|
+
description: "Revert to a named snapshot."
|
31
31
|
|
32
32
|
option :revert_current_snapshot,
|
33
|
-
long:
|
34
|
-
description:
|
33
|
+
long: "--revert-current",
|
34
|
+
description: "Revert to current snapshot.",
|
35
35
|
boolean: false
|
36
36
|
|
37
37
|
option :power,
|
38
|
-
long:
|
39
|
-
description:
|
38
|
+
long: "--start",
|
39
|
+
description: "Indicates whether to start the VM after a successful revert",
|
40
40
|
boolean: false
|
41
41
|
|
42
42
|
option :wait,
|
43
|
-
long:
|
44
|
-
description:
|
43
|
+
long: "--wait",
|
44
|
+
description: "Indicates whether to wait for creation/removal to complete",
|
45
45
|
boolean: false
|
46
46
|
|
47
47
|
option :find, # imma deprecate this
|
48
|
-
long:
|
49
|
-
description:
|
48
|
+
long: "--find",
|
49
|
+
description: "Finds the virtual machine by searching all folders"
|
50
50
|
|
51
51
|
option :dump_memory,
|
52
|
-
long:
|
52
|
+
long: "--dump-memory",
|
53
53
|
boolean: true,
|
54
|
-
description:
|
54
|
+
description: "Dump the memory in the snapshot",
|
55
55
|
default: false
|
56
56
|
|
57
57
|
option :quiesce,
|
58
|
-
long:
|
58
|
+
long: "--quiesce",
|
59
59
|
boolean: true,
|
60
|
-
description:
|
60
|
+
description: "Quiesce the VM prior to snapshotting",
|
61
61
|
default: false
|
62
62
|
|
63
63
|
option :snapshot_description,
|
64
|
-
long:
|
65
|
-
description:
|
66
|
-
default:
|
64
|
+
long: "--snapshot-descr DESCR",
|
65
|
+
description: "Snapshot description",
|
66
|
+
default: ""
|
67
67
|
|
68
68
|
def run
|
69
69
|
$stdout.sync = true
|
@@ -71,7 +71,7 @@ class Chef::Knife::VsphereVmSnapshot < Chef::Knife::BaseVsphereCommand
|
|
71
71
|
vmname = @name_args[0]
|
72
72
|
if vmname.nil?
|
73
73
|
show_usage
|
74
|
-
ui.fatal(
|
74
|
+
ui.fatal("You must specify a virtual machine name")
|
75
75
|
exit 1
|
76
76
|
end
|
77
77
|
|
@@ -105,7 +105,7 @@ class Chef::Knife::VsphereVmSnapshot < Chef::Knife::BaseVsphereCommand
|
|
105
105
|
end
|
106
106
|
|
107
107
|
if get_config(:revert_current_snapshot)
|
108
|
-
puts
|
108
|
+
puts "Reverting to Current Snapshot"
|
109
109
|
vm.RevertToCurrentSnapshot_Task(suppressPowerOn: false).wait_for_completion
|
110
110
|
if get_config(:power)
|
111
111
|
vm.PowerOnVM_Task.wait_for_completion
|
@@ -137,12 +137,12 @@ class Chef::Knife::VsphereVmSnapshot < Chef::Knife::BaseVsphereCommand
|
|
137
137
|
|
138
138
|
def display_node(node, current)
|
139
139
|
children = node.childSnapshotList.map { |item| display_node(item, current) }
|
140
|
-
snapshot_tree = {
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
snapshot_tree
|
140
|
+
snapshot_tree = { "SnapshotName" => node.name,
|
141
|
+
"SnapshotId" => node.id,
|
142
|
+
"SnapshotDescription" => node.description,
|
143
|
+
"SnapshotCreationDate" => node.createTime.iso8601,
|
144
|
+
"Children" => children }
|
145
|
+
snapshot_tree["IsCurrentSnapshot"] = true if node.snapshot == current
|
146
146
|
snapshot_tree
|
147
147
|
end
|
148
148
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require "chef/knife"
|
7
|
+
require "chef/knife/base_vsphere_command"
|
8
|
+
require "chef/knife/search_helper"
|
9
9
|
|
10
10
|
# Manage power state of a virtual machine
|
11
11
|
# VsphereVmState extends the BaseVspherecommand
|
@@ -13,34 +13,34 @@ class Chef::Knife::VsphereVmState < Chef::Knife::BaseVsphereCommand
|
|
13
13
|
include SearchHelper
|
14
14
|
# The Different power states that vSphere reports
|
15
15
|
POWER_STATES = {
|
16
|
-
PS_ON =>
|
17
|
-
PS_OFF =>
|
18
|
-
PS_SUSPENDED =>
|
19
|
-
}
|
16
|
+
PS_ON => "powered on",
|
17
|
+
PS_OFF => "powered off",
|
18
|
+
PS_SUSPENDED => "suspended",
|
19
|
+
}.freeze
|
20
20
|
|
21
|
-
banner
|
21
|
+
banner "knife vsphere vm state VMNAME (options)"
|
22
22
|
|
23
23
|
common_options
|
24
24
|
|
25
25
|
option :state,
|
26
|
-
short:
|
27
|
-
long:
|
28
|
-
description:
|
26
|
+
short: "-s STATE",
|
27
|
+
long: "--state STATE",
|
28
|
+
description: "The power state to transition the VM into; one of on|off|suspended|reboot"
|
29
29
|
|
30
30
|
option :wait_port,
|
31
|
-
short:
|
32
|
-
long:
|
33
|
-
description:
|
31
|
+
short: "-w PORT",
|
32
|
+
long: "--wait-port PORT",
|
33
|
+
description: "Wait for VM to be accessible on a port"
|
34
34
|
|
35
35
|
option :shutdown,
|
36
|
-
short:
|
37
|
-
long:
|
38
|
-
description:
|
36
|
+
short: "-g",
|
37
|
+
long: "--shutdown",
|
38
|
+
description: "Guest OS shutdown"
|
39
39
|
|
40
40
|
option :recursive,
|
41
|
-
short:
|
42
|
-
long:
|
43
|
-
description:
|
41
|
+
short: "-r",
|
42
|
+
long: "--recursive",
|
43
|
+
description: "Search all folders"
|
44
44
|
|
45
45
|
# The main run method for vm_state
|
46
46
|
#
|
@@ -50,7 +50,7 @@ class Chef::Knife::VsphereVmState < Chef::Knife::BaseVsphereCommand
|
|
50
50
|
vmname = @name_args[0]
|
51
51
|
if vmname.nil?
|
52
52
|
show_usage
|
53
|
-
ui.fatal(
|
53
|
+
ui.fatal("You must specify a virtual machine name")
|
54
54
|
exit 1
|
55
55
|
end
|
56
56
|
|
@@ -65,14 +65,14 @@ class Chef::Knife::VsphereVmState < Chef::Knife::BaseVsphereCommand
|
|
65
65
|
else
|
66
66
|
|
67
67
|
case config[:state]
|
68
|
-
when
|
68
|
+
when "on"
|
69
69
|
if state == PS_ON
|
70
70
|
puts "Virtual machine #{vmname} was already powered on"
|
71
71
|
else
|
72
72
|
vm.PowerOnVM_Task.wait_for_completion
|
73
73
|
puts "Powered on virtual machine #{vmname}"
|
74
74
|
end
|
75
|
-
when
|
75
|
+
when "off"
|
76
76
|
if state == PS_OFF
|
77
77
|
puts "Virtual machine #{vmname} was already powered off"
|
78
78
|
else
|
@@ -81,33 +81,33 @@ class Chef::Knife::VsphereVmState < Chef::Knife::BaseVsphereCommand
|
|
81
81
|
print "Waiting for virtual machine #{vmname} to shut down..."
|
82
82
|
until vm.runtime.powerState == PS_OFF
|
83
83
|
sleep 2
|
84
|
-
print
|
84
|
+
print "."
|
85
85
|
end
|
86
|
-
puts
|
86
|
+
puts "done"
|
87
87
|
else
|
88
88
|
vm.PowerOffVM_Task.wait_for_completion
|
89
89
|
puts "Powered off virtual machine #{vmname}"
|
90
90
|
end
|
91
91
|
end
|
92
|
-
when
|
93
|
-
if state == POWER_STATES[
|
92
|
+
when "suspend"
|
93
|
+
if state == POWER_STATES["suspended"]
|
94
94
|
puts "Virtual machine #{vmname} was already suspended"
|
95
95
|
else
|
96
96
|
vm.SuspendVM_Task.wait_for_completion
|
97
97
|
puts "Suspended virtual machine #{vmname}"
|
98
98
|
end
|
99
|
-
when
|
99
|
+
when "reset"
|
100
100
|
vm.ResetVM_Task.wait_for_completion
|
101
101
|
puts "Reset virtual machine #{vmname}"
|
102
|
-
when
|
102
|
+
when "reboot"
|
103
103
|
vm.RebootGuest
|
104
104
|
puts "Reboot virtual machine #{vmname}"
|
105
105
|
end
|
106
106
|
|
107
107
|
if get_config(:wait_port)
|
108
108
|
print "Waiting for port #{get_config(:wait_port)}..."
|
109
|
-
print
|
110
|
-
puts
|
109
|
+
print "." until tcp_test_port_vm(vm, get_config(:wait_port))
|
110
|
+
puts "done"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|