knife-cloudstack-fog 0.2.19 → 0.3.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.
- data/lib/chef/knife/cloudstack_diskoffering_list.rb +1 -1
- data/lib/chef/knife/cloudstack_keypair_create.rb +3 -3
- data/lib/chef/knife/cloudstack_keypair_delete.rb +2 -2
- data/lib/chef/knife/cloudstack_keypair_list.rb +1 -1
- data/lib/chef/knife/cloudstack_network_create.rb +147 -0
- data/lib/chef/knife/cloudstack_network_delete.rb +53 -0
- data/lib/chef/knife/{cloudstack_networks_list.rb → cloudstack_network_list.rb} +2 -2
- data/lib/chef/knife/cloudstack_networkoffering_list.rb +74 -0
- data/lib/chef/knife/cloudstack_portforwardingrule_list.rb +1 -1
- data/lib/chef/knife/cloudstack_publicip_create.rb +1 -1
- data/lib/chef/knife/cloudstack_publicip_list.rb +1 -1
- data/lib/chef/knife/cloudstack_server_create.rb +65 -48
- data/lib/chef/knife/cloudstack_server_delete.rb +1 -1
- data/lib/chef/knife/cloudstack_server_destroy.rb +53 -0
- data/lib/chef/knife/cloudstack_server_start.rb +69 -0
- data/lib/chef/knife/cloudstack_server_stop.rb +1 -1
- data/lib/chef/knife/cloudstack_serviceoffering_list.rb +1 -1
- data/lib/chef/knife/cloudstack_volumes_list.rb +1 -1
- data/lib/chef/knife/cloudstack_zone_list.rb +1 -1
- data/lib/knife-cloudstack-fog/version.rb +1 -1
- metadata +11 -6
@@ -24,12 +24,12 @@ class Chef
|
|
24
24
|
|
25
25
|
include Knife::CloudstackBase
|
26
26
|
|
27
|
-
banner "knife cloudstack keypair create (options)"
|
27
|
+
banner "knife cloudstack keypair create -k NAME (options)"
|
28
28
|
|
29
29
|
option :name,
|
30
30
|
:short => "-k KEYPAIR",
|
31
31
|
:long => "--keypair KEYPAIR",
|
32
|
-
:description => "The
|
32
|
+
:description => "The name of the Key Pair to create."
|
33
33
|
|
34
34
|
option :publickey,
|
35
35
|
:short => "-p publickey",
|
@@ -92,7 +92,7 @@ class Chef
|
|
92
92
|
puts ui.list(sshkeypair_list, :columns_across, 3)
|
93
93
|
end
|
94
94
|
else
|
95
|
-
puts 'Error. Missing -k option.'
|
95
|
+
puts 'Error. Missing Keypair Name (-k) option.'
|
96
96
|
end
|
97
97
|
|
98
98
|
end
|
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
|
25
25
|
include Knife::CloudstackBase
|
26
26
|
|
27
|
-
banner "knife cloudstack keypair delete NAME
|
27
|
+
banner "knife cloudstack keypair delete NAME"
|
28
28
|
|
29
29
|
|
30
30
|
def run
|
@@ -39,7 +39,7 @@ class Chef
|
|
39
39
|
puts "#{ui.color("Name", :red)}: #{real_keypair_name}"
|
40
40
|
puts "#{ui.color("Fingerprint", :red)}: #{fingerprint}"
|
41
41
|
puts "\n"
|
42
|
-
confirm("#{ui.color("Do you really want to delete this keypair", :red)}")
|
42
|
+
confirm("#{ui.color("Do you really want to delete this keypair?", :red)}")
|
43
43
|
connection.delete_ssh_key_pair(real_keypair_name)
|
44
44
|
ui.warn("Deleted SSH keypair #{real_keypair_name}")
|
45
45
|
end
|
@@ -0,0 +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
|
@@ -0,0 +1,53 @@
|
|
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 CloudstackNetworkDelete < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
|
27
|
+
banner "knife cloudstack network delete ID"
|
28
|
+
|
29
|
+
|
30
|
+
def run
|
31
|
+
if @name_args.nil?
|
32
|
+
puts #{ui.color("Please provide a network ID.", :red)}
|
33
|
+
end
|
34
|
+
|
35
|
+
@name_args.each do |network_id|
|
36
|
+
response = connection.list_networks('id' => network_id)
|
37
|
+
|
38
|
+
apiresponse = response['listnetworksresponse']
|
39
|
+
network = apiresponse['network']
|
40
|
+
Chef::Log.debug("Network: #{network}")
|
41
|
+
network_name = network[0]['name'].to_s
|
42
|
+
network_display = network[0]['displaytext'].to_s
|
43
|
+
puts "#{ui.color("Name", :red)}: #{network_name}"
|
44
|
+
puts "#{ui.color("Display Text", :red)}: #{network_display}"
|
45
|
+
puts "\n"
|
46
|
+
confirm("#{ui.color("Do you really want to delete this network?", :red)}")
|
47
|
+
connection.delete_network(network_id)
|
48
|
+
ui.warn("Deleted network #{network_name}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -20,11 +20,11 @@ require 'chef/knife/cloudstack_base'
|
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Knife
|
23
|
-
class
|
23
|
+
class CloudstackNetworkList < Knife
|
24
24
|
|
25
25
|
include Knife::CloudstackBase
|
26
26
|
|
27
|
-
banner "knife cloudstack
|
27
|
+
banner "knife cloudstack network list"
|
28
28
|
|
29
29
|
def run
|
30
30
|
$stdout.sync = true
|
@@ -0,0 +1,74 @@
|
|
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 CloudstackNetworkofferingList < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
|
27
|
+
banner "knife cloudstack networkoffering list"
|
28
|
+
|
29
|
+
def run
|
30
|
+
$stdout.sync = true
|
31
|
+
|
32
|
+
validate!
|
33
|
+
|
34
|
+
network_list = [
|
35
|
+
ui.color('ID', :bold),
|
36
|
+
ui.color('Name', :bold),
|
37
|
+
ui.color('Display Name', :bold),
|
38
|
+
ui.color('Traffic Type', :bold),
|
39
|
+
ui.color('State', :bold),
|
40
|
+
ui.color('Service Offering ID', :bold)
|
41
|
+
]
|
42
|
+
|
43
|
+
response = connection.list_network_offerings['listnetworkofferingsresponse']
|
44
|
+
|
45
|
+
if networks = response['networkoffering']
|
46
|
+
|
47
|
+
networks.each do |networkoffering|
|
48
|
+
# puts networkoffering
|
49
|
+
network_list << networkoffering['id'].to_s
|
50
|
+
network_list << networkoffering['name'].to_s
|
51
|
+
network_list << networkoffering['displaytext'].to_s
|
52
|
+
network_list << networkoffering['traffictype'].to_s
|
53
|
+
network_list << begin
|
54
|
+
state = networkoffering['state'].to_s.downcase
|
55
|
+
case state
|
56
|
+
when 'allocated'
|
57
|
+
ui.color(state, :red)
|
58
|
+
when 'pending'
|
59
|
+
ui.color(state, :yellow)
|
60
|
+
else
|
61
|
+
ui.color(state, :green)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
network_list << networkoffering['serviceofferingid'].to_s
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
puts ui.list(network_list, :uneven_columns_across, 6)
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
|
29
29
|
include Knife::CloudstackBase
|
30
30
|
|
31
|
-
banner "knife cloudstack server create (options)"
|
31
|
+
banner "knife cloudstack server create -s SERVICEID -t TEMPLATEID -z ZONEID (options)"
|
32
32
|
|
33
33
|
option :cloudstack_serviceid,
|
34
34
|
:short => "-s SERVICEID",
|
@@ -145,6 +145,7 @@ class Chef
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def tcp_test_ssh(hostname)
|
148
|
+
print("#{ui.color(".", :magenta)}")
|
148
149
|
tcp_socket = TCPSocket.new(hostname, 22)
|
149
150
|
readable = IO.select([tcp_socket], nil, nil, 5)
|
150
151
|
if readable
|
@@ -230,62 +231,78 @@ class Chef
|
|
230
231
|
jobid = server['deployvirtualmachineresponse'].fetch('jobid')
|
231
232
|
|
232
233
|
server_start = connection.query_async_job_result('jobid'=>jobid)
|
234
|
+
|
235
|
+
Chef::Log.debug("Job ID: #{jobid} \n")
|
236
|
+
|
233
237
|
print "#{ui.color("Waiting for server", :magenta)}"
|
234
|
-
while server_start['queryasyncjobresultresponse'].fetch('jobstatus')
|
238
|
+
while server_start['queryasyncjobresultresponse'].fetch('jobstatus') == 0
|
235
239
|
print "#{ui.color(".", :magenta)}"
|
236
240
|
sleep(15)
|
237
241
|
server_start = connection.query_async_job_result('jobid'=>jobid)
|
242
|
+
Chef::Log.debug("Server_Start: #{server_start} \n")
|
238
243
|
end
|
239
244
|
puts "\n\n"
|
240
245
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
Chef::Log.debug("Server_Start: #{server_start} \n")
|
245
|
-
|
246
|
-
server_info = server_start['queryasyncjobresultresponse']['jobresult']['virtualmachine']
|
247
|
-
|
248
|
-
server_name = server_info['displayname']
|
249
|
-
server_id = server_info['hostname']
|
250
|
-
server_serviceoffering = server_info['serviceofferingname']
|
251
|
-
server_template = server_info['templatename']
|
252
|
-
if server_info['password'] != nil
|
253
|
-
ssh_password = server_info['password']
|
254
|
-
else
|
255
|
-
ssh_password = locate_config_value(:ssh_password)
|
246
|
+
if server_start['queryasyncjobresultresponse'].fetch('jobstatus') == 2
|
247
|
+
errortext = server_start['queryasyncjobresultresponse'].fetch('jobresult').fetch('errortext')
|
248
|
+
puts "#{ui.color("ERROR! Job failed with #{errortext}", :red)}"
|
256
249
|
end
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
250
|
+
|
251
|
+
if server_start['queryasyncjobresultresponse'].fetch('jobstatus') == 1
|
252
|
+
|
253
|
+
Chef::Log.debug("Job ID: #{jobid} \n")
|
254
|
+
Chef::Log.debug("Options: #{options} \n")
|
255
|
+
server_start = connection.query_async_job_result('jobid'=>jobid)
|
256
|
+
Chef::Log.debug("Server_Start: #{server_start} \n")
|
257
|
+
|
258
|
+
server_info = server_start['queryasyncjobresultresponse']['jobresult']['virtualmachine']
|
259
|
+
|
260
|
+
server_name = server_info['displayname']
|
261
|
+
server_id = server_info['name']
|
262
|
+
server_serviceoffering = server_info['serviceofferingname']
|
263
|
+
server_template = server_info['templatename']
|
264
|
+
if server_info['password'] != nil
|
265
|
+
ssh_password = server_info['password']
|
266
|
+
else
|
267
|
+
ssh_password = locate_config_value(:ssh_password)
|
268
|
+
end
|
269
|
+
|
270
|
+
ssh_user = locate_config_value(:ssh_user)
|
271
|
+
|
272
|
+
public_ip = nil
|
273
|
+
|
274
|
+
if server_info['nic'].size > 0
|
275
|
+
public_ip = server_info['nic'].first['ipaddress']
|
276
|
+
end
|
277
|
+
|
278
|
+
puts "\n\n"
|
279
|
+
puts "#{ui.color("Name", :cyan)}: #{server_name}"
|
280
|
+
puts "#{ui.color("Public IP", :cyan)}: #{public_ip}"
|
281
|
+
puts "#{ui.color("Username", :cyan)}: #{ssh_user}"
|
282
|
+
puts "#{ui.color("Password", :cyan)}: #{ssh_password}"
|
283
|
+
|
284
|
+
print "\n#{ui.color("Waiting for sshd", :magenta)}"
|
285
|
+
|
286
|
+
print("#{ui.color(".", :magenta)}") until tcp_test_ssh(public_ip) { sleep @initial_sleep_delay ||= 10; puts("done") }
|
287
|
+
|
288
|
+
puts("#{ui.color("Waiting for password/keys to sync.", :magenta)}")
|
289
|
+
sleep 15
|
290
|
+
|
291
|
+
bootstrap_for_node(public_ip, ssh_user, ssh_password).run
|
292
|
+
|
293
|
+
Chef::Log.debug("#{server_info}")
|
294
|
+
|
295
|
+
puts "\n"
|
296
|
+
puts "#{ui.color("Instance Name", :green)}: #{server_name}"
|
297
|
+
puts "#{ui.color("Instance ID", :green)}: #{server_id}"
|
298
|
+
puts "#{ui.color("Service Offering", :green)}: #{server_serviceoffering}"
|
299
|
+
puts "#{ui.color("Template", :green)}: #{server_template}"
|
300
|
+
puts "#{ui.color("Public IP Address", :green)}: #{public_ip}"
|
301
|
+
puts "#{ui.color("User", :green)}: #{ssh_user}"
|
302
|
+
puts "#{ui.color("Password", :green)}: #{ssh_password}"
|
303
|
+
puts "#{ui.color("Environment", :green)}: #{config[:environment] || '_default'}"
|
304
|
+
puts "#{ui.color("Run List", :green)}: #{config[:run_list].join(', ')}"
|
264
305
|
end
|
265
|
-
|
266
|
-
puts "\n\n"
|
267
|
-
puts "#{ui.color("Name", :cyan)}: #{server_name}"
|
268
|
-
puts "#{ui.color("Public IP", :cyan)}: #{public_ip}"
|
269
|
-
puts "#{ui.color("Username", :cyan)}: #{ssh_user}"
|
270
|
-
puts "#{ui.color("Password", :cyan)}: #{ssh_password}"
|
271
|
-
|
272
|
-
print "\n#{ui.color("Waiting for sshd", :magenta)}"
|
273
|
-
|
274
|
-
print("#{ui.color(".", :magenta)}") until tcp_test_ssh(public_ip) { sleep @initial_sleep_delay ||= 10; puts("done") }
|
275
|
-
|
276
|
-
bootstrap_for_node(public_ip, ssh_user, ssh_password).run
|
277
|
-
|
278
|
-
puts "\n"
|
279
|
-
puts "#{ui.color("Instance Name", :green)}: #{server_name}"
|
280
|
-
puts "#{ui.color("Instance ID", :green)}: #{server_id}"
|
281
|
-
puts "#{ui.color("Service Offering", :green)}: #{server_serviceoffering}"
|
282
|
-
puts "#{ui.color("Template", :green)}: #{server_template}"
|
283
|
-
puts "#{ui.color("Public IP Address", :green)}: #{public_ip}"
|
284
|
-
puts "#{ui.color("User", :green)}: #{ssh_user}"
|
285
|
-
puts "#{ui.color("Password", :green)}: #{ssh_password}"
|
286
|
-
puts "#{ui.color("Environment", :green)}: #{config[:environment] || '_default'}"
|
287
|
-
puts "#{ui.color("Run List", :green)}: #{config[:run_list].join(', ')}"
|
288
|
-
|
289
306
|
|
290
307
|
end
|
291
308
|
|
@@ -0,0 +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 CloudstackServerDestroy < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
banner "knife cloudstack server destroy INSTANCE_ID"
|
27
|
+
|
28
|
+
def run
|
29
|
+
|
30
|
+
if @name_args.nil?
|
31
|
+
puts #{ui.color("Please provide an Instance ID.", :red)}
|
32
|
+
end
|
33
|
+
|
34
|
+
@name_args.each do |instance_id|
|
35
|
+
response = connection.list_virtual_machines('name' => instance_id)
|
36
|
+
instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name']
|
37
|
+
instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress']
|
38
|
+
real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id']
|
39
|
+
puts "#{ui.color("Name", :red)}: #{instance_name}"
|
40
|
+
puts "#{ui.color("Public IP", :red)}: #{instance_ip}"
|
41
|
+
puts "\n"
|
42
|
+
confirm("#{ui.color("Do you really want to destroy this server", :red)}")
|
43
|
+
connection.destroy_virtual_machine('id' => real_instance_id)
|
44
|
+
ui.warn("Destroyed server #{instance_name}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,69 @@
|
|
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 CloudstackServerStart < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
banner "knife cloudstack server start INSTANCE_ID"
|
27
|
+
|
28
|
+
def run
|
29
|
+
|
30
|
+
if @name_args.nil?
|
31
|
+
puts #{ui.color("Please provide an Instance ID.", :red)}
|
32
|
+
end
|
33
|
+
|
34
|
+
@name_args.each do |instance_id|
|
35
|
+
response = connection.list_virtual_machines('name' => instance_id)
|
36
|
+
instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name']
|
37
|
+
instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress']
|
38
|
+
real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id']
|
39
|
+
puts "#{ui.color("Name", :green)}: #{instance_name}"
|
40
|
+
puts "#{ui.color("Public IP", :green)}: #{instance_ip}"
|
41
|
+
puts "\n"
|
42
|
+
confirm("#{ui.color("Do you really want to start this server", :green)}")
|
43
|
+
|
44
|
+
|
45
|
+
if :force
|
46
|
+
server = connection.start_virtual_machine('id' => real_instance_id, 'forced' => true)
|
47
|
+
else
|
48
|
+
server = connection.start_virtual_machine('id' => real_instance_id)
|
49
|
+
end
|
50
|
+
jobid = server['startvirtualmachineresponse'].fetch('jobid')
|
51
|
+
server_start = connection.query_async_job_result('jobid'=>jobid)
|
52
|
+
print "#{ui.color("Waiting for server", :magenta)}"
|
53
|
+
while server_start['queryasyncjobresultresponse'].fetch('jobstatus') != 1
|
54
|
+
print "#{ui.color(".", :magenta)}"
|
55
|
+
sleep(1)
|
56
|
+
server_start = connection.query_async_job_result('jobid'=>jobid)
|
57
|
+
end
|
58
|
+
puts "\n\n"
|
59
|
+
|
60
|
+
ui.warn("Started server #{instance_name}")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
class CloudstackServerStop < Knife
|
24
24
|
|
25
25
|
include Knife::CloudstackBase
|
26
|
-
banner "knife cloudstack server stop INSTANCE_ID
|
26
|
+
banner "knife cloudstack server stop INSTANCE_ID (options)"
|
27
27
|
option :forced,
|
28
28
|
:short => "-f",
|
29
29
|
:description => "Issue this as a forced stop command."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-cloudstack-fog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-01-
|
15
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: fog
|
@@ -37,7 +37,7 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 10.
|
40
|
+
version: 10.16.6
|
41
41
|
type: :runtime
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -45,9 +45,9 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ! '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 10.
|
48
|
+
version: 10.16.6
|
49
49
|
description: Support for the Chef Knife command, leveraging FOG, for the Apache CloudStack
|
50
|
-
|
50
|
+
/ Citrix CloudPlatform API
|
51
51
|
email:
|
52
52
|
- chirag@clogeny.com
|
53
53
|
- jmoody@datapipe.com
|
@@ -64,14 +64,19 @@ files:
|
|
64
64
|
- lib/chef/knife/cloudstack_keypair_create.rb
|
65
65
|
- lib/chef/knife/cloudstack_keypair_delete.rb
|
66
66
|
- lib/chef/knife/cloudstack_keypair_list.rb
|
67
|
-
- lib/chef/knife/
|
67
|
+
- lib/chef/knife/cloudstack_network_create.rb
|
68
|
+
- lib/chef/knife/cloudstack_network_delete.rb
|
69
|
+
- lib/chef/knife/cloudstack_network_list.rb
|
70
|
+
- lib/chef/knife/cloudstack_networkoffering_list.rb
|
68
71
|
- lib/chef/knife/cloudstack_portforwardingrule_list.rb
|
69
72
|
- lib/chef/knife/cloudstack_publicip_create.rb
|
70
73
|
- lib/chef/knife/cloudstack_publicip_list.rb
|
71
74
|
- lib/chef/knife/cloudstack_securitygroup_list.rb
|
72
75
|
- lib/chef/knife/cloudstack_server_create.rb
|
73
76
|
- lib/chef/knife/cloudstack_server_delete.rb
|
77
|
+
- lib/chef/knife/cloudstack_server_destroy.rb
|
74
78
|
- lib/chef/knife/cloudstack_server_list.rb
|
79
|
+
- lib/chef/knife/cloudstack_server_start.rb
|
75
80
|
- lib/chef/knife/cloudstack_server_stop.rb
|
76
81
|
- lib/chef/knife/cloudstack_serviceoffering_list.rb
|
77
82
|
- lib/chef/knife/cloudstack_template_list.rb
|