panoramix 0.5.1 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/panoramix/external.rb +1 -1
- data/lib/panoramix/mpi.rb +1 -1
- data/lib/panoramix/panoramix_core.rb +8 -39
- data/lib/panoramix/plugin/base.rb +40 -13
- data/lib/panoramix/plugin/docker_build.rb +3 -13
- data/lib/panoramix/plugin/docker_image.rb +3 -20
- data/lib/panoramix/plugin/docker_image_base.rb +10 -5
- data/lib/panoramix/plugin/docker_up.rb +7 -26
- data/lib/panoramix/plugin/git.rb +3 -15
- data/lib/panoramix/plugin/s3.rb +3 -15
- data/lib/panoramix/plugin/wget.rb +3 -16
- data/lib/panoramix/tasks/actions.rb +11 -5
- data/lib/panoramix/tasks/global_tasks.rb +26 -0
- data/lib/panoramix.rb +31 -32
- metadata +44 -24
- data/lib/panoramix/aws.rb +0 -13
- data/lib/panoramix/connections/base_connection.rb +0 -49
- data/lib/panoramix/connections/docker_connection.rb +0 -85
- data/lib/panoramix/connections/local_connection.rb +0 -15
- data/lib/panoramix/connections.rb +0 -28
- data/lib/panoramix/hosts.rb +0 -58
- data/lib/panoramix/instances/aws.rb +0 -74
- data/lib/panoramix/instances/base.rb +0 -13
- data/lib/panoramix/instances/local.rb +0 -24
- data/lib/panoramix/instances/metal.rb +0 -26
- data/lib/panoramix/metal.rb +0 -13
- data/lib/panoramix/plugin/provision.rb +0 -95
- data/lib/panoramix/tasks/common_host_tasks.rb +0 -44
data/lib/panoramix/external.rb
CHANGED
@@ -14,7 +14,7 @@ def external(dep, &block)
|
|
14
14
|
# Handle with MPI
|
15
15
|
handled_dep = Panoramix::MPI.handle_external(dep.keys[0], params)
|
16
16
|
|
17
|
-
raise "Only a single external
|
17
|
+
raise "Only a single external dependency supported (received: #{dep.keys})" if handled_dep.length != 1
|
18
18
|
|
19
19
|
# Select provided dependencies
|
20
20
|
prerequisites = value.select { |d| ! d.is_a? Hash }
|
data/lib/panoramix/mpi.rb
CHANGED
@@ -41,12 +41,14 @@ module Panoramix
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def define_action_task(name, desctiption, instance,
|
45
|
-
if instance.respond_to?
|
44
|
+
def define_action_task(name, desctiption, instance, action)
|
45
|
+
if instance.respond_to? action.name
|
46
46
|
Rake.application.last_description = desctiption
|
47
|
-
Rake::Task.define_task "#{name}:#{
|
48
|
-
run_custom_task(instance,
|
47
|
+
Rake::Task.define_task "#{name}:#{action.name.to_s}" do |t|
|
48
|
+
run_custom_task(instance, action.name)
|
49
49
|
end
|
50
|
+
|
51
|
+
action.addTask("#{name}:#{action.name.to_s}", instance.class)
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -56,7 +58,6 @@ module Panoramix
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def define_tasks(name, descriptions, instance, prerequisites, block=nil)
|
59
|
-
fill_current_host_tasks(name, instance.class)
|
60
61
|
action = Proc.new do |t|
|
61
62
|
run_task(t, instance, block) if block
|
62
63
|
run_task(t, instance) unless block
|
@@ -64,46 +65,14 @@ module Panoramix
|
|
64
65
|
end
|
65
66
|
|
66
67
|
define_task(name, prerequisites, descriptions[:main], action)
|
67
|
-
Panoramix::Tasks::Actions.each do |act|
|
68
|
-
define_action_task(name, descriptions[act.action_name.to_sym], instance, act.action_name)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def resolve_host_dependencies
|
73
|
-
current_host.class.deployable? ? :host : nil
|
74
|
-
end
|
75
|
-
|
76
|
-
def connection host_name
|
77
|
-
unless Panoramix::Connections[host_name]
|
78
|
-
host = Panoramix::Hosts[host_name][:instance]
|
79
|
-
Panoramix::Connections.register(host_name, host.connection_params)
|
80
|
-
Panoramix::Connections.connect host_name
|
81
|
-
end
|
82
|
-
Panoramix::Connections[host_name]
|
83
|
-
end
|
84
|
-
|
85
|
-
def current_host
|
86
|
-
Panoramix::Hosts[current_host_name][:instance]
|
87
|
-
end
|
88
68
|
|
89
|
-
|
90
|
-
|
91
|
-
Panoramix::Hosts[current_host_name][:tasks][type] = []
|
69
|
+
Panoramix::Tasks::Actions.each do |act|
|
70
|
+
define_action_task(name, descriptions[act.name.to_sym], instance, act)
|
92
71
|
end
|
93
|
-
Panoramix::Hosts[current_host_name][:tasks][type].push(name)
|
94
|
-
end
|
95
|
-
|
96
|
-
def current_host_name
|
97
|
-
Rake.application.current_scope.first || "local"
|
98
72
|
end
|
99
73
|
|
100
74
|
def validation_error(instance, error)
|
101
75
|
puts "#{instance.class.name.split("::").last} validation error \n\t#{error.gsub("\n", "\n\t").red}"
|
102
76
|
end
|
103
77
|
|
104
|
-
def ip_host host_name
|
105
|
-
host = Panoramix::Hosts[host_name]
|
106
|
-
return !host.nil? ? host[:instance].ip : nil
|
107
|
-
end
|
108
|
-
|
109
78
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'panoramix/locale'
|
2
|
+
require 'open3'
|
3
|
+
require 'colorize'
|
2
4
|
|
3
5
|
module Panoramix
|
4
6
|
module Plugin
|
@@ -7,10 +9,6 @@ module Panoramix
|
|
7
9
|
|
8
10
|
class Base
|
9
11
|
|
10
|
-
def initialize host
|
11
|
-
@host = host
|
12
|
-
end
|
13
|
-
|
14
12
|
# Return current timestamp
|
15
13
|
def timestamp
|
16
14
|
raise "Not implemented"
|
@@ -32,16 +30,45 @@ module Panoramix
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def shell(cmd, silent=false, env=Hash.new)
|
35
|
-
# Get a connection for the current host
|
36
|
-
connection = Panoramix.connection(@host)
|
37
|
-
# Run the shell command
|
38
|
-
connection.shell(cmd, silent, env)
|
39
|
-
end
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
puts "Running #{cmd}".magenta if ENV["VERBOSE"]
|
35
|
+
|
36
|
+
@err = ""
|
37
|
+
@out = ""
|
38
|
+
Open3.popen3(env, cmd) do |stdin, stdout, stderr, wait_thr|
|
39
|
+
stdin.close
|
40
|
+
stdout.each_line do |line|
|
41
|
+
puts line unless silent
|
42
|
+
@out << "#{line}"
|
43
|
+
end
|
44
|
+
stderr.each_line do |line|
|
45
|
+
puts line.red unless silent
|
46
|
+
@err << "#{line}"
|
47
|
+
end
|
48
|
+
@exit_status = wait_thr.value
|
49
|
+
end
|
50
|
+
|
51
|
+
if ENV["VERBOSE"] && !@out.empty?
|
52
|
+
puts "\tout => \n\t\t#{@out.gsub("\n","\n\t\t")}".green
|
53
|
+
end
|
54
|
+
if ENV["VERBOSE"] && !@err.empty?
|
55
|
+
if @exit_status.success?
|
56
|
+
puts "\terr => \n\t\t#{@err.gsub("\n","\n\t\t")}".yellow
|
57
|
+
else
|
58
|
+
puts "\terr => \n\t\t#{@err.gsub("\n","\n\t\t")}".red
|
59
|
+
end
|
60
|
+
end
|
61
|
+
puts "\texit_status => #{@exit_status}\n".blue if ENV["VERBOSE"]
|
62
|
+
|
63
|
+
raise @err unless @exit_status.success?
|
44
64
|
|
65
|
+
return {
|
66
|
+
:out => @out,
|
67
|
+
:err => @err,
|
68
|
+
:exit_status => @exit_status
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
45
72
|
end
|
46
73
|
end
|
47
74
|
end
|
@@ -7,8 +7,8 @@ module Panoramix
|
|
7
7
|
|
8
8
|
attr_reader :src
|
9
9
|
|
10
|
-
def initialize(dst, src
|
11
|
-
super(dst
|
10
|
+
def initialize(dst, src)
|
11
|
+
super(dst)
|
12
12
|
@src = src
|
13
13
|
end
|
14
14
|
|
@@ -28,9 +28,6 @@ module Panoramix
|
|
28
28
|
super ("Built image")
|
29
29
|
end
|
30
30
|
|
31
|
-
def validate
|
32
|
-
end
|
33
|
-
|
34
31
|
end
|
35
32
|
|
36
33
|
end
|
@@ -65,16 +62,9 @@ def docker_build(args, &block)
|
|
65
62
|
|
66
63
|
# Merge prerequisites with the Dockerfile file_task
|
67
64
|
prerequisites = prerequisites.push(dockerfile) unless dockerfile.nil?
|
68
|
-
|
69
|
-
# Set host as a new prerequisite if needed
|
70
|
-
host_dep = Panoramix.resolve_host_dependencies
|
71
|
-
prerequisites = prerequisites.push(host_dep) unless host_dep.nil?
|
72
65
|
prerequisites.flatten!
|
73
66
|
|
74
|
-
|
75
|
-
host = Panoramix.current_host_name
|
76
|
-
|
77
|
-
instance = Panoramix::Plugin::DockerBuild.new(name, dockerfile, host)
|
67
|
+
instance = Panoramix::Plugin::DockerBuild.new(name, dockerfile)
|
78
68
|
|
79
69
|
descriptions = I18n.t('docker_build')
|
80
70
|
descriptions = Hash.new if descriptions.class != Hash
|
@@ -7,8 +7,8 @@ module Panoramix
|
|
7
7
|
|
8
8
|
attr_reader :src
|
9
9
|
|
10
|
-
def initialize(dst, src
|
11
|
-
super(dst
|
10
|
+
def initialize(dst, src)
|
11
|
+
super(dst)
|
12
12
|
@src = src
|
13
13
|
end
|
14
14
|
|
@@ -17,16 +17,6 @@ module Panoramix
|
|
17
17
|
true
|
18
18
|
end
|
19
19
|
|
20
|
-
# Action clobber for this task
|
21
|
-
def clobber
|
22
|
-
super
|
23
|
-
info = created?
|
24
|
-
if info
|
25
|
-
id = info.split(" ")[2]
|
26
|
-
shell "docker rmi -f #{id}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
20
|
# Default action for this task
|
31
21
|
def run_default
|
32
22
|
shell "docker pull #{@src}" unless ENV["NO_PULL"]
|
@@ -51,14 +41,7 @@ def external_docker_image(args, block)
|
|
51
41
|
|
52
42
|
prerequisites = []
|
53
43
|
|
54
|
-
|
55
|
-
host_dep = Panoramix.resolve_host_dependencies
|
56
|
-
prerequisites = prerequisites.push(host_dep) unless host_dep.nil?
|
57
|
-
|
58
|
-
# Get hostname for this scope
|
59
|
-
host = Panoramix.current_host_name
|
60
|
-
|
61
|
-
instance = Panoramix::Plugin::DockerImage.new(name, src, host)
|
44
|
+
instance = Panoramix::Plugin::DockerImage.new(name, src)
|
62
45
|
|
63
46
|
descriptions = I18n.t('docker_image')
|
64
47
|
descriptions = Hash.new if descriptions.class != Hash
|
@@ -8,8 +8,7 @@ module Panoramix
|
|
8
8
|
|
9
9
|
attr_reader :dst
|
10
10
|
|
11
|
-
def initialize(dst
|
12
|
-
super host
|
11
|
+
def initialize(dst)
|
13
12
|
@dst = dst
|
14
13
|
@tag = "latest"
|
15
14
|
end
|
@@ -30,9 +29,15 @@ module Panoramix
|
|
30
29
|
# Has this image already been created
|
31
30
|
def created?
|
32
31
|
return @created if @created
|
33
|
-
|
34
|
-
info = shell("docker images
|
35
|
-
|
32
|
+
|
33
|
+
info = shell("docker images", true)[:out]
|
34
|
+
|
35
|
+
images_list = info.split("\n")
|
36
|
+
images_list.shift
|
37
|
+
|
38
|
+
image_info = images_list.select {|img| img.match(/#{@dst}\s+#{@tag}/) }
|
39
|
+
|
40
|
+
@created = info = info.empty? ? nil: image_info[0]
|
36
41
|
end
|
37
42
|
|
38
43
|
# Action clobber for this task
|
@@ -12,8 +12,7 @@ module Panoramix
|
|
12
12
|
attr_reader :src
|
13
13
|
attr_reader :env
|
14
14
|
|
15
|
-
def initialize(dst, src, env
|
16
|
-
super (host)
|
15
|
+
def initialize(dst, src, env)
|
17
16
|
@dst = dst
|
18
17
|
@src = src
|
19
18
|
@env = env
|
@@ -33,11 +32,15 @@ module Panoramix
|
|
33
32
|
|
34
33
|
# Has this image already been created
|
35
34
|
def created?
|
36
|
-
return nil unless shell_ready?
|
37
35
|
info = shell("docker-compose -p #{@dst} -f #{@src} ps -q", true, @env)[:out]
|
38
36
|
@created = info = info.empty? ? nil: info
|
39
37
|
end
|
40
38
|
|
39
|
+
# Action rm for this task
|
40
|
+
def rm
|
41
|
+
clobber
|
42
|
+
end
|
43
|
+
|
41
44
|
# Action clobber for this task
|
42
45
|
def clobber
|
43
46
|
shell("docker-compose -p #{@dst} -f #{@src} kill; docker-compose -p #{@dst} -f #{@src} rm -v --force", false, @env) if created?
|
@@ -104,21 +107,6 @@ module Panoramix
|
|
104
107
|
end
|
105
108
|
puts
|
106
109
|
end
|
107
|
-
|
108
|
-
def validate
|
109
|
-
keys_errors = ""
|
110
|
-
@env.each do |key, value|
|
111
|
-
if value.nil?
|
112
|
-
keys_errors << "#{key} " if Panoramix::Link[key].nil?
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
if keys_errors != ""
|
117
|
-
message = I18n.t('errors.docker_up.env_var_not_given', {:env => keys_errors})
|
118
|
-
raise(ValidationError, message)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
110
|
end
|
123
111
|
|
124
112
|
end
|
@@ -162,14 +150,7 @@ def docker_up(args, &block)
|
|
162
150
|
prerequisites = deps.select { |d| ! d.is_a? Hash }
|
163
151
|
prerequisites = prerequisites.push(compose)
|
164
152
|
|
165
|
-
|
166
|
-
host_dep = Panoramix.resolve_host_dependencies
|
167
|
-
prerequisites = prerequisites.push(host_dep) unless host_dep.nil?
|
168
|
-
|
169
|
-
# Get hostname for this scope
|
170
|
-
host = Panoramix.current_host_name
|
171
|
-
|
172
|
-
instance = Panoramix::Plugin::DockerUp.new(name, compose, environment, host)
|
153
|
+
instance = Panoramix::Plugin::DockerUp.new(name, compose, environment)
|
173
154
|
|
174
155
|
descriptions = I18n.t('docker_up')
|
175
156
|
descriptions = Hash.new if descriptions.class != Hash
|
data/lib/panoramix/plugin/git.rb
CHANGED
@@ -9,8 +9,7 @@ module Panoramix
|
|
9
9
|
attr_reader :src
|
10
10
|
attr_reader :tag
|
11
11
|
|
12
|
-
def initialize(dst, src, tag
|
13
|
-
super host
|
12
|
+
def initialize(dst, src, tag)
|
14
13
|
# Get git project name
|
15
14
|
repo_name=src.split("/").last.gsub(".git", "")
|
16
15
|
|
@@ -74,15 +73,7 @@ module Panoramix
|
|
74
73
|
# Switch to tag
|
75
74
|
shell "git -C #{@dst} checkout #{@tag}"
|
76
75
|
end
|
77
|
-
|
78
|
-
def validate
|
79
|
-
out = shell("git ls-remote #{@src} | grep \'#{@tag}$\' | wc -l", true)
|
80
|
-
if (! out[:exit_status].success? || out[:out] =~ /0/)
|
81
|
-
message = I18n.t('errors.git.not_found', {:branch => @src, :tag => @tag})
|
82
|
-
raise(ValidationError, message)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
76
|
+
|
86
77
|
end
|
87
78
|
end
|
88
79
|
end
|
@@ -95,11 +86,8 @@ def git(args, prerequisites, block=nil)
|
|
95
86
|
# Get :tag value from arguments
|
96
87
|
tag = args.values[0][:tag]
|
97
88
|
|
98
|
-
# Git tasks always run as local
|
99
|
-
host = "local"
|
100
|
-
|
101
89
|
# Generate a new instance using the provided arguments
|
102
|
-
instance = Panoramix::Plugin::Git.new(name, src, tag
|
90
|
+
instance = Panoramix::Plugin::Git.new(name, src, tag)
|
103
91
|
|
104
92
|
descriptions = I18n.t('git')
|
105
93
|
descriptions = Hash.new if descriptions.class != Hash
|
data/lib/panoramix/plugin/s3.rb
CHANGED
@@ -9,8 +9,7 @@ module Panoramix
|
|
9
9
|
attr_reader :src
|
10
10
|
attr_reader :flags
|
11
11
|
|
12
|
-
def initialize(dst, src, flags
|
13
|
-
super host
|
12
|
+
def initialize(dst, src, flags)
|
14
13
|
@dst = dst
|
15
14
|
@src = src
|
16
15
|
@flags = flags
|
@@ -47,15 +46,7 @@ module Panoramix
|
|
47
46
|
def run_default
|
48
47
|
shell "aws s3 cp #{@flags} #{@src} #{@dst}"
|
49
48
|
end
|
50
|
-
|
51
|
-
def validate
|
52
|
-
out = shell("aws s3 cp --dryrun #{@flags} #{@src} #{@dst}" , true)
|
53
|
-
if (! out[:exit_status].success?)
|
54
|
-
message = I18n.t('errors.s3.not_found', {:uri => @src})
|
55
|
-
raise(ValidationError, message)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
49
|
+
|
59
50
|
end
|
60
51
|
end
|
61
52
|
end
|
@@ -69,10 +60,7 @@ def s3(args, prerequisites, block=nil)
|
|
69
60
|
# Provided flags
|
70
61
|
flags = args.values[0][:flags]
|
71
62
|
|
72
|
-
|
73
|
-
host = "local"
|
74
|
-
|
75
|
-
instance=Panoramix::Plugin::S3.new(name, src, flags, host)
|
63
|
+
instance=Panoramix::Plugin::S3.new(name, src, flags)
|
76
64
|
|
77
65
|
descriptions = I18n.t('s3')
|
78
66
|
descriptions = Hash.new if descriptions.class != Hash
|
@@ -9,8 +9,7 @@ module Panoramix
|
|
9
9
|
attr_reader :src
|
10
10
|
attr_reader :flags
|
11
11
|
|
12
|
-
def initialize(dst, src, flags
|
13
|
-
super host
|
12
|
+
def initialize(dst, src, flags)
|
14
13
|
@dst = dst
|
15
14
|
@src = src
|
16
15
|
@flags = flags
|
@@ -44,20 +43,11 @@ module Panoramix
|
|
44
43
|
def run_default
|
45
44
|
shell "wget -nv #{@flags} #{@src} -O #{@dst}"
|
46
45
|
end
|
47
|
-
|
48
|
-
def validate
|
49
|
-
out = shell("wget #{@flags} --spider -S #{@src}", true)
|
50
|
-
if (! out[:exit_status].success?)
|
51
|
-
message = I18n.t('errors.wget.not_found', {:uri => @src})
|
52
|
-
raise(ValidationError, message)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
46
|
+
|
56
47
|
end
|
57
48
|
end
|
58
49
|
end
|
59
50
|
|
60
|
-
|
61
51
|
def wget(args, prerequisites, block=nil)
|
62
52
|
# Task name
|
63
53
|
name = args.keys[0]
|
@@ -66,10 +56,7 @@ def wget(args, prerequisites, block=nil)
|
|
66
56
|
# Provided flags
|
67
57
|
flags = args.values[0][:flags]
|
68
58
|
|
69
|
-
|
70
|
-
host = "local"
|
71
|
-
|
72
|
-
instance=Panoramix::Plugin::Wget.new(name, src, flags, host)
|
59
|
+
instance=Panoramix::Plugin::Wget.new(name, src, flags)
|
73
60
|
|
74
61
|
descriptions = I18n.t('wget')
|
75
62
|
descriptions = Hash.new if descriptions.class != Hash
|
@@ -2,23 +2,29 @@ module Panoramix
|
|
2
2
|
module Tasks
|
3
3
|
|
4
4
|
class Action
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :name
|
6
6
|
attr_reader :silent
|
7
7
|
attr_reader :order_class
|
8
|
+
attr_reader :tasks
|
8
9
|
|
9
10
|
def initialize(action_name, silent, order_class)
|
10
|
-
@
|
11
|
+
@name = action_name
|
11
12
|
@silent = silent
|
12
13
|
@order_class = order_class
|
14
|
+
@tasks = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def addTask(name, instance_type)
|
18
|
+
@tasks.push Hash[:name => name, :instance_type => instance_type]
|
13
19
|
end
|
14
20
|
|
15
21
|
end
|
16
22
|
|
17
23
|
Actions = Array.new
|
18
|
-
Actions.push(Action.new("
|
19
|
-
Actions.push(Action.new("
|
24
|
+
Actions.push(Action.new("ps", false, [Plugin::DockerUp]))
|
25
|
+
Actions.push(Action.new("rm", false, [Plugin::DockerUp]))
|
20
26
|
Actions.push(Action.new("logs", false, [Plugin::DockerUp]))
|
21
|
-
Actions.push(Action.new("clobber", false, [Plugin::DockerUp, Plugin::DockerBuild, Plugin::DockerImage
|
27
|
+
Actions.push(Action.new("clobber", false, [Plugin::DockerUp, Plugin::DockerBuild, Plugin::DockerImage]))
|
22
28
|
Actions.push(Action.new("clean", true, [Plugin::Wget, Plugin::Git, Plugin::S3]))
|
23
29
|
Actions.push(Action.new("stop", false, [Plugin::DockerUp]))
|
24
30
|
Actions.push(Action.new("start", false, [Plugin::DockerUp]))
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Panoramix
|
2
|
+
module Tasks
|
3
|
+
module GlobalTasks
|
4
|
+
module_function
|
5
|
+
|
6
|
+
def define_tasks
|
7
|
+
descriptions = I18n.t('global')
|
8
|
+
Panoramix::Tasks::Actions.each do |action|
|
9
|
+
|
10
|
+
block = Proc.new do |t|
|
11
|
+
action.order_class.each do |type|
|
12
|
+
action.tasks.each do |task|
|
13
|
+
if task[:instance_type].to_s == type.to_s
|
14
|
+
Rake::Task[task[:name]].invoke
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Panoramix.define_task(action.name, [], descriptions[action.name.to_sym], block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/panoramix.rb
CHANGED
@@ -2,48 +2,47 @@ require "panoramix/external"
|
|
2
2
|
require "panoramix/plugin/docker_image"
|
3
3
|
require "panoramix/plugin/docker_build"
|
4
4
|
require "panoramix/plugin/docker_up"
|
5
|
-
require "panoramix/plugin/provision"
|
6
5
|
require "panoramix/dsl"
|
7
|
-
require "panoramix/hosts"
|
8
|
-
require "panoramix/connections"
|
9
6
|
require "panoramix/panoramix_core"
|
10
7
|
require "panoramix/tasks/actions"
|
11
|
-
require "panoramix/tasks/common_host_tasks"
|
12
8
|
require "panoramix/tasks/task_mpi"
|
9
|
+
require "panoramix/tasks/global_tasks"
|
13
10
|
require "rake/clean"
|
11
|
+
require 'git'
|
12
|
+
require 'colorize'
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
def load_env_variables current_dir
|
15
|
+
g = Git.open current_dir
|
16
|
+
current_branch = g.current_branch
|
17
|
+
current_project_url = g.remote.url.split(":").last.split("/")[-2..-1].join("/")
|
18
|
+
env_file_path = File.join(current_dir, 'env.rb')
|
19
|
+
tries = 0
|
20
|
+
begin
|
21
|
+
system "aws s3 cp s3://safelayer-env-#{current_branch}/#{current_project_url}/env.rb #{env_file_path}"
|
22
|
+
raise unless $?.exitstatus == 0
|
23
|
+
load env_file_path
|
24
|
+
rescue
|
25
|
+
tries += 1
|
26
|
+
sleep 1
|
27
|
+
retry if tries < 3
|
28
|
+
raise "Error downloading file s3://safelayer-env-#{current_branch}/#{current_project_url}/env.rb"
|
29
|
+
end
|
30
|
+
end
|
20
31
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
def gray; "\033[37m#{self}\033[0m" end
|
30
|
-
def bg_black; "\033[40m#{self}\033[0m" end
|
31
|
-
def bg_red; "\033[41m#{self}\033[0m" end
|
32
|
-
def bg_green; "\033[42m#{self}\033[0m" end
|
33
|
-
def bg_brown; "\033[43m#{self}\033[0m" end
|
34
|
-
def bg_blue; "\033[44m#{self}\033[0m" end
|
35
|
-
def bg_magenta; "\033[45m#{self}\033[0m" end
|
36
|
-
def bg_cyan; "\033[46m#{self}\033[0m" end
|
37
|
-
def bg_gray; "\033[47m#{self}\033[0m" end
|
38
|
-
def bold; "\033[1m#{self}\033[22m" end
|
39
|
-
def reverse_color; "\033[7m#{self}\033[27m" end
|
32
|
+
def check_env_variables env_vars
|
33
|
+
env_vars = [ env_vars ] if env_vars.class == String
|
34
|
+
env_vars.each do |env_var|
|
35
|
+
if ! ENV[env_var]
|
36
|
+
puts "error: #{env_var} environment variable not set".red
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
end
|
40
40
|
end
|
41
41
|
|
42
|
-
Panoramix::
|
42
|
+
Panoramix::MPI.initialize
|
43
|
+
Panoramix::TIMESTAMP = Hash.new
|
44
|
+
Panoramix::Tasks::GlobalTasks.define_tasks
|
43
45
|
Panoramix::Tasks::MpiInfo.define_tasks
|
44
46
|
Panoramix::Tasks::MpiGen.define_task
|
45
|
-
Panoramix::Link = Hash.new
|
46
47
|
|
47
48
|
Rake::Task.tasks.select{|t| t.name == "clobber"}.first.instance_variable_set(:@prerequisites,[])
|
48
|
-
|
49
|
-
at_exit { Panoramix::Connections.connections.each {|k,v| v.close_connection } }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panoramix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.6'
|
5
5
|
prerelease:
|
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: 2015-
|
12
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|
@@ -75,41 +75,61 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: git
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: colorize
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
78
110
|
description: Panoramix is a Rakefile like lib, capable of handling docker deployments
|
79
111
|
email: jig@safelayer.com
|
80
112
|
executables: []
|
81
113
|
extensions: []
|
82
114
|
extra_rdoc_files: []
|
83
115
|
files:
|
84
|
-
- lib/panoramix
|
85
|
-
- lib/panoramix/
|
86
|
-
- lib/panoramix/tasks/task_mpi.rb
|
87
|
-
- lib/panoramix/tasks/actions.rb
|
116
|
+
- lib/panoramix.rb
|
117
|
+
- lib/panoramix/locale.rb
|
88
118
|
- lib/panoramix/plugin/docker_image.rb
|
89
|
-
- lib/panoramix/plugin/base.rb
|
90
|
-
- lib/panoramix/plugin/docker_image_base.rb
|
91
119
|
- lib/panoramix/plugin/docker_up.rb
|
92
|
-
- lib/panoramix/plugin/docker_build.rb
|
93
|
-
- lib/panoramix/plugin/provision.rb
|
94
120
|
- lib/panoramix/plugin/s3.rb
|
95
121
|
- lib/panoramix/plugin/git.rb
|
122
|
+
- lib/panoramix/plugin/base.rb
|
123
|
+
- lib/panoramix/plugin/docker_build.rb
|
124
|
+
- lib/panoramix/plugin/docker_image_base.rb
|
96
125
|
- lib/panoramix/plugin/wget.rb
|
97
|
-
- lib/panoramix/
|
98
|
-
- lib/panoramix/connections.rb
|
99
|
-
- lib/panoramix/connections/local_connection.rb
|
100
|
-
- lib/panoramix/connections/base_connection.rb
|
101
|
-
- lib/panoramix/connections/docker_connection.rb
|
102
|
-
- lib/panoramix/locale.rb
|
103
|
-
- lib/panoramix/mpi.rb
|
104
|
-
- lib/panoramix/metal.rb
|
126
|
+
- lib/panoramix/dsl.rb
|
105
127
|
- lib/panoramix/external.rb
|
106
|
-
- lib/panoramix/
|
107
|
-
- lib/panoramix/
|
108
|
-
- lib/panoramix/
|
109
|
-
- lib/panoramix/
|
110
|
-
- lib/panoramix/aws.rb
|
128
|
+
- lib/panoramix/tasks/task_mpi.rb
|
129
|
+
- lib/panoramix/tasks/global_tasks.rb
|
130
|
+
- lib/panoramix/tasks/actions.rb
|
131
|
+
- lib/panoramix/mpi.rb
|
111
132
|
- lib/panoramix/panoramix_core.rb
|
112
|
-
- lib/panoramix.rb
|
113
133
|
- locales/en.yml
|
114
134
|
homepage: https://github.com/sflyr
|
115
135
|
licenses:
|
data/lib/panoramix/aws.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'open3'
|
2
|
-
|
3
|
-
module Panoramix
|
4
|
-
class BaseConnection
|
5
|
-
|
6
|
-
def shell(cmd, silent, env)
|
7
|
-
|
8
|
-
env.select{|k,v| v.nil?}.each{ |k, v| env[k]=Panoramix.ip_host(Panoramix::Link[k]) }
|
9
|
-
puts "Running #{cmd}".magenta if ENV["VERBOSE"]
|
10
|
-
|
11
|
-
@err = ""
|
12
|
-
@out = ""
|
13
|
-
Open3.popen3(env, cmd) do |stdin, stdout, stderr, wait_thr|
|
14
|
-
stdin.close
|
15
|
-
stdout.each_line do |line|
|
16
|
-
puts line unless silent
|
17
|
-
@out << "#{line}"
|
18
|
-
end
|
19
|
-
stderr.each_line do |line|
|
20
|
-
puts line.red unless silent
|
21
|
-
@err << "#{line}"
|
22
|
-
end
|
23
|
-
@exit_status = wait_thr.value
|
24
|
-
end
|
25
|
-
|
26
|
-
if ENV["VERBOSE"] && !@out.empty?
|
27
|
-
puts "\tout => \n\t\t#{@out.gsub("\n","\n\t\t")}".green
|
28
|
-
end
|
29
|
-
if ENV["VERBOSE"] && !@err.empty?
|
30
|
-
if @exit_status.success?
|
31
|
-
puts "\terr => \n\t\t#{@err.gsub("\n","\n\t\t")}".brown
|
32
|
-
else
|
33
|
-
puts "\terr => \n\t\t#{@err.gsub("\n","\n\t\t")}".red
|
34
|
-
end
|
35
|
-
end
|
36
|
-
puts "\texit_status => #{@exit_status}\n".blue if ENV["VERBOSE"]
|
37
|
-
|
38
|
-
return {
|
39
|
-
:out => @out,
|
40
|
-
:err => @err,
|
41
|
-
:exit_status => @exit_status
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def close_connection
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
require 'net/ssh/gateway'
|
3
|
-
require 'panoramix/connections/base_connection'
|
4
|
-
|
5
|
-
|
6
|
-
module Panoramix
|
7
|
-
class DockerConnection < BaseConnection
|
8
|
-
|
9
|
-
def initialize(host, user)
|
10
|
-
@host = host
|
11
|
-
@user = user
|
12
|
-
@connected = false
|
13
|
-
end
|
14
|
-
|
15
|
-
def connected?
|
16
|
-
@connected
|
17
|
-
end
|
18
|
-
|
19
|
-
def connect
|
20
|
-
return if @connected
|
21
|
-
return unless @host && @user
|
22
|
-
ready?
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns true if connection is enabled
|
26
|
-
def ready?
|
27
|
-
return false unless @host && @user
|
28
|
-
! open_tunnel.nil?
|
29
|
-
end
|
30
|
-
|
31
|
-
def shell(cmd, silent=false, env=Hash.new)
|
32
|
-
raise "No host unless" unless @host && @user
|
33
|
-
#open_tunnel unless @gateway
|
34
|
-
# Run passing tunneled port
|
35
|
-
env['DOCKER_HOST'] = "tcp://127.0.0.1:#{@port}"
|
36
|
-
super(cmd, silent, env)
|
37
|
-
end
|
38
|
-
|
39
|
-
def close_connection
|
40
|
-
if @connected
|
41
|
-
@gateway.close(@port)
|
42
|
-
@connected = false
|
43
|
-
@gateway = nil
|
44
|
-
@port = nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def open_tunnel
|
51
|
-
unless @gateway
|
52
|
-
# Open a new ssh tunnel
|
53
|
-
print "Connecting remote host..."
|
54
|
-
# Wait until docker starts
|
55
|
-
Timeout::timeout(600) do
|
56
|
-
begin
|
57
|
-
@gateway = Net::SSH::Gateway.new(@host, @user)
|
58
|
-
3.times do
|
59
|
-
begin
|
60
|
-
@port = @gateway.open('127.0.0.1', 666, rand(63000)+2000)
|
61
|
-
break
|
62
|
-
rescue
|
63
|
-
puts "Port already in use"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
#Check this connection
|
67
|
-
Timeout::timeout(10) do
|
68
|
-
res = shell("docker ps", true)
|
69
|
-
raise "Servide docker not available" unless res[:exit_status].success?
|
70
|
-
end
|
71
|
-
rescue Exception => err
|
72
|
-
sleep(10)
|
73
|
-
print "."
|
74
|
-
@gateway.close(@port) if @gateway
|
75
|
-
retry
|
76
|
-
end
|
77
|
-
end
|
78
|
-
@connected = true
|
79
|
-
puts " done."
|
80
|
-
end
|
81
|
-
@gateway
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'panoramix/connections/local_connection'
|
2
|
-
require 'panoramix/connections/docker_connection'
|
3
|
-
|
4
|
-
module Panoramix
|
5
|
-
|
6
|
-
class Connections
|
7
|
-
class << self
|
8
|
-
attr_reader :connections
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@connections=Hash.new
|
12
|
-
@connections["local"] = LocalConnection.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def register(host, config)
|
16
|
-
@connections[host] = DockerConnection.new(config[:host], config[:user])
|
17
|
-
end
|
18
|
-
|
19
|
-
def connect key
|
20
|
-
@connections[key].connect unless @connections[key].connected?
|
21
|
-
end
|
22
|
-
|
23
|
-
def [](key)
|
24
|
-
@connections[key]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/panoramix/hosts.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require "panoramix/instances/local"
|
2
|
-
|
3
|
-
module Panoramix
|
4
|
-
class Hosts
|
5
|
-
class << self
|
6
|
-
|
7
|
-
attr_reader :hosts
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@hosts=Hash.new
|
11
|
-
register("local", LocalInstance.new)
|
12
|
-
end
|
13
|
-
|
14
|
-
def register(name, instance)
|
15
|
-
if instance.class.ancestors.include? BaseInstance
|
16
|
-
instance.host(name)
|
17
|
-
@hosts[name] = {instance: instance, tasks: {}}
|
18
|
-
define_tasks(name)
|
19
|
-
else
|
20
|
-
puts "Warning using obsolete instance on host key
|
21
|
-
\t => host <host_name>, #{"<environment_class>".bold} \n\tchange to:
|
22
|
-
\t => host <host_name>, #{"Panoramix::<Cloud>.config(<environment_class>)".bold}
|
23
|
-
\t where Cloud must be AWS or Metal".red
|
24
|
-
exit(1)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def define_tasks(name)
|
29
|
-
Panoramix::Tasks::Actions.each do |act|
|
30
|
-
block_act = custom_host_action(act.action_name, act.order_class, name)
|
31
|
-
descriptions =(name != 'local') ? I18n.t('host') : Hash.new
|
32
|
-
Panoramix.define_task("#{name}:#{act.action_name}", [], descriptions[act.action_name.to_sym], block_act)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def custom_host_action(action, class_order, host_name)
|
37
|
-
Proc.new do |t|
|
38
|
-
tasks = Panoramix::Hosts[host_name][:tasks]
|
39
|
-
class_order.each do |p|
|
40
|
-
tasks[p].each do |task_name|
|
41
|
-
host_name2 =(host_name != 'local') ? "#{host_name}:" : ""
|
42
|
-
Rake::Task["#{host_name2}#{task_name}:#{action}"].invoke
|
43
|
-
end if tasks[p]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def [](key)
|
49
|
-
@hosts[key]
|
50
|
-
end
|
51
|
-
|
52
|
-
def to_s
|
53
|
-
@hosts.pretty_inspect
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require "raws"
|
2
|
-
require "panoramix/instances/base"
|
3
|
-
|
4
|
-
module Panoramix
|
5
|
-
|
6
|
-
class AwsInstance < BaseInstance
|
7
|
-
|
8
|
-
attr_reader :machine
|
9
|
-
|
10
|
-
def initialize(config)
|
11
|
-
@tunnel=nil
|
12
|
-
@machine = Raws::EC2::Machine.new(config[:name], config[:region])
|
13
|
-
@machine.config = config
|
14
|
-
@record = Raws::Route53::Record.new(config[:subdomain_id], config[:region])
|
15
|
-
end
|
16
|
-
|
17
|
-
def host(host)
|
18
|
-
@id=host
|
19
|
-
@machine.config[:name] = host
|
20
|
-
@record.name = host
|
21
|
-
end
|
22
|
-
|
23
|
-
def status
|
24
|
-
puts @machine.status
|
25
|
-
end
|
26
|
-
|
27
|
-
def deployed?
|
28
|
-
@machine.deployed?
|
29
|
-
end
|
30
|
-
|
31
|
-
def timestamp
|
32
|
-
@machine.timestamp
|
33
|
-
end
|
34
|
-
|
35
|
-
def run_instance args = {}
|
36
|
-
@machine.config.merge!(args)
|
37
|
-
if (@machine.config[:create_dns_record])
|
38
|
-
@record.ips.push(@machine.public_ip) #TODO: Wrong if private dns in aws => change for ip
|
39
|
-
@record.save
|
40
|
-
end
|
41
|
-
@machine.save
|
42
|
-
clear_known_hosts_by_hostid
|
43
|
-
end
|
44
|
-
|
45
|
-
def terminate_instance args=nil
|
46
|
-
@machine.terminate_instance
|
47
|
-
@record.delete if (@machine.config[:create_dns_record])
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.deployable?
|
51
|
-
true
|
52
|
-
end
|
53
|
-
|
54
|
-
def connection_params
|
55
|
-
{:user => "ubuntu", :host => ip}
|
56
|
-
end
|
57
|
-
|
58
|
-
def ip
|
59
|
-
if @machine.config[:use_public_ip]
|
60
|
-
@ip = @machine.public_ip unless @ip
|
61
|
-
else
|
62
|
-
@ip = @machine.private_ip unless @ip
|
63
|
-
end
|
64
|
-
@ip
|
65
|
-
end
|
66
|
-
private
|
67
|
-
|
68
|
-
def clear_known_hosts_by_hostid
|
69
|
-
result = `ssh-keygen -R #{ip} 2>&1`
|
70
|
-
raie ("Failed to update known_host file. \n#{result}") if !result.include? "updated"
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require "panoramix/instances/base"
|
2
|
-
|
3
|
-
module Panoramix
|
4
|
-
|
5
|
-
class LocalInstance < BaseInstance
|
6
|
-
def deployed?
|
7
|
-
true
|
8
|
-
end
|
9
|
-
|
10
|
-
def status
|
11
|
-
""
|
12
|
-
end
|
13
|
-
|
14
|
-
def ip
|
15
|
-
"127.0.0.1"
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.deployable?
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require "panoramix/instances/base"
|
2
|
-
|
3
|
-
module Panoramix
|
4
|
-
|
5
|
-
class MetalInstance < BaseInstance
|
6
|
-
def initialize(user)
|
7
|
-
@tunnel = nil
|
8
|
-
@user = user
|
9
|
-
end
|
10
|
-
|
11
|
-
def connection_params
|
12
|
-
{:user => @user, :host => @host}
|
13
|
-
end
|
14
|
-
|
15
|
-
def deployed?
|
16
|
-
`ping -c 1 #{@host}`
|
17
|
-
$?.exitstatus == 0
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.deployable?
|
21
|
-
false
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
data/lib/panoramix/metal.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
require "panoramix/plugin/base"
|
2
|
-
|
3
|
-
module Panoramix
|
4
|
-
module Plugin
|
5
|
-
class Provision < Base
|
6
|
-
|
7
|
-
attr_reader :host
|
8
|
-
attr_accessor :config
|
9
|
-
|
10
|
-
def initialize(host, config)
|
11
|
-
super host
|
12
|
-
@host = host
|
13
|
-
@config = config
|
14
|
-
end
|
15
|
-
|
16
|
-
# Return current timestamp
|
17
|
-
def timestamp
|
18
|
-
if created?
|
19
|
-
@host.timestamp
|
20
|
-
else
|
21
|
-
Time.at 0
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# When this instance needs to be executed
|
26
|
-
def needed? timestamps
|
27
|
-
!created?
|
28
|
-
end
|
29
|
-
|
30
|
-
# Has this instance already been created
|
31
|
-
def created?
|
32
|
-
@host.deployed?
|
33
|
-
end
|
34
|
-
|
35
|
-
# Action clobber for this task
|
36
|
-
def clobber
|
37
|
-
terminate_instance
|
38
|
-
end
|
39
|
-
|
40
|
-
# Run a new instance
|
41
|
-
def run_instance args
|
42
|
-
@host.run_instance args
|
43
|
-
end
|
44
|
-
|
45
|
-
# Terminate instance
|
46
|
-
def terminate_instance args=nil
|
47
|
-
unless args
|
48
|
-
args=@config
|
49
|
-
end
|
50
|
-
|
51
|
-
@host.terminate_instance args
|
52
|
-
end
|
53
|
-
|
54
|
-
# Default action for this task
|
55
|
-
def run_default
|
56
|
-
raise "Machine already created" if created?
|
57
|
-
run_instance @config
|
58
|
-
end
|
59
|
-
|
60
|
-
# Get aws status
|
61
|
-
def ps
|
62
|
-
if created?
|
63
|
-
puts "Timestamp: #{timestamp}"
|
64
|
-
puts @host.status
|
65
|
-
else
|
66
|
-
puts "Timestamp: Not created"
|
67
|
-
end
|
68
|
-
puts
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def provision(&block)
|
78
|
-
|
79
|
-
raise "Provision defined outside an scope" unless Rake.application.current_scope.any?
|
80
|
-
|
81
|
-
# Get host for this task
|
82
|
-
name = Rake.application.current_scope.first
|
83
|
-
|
84
|
-
# Get host for this task
|
85
|
-
host = Panoramix::Hosts[name][:instance]
|
86
|
-
|
87
|
-
instance = Panoramix::Plugin::Provision.new(host, host.machine.config)
|
88
|
-
|
89
|
-
descriptions = I18n.t('provision')
|
90
|
-
descriptions = Hash.new if descriptions.class != Hash
|
91
|
-
|
92
|
-
prerequisites = []
|
93
|
-
|
94
|
-
Panoramix.define_tasks(:host, descriptions, instance, prerequisites, block)
|
95
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Panoramix
|
2
|
-
module Tasks
|
3
|
-
module CommonHostTasks
|
4
|
-
module_function
|
5
|
-
|
6
|
-
# puts_header writes a formatted name to stdout
|
7
|
-
def puts_header host
|
8
|
-
docker_host = "(#{ENV["DOCKER_HOST"]})" if ENV["DOCKER_HOST"] && host == "localhost"
|
9
|
-
|
10
|
-
puts ""
|
11
|
-
head = "- #{host} #{docker_host} -"
|
12
|
-
(head.length - 1).times {print "-"}
|
13
|
-
puts "-"
|
14
|
-
puts head
|
15
|
-
(head.length - 1).times {print "-"}
|
16
|
-
puts "-\n\n"
|
17
|
-
end
|
18
|
-
|
19
|
-
# define_task defines the main ps task
|
20
|
-
def define_common_task(action, description, silent=false)
|
21
|
-
# Task body
|
22
|
-
|
23
|
-
block = Proc.new do |t|
|
24
|
-
|
25
|
-
Panoramix::Hosts.hosts.each do |k, v|
|
26
|
-
puts_header k if((k != "localhost") && (!silent && (k != "localhost")))
|
27
|
-
Rake::Task["#{k}:#{action}"].invoke
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Define the ps task
|
32
|
-
Panoramix.define_task(action, [], description, block)
|
33
|
-
end
|
34
|
-
|
35
|
-
def define_tasks
|
36
|
-
descriptions = I18n.t('global')
|
37
|
-
Panoramix::Tasks::Actions.each do |act|
|
38
|
-
define_common_task(act.action_name, descriptions[act.action_name.to_sym], act.silent)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|