knife-cloudstack 0.0.15 → 0.0.16
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.
- data/CHANGES.rdoc +15 -0
- data/README.rdoc +18 -0
- data/lib/chef/knife/cs_aag_list.rb +58 -0
- data/lib/chef/knife/cs_account_list.rb +32 -75
- data/lib/chef/knife/cs_base.rb +2 -5
- data/lib/chef/knife/cs_baselist.rb +37 -7
- data/lib/chef/knife/cs_cluster_list.rb +18 -51
- data/lib/chef/knife/cs_config_list.rb +14 -43
- data/lib/chef/knife/cs_disk_list.rb +16 -47
- data/lib/chef/knife/cs_domain_list.rb +15 -45
- data/lib/chef/knife/cs_firewallrule_list.rb +19 -52
- data/lib/chef/knife/cs_host_list.rb +19 -53
- data/lib/chef/knife/cs_iso_list.rb +30 -44
- data/lib/chef/knife/cs_keypair_list.rb +12 -51
- data/lib/chef/knife/cs_network_list.rb +20 -51
- data/lib/chef/knife/cs_oscategory_list.rb +12 -40
- data/lib/chef/knife/cs_ostype_list.rb +15 -43
- data/lib/chef/knife/cs_pod_list.rb +18 -51
- data/lib/chef/knife/cs_project_list.rb +16 -45
- data/lib/chef/knife/cs_publicip_list.rb +16 -49
- data/lib/chef/knife/cs_router_list.rb +16 -46
- data/lib/chef/knife/cs_securitygroup_list.rb +14 -89
- data/lib/chef/knife/cs_server_add_nic.rb +109 -0
- data/lib/chef/knife/cs_server_create.rb +25 -5
- data/lib/chef/knife/cs_server_list.rb +35 -62
- data/lib/chef/knife/cs_server_remove_nic.rb +101 -0
- data/lib/chef/knife/cs_service_list.rb +19 -59
- data/lib/chef/knife/cs_stack_create.rb +2 -0
- data/lib/chef/knife/cs_template_list.rb +26 -55
- data/lib/chef/knife/cs_template_register.rb +4 -4
- data/lib/chef/knife/cs_user_list.rb +19 -50
- data/lib/chef/knife/cs_volume_list.rb +17 -46
- data/lib/chef/knife/cs_zone_list.rb +13 -57
- data/lib/knife-cloudstack/connection.rb +60 -9
- metadata +5 -3
data/CHANGES.rdoc
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
= Changes
|
2
2
|
|
3
|
+
== 2014-02-12 (0.0.16)
|
4
|
+
* Added support for --no-public-ip for <tt>cs server list</tt> (Sander Botman, 12 Feb 2014)
|
5
|
+
* Added support for secret and secret_file in <tt>cs server create</tt> (Jeremy Baumont, 10 Feb 2014)
|
6
|
+
* Bugfix: correction in isextractable on <tt>cs template register</tt> (Etharin, 30 Jan 2014
|
7
|
+
* Added support for private-ip in <tt>cs server create</tt> (Joaquim Dos Santos, 26 Jan 2014)
|
8
|
+
* Bugfix: Keypair support on stack create (Ben Langfeld, 29 Nov 2013)
|
9
|
+
* Bugfix: Bootstrap even without port_rules options (Ben Langfeld, 29 Nov 2013)
|
10
|
+
* Bugfix: Option to specify iso as template when deploying instance <tt>cs server create</tt> (Sander Botman, 28 Nov 2013)
|
11
|
+
* Restructure all list commands (Sander Botman, 28 Nov 2013)
|
12
|
+
* Added subcommand: <tt>cs aag list</tt> (John E. Vincent, 23 Nov 2013)
|
13
|
+
* Added support for anti-affinity groups in <tt>cs server create</tt> (John E. Vincent, 23 Nov 2013)
|
14
|
+
* Added subcommand: <tt>cs server add nic</tt> (John E. Vincent, 13 Nov 2014)
|
15
|
+
* Added Trademark (David Nalley, 08 Nov 2013)
|
16
|
+
* Bugfix: fixing server creation inside basic networks (Sander Botman, 07 Nov 2013)
|
17
|
+
|
3
18
|
== 2013-11-04 (0.0.15)
|
4
19
|
* Bugfix: fixed the proxy with the option: --cloudstack-proxy http://username:password@yourproxy:8080 or use config file. (Sander Botman, 04 Nov 2013)
|
5
20
|
* Added subcommand: <tt>cs publicip list</tt> (Sander Botman, 03 Nov 2013)
|
data/README.rdoc
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
= knife-cloudstack
|
2
2
|
|
3
|
+
{<img src="https://codeclimate.com/github/CloudStack-extras/knife-cloudstack.png" />}[https://codeclimate.com/github/CloudStack-extras/knife-cloudstack]
|
4
|
+
{<img src="https://gemnasium.com/CloudStack-extras/knife-cloudstack.png" alt="Dependency Status" />}[https://gemnasium.com/CloudStack-extras/knife-cloudstack]
|
5
|
+
|
3
6
|
== DESCRIPTION:
|
4
7
|
|
5
8
|
This is the Edmunds Knife plugin for CloudStack. This plugin gives Knife the ability to create, bootstrap and manage
|
@@ -72,6 +75,12 @@ VM provided with <tt>--no-bootstrap</tt> option have no forwarded ports or forwa
|
|
72
75
|
|
73
76
|
By default, new servers are allocated a public IP address mapping to the CloudStack private IP address. If you do not want this behavior, pass the <tt>--no-public-ip</tt> option.
|
74
77
|
|
78
|
+
Forcing cloustack to reserve and use a certain private ipv4 address when deploying an instance inside an advanced zone is possible by passing <option>--private-ip</option> followed by the intended ipv4 address. Ip Address must be contained within the network mask of the isolated network, of course.
|
79
|
+
|
80
|
+
Example: knife cs server create testvm --private-ip 192.168.1.1 --networks mynetwork
|
81
|
+
|
82
|
+
Here mynetwork must have a network mask for example like 192.168.1.0/24.
|
83
|
+
|
75
84
|
==== Port forwarding rules for virtual networks
|
76
85
|
The <tt>--port-rules</tt> option takes a comma separated list of port forwarding rules. These rules are created on the
|
77
86
|
virtual public ip address of the server. Note that this option only applies to servers using a virtual network; it is
|
@@ -405,3 +414,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
405
414
|
See the License for the specific language governing permissions and
|
406
415
|
limitations under the License.
|
407
416
|
|
417
|
+
== Trademark Attribution
|
418
|
+
|
419
|
+
knife is a trademark of Opscode
|
420
|
+
|
421
|
+
CloudStack is a trademark or registered trademark of The Apache Software Foundation
|
422
|
+
|
423
|
+
The use of these marks is nominative in describing the function and integration of
|
424
|
+
this software and does not imply endorsement by Opscode, the Apache Software Foundation,
|
425
|
+
or Apache CloudStack.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John E. Vincent (<lusis.org+github.com@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 John E. Vincent.
|
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/cs_baselist'
|
21
|
+
|
22
|
+
module KnifeCloudstack
|
23
|
+
class CsAagList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifeCloudstackBaseList
|
26
|
+
|
27
|
+
banner "knife cs aag list (options)"
|
28
|
+
|
29
|
+
option :name,
|
30
|
+
:long => "--name NAME",
|
31
|
+
:description => "Specify aag name to list"
|
32
|
+
|
33
|
+
option :keyword,
|
34
|
+
:long => "--service NAME",
|
35
|
+
:description => "Specify part of aag name to list"
|
36
|
+
|
37
|
+
def run
|
38
|
+
validate_base_options
|
39
|
+
|
40
|
+
columns = [
|
41
|
+
'Name :name',
|
42
|
+
'Domain :domain',
|
43
|
+
'Type :type',
|
44
|
+
'Description :description',
|
45
|
+
'Id :id'
|
46
|
+
]
|
47
|
+
|
48
|
+
params = { 'command' => "listAffinityGroups" }
|
49
|
+
params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
|
50
|
+
params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
|
51
|
+
params['name'] = locate_config_value(:name) if locate_config_value(:name)
|
52
|
+
|
53
|
+
result = connection.list_object(params, "affinitygroup")
|
54
|
+
list_object(columns, result)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -16,20 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife
|
19
|
+
require 'chef/knife'
|
20
20
|
require 'chef/knife/cs_baselist'
|
21
21
|
|
22
22
|
module KnifeCloudstack
|
23
23
|
class CsAccountList < Chef::Knife
|
24
24
|
|
25
|
-
include Chef::Knife::KnifeCloudstackBase
|
26
25
|
include Chef::Knife::KnifeCloudstackBaseList
|
27
26
|
|
28
|
-
deps do
|
29
|
-
require 'knife-cloudstack/connection'
|
30
|
-
Chef::Knife::Bootstrap.load_deps
|
31
|
-
end
|
32
|
-
|
33
27
|
banner "knife cs account list (options)"
|
34
28
|
|
35
29
|
option :listall,
|
@@ -48,82 +42,45 @@ module KnifeCloudstack
|
|
48
42
|
def run
|
49
43
|
validate_base_options
|
50
44
|
|
51
|
-
if locate_config_value(:
|
52
|
-
|
53
|
-
|
45
|
+
if locate_config_value(:cloudstack_project)
|
46
|
+
columns = [
|
47
|
+
'Account :account',
|
48
|
+
'Domain :domain',
|
49
|
+
'Type :accounttype',
|
50
|
+
'Role :role',
|
51
|
+
'Users :user'
|
52
|
+
]
|
53
|
+
params = { 'command' => "listProjectAccounts" }
|
54
54
|
else
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
else
|
64
|
-
object_list = [
|
65
|
-
ui.color('Name', :bold),
|
66
|
-
ui.color('Domain', :bold),
|
67
|
-
ui.color('State', :bold),
|
68
|
-
ui.color('Type', :bold),
|
69
|
-
ui.color('Users', :bold)
|
70
|
-
]
|
71
|
-
end
|
55
|
+
columns = [
|
56
|
+
'Name :name',
|
57
|
+
'Domain :domain',
|
58
|
+
'State :state',
|
59
|
+
'Type :accounttype',
|
60
|
+
'Users :user'
|
61
|
+
]
|
62
|
+
params = { 'command' => "listAccounts" }
|
72
63
|
end
|
73
64
|
|
74
|
-
|
75
|
-
|
76
|
-
|
65
|
+
params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
|
66
|
+
params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
|
67
|
+
params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
|
68
|
+
params['name'] = locate_config_value(:name) if locate_config_value(:name)
|
69
|
+
|
77
70
|
if locate_config_value(:cloudstack_project)
|
78
|
-
|
79
|
-
api_result = "projectaccount"
|
71
|
+
result = connection.list_object(params, "projectaccount")
|
80
72
|
else
|
81
|
-
|
82
|
-
api_result = "account"
|
73
|
+
result = connection.list_object(params, "account")
|
83
74
|
end
|
84
75
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
locate_config_value(:keyword),
|
91
|
-
locate_config_value(:name)
|
92
|
-
)
|
93
|
-
|
94
|
-
output_format(connection_result)
|
95
|
-
|
96
|
-
connection_result.each do |r|
|
97
|
-
if locate_config_value(:fields)
|
98
|
-
locate_config_value(:fields).downcase.split(',').each { |n| object_list << ((r[("#{n}").strip]).to_s || 'N/A') }
|
99
|
-
else
|
100
|
-
if locate_config_value(:cloudstack_project)
|
101
|
-
object_list << r['account'].to_s
|
102
|
-
object_list << r['domain'].to_s
|
103
|
-
case r['accounttype']
|
104
|
-
when 0 then object_list << "User"
|
105
|
-
when 1 then object_list << "Admin"
|
106
|
-
when 2 then object_list << "Domain Admin"
|
107
|
-
else object_list << "unknown"
|
108
|
-
end
|
109
|
-
object_list << r['role'].to_s
|
110
|
-
object_list << r['user'].count.to_s
|
111
|
-
else
|
112
|
-
object_list << r['name'].to_s
|
113
|
-
object_list << r['domain'].to_s
|
114
|
-
object_list << r['state'].to_s
|
115
|
-
case r['accounttype']
|
116
|
-
when 0 then object_list << "User"
|
117
|
-
when 1 then object_list << "Admin"
|
118
|
-
when 2 then object_list << "Domain Admin"
|
119
|
-
else object_list << "unknown"
|
120
|
-
end
|
121
|
-
object_list << r['user'].count.to_s
|
122
|
-
end
|
123
|
-
end
|
76
|
+
result.each do |r|
|
77
|
+
r['accounttype'] = 'User' if r['accounttype'] == 0
|
78
|
+
r['accounttype'] = 'Admin' if r['accounttype'] == 1
|
79
|
+
r['accounttype'] = 'Domain Admin' if r['accounttype'] == 2
|
80
|
+
r['user'] = r['user'].count if r['user']
|
124
81
|
end
|
125
|
-
|
126
|
-
|
82
|
+
|
83
|
+
list_object(columns, result)
|
127
84
|
end
|
128
85
|
|
129
86
|
end
|
data/lib/chef/knife/cs_base.rb
CHANGED
@@ -16,8 +16,6 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
20
|
-
|
21
19
|
class Chef
|
22
20
|
class Knife
|
23
21
|
module KnifeCloudstackBase
|
@@ -26,8 +24,7 @@ class Chef
|
|
26
24
|
includer.class_eval do
|
27
25
|
|
28
26
|
deps do
|
29
|
-
require '
|
30
|
-
require 'chef/json_compat'
|
27
|
+
require 'knife-cloudstack/connection'
|
31
28
|
end
|
32
29
|
|
33
30
|
option :cloudstack_url,
|
@@ -92,7 +89,7 @@ class Chef
|
|
92
89
|
|
93
90
|
def locate_config_value(key)
|
94
91
|
key = key.to_sym
|
95
|
-
config[key] || Chef::Config[:knife][key]
|
92
|
+
config[key] || Chef::Config[:knife][key] || nil
|
96
93
|
end
|
97
94
|
|
98
95
|
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'json'
|
20
|
-
require 'chef/knife'
|
20
|
+
require 'chef/knife/cs_base'
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
class Knife
|
@@ -25,6 +25,7 @@ class Chef
|
|
25
25
|
|
26
26
|
def self.included(includer)
|
27
27
|
includer.class_eval do
|
28
|
+
include Chef::Knife::KnifeCloudstackBase
|
28
29
|
|
29
30
|
option :filter,
|
30
31
|
:long => "--filter 'FIELD:NAME'",
|
@@ -47,10 +48,10 @@ class Chef
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def output_format(json)
|
50
|
-
if locate_config_value(:format) =~ /
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
if locate_config_value(:format) =~ /^j/i
|
52
|
+
json_hash = {};
|
53
|
+
json.each { |k| json_hash.merge!( k['id'] => k) }
|
54
|
+
puts JSON.pretty_generate(json_hash)
|
54
55
|
exit 0
|
55
56
|
end
|
56
57
|
end
|
@@ -66,7 +67,9 @@ class Chef
|
|
66
67
|
object.first.sort.each do |k,v|
|
67
68
|
object_fields << ui.color(k, :yellow, :bold)
|
68
69
|
object_fields << v.class.to_s
|
69
|
-
if v.kind_of?(
|
70
|
+
if v.kind_of?(Hash)
|
71
|
+
object_fields << '<Hash>'
|
72
|
+
elsif v.kind_of?(Array)
|
70
73
|
object_fields << '<Array>'
|
71
74
|
else
|
72
75
|
object_fields << ("#{v}").strip.to_s
|
@@ -75,7 +78,34 @@ class Chef
|
|
75
78
|
puts "\n"
|
76
79
|
puts ui.list(object_fields, :uneven_columns_across, 3)
|
77
80
|
end
|
78
|
-
|
81
|
+
|
82
|
+
def list_object(columns, object)
|
83
|
+
|
84
|
+
output_format(object)
|
85
|
+
object_list = []
|
86
|
+
if locate_config_value(:fields)
|
87
|
+
locate_config_value(:fields).split(',').each { |n| object_list << ui.color(("#{n}").strip, :bold) }
|
88
|
+
else
|
89
|
+
columns.each do |column|
|
90
|
+
n = (column.split(':').first).strip
|
91
|
+
object_list << (ui.color("#{n}", :bold) || 'N/A')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
n_columns = object_list.count
|
96
|
+
object_list = [] if locate_config_value(:noheader)
|
97
|
+
|
98
|
+
object.each do |r|
|
99
|
+
if locate_config_value(:fields)
|
100
|
+
locate_config_value(:fields).downcase.split(',').each { |n| object_list << ((r[("#{n}").strip]).to_s || 'N/A') }
|
101
|
+
else
|
102
|
+
columns.each { |column| object_list << (r["#{column.split(':').last.strip}"].to_s || 'N/A') }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
puts ui.list(object_list, :uneven_columns_across, n_columns)
|
106
|
+
list_object_fields(object) if locate_config_value(:fieldlist)
|
107
|
+
end
|
108
|
+
|
79
109
|
end
|
80
110
|
end
|
81
111
|
end
|
@@ -16,20 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife
|
19
|
+
require 'chef/knife'
|
20
20
|
require 'chef/knife/cs_baselist'
|
21
21
|
|
22
22
|
module KnifeCloudstack
|
23
23
|
class CsClusterList < Chef::Knife
|
24
24
|
|
25
|
-
include Chef::Knife::KnifeCloudstackBase
|
26
25
|
include Chef::Knife::KnifeCloudstackBaseList
|
27
26
|
|
28
|
-
deps do
|
29
|
-
require 'knife-cloudstack/connection'
|
30
|
-
Chef::Knife.load_deps
|
31
|
-
end
|
32
|
-
|
33
27
|
banner "knife cs cluster list (options)"
|
34
28
|
|
35
29
|
option :name,
|
@@ -43,50 +37,23 @@ module KnifeCloudstack
|
|
43
37
|
def run
|
44
38
|
validate_base_options
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
connection_result = connection.list_object(
|
65
|
-
"listClusters",
|
66
|
-
"cluster",
|
67
|
-
locate_config_value(:filter),
|
68
|
-
false,
|
69
|
-
locate_config_value(:keyword),
|
70
|
-
locate_config_value(:name)
|
71
|
-
)
|
72
|
-
|
73
|
-
output_format(connection_result)
|
74
|
-
|
75
|
-
connection_result.each do |r|
|
76
|
-
if locate_config_value(:fields)
|
77
|
-
locate_config_value(:fields).downcase.split(',').each { |n| object_list << ((r[("#{n}").strip]).to_s || 'N/A') }
|
78
|
-
else
|
79
|
-
object_list << r['name'].to_s
|
80
|
-
object_list << r['podname'].to_s
|
81
|
-
object_list << r['zonename'].to_s
|
82
|
-
object_list << r['hypervisortype'].to_s
|
83
|
-
object_list << r['clustertype'].to_s
|
84
|
-
object_list << r['allocationstate'].to_s
|
85
|
-
object_list << r['managedstate'].to_s
|
86
|
-
end
|
87
|
-
end
|
88
|
-
puts ui.list(object_list, :uneven_columns_across, columns)
|
89
|
-
list_object_fields(connection_result) if locate_config_value(:fieldlist)
|
40
|
+
columns = [
|
41
|
+
'Name :name',
|
42
|
+
'Pod :podname',
|
43
|
+
'Zone :zonename',
|
44
|
+
'HypervizorType :hypervisortype',
|
45
|
+
'ClusterType :clustertype',
|
46
|
+
'AllocationState :allocationstate',
|
47
|
+
'ManagedState :managedstate'
|
48
|
+
]
|
49
|
+
|
50
|
+
params = { 'command' => "listClusters" }
|
51
|
+
params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
|
52
|
+
params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
|
53
|
+
params['name'] = locate_config_value(:name) if locate_config_value(:name)
|
54
|
+
|
55
|
+
result = connection.list_object(params, "cluster")
|
56
|
+
list_object(columns, result)
|
90
57
|
end
|
91
58
|
|
92
59
|
end
|
@@ -16,20 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife
|
19
|
+
require 'chef/knife'
|
20
20
|
require 'chef/knife/cs_baselist'
|
21
21
|
|
22
22
|
module KnifeCloudstack
|
23
23
|
class CsConfigList < Chef::Knife
|
24
24
|
|
25
|
-
include Chef::Knife::KnifeCloudstackBase
|
26
25
|
include Chef::Knife::KnifeCloudstackBaseList
|
27
26
|
|
28
|
-
deps do
|
29
|
-
require 'knife-cloudstack/connection'
|
30
|
-
Chef::Knife.load_deps
|
31
|
-
end
|
32
|
-
|
33
27
|
banner "knife cs config list (options)"
|
34
28
|
|
35
29
|
option :name,
|
@@ -43,42 +37,19 @@ module KnifeCloudstack
|
|
43
37
|
def run
|
44
38
|
validate_base_options
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
connection_result = connection.list_object(
|
61
|
-
"listConfigurations",
|
62
|
-
"configuration",
|
63
|
-
locate_config_value(:filter),
|
64
|
-
false,
|
65
|
-
locate_config_value(:keyword),
|
66
|
-
locate_config_value(:name)
|
67
|
-
)
|
68
|
-
|
69
|
-
output_format(connection_result)
|
70
|
-
|
71
|
-
connection_result.each do |r|
|
72
|
-
if locate_config_value(:fields)
|
73
|
-
locate_config_value(:fields).downcase.split(',').each { |n| object_list << ((r[("#{n}").strip]).to_s || 'N/A') }
|
74
|
-
else
|
75
|
-
object_list << r['category'].to_s
|
76
|
-
object_list << r['name'].to_s
|
77
|
-
object_list << r['value'].to_s
|
78
|
-
end
|
79
|
-
end
|
80
|
-
puts ui.list(object_list, :uneven_columns_across, columns)
|
81
|
-
list_object_fields(connection_result) if locate_config_value(:fieldlist)
|
40
|
+
columns = [
|
41
|
+
'Category :category',
|
42
|
+
'Name :name',
|
43
|
+
'Value :value'
|
44
|
+
]
|
45
|
+
|
46
|
+
params = { 'command' => "listConfigurations" }
|
47
|
+
params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
|
48
|
+
params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
|
49
|
+
params['name'] = locate_config_value(:name) if locate_config_value(:name)
|
50
|
+
|
51
|
+
result = connection.list_object(params, "configuration")
|
52
|
+
list_object(columns, result)
|
82
53
|
end
|
83
54
|
|
84
55
|
end
|
@@ -16,20 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife
|
19
|
+
require 'chef/knife'
|
20
20
|
require 'chef/knife/cs_baselist'
|
21
21
|
|
22
22
|
module KnifeCloudstack
|
23
23
|
class CsDiskList < Chef::Knife
|
24
24
|
|
25
|
-
include Chef::Knife::KnifeCloudstackBase
|
26
25
|
include Chef::Knife::KnifeCloudstackBaseList
|
27
26
|
|
28
|
-
deps do
|
29
|
-
require 'knife-cloudstack/connection'
|
30
|
-
Chef::Knife.load_deps
|
31
|
-
end
|
32
|
-
|
33
27
|
banner "knife cs disk list (options)"
|
34
28
|
|
35
29
|
option :name,
|
@@ -43,46 +37,21 @@ module KnifeCloudstack
|
|
43
37
|
def run
|
44
38
|
validate_base_options
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
connection_result = connection.list_object(
|
63
|
-
"listDiskOfferings",
|
64
|
-
"diskoffering",
|
65
|
-
locate_config_value(:filter),
|
66
|
-
false,
|
67
|
-
locate_config_value(:keyword),
|
68
|
-
locate_config_value(:name)
|
69
|
-
)
|
70
|
-
|
71
|
-
output_format(connection_result)
|
72
|
-
|
73
|
-
connection_result.each do |r|
|
74
|
-
if locate_config_value(:fields)
|
75
|
-
locate_config_value(:fields).downcase.split(',').each { |n| object_list << ((r[("#{n}").strip]).to_s || 'N/A') }
|
76
|
-
else
|
77
|
-
object_list << r['name'].to_s
|
78
|
-
object_list << r['domain'].to_s
|
79
|
-
object_list << r['disksize'].to_s + 'GB'
|
80
|
-
object_list << r['displaytext'].to_s
|
81
|
-
object_list << r['created']
|
82
|
-
end
|
83
|
-
end
|
84
|
-
puts ui.list(object_list, :uneven_columns_across, columns)
|
85
|
-
list_object_fields(connection_result) if locate_config_value(:fieldlist)
|
40
|
+
columns = [
|
41
|
+
'Name :name',
|
42
|
+
'Domain :domain',
|
43
|
+
'Size :disksize',
|
44
|
+
'Comment :displaytext',
|
45
|
+
'Created :created'
|
46
|
+
]
|
47
|
+
|
48
|
+
params = { 'command' => "listDiskOfferings" }
|
49
|
+
params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
|
50
|
+
params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
|
51
|
+
params['name'] = locate_config_value(:name) if locate_config_value(:name)
|
52
|
+
|
53
|
+
result = connection.list_object(params, "diskoffering")
|
54
|
+
list_object(columns, result)
|
86
55
|
end
|
87
56
|
|
88
57
|
end
|