knife-cloudstack-fog 0.3.3 → 0.3.4

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.
@@ -1,49 +1,49 @@
1
- # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
- # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackKeypairDelete < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack keypair delete NAME"
28
-
29
-
30
- def run
31
- if @name_args.nil?
32
- puts #{ui.color("Please provide a keypair name.", :red)}
33
- end
34
-
35
- @name_args.each do |keypair_name|
36
- response = connection.list_ssh_key_pairs('name' => keypair_name)
37
- fingerprint = response['listsshkeypairsresponse']['sshkeypair'].first['fingerprint']
38
- real_keypair_name = response['listsshkeypairsresponse']['sshkeypair'].first['name']
39
- puts "#{ui.color("Name", :red)}: #{real_keypair_name}"
40
- puts "#{ui.color("Fingerprint", :red)}: #{fingerprint}"
41
- puts "\n"
42
- confirm("#{ui.color("Do you really want to delete this keypair?", :red)}")
43
- connection.delete_ssh_key_pair(real_keypair_name)
44
- ui.warn("Deleted SSH keypair #{real_keypair_name}")
45
- end
46
- end
47
- end
48
- end
49
- end
1
+ # Author:: Takashi Kanai (<anikundesu@gmail.com>)
2
+ # Copyright:: Copyright (c) 2012 IDC Frontier Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackKeypairDelete < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack keypair delete NAME"
28
+
29
+
30
+ def run
31
+ if @name_args.nil? || @name_args.empty?
32
+ puts "#{ui.color("Please provide a keypair name.", :red)}"
33
+ end
34
+
35
+ @name_args.each do |keypair_name|
36
+ response = connection.list_ssh_key_pairs('name' => keypair_name)
37
+ fingerprint = response['listsshkeypairsresponse']['sshkeypair'].first['fingerprint']
38
+ real_keypair_name = response['listsshkeypairsresponse']['sshkeypair'].first['name']
39
+ puts "#{ui.color("Name", :red)}: #{real_keypair_name}"
40
+ puts "#{ui.color("Fingerprint", :red)}: #{fingerprint}"
41
+ puts "\n"
42
+ confirm("#{ui.color("Do you really want to delete this keypair?", :red)}")
43
+ connection.delete_ssh_key_pair(real_keypair_name)
44
+ ui.warn("Deleted SSH keypair #{real_keypair_name}")
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,53 +1,53 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackKeypairList < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack keypair list"
28
-
29
- def run
30
- $stdout.sync = true
31
-
32
- validate!
33
-
34
- sshkeypair_list = [
35
- ui.color('Name', :bold),
36
- ui.color('Fingerprint', :bold),
37
- ui.color('Private Key', :bold)
38
- ]
39
- response = connection.list_ssh_key_pairs['listsshkeypairsresponse']
40
- if sshkeypairs = response['sshkeypair']
41
- sshkeypairs.each do |sshkeypair|
42
- sshkeypair_list << sshkeypair['name'].to_s
43
- sshkeypair_list << sshkeypair['fingerprint'].to_s
44
- sshkeypair_list << sshkeypair['privatekey'].to_s
45
- end
46
- end
47
- puts ui.list(sshkeypair_list, :columns_across, 3)
48
-
49
- end
50
-
51
- end
52
- end
53
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackKeypairList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack keypair list"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ sshkeypair_list = [
35
+ ui.color('Name', :bold),
36
+ ui.color('Fingerprint', :bold),
37
+ ui.color('Private Key', :bold)
38
+ ]
39
+ response = connection.list_ssh_key_pairs['listsshkeypairsresponse']
40
+ if sshkeypairs = response['sshkeypair']
41
+ sshkeypairs.each do |sshkeypair|
42
+ sshkeypair_list << sshkeypair['name'].to_s
43
+ sshkeypair_list << sshkeypair['fingerprint'].to_s
44
+ sshkeypair_list << sshkeypair['privatekey'].to_s
45
+ end
46
+ end
47
+ puts ui.list(sshkeypair_list, :columns_across, 3)
48
+
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -1,147 +1,147 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2013 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackNetworkCreate < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack network create -n NAME -o NETWORKOFFERINGID -z ZONE (options)"
28
-
29
- option :name,
30
- :short => "-n NAME",
31
- :long => "--name NAME",
32
- :description => "The name of the network to create."
33
-
34
- option :networkoffering,
35
- :short => "-o NETWORKOFFERINGID",
36
- :long => "--networkoffering NETWORKOFFERINGID",
37
- :description => "The network service offering ID to use."
38
-
39
- option :zone,
40
- :short => "-z ZONE",
41
- :long => "--zone ZONE",
42
- :description => "The zone to create the network in."
43
-
44
- option :startip,
45
- :short => "-s STARTIP",
46
- :long => "--startip STARTIP",
47
- :description => "The starting IP for the network."
48
-
49
- option :endip,
50
- :short => "-e ENDIP",
51
- :long => "--endip ENDIP",
52
- :description => "The ending IP for the network."
53
-
54
- option :netmask,
55
- :short => "-m NETMASK",
56
- :long => "--netmask NETMASK",
57
- :description => "The netmask for the network."
58
-
59
- option :gateway,
60
- :short => "-g GATEWAY",
61
- :long => "--gateway GATEWAY",
62
- :description => "The gateway for the network."
63
-
64
- option :vlan,
65
- :short => "-l VLANID",
66
- :long => "--vlan VLANID",
67
- :description => "The VLAN for the network."
68
-
69
- option :displaytext,
70
- :short => "-i DISPLAYTEXT",
71
- :long => "--displaytext DISPLAYTEXT",
72
- :description => "The display name of the network, if different than the name."
73
-
74
-
75
- def run
76
- $stdout.sync = true
77
-
78
- validate!
79
-
80
- netoptions = {}
81
-
82
- if (locate_config_value(:name).nil? || locate_config_value(:networkoffering).nil? || locate_config_value(:zone).nil?)
83
- puts "Name (-n), Service Offering ID (-o), and Zone ID (-z) are required."
84
- else
85
- netoptions['name'] = locate_config_value(:name)
86
- netoptions['networkofferingid'] = locate_config_value(:networkoffering)
87
- netoptions['zoneid'] = locate_config_value(:zone)
88
-
89
- if locate_config_value(:startip) != nil
90
- netoptions['startip'] = locate_config_value(:startip)
91
- end
92
-
93
- if locate_config_value(:endip) != nil
94
- netoptions['endip'] = locate_config_value(:endip)
95
- end
96
-
97
- if locate_config_value(:netmask) != nil
98
- netoptions['netmask'] = locate_config_value(:netmask)
99
- end
100
-
101
- if locate_config_value(:gateway) != nil
102
- netoptions['gateway'] = locate_config_value(:gateway)
103
- end
104
-
105
- if locate_config_value(:vlan) != nil
106
- netoptions['vlan'] = locate_config_value(:vlan)
107
- end
108
-
109
- if locate_config_value(:displaytext) != nil
110
- netoptions['displaytext'] = locate_config_value(:displaytext)
111
- else
112
- netoptions['displaytext'] = locate_config_value(:name)
113
- end
114
-
115
- Chef::Log.debug("Options: #{netoptions}")
116
-
117
- response = connection.create_network(netoptions)
118
-
119
- Chef::Log.debug("API Response: #{response}")
120
-
121
- network_list = [
122
- ui.color('ID', :bold),
123
- ui.color('Name', :bold),
124
- ui.color('Display Text', :bold),
125
- ui.color('Zone ID', :bold),
126
- ui.color('VLAN', :bold),
127
- ui.color('State', :bold)
128
- ]
129
-
130
- newnetwork = response['createnetworkresponse']['network']
131
-
132
- network_list << newnetwork['id'].to_s
133
- network_list << newnetwork['name'].to_s
134
- network_list << newnetwork['displaytext'].to_s
135
- network_list << newnetwork['zoneid'].to_s
136
- network_list << newnetwork['vlan'].to_s
137
- network_list << newnetwork['state'].to_s
138
-
139
- puts ui.list(network_list, :columns_across, 6)
140
-
141
- end
142
-
143
- end
144
-
145
- end
146
- end
147
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2013 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackNetworkCreate < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack network create -n NAME -o NETWORKOFFERINGID -z ZONE (options)"
28
+
29
+ option :name,
30
+ :short => "-n NAME",
31
+ :long => "--name NAME",
32
+ :description => "The name of the network to create."
33
+
34
+ option :networkoffering,
35
+ :short => "-o NETWORKOFFERINGID",
36
+ :long => "--networkoffering NETWORKOFFERINGID",
37
+ :description => "The network service offering ID to use."
38
+
39
+ option :zone,
40
+ :short => "-z ZONE",
41
+ :long => "--zone ZONE",
42
+ :description => "The zone to create the network in."
43
+
44
+ option :startip,
45
+ :short => "-s STARTIP",
46
+ :long => "--startip STARTIP",
47
+ :description => "The starting IP for the network."
48
+
49
+ option :endip,
50
+ :short => "-e ENDIP",
51
+ :long => "--endip ENDIP",
52
+ :description => "The ending IP for the network."
53
+
54
+ option :netmask,
55
+ :short => "-m NETMASK",
56
+ :long => "--netmask NETMASK",
57
+ :description => "The netmask for the network."
58
+
59
+ option :gateway,
60
+ :short => "-g GATEWAY",
61
+ :long => "--gateway GATEWAY",
62
+ :description => "The gateway for the network."
63
+
64
+ option :vlan,
65
+ :short => "-l VLANID",
66
+ :long => "--vlan VLANID",
67
+ :description => "The VLAN for the network."
68
+
69
+ option :displaytext,
70
+ :short => "-i DISPLAYTEXT",
71
+ :long => "--displaytext DISPLAYTEXT",
72
+ :description => "The display name of the network, if different than the name."
73
+
74
+
75
+ def run
76
+ $stdout.sync = true
77
+
78
+ validate!
79
+
80
+ netoptions = {}
81
+
82
+ if (locate_config_value(:name).nil? || locate_config_value(:networkoffering).nil? || locate_config_value(:zone).nil?)
83
+ puts "Name (-n), Service Offering ID (-o), and Zone ID (-z) are required."
84
+ else
85
+ netoptions['name'] = locate_config_value(:name)
86
+ netoptions['networkofferingid'] = locate_config_value(:networkoffering)
87
+ netoptions['zoneid'] = locate_config_value(:zone)
88
+
89
+ if locate_config_value(:startip) != nil
90
+ netoptions['startip'] = locate_config_value(:startip)
91
+ end
92
+
93
+ if locate_config_value(:endip) != nil
94
+ netoptions['endip'] = locate_config_value(:endip)
95
+ end
96
+
97
+ if locate_config_value(:netmask) != nil
98
+ netoptions['netmask'] = locate_config_value(:netmask)
99
+ end
100
+
101
+ if locate_config_value(:gateway) != nil
102
+ netoptions['gateway'] = locate_config_value(:gateway)
103
+ end
104
+
105
+ if locate_config_value(:vlan) != nil
106
+ netoptions['vlan'] = locate_config_value(:vlan)
107
+ end
108
+
109
+ if locate_config_value(:displaytext) != nil
110
+ netoptions['displaytext'] = locate_config_value(:displaytext)
111
+ else
112
+ netoptions['displaytext'] = locate_config_value(:name)
113
+ end
114
+
115
+ Chef::Log.debug("Options: #{netoptions}")
116
+
117
+ response = connection.create_network(netoptions)
118
+
119
+ Chef::Log.debug("API Response: #{response}")
120
+
121
+ network_list = [
122
+ ui.color('ID', :bold),
123
+ ui.color('Name', :bold),
124
+ ui.color('Display Text', :bold),
125
+ ui.color('Zone ID', :bold),
126
+ ui.color('VLAN', :bold),
127
+ ui.color('State', :bold)
128
+ ]
129
+
130
+ newnetwork = response['createnetworkresponse']['network']
131
+
132
+ network_list << newnetwork['id'].to_s
133
+ network_list << newnetwork['name'].to_s
134
+ network_list << newnetwork['displaytext'].to_s
135
+ network_list << newnetwork['zoneid'].to_s
136
+ network_list << newnetwork['vlan'].to_s
137
+ network_list << newnetwork['state'].to_s
138
+
139
+ puts ui.list(network_list, :columns_across, 6)
140
+
141
+ end
142
+
143
+ end
144
+
145
+ end
146
+ end
147
+ end