14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/vpsadminos-converter/cli/app.rb', line 14
def setup
Thread.abort_on_exception = true
program_desc 'Convert OpenVZ containers into vpsAdminOS'
version VpsAdminOS::Converter::VERSION
subcommand_option_handling :normal
preserve_argv true
arguments :strict
desc 'Log file'
flag 'log-file'
desc 'Convert containers from OpenVZ Legacy'
command :vz6 do |vz|
vz.desc 'Export OpenVZ container into vpsAdminOS-compatible archive'
vz.arg_name '<ctid> <file>'
vz.command :export do |c|
c.desc 'Stop the container during the export'
c.switch :consistent, default_value: true
c.desc 'Compression'
c.flag %i[c compression], must_match: %w[auto off gzip],
default_value: 'gzip'
vz6_opts(c)
c.action(&Command.run(Vz6::Export, :export))
end
vz.desc 'Migrate OpenVZ container onto vpsAdminOS node'
vz.command :migrate do |m|
m.desc 'Step 1., copy configs to target node'
m.arg_name '<id> <dst>'
m.command :stage do |c|
c.desc 'SSH port'
c.flag %i[p port], type: Integer
vz6_opts(c)
c.action(&Command.run(Vz6::Migrate, :stage))
end
m.desc 'Step 2., do an initial copy of container rootfs'
m.arg_name '<id>'
m.command :sync do |c|
c.action(&Command.run(Vz6::Migrate, :sync))
end
m.desc 'Step 3., transfer the container to target node'
m.arg_name '<id>'
m.command :transfer do |c|
c.action(&Command.run(Vz6::Migrate, :transfer))
end
m.desc 'Step 4., cleanup the container on the source node'
m.arg_name '<id>'
m.command :cleanup do |c|
c.desc 'Delete the container'
c.switch %i[d delete], default_value: false
c.action(&Command.run(Vz6::Migrate, :cleanup))
end
m.desc 'Cancel ongoing migration in mid-step'
m.arg_name '<id>'
m.command :cancel do |c|
c.desc 'Cancel the migration on the local node, even if remote fails'
c.switch %i[f force], negatable: false
c.action(&Command.run(Vz6::Migrate, :cancel))
end
m.desc 'Migrate container at once (equals to steps 1-4 in succession)'
m.arg_name '<id> <dst>'
m.command :now do |c|
c.desc 'SSH port'
c.flag %i[p port], type: Integer
c.desc 'Delete the container after migration'
c.switch %i[d delete], default_value: false
c.desc 'Proceed with the migration or ask after successful staging'
c.switch %i[y proceed]
vz6_opts(c)
c.action(&Command.run(Vz6::Migrate, :now))
end
end
end
desc 'Read man page'
command :man do |c|
c.action do
manpath = File.realpath(File.join(
__dir__,
'..', '..', '..', 'man'
))
system("man -M #{manpath} vpsadminos-convert")
end
end
end
|