vpsadmin-client 2.1.0 → 2.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 +4 -4
- data/CHANGELOG +2 -0
- data/lib/vpsadmin/cli.rb +1 -0
- data/lib/vpsadmin/cli/commands/vps_migrate_many.rb +123 -0
- data/lib/vpsadmin/client/version.rb +1 -1
- data/vpsadmin-client.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90de46caa07d6a1e3b79cc71f322d6b5deea4cc2
|
4
|
+
data.tar.gz: 95cd27f3867fe42945542f0965be82ff47e5d6d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daff91e634cf9b40cbd113423874a08feec9fd8b46dc0a64fa6c843ee4f0735b1ebab09607d3ffb3382a8c6053cdc169ee167503f7bcd5477721c75f53e68a42
|
7
|
+
data.tar.gz: d67762ed6357b3c3463c05253a500b8f50fcb7b76933a24844f9cd31ffdfad05805306b0545937b303df71e0fedf4a23f0ca00a93bdc1f92e4605f171cd61714
|
data/CHANGELOG
CHANGED
data/lib/vpsadmin/cli.rb
CHANGED
@@ -0,0 +1,123 @@
|
|
1
|
+
module VpsAdmin::CLI::Commands
|
2
|
+
class VpsMigrateMany < HaveAPI::CLI::Command
|
3
|
+
cmd :vps, :migrate_many
|
4
|
+
args 'VPS_ID...'
|
5
|
+
desc 'Migrate multiple VPSes using a migration plan'
|
6
|
+
|
7
|
+
def options(opts)
|
8
|
+
@opts = {}
|
9
|
+
|
10
|
+
opts.on('--migration-plan PLAN_ID', 'Reuse existing migration plan') do |id|
|
11
|
+
@opts[:plan] = id
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.on('--dst-node NODE_ID', 'Destination node') do |id|
|
15
|
+
@opts[:dst_node] = id.to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('--[no-]outage-window', 'Migrate VPSes inside outage windows') do |w|
|
19
|
+
@opts[:outage_window] = w
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on('--[no-]stop-on-error', 'Cancel the plan if a migration fails') do |s|
|
23
|
+
@opts[:stop_on_error] = s
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on('--concurrency N', 'How many migrations run concurrently') do |n|
|
27
|
+
@opts[:concurrency] = n.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on('--[no-]send-mail', 'Send users mail informing about the migration') do |s|
|
31
|
+
@opts[:send_mail] = s
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('--reason REASON', 'Why are the VPS being migrated') do |r|
|
35
|
+
@opts[:reason] = r
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def exec(args)
|
40
|
+
if args.size < 2
|
41
|
+
puts "provide at least two VPS IDs"
|
42
|
+
exit(false)
|
43
|
+
|
44
|
+
elsif @opts[:dst_node].nil?
|
45
|
+
puts "provide --dst-node"
|
46
|
+
exit(false)
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "Verifying VPS IDs..."
|
50
|
+
vpses = []
|
51
|
+
|
52
|
+
args.each do |vps_id|
|
53
|
+
if /^\d+$/ !~ vps_id
|
54
|
+
puts "'#{vps_id}' is not a valid VPS ID"
|
55
|
+
exit(false)
|
56
|
+
end
|
57
|
+
|
58
|
+
vpses << vps_id.to_i
|
59
|
+
end
|
60
|
+
|
61
|
+
plan = nil
|
62
|
+
|
63
|
+
begin
|
64
|
+
if @opts[:plan]
|
65
|
+
puts "Reusing an existing migration plan..."
|
66
|
+
plan = @api.migration_plan.find(@opts[:plan])
|
67
|
+
|
68
|
+
if plan.state != 'staged'
|
69
|
+
puts "Cannot reuse a plan that has already left the staging phase"
|
70
|
+
exit(false)
|
71
|
+
end
|
72
|
+
|
73
|
+
else
|
74
|
+
puts "Creating a migration plan..."
|
75
|
+
plan = @api.migration_plan.create(@opts)
|
76
|
+
end
|
77
|
+
|
78
|
+
rescue HaveAPI::Client::ActionFailed => e
|
79
|
+
report_error(e)
|
80
|
+
end
|
81
|
+
|
82
|
+
puts "Scheduling VPS migrations..."
|
83
|
+
begin
|
84
|
+
vpses.each do |vps_id|
|
85
|
+
params = {
|
86
|
+
vps: vps_id,
|
87
|
+
dst_node: @opts[:dst_node],
|
88
|
+
}
|
89
|
+
params[:outage_window] = @opts[:outage_window] unless @opts[:outage_window].nil?
|
90
|
+
|
91
|
+
plan.vps_migration.create(params)
|
92
|
+
end
|
93
|
+
|
94
|
+
rescue HaveAPI::Client::ActionFailed => e
|
95
|
+
report_error(e)
|
96
|
+
end
|
97
|
+
|
98
|
+
puts "Executing the migration plan"
|
99
|
+
begin
|
100
|
+
ret = plan.start
|
101
|
+
|
102
|
+
rescue HaveAPI::Client::ActionFailed => e
|
103
|
+
report_error(e)
|
104
|
+
end
|
105
|
+
|
106
|
+
HaveAPI::CLI::OutputFormatter.print(ret.attributes)
|
107
|
+
end
|
108
|
+
|
109
|
+
protected
|
110
|
+
def report_error(e)
|
111
|
+
puts e.message
|
112
|
+
|
113
|
+
# FIXME: uncomment this code when ActionFailed makes response accessible
|
114
|
+
# if e.response.errors
|
115
|
+
# e.response.errors.each do |param, errs|
|
116
|
+
# puts " #{param}: #{errs.join('; ')}"
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
|
120
|
+
exit(false)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/vpsadmin-client.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'haveapi-client', '~> 0.
|
24
|
+
spec.add_runtime_dependency 'haveapi-client', '~> 0.5.0'
|
25
25
|
spec.add_runtime_dependency 'eventmachine', '~> 1.0.3'
|
26
26
|
spec.add_runtime_dependency 'em-http-request', '~> 1.1.3'
|
27
27
|
spec.add_runtime_dependency 'json', '~> 1.8.3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vpsadmin-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Skokan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.5.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: eventmachine
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- bin/vpsadminctl
|
112
112
|
- lib/terminal-size.rb
|
113
113
|
- lib/vpsadmin/cli.rb
|
114
|
+
- lib/vpsadmin/cli/commands/vps_migrate_many.rb
|
114
115
|
- lib/vpsadmin/cli/commands/vps_remote_console.rb
|
115
116
|
- lib/vpsadmin/client.rb
|
116
117
|
- lib/vpsadmin/client/version.rb
|