claudius 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,11 +11,66 @@ Install it as:
11
11
 
12
12
  If you want export execution tree to image you need [Graphivz](http://www.graphviz.org).
13
13
 
14
+ ## Keywords
15
+
16
+ * **experiment** - central part of claudius. Method defines a new experiment. Parameters:
17
+ * **experiment_name**
18
+ * **body** - block of code describing performed experiment
19
+
20
+ You may call the following methods on returned experiment object:
21
+
22
+ * **run** - method starts previously defined experiment,
23
+ * **export_tree(path = 'execution_tree_path')** - method creates an execution graph of experiment and save it as an image
24
+
25
+ * **define_providers** - method takes as a parameter description of machines used in experiment. In experiments You are allowed to use 2 different types of machines
26
+
27
+ * **manual** - those machines have been created before experiment start, You should possess appropriate credentials such as: ip address, login, password etc.
28
+
29
+ * **cloud** - if You like to perform your experiment in cloud, You should firstly provide necessary information to authenticate to Your cloud provider ( e.g. AWS). After successfully authentication, please define instances which You are going to use in your experiment by create_instances method.
30
+
31
+ * **foreach** - keyword is similar to ruby ‘each’ method, but in contrast to ordinary ‘each’, you may provide adjectives describing how parameters should be process
32
+ Currently supported adjectives are.
33
+ * **asynchronously** - each parameter is processed in separate thread. Execution of instructions after foreach block is pursued when each loop is finished.
34
+ * **safely** - experiment is continued even if some exception occurs during loop execution,
35
+ * **on** - specify on which machine instructions should be executed, by default it is localhost. It takes instance name as a parameter.
36
+
37
+ * **before**, **after** - keywords are used to construct metrics
38
+
39
+ * **concurrent** - if elements (such as execute or foreach) are in common concurrent block, they are executed each in separate thread.
40
+
41
+ * **execute** - method takes as a parameter block of code (which contain ssh methods calls), end perform instructions sequentially
42
+
43
+ * **ssh** - specify instruction(s) which are going to be invoked on machine. As a parameter takes a string representing shell command.
44
+
45
+ ## Credentials
46
+
47
+ In order to authenticate in AWS services (at other cloud providers also) you are obligated to provide some credentials data, which are: aws_access_key_id, aws_secret_access_key, and so on. It is recomended to store configuration in json file and refer to them, when they are require. Sample config file looks like one below:
48
+
49
+
50
+ ``` javascript
51
+ {
52
+ "provider" : "AWS",
53
+ "region" : "eu-west-1",
54
+ "aws_access_key_id" : "XXXXXXXXXXXXXXXXXXXX",
55
+ "aws_secret_access_key" : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
56
+ "key_name" : "My-irleand-key",
57
+ "groups" : "My-irleand-group"
58
+ "path_to_pem_file" : "./pems/my-irleand-key.pem"
59
+ }
60
+ ```
61
+
62
+ After creation, You could load your file, assign it to variable and use freely as dictionary.
63
+
64
+ ``` ruby
65
+ config = load_config('./user_config.json')
66
+ aws_key = config['aws_access_key_id']
67
+ ```
68
+
69
+
14
70
  ## Usage
15
71
 
16
72
  Check doc [here](http://blostic.github.io/claudius).
17
73
 
18
-
19
74
  ## Documentation
20
75
 
21
76
  Documemtation is autogenerated from examples by [Groc](https://github.com/nevir/groc).
@@ -31,7 +86,6 @@ Generate to GitHub page:
31
86
 
32
87
  groc --gh examples/* README.md
33
88
 
34
-
35
89
  ## Contributing
36
90
 
37
91
  1. Fork it
data/claudius.gemspec CHANGED
@@ -4,11 +4,16 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "claudius"
7
- spec.version = "0.0.3"
7
+ spec.version = "0.0.4"
8
8
  spec.authors = ["radk0s", "blost"]
9
- spec.email = ["rachamot@gmail.com"]
10
- spec.description = "Write a gem description"
11
- spec.summary = "Write a gem summary"
9
+ spec.email = ["rachamot@gmail.com", "piotr.skibiak@gmail.com"]
10
+ spec.description = 'Claudius is an easy-to-use domain specific language for cloud experiments. ' +
11
+ 'It has been designed to speed up process of building distributed experiments and highly reduce time of ' +
12
+ 'remote machines configuration. To avoid vendor lock-in, Claudius was build on top of fog.io library, ' +
13
+ 'which enables flexible and powerful way to manage machine instances at various cloud providers. Remote ' +
14
+ 'commands execution is based on SSH protocol (SSH-2). DLS allow users to generate readable execution graph, ' +
15
+ 'which is extremely useful for experiment flow verification and help avoid wasting your money.'
16
+ spec.summary = "DSL for cloud experiments"
12
17
  spec.homepage = "https://github.com/blostic/claudius"
13
18
  spec.license = "MIT"
14
19
  spec.files = `git ls-files`.split($/)
@@ -18,7 +23,7 @@ Gem::Specification.new do |spec|
18
23
 
19
24
  spec.add_development_dependency "bundler", "~> 1.3"
20
25
  spec.add_development_dependency "rake"
21
- spec.add_runtime_dependency "fog", ">= 1.22.0"
26
+ spec.add_runtime_dependency "fog", "1.22.0"
22
27
  spec.add_runtime_dependency "net-ssh", "2.9.1"
23
28
  spec.add_runtime_dependency "graph", "2.7.0"
24
29
  spec.add_runtime_dependency "awesome_print", "1.2.0"
@@ -0,0 +1,47 @@
1
+
2
+ # Distributed app
3
+ # ---------
4
+ # Set up distributed key-value store Etcd using Docker.
5
+ #
6
+
7
+ require "claudius"
8
+ config = load_config('./user_config.json')
9
+ $discovery_token = "https://discovery.etcd.io/c4c7919104cbf432d2a92036cddd8d33"
10
+
11
+ execution_tree = experiment 'Hello' do
12
+ define_providers do
13
+ cloud('aws', :provider => config['provider'],
14
+ :region =>config['region'],
15
+ :endpoint => 'https://ec2.eu-west-1.amazonaws.com/',
16
+ :aws_access_key_id => config['aws_access_key_id'],
17
+ :aws_secret_access_key => config['aws_secret_access_key'])
18
+ .create_instances(
19
+ ['t1.micro=>in1'],
20
+ :username => 'ubuntu',
21
+ :private_key_path =>config['path_to_pem_file'],
22
+ :key_name => config['key_name'],
23
+ :groups => config['groups'])
24
+ end
25
+ foreach ['in1', 'in2'] do |instance_name|
26
+ on instance_name do
27
+ before "set up docker" do
28
+ # ssh "curl -sSL https://get.docker.io/ubuntu/ | sudo sh"
29
+ # ssh "sudo apt-get install git -y"
30
+ # ssh "wget https://github.com/coreos/etcd/archive/v0.4.6.tar.gz"
31
+ # ssh "tar xzvf v0.4.6.tar.gz"
32
+ # ssh "mv etcd-0.4.6 etcd"
33
+ # ssh "rm v0.4.6.tar.gz"
34
+ end
35
+ execute do
36
+ # ssh "sudo docker build -t etcd etcd"
37
+ # ssh "sudo docker run --name etcd1 -d -p 4001:4001 -p 7001:7001 -v /data/etcd1:/etcd-data etcd -name #{instance_name} -peer-addr #{getOtherInstances(instance_name).hosts}:7001 -addr #{getInstance(instance_name).host}:4001 -discovery %s" % $discovery_token
38
+ end
39
+ after "clean up docker containers" do
40
+ # ssh "docker stop $(docker ps -a -q)"
41
+ # ssh "docker rm $(docker ps -a -q)"
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ ap execution_tree.run
@@ -0,0 +1,84 @@
1
+ require "claudius"
2
+ require "json"
3
+
4
+ config = load_config('./user_config.json')
5
+
6
+ execution_tree = experiment 'Helloo' do
7
+ define_providers do
8
+ cloud('aws', :provider => config['provider'],
9
+ :region =>config['region'],
10
+ :endpoint => 'https://ec2.eu-west-1.amazonaws.com/',
11
+ :aws_access_key_id => config['aws_access_key_id'],
12
+ :aws_secret_access_key => config['aws_secret_access_key'])
13
+ .create_instances(
14
+ ['m3.medium=>in1', 'm3.large=>in2'],
15
+ :username => 'ubuntu',
16
+ :private_key_path =>config['path_to_pem_file'],
17
+ :key_name => config['key_name'],
18
+ :image_id => config['image_id'],
19
+ :groups => config['groups'])
20
+ end
21
+ foreach ['in1', 'in2'] do |instance_name|
22
+ on instance_name do
23
+ execute do
24
+ ssh "yes | sudo apt-get update"
25
+ ssh "yes | sudo apt-get install build-essential"
26
+
27
+ ssh "yes | sudo apt-get install python-software-properties python g++ make"
28
+ ssh "yes | sudo add-apt-repository ppa:chris-lea/node.js"
29
+ ssh "yes | sudo apt-get update"
30
+ ssh "yes | sudo apt-get install nodejs"
31
+
32
+ ssh "yes | sudo apt-get install git-core"
33
+
34
+ ssh "yes | sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev"
35
+ ssh "yes | sudo apt-get install ruby2.0 ruby2.0-dev build-essential libxml2-dev libxslt1-dev"
36
+ ssh "yes | sudo apt-get install rabbitmq-server"
37
+ ssh "yes | sudo apt-get install redis-server"
38
+
39
+ ssh "echo 'Git:'"
40
+ ssh "git --version"
41
+ ssh "echo 'Ruby'"
42
+ ssh "ruby --version"
43
+ ssh "echo 'Nodejs'"
44
+ ssh "nodejs --version"
45
+ ssh "echo 'Redis'"
46
+ ssh "redis-server --version"
47
+
48
+ ssh "curl -O http://pegasus.isi.edu/montage/Montage_v3.3_patched_4.tar.gz"
49
+ ssh "tar zxvf Montage_v3.3_patched_4.tar.gz"
50
+ ssh "cd Montage_v3.3_patched_4 && make"
51
+
52
+ ssh "curl -O https://dl.dropboxusercontent.com/u/81819/hyperflow-amqp-executor.gem"
53
+ ssh "sudo gem2.0 install --no-ri --no-rdoc hyperflow-amqp-executor.gem"
54
+
55
+ ssh "wget https://github.com/dice-cyfronet/hyperflow/archive/v1.0.0-beta-6.tar.gz"
56
+ ssh "tar zxvf v1.0.0-beta-6.tar.gz"
57
+ ssh "mv hyperflow-1.0.0-beta-6 hyperflow"
58
+ ssh "cd hyperflow && npm install"
59
+ end
60
+ end
61
+ end
62
+ on 'in1' do
63
+ execute do
64
+ ssh "cd hyperflow && echo 'amqp_url: amqp://localhost\nstorage: local\nthreads: <%= Executor::cpu_count %>' > executor_config.yml"
65
+ ssh "export PATH=$PATH:~/Montage_v3.3_patched_4/bin; nohup hyperflow-amqp-executor $(pwd)/hyperflow/executor_config.yml > amqp.out 2>&1 &"
66
+ end
67
+ end
68
+ on 'in2' do
69
+ execute do
70
+ ssh "mkdir data"
71
+ ssh "cd data && wget https://gist.github.com/kfigiela/9075623/raw/dacb862176e9d576c1b23f6a243f9fa318c74bce/bootstrap.sh"
72
+ ssh "cd data && chmod +x bootstrap.sh"
73
+ ssh "export PATH=$PATH:~/Montage_v3.3_patched_4/bin && ./data/bootstrap.sh 0.25"
74
+ ssh "cd hyperflow && echo \"var AMQP_URL=process.env.AMQP_URL?process.env.AMQP_URL:'amqp://#{getInstance('in1').host}:5672';exports.amqp_url=AMQP_URL;exports.options={'storage':'local','workdir':'/home/ubuntu/0.25/input'}\" > functions/amqpCommand.config.js"
75
+ ssh "nodejs hyperflow/scripts/dax_convert_amqp.js 0.25/workdir/dag.xml > 0.25/workdir/dag.json"
76
+ ssh "nohup nodejs hyperflow/scripts/runwf.js -f 0.25/workdir/dag.json -s > amqp.out 2>&1 &"
77
+ end
78
+ end
79
+ end
80
+
81
+ result = execution_tree.run
82
+ ap result
83
+
84
+ puts result.to_json
@@ -0,0 +1,88 @@
1
+ require "claudius"
2
+ require "json"
3
+
4
+ config = load_config('./user_config.json')
5
+
6
+ execution_tree = experiment 'Helloo' do
7
+ define_providers do
8
+ cloud('aws', :provider => config['provider'],
9
+ :region =>config['region'],
10
+ :endpoint => 'https://ec2.eu-west-1.amazonaws.com/',
11
+ :aws_access_key_id => config['aws_access_key_id'],
12
+ :aws_secret_access_key => config['aws_secret_access_key'])
13
+ .create_instances(
14
+ ['m3.medium=>in2', 'm3.large=>in3', 'c3.large=>in4', 'c3.xlarge=>in5'],
15
+ :username => 'ubuntu',
16
+ :private_key_path =>config['path_to_pem_file'],
17
+ :key_name => config['key_name'],
18
+ :image_id => config['image_id'],
19
+ :groups => config['groups'])
20
+ end
21
+ foreach ['in2', 'in3', 'in4', 'in5'] do |instance_name|
22
+ on instance_name do
23
+ before "set up docker" do
24
+ ssh "yes | sudo apt-get update"
25
+ ssh "yes | sudo apt-get install build-essential"
26
+
27
+ ssh "yes | sudo apt-get install python-software-properties python g++ make"
28
+ ssh "yes | sudo add-apt-repository ppa:chris-lea/node.js"
29
+ ssh "yes | sudo apt-get update"
30
+ ssh "yes | sudo apt-get install nodejs"
31
+
32
+ ssh "yes | sudo apt-get install git-core"
33
+
34
+ ssh "yes | sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev"
35
+ ssh "yes | sudo apt-get install ruby2.0 ruby2.0-dev build-essential libxml2-dev libxslt1-dev"
36
+ ssh "yes | sudo apt-get install rabbitmq-server"
37
+ ssh "yes | sudo apt-get install redis-server"
38
+
39
+ ssh "echo 'Git:'"
40
+ ssh "git --version"
41
+ ssh "echo 'Ruby'"
42
+ ssh "ruby --version"
43
+ ssh "echo 'Nodejs'"
44
+ ssh "nodejs --version"
45
+ ssh "echo 'Redis'"
46
+ ssh "redis-server --version"
47
+
48
+ ssh "curl -O http://pegasus.isi.edu/montage/Montage_v3.3_patched_4.tar.gz"
49
+ ssh "tar zxvf Montage_v3.3_patched_4.tar.gz"
50
+ ssh "cd Montage_v3.3_patched_4 && make"
51
+
52
+ ssh "curl -O https://dl.dropboxusercontent.com/u/81819/hyperflow-amqp-executor.gem"
53
+ ssh "sudo gem2.0 install --no-ri --no-rdoc hyperflow-amqp-executor.gem"
54
+
55
+ ssh "wget https://github.com/dice-cyfronet/hyperflow/archive/v1.0.0-beta-6.tar.gz"
56
+ ssh "tar zxvf v1.0.0-beta-6.tar.gz"
57
+ ssh "mv hyperflow-1.0.0-beta-6 hyperflow"
58
+ ssh "cd hyperflow && npm install"
59
+
60
+ ssh "cd hyperflow && echo 'amqp_url: amqp://localhost\nstorage: local\nthreads: <%= Executor::cpu_count %>' > executor_config.yml"
61
+
62
+ ssh "mkdir data"
63
+ ssh "cd data && wget https://gist.github.com/kfigiela/9075623/raw/dacb862176e9d576c1b23f6a243f9fa318c74bce/bootstrap.sh"
64
+ ssh "cd data && chmod +x bootstrap.sh"
65
+
66
+ end
67
+ foreach [1, 2, 3] do |a|
68
+ foreach [0.1, 0.25, 0.4] do |size|
69
+ execute do
70
+
71
+ ssh "export PATH=$PATH:~/Montage_v3.3_patched_4/bin && ./data/bootstrap.sh #{size}#{a}"
72
+
73
+ ssh "cd hyperflow && echo \"var AMQP_URL=process.env.AMQP_URL?process.env.AMQP_URL:'amqp://localhost:5672';exports.amqp_url=AMQP_URL;exports.options={'storage':'local','workdir':'/home/ubuntu/#{size}#{a}/input'}\" > functions/amqpCommand.config.js"
74
+
75
+ ssh "export PATH=$PATH:~/Montage_v3.3_patched_4/bin; nohup hyperflow-amqp-executor $(pwd)/hyperflow/executor_config.yml > amqp.out 2>&1 &"
76
+ ssh "nodejs hyperflow/scripts/dax_convert_amqp.js #{size}#{a}/workdir/dag.xml > #{size}#{a}/workdir/dag.json"
77
+ # ssh "nohup nodejs hyperflow/scripts/runwf.js -f #{size}/workdir/dag.json -s > amqp.out 2>&1 &"
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ result = execution_tree.run
86
+ ap result
87
+
88
+ puts result.to_json
data/examples/ping.rb CHANGED
@@ -13,14 +13,14 @@ execution_tree = experiment 'Hello' do
13
13
  :endpoint => 'https://ec2.eu-west-1.amazonaws.com/',
14
14
  :aws_access_key_id => config['aws_access_key_id'],
15
15
  :aws_secret_access_key => config['aws_secret_access_key'])
16
- .create_instances(['t1.micro=>in1'],
16
+ .create_instances(['t2.micro=>in1'],
17
17
  :username => 'ubuntu',
18
- :private_key_path =>'./Piotr-key-pair-irleand.pem',
19
- :key_name => 'Piotr-key-pair-irleand',
20
- :groups => ['Piotr-irleand'])
21
- manual('kali', '172.16.0.109', 'root', :password => 'toor')
18
+ :private_key_path =>config['path_to_pem_file'],
19
+ :key_name => config['key_name'],
20
+ :image_id => config['image_id'],
21
+ :groups => config['groups'])
22
22
  end
23
- foreach ['kali', 'in1'] do |instance_name|
23
+ foreach ['in1'] do |instance_name|
24
24
  concurrent do
25
25
  on 'localhost' do
26
26
  execute do
@@ -3,6 +3,7 @@ require 'cloud_provider.rb'
3
3
  require 'json'
4
4
 
5
5
  $virtual_machines = Hash.new
6
+ $vms_manager
6
7
 
7
8
  class MachineManager
8
9
  attr_accessor :cloud_providers
@@ -40,6 +41,12 @@ class MachineManager
40
41
  end
41
42
  end
42
43
 
44
+ def destroy_machines
45
+ cloud_providers.each do |provider|
46
+ provider.destroy
47
+ end
48
+ end
49
+
43
50
  end
44
51
 
45
52
  def load_config( filename )
@@ -49,7 +56,7 @@ def load_config( filename )
49
56
  end
50
57
 
51
58
  def define_providers (&block)
52
- MachineManager.new &block
59
+ $vms_manager = MachineManager.new &block
53
60
  end
54
61
 
55
62
  def getInstance(name)
@@ -95,6 +95,7 @@ class Experiment
95
95
 
96
96
  def run
97
97
  @root.run(nil)
98
+ # $vms_manager.destroy_machines
98
99
  end
99
100
 
100
101
  def export_tree(path = 'execution_tree')
@@ -17,7 +17,6 @@ class ExecutionNode < Node
17
17
  :before => 0,
18
18
  :exec => [],
19
19
  }
20
-
21
20
  end
22
21
 
23
22
  def draw_block(graph)
@@ -25,7 +25,6 @@ class Node
25
25
  :name => @name,
26
26
  :exec => []
27
27
  }
28
-
29
28
  end
30
29
 
31
30
  def run(instance)
@@ -8,11 +8,12 @@ class Test_local_execution < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  def test_simple
11
- experiment 'Hello' do
11
+ helloExp = experiment 'Hello' do
12
12
  execute do
13
13
  ssh 'mkdir Hello123456'
14
14
  end
15
15
  end
16
+ helloExp.run()
16
17
  result = `ls -la`
17
18
  assert_equal(true, result.include?('Hello123456'), 'Test should create a folder in current directory')
18
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claudius
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-06-07 00:00:00.000000000 Z
13
+ date: 2014-12-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -49,7 +49,7 @@ dependencies:
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.22.0
55
55
  type: :runtime
@@ -57,7 +57,7 @@ dependencies:
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
- - - ! '>='
60
+ - - '='
61
61
  - !ruby/object:Gem::Version
62
62
  version: 1.22.0
63
63
  - !ruby/object:Gem::Dependency
@@ -108,9 +108,17 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.2.0
111
- description: Write a gem description
111
+ description: Claudius is an easy-to-use domain specific language for cloud experiments.
112
+ It has been designed to speed up process of building distributed experiments and
113
+ highly reduce time of remote machines configuration. To avoid vendor lock-in, Claudius
114
+ was build on top of fog.io library, which enables flexible and powerful way to manage
115
+ machine instances at various cloud providers. Remote commands execution is based
116
+ on SSH protocol (SSH-2). DLS allow users to generate readable execution graph,
117
+ which is extremely useful for experiment flow verification and help avoid wasting
118
+ your money.
112
119
  email:
113
120
  - rachamot@gmail.com
121
+ - piotr.skibiak@gmail.com
114
122
  executables: []
115
123
  extensions: []
116
124
  extra_rdoc_files: []
@@ -122,6 +130,9 @@ files:
122
130
  - Rakefile
123
131
  - claudius.gemspec
124
132
  - examples/_
133
+ - examples/distributed_app.rb
134
+ - examples/distributed_montage.rb
135
+ - examples/montage.rb
125
136
  - examples/on_instance.rb
126
137
  - examples/ping.rb
127
138
  - examples/simple_program.rb
@@ -163,7 +174,7 @@ rubyforge_project:
163
174
  rubygems_version: 1.8.23
164
175
  signing_key:
165
176
  specification_version: 3
166
- summary: Write a gem summary
177
+ summary: DSL for cloud experiments
167
178
  test_files:
168
179
  - test/execution_test.rb
169
180
  - test/gem_usage_test.rb