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
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'cloudflock'
|
3
|
+
require 'console-glitter'
|
4
|
+
|
5
|
+
module CloudFlock
|
6
|
+
# Public: The App module provides any functionality that is expected to be
|
7
|
+
# used by all CLI applications.
|
8
|
+
module App extend self
|
9
|
+
include ConsoleGlitter
|
10
|
+
|
11
|
+
# Public: Check if an option is set; return the value if so, otherwise
|
12
|
+
# prompt the user for a response.
|
13
|
+
#
|
14
|
+
# options - Hash containing options to test against.
|
15
|
+
# name - The key in the options Hash expected to contain the
|
16
|
+
# response desired.
|
17
|
+
# prompt - Prompt to present to the user.
|
18
|
+
# prompt_options - Options to pass along to ConsoleGlitter::UI#prompt.
|
19
|
+
# (default: {})
|
20
|
+
#
|
21
|
+
# Returns the contents of the options[name] or else a String if
|
22
|
+
# options[name] is nil.
|
23
|
+
def check_option(options, name, prompt, prompt_options = {})
|
24
|
+
return options[name] unless options[name].nil?
|
25
|
+
|
26
|
+
options[name] = UI.prompt(prompt, prompt_options)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Public: Check if an option is set; return the value if so, otherwise
|
30
|
+
# prompt the user for a response.
|
31
|
+
#
|
32
|
+
# options - Hash containing options to test against.
|
33
|
+
# name - The key in the options Hash expected to contain the
|
34
|
+
# response desired.
|
35
|
+
# prompt - Prompt to present to the user.
|
36
|
+
# prompt_options - Options to pass along to ConsoleGlitter::UI#prompt_yn.
|
37
|
+
# (default: {})
|
38
|
+
#
|
39
|
+
# Returns true or false.
|
40
|
+
def check_option_yn(options, name, prompt, prompt_options = {})
|
41
|
+
return(options[name] ? true : false) unless options[name].nil?
|
42
|
+
|
43
|
+
options[name] = UI.prompt_yn(prompt, prompt_options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Public: Parse options and expose global options which are expected to be
|
47
|
+
# useful in any CLI application.
|
48
|
+
#
|
49
|
+
# options - Hash containing already-set options.
|
50
|
+
#
|
51
|
+
# Yields the OptionsParser object in use if a block is given.
|
52
|
+
#
|
53
|
+
# Returns a Hash.
|
54
|
+
def parse_options(options = {})
|
55
|
+
opts = OptionParser.new
|
56
|
+
|
57
|
+
yield opts if block_given?
|
58
|
+
|
59
|
+
opts.separator ''
|
60
|
+
opts.separator 'Global Options:'
|
61
|
+
|
62
|
+
opts.on('-c', '--config FILE', 'Specify configuration file') do |file|
|
63
|
+
options[:config_file] = File.expand_path(file)
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on_tail('--version', 'Show Version Information') do
|
67
|
+
puts "CloudFlock v#{CloudFlock::VERSION}"
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on_tail('-?', '--help', 'Show this Message') do
|
72
|
+
puts opts
|
73
|
+
exit
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.parse!(ARGV)
|
77
|
+
|
78
|
+
options
|
79
|
+
rescue OptionParser::MissingArgument, OptionParser::InvalidOption => error
|
80
|
+
puts error.message.capitalize
|
81
|
+
puts
|
82
|
+
ARGV.clear
|
83
|
+
ARGV.unshift('-?')
|
84
|
+
retry
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/cloudflock/error.rb
CHANGED
@@ -1,26 +1,13 @@
|
|
1
1
|
module CloudFlock
|
2
|
-
module
|
3
|
-
|
4
|
-
class
|
5
|
-
class ConnectionFailed < StandardError; end
|
6
|
-
class LoginFailed < StandardError; end
|
7
|
-
class RootFailed < StandardError; end
|
2
|
+
module App
|
3
|
+
module Common
|
4
|
+
class NoRsyncAvailable < StandardError; end
|
8
5
|
end
|
9
6
|
end
|
10
7
|
|
11
|
-
module
|
12
|
-
|
13
|
-
|
14
|
-
class LongRunFailed < StandardError; end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Platform
|
18
|
-
class ValueError < StandardError; end
|
19
|
-
class MapUndefined < NameError; end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Profile
|
23
|
-
end
|
8
|
+
module Remote
|
9
|
+
class SSH
|
10
|
+
class InvalidHostname < StandardError; end
|
24
11
|
end
|
25
12
|
end
|
26
13
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CloudFlock
|
2
|
+
module App
|
3
|
+
module Common
|
4
|
+
module Errstr
|
5
|
+
NO_RSYNC = 'Cannot find rsync on the destination host'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Remote
|
11
|
+
class SSH
|
12
|
+
module Errstr
|
13
|
+
NOHOST = 'No host specified'
|
14
|
+
INVALID_HOST = 'Unable to look up host: %s'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Target
|
20
|
+
module Servers
|
21
|
+
class Profile
|
22
|
+
NOT_SSH = 'SSH session expected'
|
23
|
+
end
|
24
|
+
|
25
|
+
class Platform
|
26
|
+
NOT_CPE = 'Expected a CPE object'
|
27
|
+
CPE_INCOMPLETE = 'CPE must contain at least vendor and version'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,28 +1,88 @@
|
|
1
1
|
require 'cloudflock'
|
2
|
+
require 'fog'
|
2
3
|
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
raise Errno::ENOENT, "#{target_parent} is not a directory"
|
4
|
+
module CloudFlock; module Remote
|
5
|
+
# Public: Provide a unified interface to instantiate various Fog::Storage
|
6
|
+
# objects while providing sanity checking where applicable.
|
7
|
+
class Files
|
8
|
+
# Public: Gets the location prefix for local stores
|
9
|
+
attr_reader :prefix
|
10
|
+
|
11
|
+
# Public: Connect via API and store the Fog instance as well as relative
|
12
|
+
# path information if a local store.
|
13
|
+
#
|
14
|
+
# store_spec - Hash containing data necessary to connect to an object
|
15
|
+
# storage service via Fog.
|
16
|
+
def initialize(store_spec)
|
17
|
+
@local = false
|
18
|
+
if store_spec[:provider] == 'local'
|
19
|
+
@local = true
|
20
|
+
@prefix = File.expand_path(store_spec[:local_root])
|
21
|
+
location = File.basename(store_spec[:local_root])
|
22
|
+
store_spec[:local_root] = File.expand_path(File.join(@prefix, '..'))
|
23
23
|
end
|
24
|
+
|
25
|
+
@fog = Fog::Storage.new(store_spec)
|
26
|
+
self.directory = (location) if local?
|
27
|
+
end
|
28
|
+
|
29
|
+
# Public: Set the active directory for fetching/uploading files.
|
30
|
+
#
|
31
|
+
# location - String denoting a directory name to use.
|
32
|
+
#
|
33
|
+
# Returns nothing.
|
34
|
+
def directory=(location)
|
35
|
+
@files = @fog.directories.select { |dir| dir.key == location }.first
|
36
|
+
end
|
37
|
+
|
38
|
+
# Public: Wrap Fog::Storage#directories
|
39
|
+
#
|
40
|
+
# Returns Fog::Storage::*::Directories.
|
41
|
+
def directories
|
42
|
+
@fog.directories
|
43
|
+
end
|
44
|
+
|
45
|
+
# Public: Wrap Fog::Storage::Directory#each
|
46
|
+
#
|
47
|
+
# Yields Fog::Storage::File objects
|
48
|
+
def each_file(&block)
|
49
|
+
@files.files.each(&block)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Public: Generate a list of all files in the current directory.
|
53
|
+
#
|
54
|
+
# Returns an array of Fog::Storage::File objects.
|
55
|
+
def file_list
|
56
|
+
@files.files.map(&:key)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Public: Return the contents of a given file in the current directory.
|
60
|
+
#
|
61
|
+
# file - String containing the path to a file.
|
62
|
+
#
|
63
|
+
# Returns a String.
|
64
|
+
def get_file(file)
|
65
|
+
@files.files.get(file).body
|
66
|
+
end
|
67
|
+
|
68
|
+
# Public: Create a file in the current directory.
|
69
|
+
#
|
70
|
+
# file_spec - Hash containing info to create a new file:
|
71
|
+
# :key - Path under which the file should be created.
|
72
|
+
# :body - Contents of the file to be created.
|
73
|
+
#
|
74
|
+
# Returns nothing.
|
75
|
+
def create(file_spec)
|
76
|
+
@files.files.create(file_spec)
|
77
|
+
rescue Excon::Errors::Timeout
|
78
|
+
retry
|
24
79
|
end
|
25
80
|
|
26
|
-
|
81
|
+
# Public: Report whether a local store is referenced.
|
82
|
+
#
|
83
|
+
# Returns whether the store is local to the host.
|
84
|
+
def local?
|
85
|
+
@local
|
86
|
+
end
|
27
87
|
end
|
28
|
-
end
|
88
|
+
end; end
|