knife-cloudstack-fog 0.2.10 → 0.2.11
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.
@@ -0,0 +1,72 @@
|
|
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 CloudstackServerStop < Knife
|
24
|
+
|
25
|
+
include Knife::CloudstackBase
|
26
|
+
banner "knife cloudstack server stop INSTANCE_ID [INSTANCE_ID] (options)"
|
27
|
+
option :forced,
|
28
|
+
:short => "-f",
|
29
|
+
:description => "Issue this as a forced stop command."
|
30
|
+
|
31
|
+
def run
|
32
|
+
|
33
|
+
if @name_args.nil?
|
34
|
+
puts #{ui.color("Please provide an Instance ID.", :red)}
|
35
|
+
end
|
36
|
+
|
37
|
+
@name_args.each do |instance_id|
|
38
|
+
response = connection.list_virtual_machines('name' => instance_id)
|
39
|
+
instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name']
|
40
|
+
instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress']
|
41
|
+
real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id']
|
42
|
+
puts "#{ui.color("Name", :red)}: #{instance_name}"
|
43
|
+
puts "#{ui.color("Public IP", :red)}: #{instance_ip}"
|
44
|
+
puts "\n"
|
45
|
+
confirm("#{ui.color("Do you really want to stop this server", :red)}")
|
46
|
+
|
47
|
+
|
48
|
+
if :force
|
49
|
+
server = connection.stop_virtual_machine('id' => real_instance_id, 'forced' => true)
|
50
|
+
else
|
51
|
+
server = connection.stop_virtual_machine('id' => real_instance_id)
|
52
|
+
end
|
53
|
+
jobid = server['stopvirtualmachineresponse'].fetch('jobid')
|
54
|
+
server_stop = connection.query_async_job_result('jobid'=>jobid)
|
55
|
+
print "#{ui.color("Waiting for server", :magenta)}"
|
56
|
+
while server_stop['queryasyncjobresultresponse'].fetch('jobstatus') != 1
|
57
|
+
print "#{ui.color(".", :magenta)}"
|
58
|
+
sleep(1)
|
59
|
+
server_start = connection.query_async_job_result('jobid'=>jobid)
|
60
|
+
end
|
61
|
+
puts "\n\n"
|
62
|
+
|
63
|
+
ui.warn("Stopped server #{instance_name}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
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.2.
|
4
|
+
version: 0.2.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fog
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/chef/knife/cloudstack_server_create.rb
|
48
48
|
- lib/chef/knife/cloudstack_server_delete.rb
|
49
49
|
- lib/chef/knife/cloudstack_server_list.rb
|
50
|
+
- lib/chef/knife/cloudstack_server_stop.rb
|
50
51
|
- lib/chef/knife/cloudstack_serviceoffering_list.rb
|
51
52
|
- lib/chef/knife/cloudstack_template_list.rb
|
52
53
|
- lib/chef/knife/cloudstack_volumes_list.rb
|