knife-cosmic 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES.rdoc +186 -0
- data/LICENSE +202 -0
- data/README.rdoc +427 -0
- data/lib/chef/knife/cosmic_aag_list.rb +58 -0
- data/lib/chef/knife/cosmic_account_list.rb +87 -0
- data/lib/chef/knife/cosmic_base.rb +108 -0
- data/lib/chef/knife/cosmic_baselist.rb +111 -0
- data/lib/chef/knife/cosmic_cluster_list.rb +60 -0
- data/lib/chef/knife/cosmic_config_list.rb +56 -0
- data/lib/chef/knife/cosmic_disk_list.rb +58 -0
- data/lib/chef/knife/cosmic_domain_list.rb +53 -0
- data/lib/chef/knife/cosmic_firewallrule_create.rb +138 -0
- data/lib/chef/knife/cosmic_firewallrule_list.rb +62 -0
- data/lib/chef/knife/cosmic_forwardrule_create.rb +145 -0
- data/lib/chef/knife/cosmic_host_list.rb +61 -0
- data/lib/chef/knife/cosmic_hosts.rb +58 -0
- data/lib/chef/knife/cosmic_iso_list.rb +89 -0
- data/lib/chef/knife/cosmic_keypair_create.rb +72 -0
- data/lib/chef/knife/cosmic_keypair_delete.rb +60 -0
- data/lib/chef/knife/cosmic_keypair_list.rb +44 -0
- data/lib/chef/knife/cosmic_network_list.rb +63 -0
- data/lib/chef/knife/cosmic_oscategory_list.rb +50 -0
- data/lib/chef/knife/cosmic_ostype_list.rb +52 -0
- data/lib/chef/knife/cosmic_pod_list.rb +60 -0
- data/lib/chef/knife/cosmic_project_list.rb +63 -0
- data/lib/chef/knife/cosmic_publicip_list.rb +55 -0
- data/lib/chef/knife/cosmic_router_list.rb +64 -0
- data/lib/chef/knife/cosmic_securitygroup_list.rb +59 -0
- data/lib/chef/knife/cosmic_server_add_nic.rb +109 -0
- data/lib/chef/knife/cosmic_server_create.rb +674 -0
- data/lib/chef/knife/cosmic_server_delete.rb +153 -0
- data/lib/chef/knife/cosmic_server_list.rb +167 -0
- data/lib/chef/knife/cosmic_server_passwordreset.rb +91 -0
- data/lib/chef/knife/cosmic_server_reboot.rb +99 -0
- data/lib/chef/knife/cosmic_server_remove_nic.rb +101 -0
- data/lib/chef/knife/cosmic_server_start.rb +104 -0
- data/lib/chef/knife/cosmic_server_stop.rb +118 -0
- data/lib/chef/knife/cosmic_server_update.rb +47 -0
- data/lib/chef/knife/cosmic_service_list.rb +74 -0
- data/lib/chef/knife/cosmic_stack_create.rb +298 -0
- data/lib/chef/knife/cosmic_stack_delete.rb +79 -0
- data/lib/chef/knife/cosmic_template_create.rb +129 -0
- data/lib/chef/knife/cosmic_template_extract.rb +104 -0
- data/lib/chef/knife/cosmic_template_list.rb +88 -0
- data/lib/chef/knife/cosmic_template_register.rb +187 -0
- data/lib/chef/knife/cosmic_user_list.rb +62 -0
- data/lib/chef/knife/cosmic_volume_attach.rb +70 -0
- data/lib/chef/knife/cosmic_volume_create.rb +108 -0
- data/lib/chef/knife/cosmic_volume_delete.rb +97 -0
- data/lib/chef/knife/cosmic_volume_detach.rb +61 -0
- data/lib/chef/knife/cosmic_volume_list.rb +77 -0
- data/lib/chef/knife/cosmic_zone_list.rb +53 -0
- data/lib/knife-cosmic/connection.rb +1046 -0
- metadata +127 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Sander Botman.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife'
|
20
|
+
require 'chef/knife/cosmic_baselist'
|
21
|
+
|
22
|
+
module Knifecosmic
|
23
|
+
class CosmicUserList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifecosmicBaseList
|
26
|
+
|
27
|
+
banner "knife cosmic user list (options)"
|
28
|
+
|
29
|
+
option :listall,
|
30
|
+
:long => "--listall",
|
31
|
+
:description => "List all users",
|
32
|
+
:boolean => true
|
33
|
+
|
34
|
+
option :keyword,
|
35
|
+
:long => "--keyword KEY",
|
36
|
+
:description => "List by keyword"
|
37
|
+
|
38
|
+
def run
|
39
|
+
validate_base_options
|
40
|
+
|
41
|
+
columns = [
|
42
|
+
'Account :account',
|
43
|
+
'Type :accounttype',
|
44
|
+
'State :state',
|
45
|
+
'Domain :domain',
|
46
|
+
'Username :username',
|
47
|
+
'First :firstname',
|
48
|
+
'Last :lastname'
|
49
|
+
]
|
50
|
+
|
51
|
+
params = { 'command' => "listUsers" }
|
52
|
+
params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
|
53
|
+
params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
|
54
|
+
params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
|
55
|
+
params['name'] = locate_config_value(:name) if locate_config_value(:name)
|
56
|
+
|
57
|
+
result = connection.list_object(params, "user")
|
58
|
+
list_object(columns, result)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Original knife-cloudstack author:: David Bruce <dbruce@schubergphilis.com>
|
3
|
+
# Copyright:: Copyright (c) Schuberg Philis 2013
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife/cosmic_base'
|
20
|
+
|
21
|
+
module Knifecosmic
|
22
|
+
class CosmicVolumeAttach < Chef::Knife
|
23
|
+
include Chef::Knife::KnifecosmicBase
|
24
|
+
|
25
|
+
deps do
|
26
|
+
require 'knife-cosmic/connection'
|
27
|
+
Chef::Knife.load_deps
|
28
|
+
end
|
29
|
+
|
30
|
+
banner 'knife cosmic volume attach NAME VM (options)'
|
31
|
+
|
32
|
+
option :volume,
|
33
|
+
:long => '--volume VOLUME_NAME',
|
34
|
+
:description => 'Specify volume name to attach'
|
35
|
+
|
36
|
+
option :vm,
|
37
|
+
:long => '--vm VM_NAME',
|
38
|
+
:description => 'Name of the VM to attach disk to'
|
39
|
+
|
40
|
+
def run
|
41
|
+
validate_base_options
|
42
|
+
|
43
|
+
volumename = locate_config_value(:volume) || @name_args[0]
|
44
|
+
exit_with_error 'Invalid volume name.' unless valid_cosmic_name? volumename
|
45
|
+
|
46
|
+
vmname = locate_config_value(:vm) || @name_args[1]
|
47
|
+
exit_with_error 'Invalid virtual machine.' unless valid_cosmic_name? vmname
|
48
|
+
|
49
|
+
volume = connection.get_volume(volumename)
|
50
|
+
exit_with_error "Volume #{volumename} not found." unless volume && volume['id']
|
51
|
+
exit_with_error "Volume #{volumename} is currently attached." if volume['vmname']
|
52
|
+
|
53
|
+
vm = connection.get_server(vmname)
|
54
|
+
exit_with_error "Virtual machine #{vmname} not found." unless vm && vm['id']
|
55
|
+
|
56
|
+
puts ui.color("Attaching volume #{volumename} to #{vmname}", :magenta)
|
57
|
+
|
58
|
+
params = {
|
59
|
+
'command' => 'attachVolume',
|
60
|
+
'id' => volume['id'],
|
61
|
+
'virtualmachineid' => vm['id']
|
62
|
+
}
|
63
|
+
|
64
|
+
json = connection.send_async_request(params)
|
65
|
+
exit_with_error 'Unable to attach volume' unless json
|
66
|
+
|
67
|
+
puts "Volume #{volumename} is now attached to #{json['volume']['vmname']}"
|
68
|
+
end
|
69
|
+
end # class
|
70
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#
|
2
|
+
# Original knife-cloudstack author:: Jeremy Baumont (<jbaumont@schubergphilis.com>)
|
3
|
+
# Copyright:: Copyright (c) Schuberg Philis 2013
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife/cosmic_base'
|
20
|
+
|
21
|
+
module Knifecosmic
|
22
|
+
class CosmicVolumeCreate < Chef::Knife
|
23
|
+
|
24
|
+
include Chef::Knife::KnifecosmicBase
|
25
|
+
|
26
|
+
deps do
|
27
|
+
require 'knife-cosmic/connection'
|
28
|
+
Chef::Knife.load_deps
|
29
|
+
end
|
30
|
+
|
31
|
+
banner "knife cosmic volume create NAME (options)"
|
32
|
+
|
33
|
+
option :name,
|
34
|
+
:long => "--name NAME",
|
35
|
+
:description => "The name of the disk volume.",
|
36
|
+
:required => true,
|
37
|
+
:on => :head
|
38
|
+
|
39
|
+
option :account,
|
40
|
+
:long => "--account ACCOUNT_NAME",
|
41
|
+
:description => "The account associated with the disk volume. Must be used with the domainId parameter."
|
42
|
+
|
43
|
+
option :diskofferingid,
|
44
|
+
:long => "--diskofferingid ID",
|
45
|
+
:description => "The ID of the disk offering. Either diskOfferingId or snapshotId must be passed in."
|
46
|
+
|
47
|
+
option :domainid,
|
48
|
+
:long => "--domainid ID",
|
49
|
+
:description => "The domain ID associated with the disk offering. If used with the account parameter returns the disk volume associated with the account for the specified domain."
|
50
|
+
|
51
|
+
option :size,
|
52
|
+
:long => "--size SIZE",
|
53
|
+
:description => "Arbitrary volume size."
|
54
|
+
|
55
|
+
option :snapshotid,
|
56
|
+
:long => "--snapshotid ID",
|
57
|
+
:description => "The snapshot ID for the disk volume. Either diskOfferingId or snapshotId must be passed in."
|
58
|
+
|
59
|
+
option :zoneid,
|
60
|
+
:long => "--zoneid ID",
|
61
|
+
:description => "The ID of the availability zone.",
|
62
|
+
:required => true,
|
63
|
+
:on => :head
|
64
|
+
|
65
|
+
|
66
|
+
def run
|
67
|
+
validate_base_options
|
68
|
+
|
69
|
+
Chef::Log.debug("Validate hostname and options")
|
70
|
+
if locate_config_value(:name)
|
71
|
+
volumename = locate_config_value(:name)
|
72
|
+
else
|
73
|
+
volumename = @name_args.first
|
74
|
+
unless /^[a-zA-Z0-9][a-zA-Z0-9_\-#]*$/.match volumename then
|
75
|
+
ui.error "Invalid volumename. Please specify a simple name without any spaces"
|
76
|
+
exit 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
print "#{ui.color("Creating volume: #{volumename}", :magenta)}\n"
|
81
|
+
|
82
|
+
params = {
|
83
|
+
'command' => 'createVolume',
|
84
|
+
'name' => volumename,
|
85
|
+
}
|
86
|
+
|
87
|
+
params['account'] = locate_config_value(:account) if locate_config_value(:account)
|
88
|
+
params['diskofferingid'] = locate_config_value(:diskofferingid) if locate_config_value(:diskofferingid)
|
89
|
+
params['domainid'] = locate_config_value(:domainid) if locate_config_value(:domainid)
|
90
|
+
params['projectid'] = locate_config_value(:projectid) if locate_config_value(:projectid)
|
91
|
+
params['size'] = locate_config_value(:size) if locate_config_value(:size)
|
92
|
+
params['snapshotid'] = locate_config_value(:snapshotid) if locate_config_value(:snapshotid)
|
93
|
+
params['zoneid'] = locate_config_value(:zoneid) if locate_config_value(:zoneid)
|
94
|
+
|
95
|
+
json = connection.send_request(params)
|
96
|
+
|
97
|
+
if ! json then
|
98
|
+
ui.error("Unable to create volume")
|
99
|
+
exit 1
|
100
|
+
end
|
101
|
+
|
102
|
+
print "Volume #{json['id']} is being created in the background\n";
|
103
|
+
|
104
|
+
return json['id']
|
105
|
+
end
|
106
|
+
|
107
|
+
end # class
|
108
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#
|
2
|
+
# Original knife-cloudstack author:: Muga Nishizawa (<muga.nishizawa@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Muga Nishizawa.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife/cosmic_base'
|
20
|
+
|
21
|
+
module Knifecosmic
|
22
|
+
class CosmicVolumeDelete < Chef::Knife
|
23
|
+
|
24
|
+
include Chef::Knife::KnifecosmicBase
|
25
|
+
|
26
|
+
deps do
|
27
|
+
require 'knife-cosmic/connection'
|
28
|
+
require 'chef/api_client'
|
29
|
+
require 'chef/knife'
|
30
|
+
Chef::Knife.load_deps
|
31
|
+
end
|
32
|
+
|
33
|
+
banner "knife cosmic volume delete VOLUME_NAME [VOLUME_NAME ...] (options)"
|
34
|
+
|
35
|
+
def run
|
36
|
+
validate_base_options
|
37
|
+
|
38
|
+
@name_args.each do |volume_name|
|
39
|
+
volume = connection.get_volume(volume_name)
|
40
|
+
|
41
|
+
if !volume then
|
42
|
+
ui.error("Volume '#{volume_name}' not found")
|
43
|
+
next
|
44
|
+
end
|
45
|
+
|
46
|
+
if vmn = volume['vmname']
|
47
|
+
ui.error("Volume '#{volume_name}' attached to VM '#{vmn}'")
|
48
|
+
ui.error("You should detach it from VM to delete the volume.")
|
49
|
+
next
|
50
|
+
end
|
51
|
+
|
52
|
+
show_object_details(volume)
|
53
|
+
|
54
|
+
result = confirm_action("Do you really want to delete this volume")
|
55
|
+
if result
|
56
|
+
print "#{ui.color("Waiting for deletion", :magenta)}"
|
57
|
+
connection.delete_volume(volume_name)
|
58
|
+
puts "\n"
|
59
|
+
ui.msg("Deleted volume #{volume_name}")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def show_object_details(v)
|
65
|
+
return if locate_config_value(:yes)
|
66
|
+
|
67
|
+
object_fields = []
|
68
|
+
object_fields << ui.color("Name:", :cyan)
|
69
|
+
object_fields << v['name'].to_s
|
70
|
+
object_fields << ui.color("Account:", :cyan)
|
71
|
+
object_fields << v['account']
|
72
|
+
object_fields << ui.color("Domain:", :cyan)
|
73
|
+
object_fields << v['domain']
|
74
|
+
object_fields << ui.color("State:", :cyan)
|
75
|
+
object_fields << v['state']
|
76
|
+
object_fields << ui.color("VMName:", :cyan)
|
77
|
+
object_fields << v['vmname']
|
78
|
+
object_fields << ui.color("VMState:", :cyan)
|
79
|
+
object_fields << v['vmstate']
|
80
|
+
|
81
|
+
puts "\n"
|
82
|
+
puts ui.list(object_fields, :uneven_columns_across, 2)
|
83
|
+
puts "\n"
|
84
|
+
end
|
85
|
+
|
86
|
+
def confirm_action(question)
|
87
|
+
return true if locate_config_value(:yes)
|
88
|
+
result = ui.ask_question(question, :default => "Y" )
|
89
|
+
if result == "Y" || result == "y" then
|
90
|
+
return true
|
91
|
+
else
|
92
|
+
return false
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Original knife-cloudstack author:: David Bruce <dbruce@schubergphilis.com>
|
3
|
+
# Copyright:: Copyright (c) Schuberg Philis 2013
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife/cosmic_base'
|
20
|
+
|
21
|
+
module Knifecosmic
|
22
|
+
class CosmicVolumeDetach < Chef::Knife
|
23
|
+
|
24
|
+
include Chef::Knife::KnifecosmicBase
|
25
|
+
|
26
|
+
deps do
|
27
|
+
require 'knife-cosmic/connection'
|
28
|
+
Chef::Knife.load_deps
|
29
|
+
end
|
30
|
+
|
31
|
+
banner 'knife cosmic volume detach NAME (options)'
|
32
|
+
|
33
|
+
option :name,
|
34
|
+
:long => '--name',
|
35
|
+
:description => 'Specify volume name to detach'
|
36
|
+
|
37
|
+
def run
|
38
|
+
validate_base_options
|
39
|
+
|
40
|
+
volumename = locate_config_value(:volume) || @name_args[0]
|
41
|
+
exit_with_error 'Invalid volumename.' unless valid_cosmic_name? volumename
|
42
|
+
|
43
|
+
volume = connection.get_volume(volumename)
|
44
|
+
exit_with_error "Volume #{volumename} not found." unless volume && volume['id']
|
45
|
+
exit_with_error "Volume #{volumename} is not attached." unless volume['vmname']
|
46
|
+
|
47
|
+
puts ui.color("Detaching volume: #{volumename}", :magenta)
|
48
|
+
|
49
|
+
params = {
|
50
|
+
'command' => 'detachVolume',
|
51
|
+
'id' => volume['id']
|
52
|
+
}
|
53
|
+
|
54
|
+
json = connection.send_async_request(params)
|
55
|
+
exit_with_error 'Unable to detach volume' unless json
|
56
|
+
|
57
|
+
puts "Volume #{volumename} is now detached."
|
58
|
+
|
59
|
+
end
|
60
|
+
end # class
|
61
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Sander Botman.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife'
|
20
|
+
require 'chef/knife/cosmic_baselist'
|
21
|
+
|
22
|
+
module Knifecosmic
|
23
|
+
class CosmicVolumeList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifecosmicBaseList
|
26
|
+
|
27
|
+
banner "knife cosmic volume list (options)"
|
28
|
+
|
29
|
+
option :listall,
|
30
|
+
:long => "--listall",
|
31
|
+
:description => "List all volumes",
|
32
|
+
:boolean => true
|
33
|
+
|
34
|
+
option :name,
|
35
|
+
:long => "--name NAME",
|
36
|
+
:description => "Specify volume name to list"
|
37
|
+
|
38
|
+
option :keyword,
|
39
|
+
:long => "--keyword KEY",
|
40
|
+
:description => "List by keyword"
|
41
|
+
|
42
|
+
option :vmname,
|
43
|
+
:long => "--vmname NAME",
|
44
|
+
:description => "Virtual machine name to list volumes for"
|
45
|
+
|
46
|
+
def run
|
47
|
+
validate_base_options
|
48
|
+
|
49
|
+
columns = [
|
50
|
+
'Name :name',
|
51
|
+
'Account :account',
|
52
|
+
'Domain :domain',
|
53
|
+
'State :state',
|
54
|
+
'VMName :vmname',
|
55
|
+
'VMState :vmstate'
|
56
|
+
]
|
57
|
+
|
58
|
+
params = { 'command' => "listVolumes" }
|
59
|
+
params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
|
60
|
+
params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
|
61
|
+
params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
|
62
|
+
params['name'] = locate_config_value(:name) if locate_config_value(:name)
|
63
|
+
if locate_config_value(:vmname)
|
64
|
+
vm = connection.get_server(locate_config_value(:vmname))
|
65
|
+
params['virtualmachineid'] = vm['id']
|
66
|
+
end
|
67
|
+
|
68
|
+
@volumelist = connection.list_object(params, "volume")
|
69
|
+
list_object(columns, @volumelist)
|
70
|
+
end
|
71
|
+
|
72
|
+
def volumelist
|
73
|
+
@volumelist
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|