knife-cosmic 0.2.0
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 +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,58 @@
|
|
1
|
+
#
|
2
|
+
# Original knife-cloudstack 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/cosmic_baselist'
|
21
|
+
|
22
|
+
module Knifecosmic
|
23
|
+
class CosmicAagList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifecosmicBaseList
|
26
|
+
|
27
|
+
banner "knife cosmic 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
|
@@ -0,0 +1,87 @@
|
|
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 CosmicAccountList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifecosmicBaseList
|
26
|
+
|
27
|
+
banner "knife cosmic account list (options)"
|
28
|
+
|
29
|
+
option :listall,
|
30
|
+
:long => "--listall",
|
31
|
+
:description => "List all the accounts",
|
32
|
+
:boolean => true
|
33
|
+
|
34
|
+
option :name,
|
35
|
+
:long => "--name NAME",
|
36
|
+
:description => "Specify account name to list"
|
37
|
+
|
38
|
+
option :keyword,
|
39
|
+
:long => "--keyword KEY",
|
40
|
+
:description => "List by keyword"
|
41
|
+
|
42
|
+
def run
|
43
|
+
validate_base_options
|
44
|
+
|
45
|
+
if locate_config_value(:cosmic_project)
|
46
|
+
columns = [
|
47
|
+
'Account :account',
|
48
|
+
'Domain :domain',
|
49
|
+
'Type :accounttype',
|
50
|
+
'Role :role',
|
51
|
+
'Users :user'
|
52
|
+
]
|
53
|
+
params = { 'command' => "listProjectAccounts" }
|
54
|
+
else
|
55
|
+
columns = [
|
56
|
+
'Name :name',
|
57
|
+
'Domain :domain',
|
58
|
+
'State :state',
|
59
|
+
'Type :accounttype',
|
60
|
+
'Users :user'
|
61
|
+
]
|
62
|
+
params = { 'command' => "listAccounts" }
|
63
|
+
end
|
64
|
+
|
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
|
+
|
70
|
+
if locate_config_value(:cosmic_project)
|
71
|
+
result = connection.list_object(params, "projectaccount")
|
72
|
+
else
|
73
|
+
result = connection.list_object(params, "account")
|
74
|
+
end
|
75
|
+
|
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']
|
81
|
+
end
|
82
|
+
|
83
|
+
list_object(columns, result)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,108 @@
|
|
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
|
+
class Chef
|
20
|
+
class Knife
|
21
|
+
module KnifecosmicBase
|
22
|
+
|
23
|
+
def self.included(includer)
|
24
|
+
includer.class_eval do
|
25
|
+
|
26
|
+
deps do
|
27
|
+
require 'knife-cosmic/connection'
|
28
|
+
end
|
29
|
+
|
30
|
+
option :cosmic_url,
|
31
|
+
:short => "-U URL",
|
32
|
+
:long => "--cosmic-url URL",
|
33
|
+
:description => "The cosmic endpoint URL",
|
34
|
+
:proc => Proc.new { |url| Chef::Config[:knife][:cosmic_url] = url }
|
35
|
+
|
36
|
+
option :cosmic_api_key,
|
37
|
+
:short => "-A KEY",
|
38
|
+
:long => "--cosmic-api-key KEY",
|
39
|
+
:description => "Your cosmic API key",
|
40
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:cosmic_api_key] = key }
|
41
|
+
|
42
|
+
option :cosmic_secret_key,
|
43
|
+
:short => "-K SECRET",
|
44
|
+
:long => "--cosmic-secret-key SECRET",
|
45
|
+
:description => "Your cosmic secret key",
|
46
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:cosmic_secret_key] = key }
|
47
|
+
|
48
|
+
option :cosmic_project,
|
49
|
+
:short => "-P PROJECT_NAME",
|
50
|
+
:long => '--cosmic-project PROJECT_NAME',
|
51
|
+
:description => "cosmic Project in which to create server",
|
52
|
+
:proc => Proc.new { |v| Chef::Config[:knife][:cosmic_project] = v },
|
53
|
+
:default => nil
|
54
|
+
|
55
|
+
option :cosmic_no_ssl_verify,
|
56
|
+
:long => '--cosmic-no-ssl-verify',
|
57
|
+
:description => "Disable certificate verify on SSL",
|
58
|
+
:boolean => true
|
59
|
+
|
60
|
+
option :cosmic_proxy,
|
61
|
+
:long => '--cosmic-proxy PROXY',
|
62
|
+
:description => "Enable proxy configuration for cosmic api access"
|
63
|
+
|
64
|
+
def validate_base_options
|
65
|
+
unless locate_config_value :cosmic_url
|
66
|
+
ui.error "cosmic URL not specified"
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
unless locate_config_value :cosmic_api_key
|
70
|
+
ui.error "cosmic API key not specified"
|
71
|
+
exit 1
|
72
|
+
end
|
73
|
+
unless locate_config_value :cosmic_secret_key
|
74
|
+
ui.error "cosmic Secret key not specified"
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def connection
|
80
|
+
@connection ||= CosmicClient::Connection.new(
|
81
|
+
locate_config_value(:cosmic_url),
|
82
|
+
locate_config_value(:cosmic_api_key),
|
83
|
+
locate_config_value(:cosmic_secret_key),
|
84
|
+
locate_config_value(:cosmic_project),
|
85
|
+
locate_config_value(:cosmic_no_ssl_verify),
|
86
|
+
locate_config_value(:cosmic_proxy)
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def locate_config_value(key)
|
91
|
+
key = key.to_sym
|
92
|
+
config[key] || Chef::Config[:knife][key] || nil
|
93
|
+
end
|
94
|
+
|
95
|
+
def exit_with_error(error)
|
96
|
+
ui.error error
|
97
|
+
exit 1
|
98
|
+
end
|
99
|
+
|
100
|
+
def valid_cosmic_name?(name)
|
101
|
+
!!(name && /^[a-zA-Z0-9][a-zA-Z0-9_\-#]*$/.match(name))
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,111 @@
|
|
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 'json'
|
20
|
+
require 'chef/knife/cosmic_base'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Knife
|
24
|
+
module KnifecosmicBaseList
|
25
|
+
|
26
|
+
def self.included(includer)
|
27
|
+
includer.class_eval do
|
28
|
+
include Chef::Knife::KnifecosmicBase
|
29
|
+
|
30
|
+
option :filter,
|
31
|
+
:long => "--filter 'FIELD:NAME'",
|
32
|
+
:description => "Specify field and part of name to list"
|
33
|
+
|
34
|
+
option :fields,
|
35
|
+
:long => "--fields 'NAME, NAME'",
|
36
|
+
:description => "The fields to output, comma-separated"
|
37
|
+
|
38
|
+
option :fieldlist,
|
39
|
+
:long => "--fieldlist",
|
40
|
+
:description => "The available fields to output/filter",
|
41
|
+
:boolean => true
|
42
|
+
|
43
|
+
option :noheader,
|
44
|
+
:long => "--noheader",
|
45
|
+
:description => "Removes header from output",
|
46
|
+
:boolean => true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def output_format(json)
|
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)
|
55
|
+
exit 0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def list_object_fields(object)
|
60
|
+
exit 1 if object.nil? || object.empty?
|
61
|
+
object_fields = [
|
62
|
+
ui.color('Key', :bold),
|
63
|
+
ui.color('Type', :bold),
|
64
|
+
ui.color('Value', :bold)
|
65
|
+
]
|
66
|
+
|
67
|
+
object.first.sort.each do |k,v|
|
68
|
+
object_fields << ui.color(k, :yellow, :bold)
|
69
|
+
object_fields << v.class.to_s
|
70
|
+
if v.kind_of?(Hash)
|
71
|
+
object_fields << '<Hash>'
|
72
|
+
elsif v.kind_of?(Array)
|
73
|
+
object_fields << '<Array>'
|
74
|
+
else
|
75
|
+
object_fields << ("#{v}").strip.to_s
|
76
|
+
end
|
77
|
+
end
|
78
|
+
puts "\n"
|
79
|
+
puts ui.list(object_fields, :uneven_columns_across, 3)
|
80
|
+
end
|
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
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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 CosmicClusterList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifecosmicBaseList
|
26
|
+
|
27
|
+
banner "knife cosmic cluster list (options)"
|
28
|
+
|
29
|
+
option :name,
|
30
|
+
:long => "--name NAME",
|
31
|
+
:description => "Specify cluster name to list"
|
32
|
+
|
33
|
+
option :keyword,
|
34
|
+
:long => "--keyword KEY",
|
35
|
+
:description => "List by keyword"
|
36
|
+
|
37
|
+
def run
|
38
|
+
validate_base_options
|
39
|
+
|
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)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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 CosmicConfigList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifecosmicBaseList
|
26
|
+
|
27
|
+
banner "knife cosmic config list (options)"
|
28
|
+
|
29
|
+
option :name,
|
30
|
+
:long => "--name NAME",
|
31
|
+
:description => "Specify router name to list"
|
32
|
+
|
33
|
+
option :keyword,
|
34
|
+
:long => "--keyword KEY",
|
35
|
+
:description => "List by keyword"
|
36
|
+
|
37
|
+
def run
|
38
|
+
validate_base_options
|
39
|
+
|
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)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|