jamie 0.1.0.alpha19 → 0.1.0.alpha20
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.
- data/lib/jamie/cli.rb +20 -16
- data/lib/jamie/version.rb +1 -1
- data/lib/jamie.rb +35 -2
- metadata +2 -2
data/lib/jamie/cli.rb
CHANGED
@@ -36,21 +36,21 @@ module Jamie
|
|
36
36
|
@config = Jamie::Config.new(ENV['JAMIE_YAML'])
|
37
37
|
end
|
38
38
|
|
39
|
-
desc "list (all
|
39
|
+
desc "list [(all|<REGEX>)]", "List all instances"
|
40
40
|
def list(*args)
|
41
|
-
result = parse_subcommand(args
|
41
|
+
result = parse_subcommand(args.first)
|
42
42
|
say Array(result).map{ |i| i.name }.join("\n")
|
43
43
|
end
|
44
44
|
|
45
45
|
[:create, :converge, :setup, :verify, :destroy].each do |action|
|
46
46
|
desc(
|
47
|
-
"#{action} (all
|
47
|
+
"#{action} [(all|<REGEX>)]",
|
48
48
|
"#{action.capitalize} one or more instances"
|
49
49
|
)
|
50
50
|
define_method(action) { |*args| exec_action(action) }
|
51
51
|
end
|
52
52
|
|
53
|
-
desc "test
|
53
|
+
desc "test [all|<REGEX>)] [opts]", "Test one or more instances"
|
54
54
|
long_desc <<-DESC
|
55
55
|
Test one or more instances
|
56
56
|
|
@@ -68,10 +68,22 @@ module Jamie
|
|
68
68
|
if ! %w{passing always never}.include?(options[:destroy])
|
69
69
|
raise ArgumentError, "Destroy mode must be passing, always, or never."
|
70
70
|
end
|
71
|
-
result = parse_subcommand(args
|
71
|
+
result = parse_subcommand(args.first)
|
72
72
|
Array(result).each { |instance| instance.test(destroy_mode.to_sym) }
|
73
73
|
end
|
74
74
|
|
75
|
+
desc "login (['REGEX']|[INSTANCE])", "Log in to one instance"
|
76
|
+
def login(regexp)
|
77
|
+
results = get_filtered_instances(regexp)
|
78
|
+
if results.size > 1
|
79
|
+
die task, "Argument `#{regexp}' returned multiple results:\n" +
|
80
|
+
results.map{ |i| " * #{i.name}" }.join("\n")
|
81
|
+
end
|
82
|
+
instance = results.pop
|
83
|
+
|
84
|
+
instance.login
|
85
|
+
end
|
86
|
+
|
75
87
|
desc "version", "Print Jamie's version information"
|
76
88
|
def version
|
77
89
|
say "Jamie version #{Jamie::VERSION}"
|
@@ -108,20 +120,12 @@ module Jamie
|
|
108
120
|
|
109
121
|
def exec_action(action)
|
110
122
|
@task = action
|
111
|
-
result = parse_subcommand(args
|
123
|
+
result = parse_subcommand(args.first)
|
112
124
|
Array(result).each { |instance| instance.send(task) }
|
113
125
|
end
|
114
126
|
|
115
|
-
def parse_subcommand(
|
116
|
-
|
117
|
-
get_all_instances
|
118
|
-
elsif name_or_all == "all" && regexp
|
119
|
-
get_filtered_instances(regexp)
|
120
|
-
elsif name_or_all != "all" && regexp.nil?
|
121
|
-
get_instance(name_or_all)
|
122
|
-
else
|
123
|
-
die task, "Invalid invocation."
|
124
|
-
end
|
127
|
+
def parse_subcommand(arg = nil)
|
128
|
+
arg == "all" ? get_all_instances : get_filtered_instances(arg)
|
125
129
|
end
|
126
130
|
|
127
131
|
def get_all_instances
|
data/lib/jamie/version.rb
CHANGED
data/lib/jamie.rb
CHANGED
@@ -31,8 +31,8 @@ require 'net/ssh'
|
|
31
31
|
require 'pathname'
|
32
32
|
require 'socket'
|
33
33
|
require 'stringio'
|
34
|
-
require 'yaml'
|
35
34
|
require 'vendor/hash_recursive_merge'
|
35
|
+
require 'yaml'
|
36
36
|
|
37
37
|
require 'jamie/version'
|
38
38
|
|
@@ -660,6 +660,20 @@ module Jamie
|
|
660
660
|
destroy if destroy_mode == :always
|
661
661
|
end
|
662
662
|
|
663
|
+
# Logs in to this instance by invoking a system command, provided by the
|
664
|
+
# instance's driver. This could be an SSH command, telnet, or serial
|
665
|
+
# console session.
|
666
|
+
#
|
667
|
+
# **Note** This method calls exec and will not return.
|
668
|
+
#
|
669
|
+
# @see Driver::Base#login_command
|
670
|
+
def login
|
671
|
+
command, *args = driver.login_command(load_state)
|
672
|
+
|
673
|
+
debug("Login command: #{command} #{args.join(' ')}")
|
674
|
+
Kernel.exec(command, *args)
|
675
|
+
end
|
676
|
+
|
663
677
|
private
|
664
678
|
|
665
679
|
def validate_options(opts)
|
@@ -1028,7 +1042,7 @@ module Jamie
|
|
1028
1042
|
|
1029
1043
|
attr_writer :instance
|
1030
1044
|
|
1031
|
-
def initialize(config)
|
1045
|
+
def initialize(config = {})
|
1032
1046
|
@config = config
|
1033
1047
|
self.class.defaults.each do |attr, value|
|
1034
1048
|
@config[attr] = value unless @config[attr]
|
@@ -1073,6 +1087,16 @@ module Jamie
|
|
1073
1087
|
# @raise [ActionFailed] if the action could not be completed
|
1074
1088
|
def destroy(state) ; end
|
1075
1089
|
|
1090
|
+
# Returns the shell command array that will log into an instance.
|
1091
|
+
#
|
1092
|
+
# @param state [Hash] mutable instance and driver state
|
1093
|
+
# @return [Array] an array of command line tokens to be used in a
|
1094
|
+
# fork/exec
|
1095
|
+
# @raise [ActionFailed] if the action could not be completed
|
1096
|
+
def login_command(state)
|
1097
|
+
raise ActionFailed, "Remote login is not supported in this driver."
|
1098
|
+
end
|
1099
|
+
|
1076
1100
|
protected
|
1077
1101
|
|
1078
1102
|
attr_reader :config, :instance
|
@@ -1147,6 +1171,15 @@ module Jamie
|
|
1147
1171
|
raise NotImplementedError, "#destroy must be implemented by subclass."
|
1148
1172
|
end
|
1149
1173
|
|
1174
|
+
def login_command(state)
|
1175
|
+
args = %W{ -o UserKnownHostsFile=/dev/null }
|
1176
|
+
args += %W{ -o StrictHostKeyChecking=no }
|
1177
|
+
args += %W{ -i #{config['ssh_key']}} if config['ssh_key']
|
1178
|
+
args += %W{ #{config['username']}@#{state['hostname']}}
|
1179
|
+
|
1180
|
+
["ssh", *args]
|
1181
|
+
end
|
1182
|
+
|
1150
1183
|
protected
|
1151
1184
|
|
1152
1185
|
def build_ssh_args(state)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jamie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.alpha20
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|