cloudflock 0.6.1 → 0.7.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 +15 -0
- data/bin/cloudflock +7 -1
- data/bin/cloudflock-files +2 -14
- data/bin/cloudflock-profile +3 -15
- data/bin/cloudflock-servers +3 -22
- data/bin/cloudflock.default +3 -22
- data/lib/cloudflock/app/common/cleanup/unix.rb +23 -0
- data/lib/cloudflock/app/common/cleanup.rb +107 -0
- data/lib/cloudflock/app/common/exclusions/unix/centos.rb +18 -0
- data/lib/cloudflock/app/common/exclusions/unix/redhat.rb +18 -0
- data/lib/cloudflock/app/common/exclusions/unix.rb +58 -0
- data/lib/cloudflock/app/common/exclusions.rb +57 -0
- data/lib/cloudflock/app/common/platform_action.rb +59 -0
- data/lib/cloudflock/app/common/rackspace.rb +63 -0
- data/lib/cloudflock/app/common/servers.rb +673 -0
- data/lib/cloudflock/app/files-migrate.rb +246 -0
- data/lib/cloudflock/app/server-migrate.rb +327 -0
- data/lib/cloudflock/app/server-profile.rb +130 -0
- data/lib/cloudflock/app.rb +87 -0
- data/lib/cloudflock/error.rb +6 -19
- data/lib/cloudflock/errstr.rb +31 -0
- data/lib/cloudflock/remote/files.rb +82 -22
- data/lib/cloudflock/remote/ssh.rb +234 -278
- data/lib/cloudflock/target/servers/platform.rb +92 -115
- data/lib/cloudflock/target/servers/profile.rb +331 -340
- data/lib/cloudflock/task/server-profile.rb +651 -0
- data/lib/cloudflock.rb +6 -8
- metadata +49 -68
- data/lib/cloudflock/interface/cli/app/common/servers.rb +0 -128
- data/lib/cloudflock/interface/cli/app/files.rb +0 -179
- data/lib/cloudflock/interface/cli/app/servers/migrate.rb +0 -491
- data/lib/cloudflock/interface/cli/app/servers/profile.rb +0 -88
- data/lib/cloudflock/interface/cli/app/servers.rb +0 -2
- data/lib/cloudflock/interface/cli/console.rb +0 -213
- data/lib/cloudflock/interface/cli/opts/servers.rb +0 -20
- data/lib/cloudflock/interface/cli/opts.rb +0 -87
- data/lib/cloudflock/interface/cli.rb +0 -15
- data/lib/cloudflock/target/servers/data/exceptions/base.txt +0 -44
- data/lib/cloudflock/target/servers/data/exceptions/platform/amazon.txt +0 -10
- data/lib/cloudflock/target/servers/data/exceptions/platform/centos.txt +0 -7
- data/lib/cloudflock/target/servers/data/exceptions/platform/debian.txt +0 -0
- data/lib/cloudflock/target/servers/data/exceptions/platform/redhat.txt +0 -7
- data/lib/cloudflock/target/servers/data/exceptions/platform/suse.txt +0 -1
- data/lib/cloudflock/target/servers/data/post-migration/chroot/base.txt +0 -1
- data/lib/cloudflock/target/servers/data/post-migration/chroot/platform/amazon.txt +0 -19
- data/lib/cloudflock/target/servers/data/post-migration/pre/base.txt +0 -3
- data/lib/cloudflock/target/servers/data/post-migration/pre/platform/amazon.txt +0 -4
- data/lib/cloudflock/target/servers/migrate.rb +0 -466
- data/lib/cloudflock/target/servers/platform/v1.rb +0 -97
- data/lib/cloudflock/target/servers/platform/v2.rb +0 -93
- data/lib/cloudflock/target/servers.rb +0 -5
- data/lib/cloudflock/version.rb +0 -3
@@ -1,213 +0,0 @@
|
|
1
|
-
# Public: Provide methods to abstract and simplify interaction with a user via
|
2
|
-
# a command-line application.
|
3
|
-
#
|
4
|
-
# Examples
|
5
|
-
#
|
6
|
-
# # prompt for a question with free-form input
|
7
|
-
# answer = Console.prompt("Question")
|
8
|
-
#
|
9
|
-
# # Print bolded text
|
10
|
-
# puts "#{Console.bold}Bold text#{Console.reset}"
|
11
|
-
module CloudFlock::Interface::CLI::Console extend self
|
12
|
-
# Public: Prompt user for input, allowing for a default answer and a list of
|
13
|
-
# valid responses.
|
14
|
-
#
|
15
|
-
# question - String containing the question to present to the user.
|
16
|
-
# args - Hash containing arguments to control acceptable responses.
|
17
|
-
# (default: {}):
|
18
|
-
# :default_answer - String containing the default answer. If the
|
19
|
-
# default is nil, a non-empty answer MUST be given.
|
20
|
-
# :valid_answers - An Array containing all valid responses.
|
21
|
-
#
|
22
|
-
# Returns a String containing the answer provided by the user.
|
23
|
-
def prompt(question, args = {})
|
24
|
-
default = args[:default_answer].to_s
|
25
|
-
allow_empty = !args[:default_answer].nil?
|
26
|
-
valid = args[:valid_answers] || []
|
27
|
-
|
28
|
-
default_display = default.empty? ? "" : "[%s]" % default.strip
|
29
|
-
question.strip!
|
30
|
-
|
31
|
-
acceptable = false
|
32
|
-
until acceptable
|
33
|
-
printf("%s %s> ", question, default_display)
|
34
|
-
answer = $stdin.readline.strip
|
35
|
-
|
36
|
-
if answer.empty? && allow_empty
|
37
|
-
acceptable = true
|
38
|
-
elsif valid.empty? && !answer.empty?
|
39
|
-
acceptable = true
|
40
|
-
elsif !(valid.grep(answer)).empty? && !valid.empty?
|
41
|
-
acceptable = true
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
answer.empty? ? default.to_s : answer
|
46
|
-
end
|
47
|
-
|
48
|
-
# Public: Wrap Console#prompt but require a Y/N response.
|
49
|
-
#
|
50
|
-
# question - String containing the question to present to the user.
|
51
|
-
# args - Hash containing arguments to control acceptable responses.
|
52
|
-
# (default: {}):
|
53
|
-
# :default_answer - String containing the default answer.
|
54
|
-
#
|
55
|
-
# Returns true or false corresponding to Y or N answer respectively.
|
56
|
-
def prompt_yn(question, args = {})
|
57
|
-
args[:valid] = []
|
58
|
-
answer = nil
|
59
|
-
|
60
|
-
until answer =~ /^[yn]/i
|
61
|
-
answer = prompt(question, args)
|
62
|
-
end
|
63
|
-
|
64
|
-
/^n/i.match(answer).nil?
|
65
|
-
end
|
66
|
-
|
67
|
-
# Public: Render a spinner on the command line and yield to a block,
|
68
|
-
# reporting success if nothing is raised, otherwise reporting failure.
|
69
|
-
#
|
70
|
-
# message - Message to be displayed describing the task being evaluated.
|
71
|
-
# block - Block to be yielded to determine pass or fail.
|
72
|
-
#
|
73
|
-
# Returns the result of the yielded block if successful.
|
74
|
-
# Raises whatever is raised inside the yielded block.
|
75
|
-
def spinner(message, &block)
|
76
|
-
success = nil
|
77
|
-
result = nil
|
78
|
-
|
79
|
-
pre = "\r#{bold}#{white} [#{reset}"
|
80
|
-
post = "#{bold}#{white}] #{reset}#{message}"
|
81
|
-
pre_ok = "\r#{bold}#{white} [#{green} ok "
|
82
|
-
pre_fail = "\r#{bold}#{white} [#{red}fail"
|
83
|
-
|
84
|
-
thread = Thread.new do
|
85
|
-
step = 0
|
86
|
-
spin = [" ", ". ", ".. ", "... ", "....", " ...", " ..", " ."]
|
87
|
-
while success.nil?
|
88
|
-
print "#{pre}#{spin[step % 8]}#{post}"
|
89
|
-
step += 1
|
90
|
-
sleep 0.5
|
91
|
-
end
|
92
|
-
|
93
|
-
if success
|
94
|
-
print "#{pre_ok}#{post}\n"
|
95
|
-
else
|
96
|
-
print "#{pre_fail}#{post}\n"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
begin
|
101
|
-
result = yield
|
102
|
-
success = true
|
103
|
-
thread.join
|
104
|
-
return result
|
105
|
-
rescue
|
106
|
-
success = false
|
107
|
-
thread.join
|
108
|
-
raise
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# Public: Generate a reasonably formatted, printable table.
|
113
|
-
#
|
114
|
-
# options - An Array containing Hash objects which contain desired options:
|
115
|
-
# [{:col1 => val1, :col2 => val2}, {:col1 => val3, :col2 => val4}]
|
116
|
-
# labels - A Hash containing key-value pairs to label each key in options.
|
117
|
-
# (default: nil)
|
118
|
-
#
|
119
|
-
# Returns a String containing the grid.
|
120
|
-
# Raises ArgumentError if options is not an Array which contains at least one
|
121
|
-
# element.
|
122
|
-
def build_grid(options, labels = nil)
|
123
|
-
raise ArgumentError unless options.kind_of?(Array) and !options[0].nil?
|
124
|
-
|
125
|
-
if labels.nil?
|
126
|
-
options.unshift(options[0].keys.reduce({}) { |c,e| {e => e.to_s} })
|
127
|
-
else
|
128
|
-
options.unshift(labels)
|
129
|
-
end
|
130
|
-
|
131
|
-
keys = options[0].keys
|
132
|
-
max_lengths = keys.reduce({}) { |c,e| c.merge({e => 0}) }
|
133
|
-
|
134
|
-
options.each do |row|
|
135
|
-
row.each_key do |key|
|
136
|
-
if max_lengths[key] < row[key].to_s.length
|
137
|
-
max_lengths[key] = row[key].to_s.length
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
# Base width = 3n+1
|
143
|
-
grid_width = (max_lengths.length * 3) + 1
|
144
|
-
|
145
|
-
# Construct rule
|
146
|
-
grid_rule = "+"
|
147
|
-
options[0].each_key { |k| grid_rule << "-" * (max_lengths[k] + 2) + "+" }
|
148
|
-
|
149
|
-
# Construct grid
|
150
|
-
grid = ""
|
151
|
-
grid << grid_rule
|
152
|
-
|
153
|
-
options.each_with_index do |row, idx|
|
154
|
-
grid << "\n|"
|
155
|
-
keys.each do |key|
|
156
|
-
grid << sprintf(" % #{max_lengths[key]}s |", row[key])
|
157
|
-
end
|
158
|
-
|
159
|
-
# Visually separate the labels
|
160
|
-
grid << "\n" + grid_rule if idx == 0
|
161
|
-
end
|
162
|
-
grid << "\n" + grid_rule
|
163
|
-
end
|
164
|
-
|
165
|
-
# Minimal documentation provided for the following functions; terminal
|
166
|
-
# control sequences are well documented; here we are only providing
|
167
|
-
# shorthand.
|
168
|
-
|
169
|
-
# Public: Escape sequence
|
170
|
-
#
|
171
|
-
# Returns a String containing an escaped terminal control sequence.
|
172
|
-
def escape(seq); "\033[#{seq}m"; end
|
173
|
-
|
174
|
-
# Public: Reset terminal control
|
175
|
-
#
|
176
|
-
# Returns a String the 'reset' terminal control sequence.
|
177
|
-
def reset; escape("0"); end
|
178
|
-
|
179
|
-
# Public: Set text bold
|
180
|
-
#
|
181
|
-
# Returns a String the terminal control sequence to set text bold.
|
182
|
-
def bold; escape("1"); end
|
183
|
-
|
184
|
-
# Public: Set text underlined
|
185
|
-
#
|
186
|
-
# Returns a String the terminal control sequence to set text underlined.
|
187
|
-
def underline; escape("4"); end
|
188
|
-
|
189
|
-
# Public: Set text flashing
|
190
|
-
#
|
191
|
-
# Returns a String the terminal control sequence to set text flashing.
|
192
|
-
def annoy; escape("5"); end
|
193
|
-
|
194
|
-
# Public: Set text red
|
195
|
-
#
|
196
|
-
# Returns a String the terminal control sequence to set text red.
|
197
|
-
def red; escape("31"); end
|
198
|
-
|
199
|
-
# Public: Set text green
|
200
|
-
#
|
201
|
-
# Returns a String the terminal control sequence to set text green.
|
202
|
-
def green; escape("32"); end
|
203
|
-
|
204
|
-
# Public: Set text blue
|
205
|
-
#
|
206
|
-
# Returns a String the terminal control sequence to set text blue.
|
207
|
-
def blue; escape("34"); end
|
208
|
-
|
209
|
-
# Public: Set text white
|
210
|
-
#
|
211
|
-
# Returns a String the terminal control sequence to set text white.
|
212
|
-
def white; escape("37"); end
|
213
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module CloudFlock::Interface::CLI::Opts extend self
|
2
|
-
# Internal: Extend the Opts module to provide options specific to the servers
|
3
|
-
# migration CLI utility.
|
4
|
-
#
|
5
|
-
# opts - OptionParser object to which to add options.
|
6
|
-
# options - Hash containing options flags and settings for the application.
|
7
|
-
#
|
8
|
-
# Returns nothing.
|
9
|
-
def argv_servers(opts, options)
|
10
|
-
opts.on('-o', '--opencloud', 'Perform an Open Cloud Servers migration') do
|
11
|
-
options[:function] = :opencloud
|
12
|
-
end
|
13
|
-
opts.on('-s', '--servers', 'Perform a Cloud Servers migration') do
|
14
|
-
options[:function] = :servers
|
15
|
-
end
|
16
|
-
opts.on('-r', '--resume', 'Resume a migration') do
|
17
|
-
options[:resume] = true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
Dir.glob(File.expand_path("../opts/*", __FILE__), &method(:require))
|
3
|
-
|
4
|
-
# Public: The CLI Opts module provides methods to abstract and simplify loading
|
5
|
-
# configuration information, parsing options and providing context to the
|
6
|
-
# application.
|
7
|
-
module CloudFlock::Interface::CLI::Opts extend self
|
8
|
-
CONFIG_LOCATION="~/.flockrc"
|
9
|
-
# Public: Open config files if applicable, overwriting default options with
|
10
|
-
# configuration passed files first, then with any options supplied via the
|
11
|
-
# command line.
|
12
|
-
#
|
13
|
-
# function - String or Symbol containing the name of the function to parse
|
14
|
-
# arguments for, if applicable. (default: '')
|
15
|
-
#
|
16
|
-
# Returns a Hash containing an option to value map.
|
17
|
-
def parse(function = '')
|
18
|
-
options = parse_config_file(CONFIG_LOCATION)
|
19
|
-
|
20
|
-
argv = parse_argv(function)
|
21
|
-
if argv[:config_file].kind_of?(String)
|
22
|
-
options.merge(parse_config_file(argv[:config_file]))
|
23
|
-
end
|
24
|
-
|
25
|
-
options.merge(argv)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Internal: Open and parse a given config file.
|
29
|
-
#
|
30
|
-
# file - String containing path to a configuration file which will be parsed.
|
31
|
-
#
|
32
|
-
# Returns a Hash containing option-value mappings.
|
33
|
-
def parse_config_file(file)
|
34
|
-
options = {}
|
35
|
-
return options if file.nil?
|
36
|
-
|
37
|
-
config_string = ""
|
38
|
-
if File.exists?(File.expand_path(file))
|
39
|
-
config_string = File.open(File.expand_path(file)).read
|
40
|
-
end
|
41
|
-
|
42
|
-
config_string.each_line do |line|
|
43
|
-
line.gsub!(/#.*/, "").strip!
|
44
|
-
next if line.empty?
|
45
|
-
|
46
|
-
opt,value = line.split(/\s*/, 2)
|
47
|
-
options[opt.to_sym] = value
|
48
|
-
end
|
49
|
-
|
50
|
-
options
|
51
|
-
end
|
52
|
-
|
53
|
-
# Internal: Parse and return options passed via the command line.
|
54
|
-
#
|
55
|
-
# function - String or Symbol containing the name of the function to parse
|
56
|
-
# arguments for. This will cause the OptionParser to search for a
|
57
|
-
# argv_function name for the given name of the function.
|
58
|
-
#
|
59
|
-
# Returns a Hash containing an option to value map.
|
60
|
-
def parse_argv(function)
|
61
|
-
options = {}
|
62
|
-
|
63
|
-
optparse = OptionParser.new do |opts|
|
64
|
-
opts.on('-v', '--verbose', 'Be verbose') do
|
65
|
-
options[:verbose] = true
|
66
|
-
end
|
67
|
-
|
68
|
-
opts.on('-c', '--config FILE', 'Load configuration saved from previous' +
|
69
|
-
' session (useful with -r)') do |file|
|
70
|
-
unless File.exists?(File.expand_path(file))
|
71
|
-
puts "Configuration file #{file} does not exist! Exiting."
|
72
|
-
exit
|
73
|
-
end
|
74
|
-
options[:config_file] = File.expand_path(file)
|
75
|
-
end
|
76
|
-
|
77
|
-
# Pull in extra options if applicable
|
78
|
-
function = ("argv_" + function.to_s).to_sym
|
79
|
-
if CloudFlock::Interface::CLI::Opts.respond_to?(function)
|
80
|
-
CloudFlock::Interface::CLI::Opts.send(function, opts, options)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
optparse.parse!
|
84
|
-
|
85
|
-
options
|
86
|
-
end
|
87
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/boot
|
2
|
-
/dev
|
3
|
-
/etc/fstab
|
4
|
-
/etc/hosts
|
5
|
-
/etc/init.d/nova-agent*
|
6
|
-
/etc/driveclient
|
7
|
-
/etc/initramfs-tools
|
8
|
-
/etc/issue
|
9
|
-
/etc/issue.net
|
10
|
-
/etc/lvm
|
11
|
-
/etc/mdadm*
|
12
|
-
/etc/mtab
|
13
|
-
/etc/mod*
|
14
|
-
/etc/network/
|
15
|
-
/etc/network.d/*
|
16
|
-
/etc/networks
|
17
|
-
/etc/rc3.d/S99Galaxy
|
18
|
-
/etc/resolv.conf
|
19
|
-
/etc/sysconfig/network
|
20
|
-
/etc/sysconfig/network-scripts/*
|
21
|
-
/etc/system-release
|
22
|
-
/etc/system-release-cpe
|
23
|
-
/etc/udev
|
24
|
-
/etc/prelink*
|
25
|
-
/etc/rc.conf
|
26
|
-
/etc/conf.d/net
|
27
|
-
/lib/init/rw
|
28
|
-
/lib/firmware
|
29
|
-
/lib/modules
|
30
|
-
/lib/udev
|
31
|
-
/root/.rackspace
|
32
|
-
/mnt
|
33
|
-
/net
|
34
|
-
/opt/galaxy/
|
35
|
-
/proc
|
36
|
-
/sys
|
37
|
-
/tmp
|
38
|
-
/usr/sbin/nova-agent*
|
39
|
-
/usr/share/initramfs-tools
|
40
|
-
/usr/share/nova-agent*
|
41
|
-
/var/cache/yum/*
|
42
|
-
/var/lib/initramfs-tools
|
43
|
-
/var/lock
|
44
|
-
/var/log
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
/etc/zypp
|
@@ -1 +0,0 @@
|
|
1
|
-
find /var/run -type f -exec rm {} \;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
for I in $(chkconfig --list|awk '/cloud-init/ {print $1}'); do chkconfig $I off; done
|
2
|
-
for I in $(rpm -qa | grep aws); do rpm -e --nodeps $I; done
|
3
|
-
rpm -e --nodeps sysvinit
|
4
|
-
rpm -e --justdb --nodeps system-release
|
5
|
-
rpm -e --justdb --nodeps epel-release
|
6
|
-
rpm -e --justdb --nodeps initscripts
|
7
|
-
rpm -e --justdb --nodeps yum
|
8
|
-
rpm -i --justdb --nodeps /root/.rackspace/rpms/db/*.rpm
|
9
|
-
rpm -i --nodeps /root/.rackspace/rpms/full/*.rpm
|
10
|
-
rpm -qa | grep mysql55 && rpm -e --justdb --nodeps mysql{55-common,-server}
|
11
|
-
cp -a /etc/my.cnf /etc/my.cnf.migration_backup
|
12
|
-
yum clean all
|
13
|
-
yum install -y sysvinit-tools
|
14
|
-
yum install -y initscripts
|
15
|
-
for I in $(rpm -qa | grep libselinux);do rpm -e --justdb --nodeps $I; printf "$I\n"|sed 's/-[0-9].*\././'>>/tmp/selinux-install; done
|
16
|
-
for I in $(cat /tmp/selinux-install); do yum install -y $I; done
|
17
|
-
yum update -y
|
18
|
-
cp -a /etc/my.cnf /etc/my.cnf.rpmnew
|
19
|
-
mv -f /etc/my.cnf.migration_backup /etc/my.cnf
|
@@ -1,4 +0,0 @@
|
|
1
|
-
yum install -y yum-plugin-downloadonly
|
2
|
-
mkdir -p /mnt/migration_target/root/.rackspace/rpms/{db,full}
|
3
|
-
yum reinstall -y --downloadonly --downloaddir=/mnt/migration_target/root/.rackspace/rpms/db/ redhat-release
|
4
|
-
yum reinstall -y --downloadonly --downloaddir=/mnt/migration_target/root/.rackspace/rpms/full/ yum
|