nuri 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +12 -0
- data/CHANGELOG +146 -0
- data/Gemfile +3 -0
- data/LICENSE +28 -0
- data/README.md +64 -0
- data/Rakefile +15 -0
- data/VERSION +1 -0
- data/bin/delete_modules +11 -0
- data/bin/install_agent +18 -0
- data/bin/install_module +65 -0
- data/bin/nuri +519 -0
- data/bin/nuri.old +183 -0
- data/bin/push_model +16 -0
- data/examples/.gitignore +3 -0
- data/examples/bonfire.sfp +95 -0
- data/examples/bonfire/epcc.sfp +43 -0
- data/examples/bonfire/epcc0.sfp +49 -0
- data/examples/bonfire/epcc2.sfp +52 -0
- data/examples/bonfire/epcc2a.sfp +25 -0
- data/examples/bonfire/inria.sfp +72 -0
- data/examples/bonfire/inria0.sfp +49 -0
- data/examples/bonfire/inria2.sfp +71 -0
- data/examples/bonfire/inria2a.sfp +44 -0
- data/examples/bonfire/inria2b.sfp +54 -0
- data/examples/bonfire/inria2c.sfp +62 -0
- data/examples/bonfire/inria2d.sfp +71 -0
- data/examples/bonfire/inria2e.sfp +80 -0
- data/examples/bonfire/main.sfp +33 -0
- data/examples/bonfire/old/bonfire-1-1-1.sfp +76 -0
- data/examples/bonfire/old/bonfire-1-10-1.sfp +77 -0
- data/examples/bonfire/old/bonfire-1-2-1.sfp +58 -0
- data/examples/bonfire/old/bonfire-1-3-1.sfp +61 -0
- data/examples/bonfire/old/bonfire-1-4-1.sfp +64 -0
- data/examples/bonfire/old/bonfire-1-5-1.sfp +67 -0
- data/examples/bonfire/old/bonfire-1-6-1.sfp +82 -0
- data/examples/bonfire/old/bonfire-1-7-1.sfp +82 -0
- data/examples/bonfire/old/bonfire-1-8-1.sfp +79 -0
- data/examples/bonfire/old/bonfire-1-9-1.sfp +83 -0
- data/examples/bonfire/old/wp-test1a.sfp +38 -0
- data/examples/bonfire/old/wp-test1b.sfp +18 -0
- data/examples/bonfire/old/wp-test1c.sfp +7 -0
- data/examples/bonfire/old/wp-test2.sfp +47 -0
- data/examples/bonfire/old3/bonfire-epcc.sfp +57 -0
- data/examples/bonfire/old3/bonfire-inria.sfp +72 -0
- data/examples/bonfire/old3/bonfire-master.sfp +18 -0
- data/examples/bonfire/old3/bonfire.sfp +23 -0
- data/examples/bonfire/old3/bonfire2.sfp +49 -0
- data/examples/bonfire/old3/bonfire3.sfp +76 -0
- data/examples/bonfire/old3/bonfire4.sfp +78 -0
- data/examples/bonfire/old3/bonfire5.sfp +34 -0
- data/examples/bonfire/old3/bonfire5b.sfp +84 -0
- data/examples/bonfire/old3/hpvm6.sfp +22 -0
- data/examples/bonfire/old3/model.json +1 -0
- data/examples/bonfire/old3/test0.sfp +16 -0
- data/examples/bonfire/old3/test1.sfp +5 -0
- data/examples/bonfire/old3/test10.sfp +5 -0
- data/examples/bonfire/old3/test2.sfp +18 -0
- data/examples/bonfire/old3/test3.sfp +10 -0
- data/examples/bonfire/old3/test4.sfp +11 -0
- data/examples/bonfire/old3/test5.sfp +18 -0
- data/examples/bonfire/old3/test6.sfp +19 -0
- data/examples/bonfire/old3/test7.sfp +34 -0
- data/examples/bonfire/old3/test8.sfp +5 -0
- data/examples/bonfire/old3/test9.sfp +16 -0
- data/examples/bonfire/old3/wordpress-test-cluster.sfp +38 -0
- data/examples/bonfire/old3/wordpress-test.sfp +22 -0
- data/examples/bonfire/old3/wp-test-2.sfp +49 -0
- data/examples/bonfire/test.sfp +13 -0
- data/examples/generator.rb +66 -0
- data/examples/hadoop2.sfp +20 -0
- data/examples/hpcloud.sfp +18 -0
- data/examples/run.rb +17 -0
- data/examples/test.inc +0 -0
- data/examples/test.sfp +11 -0
- data/lib/naas/d3.js +5 -0
- data/lib/naas/d3.v3.min.js +5 -0
- data/lib/naas/index.css +0 -0
- data/lib/naas/index.html +18 -0
- data/lib/naas/index.js +18 -0
- data/lib/naas/jquery-1.10.2.min.js +6 -0
- data/lib/naas/jquery.js +6 -0
- data/lib/naas/naas.rb +160 -0
- data/lib/nuri.rb +62 -0
- data/lib/nuri/choreographer.rb +151 -0
- data/lib/nuri/constraint_helper.rb +9 -0
- data/lib/nuri/directory.rb +40 -0
- data/lib/nuri/master.rb +725 -0
- data/lib/nuri/net_helper.rb +65 -0
- data/lib/nuri/orchestrator.rb +224 -0
- data/lib/nuri/server.rb +212 -0
- data/modules/.gitignore +4 -0
- data/modules/apache/apache.rb +255 -0
- data/modules/apache/apache.rb.old +167 -0
- data/modules/apache/apache.sfp +146 -0
- data/modules/apache/apache.sfp.future +100 -0
- data/modules/apache/load_balancer +20 -0
- data/modules/apache/model.json +1 -0
- data/modules/apache/test.sfp +8 -0
- data/modules/aptpackage/aptpackage.rb +82 -0
- data/modules/aptpackage/aptpackage.sfp +5 -0
- data/modules/bonfire/.gitignore +2 -0
- data/modules/bonfire/README.md +12 -0
- data/modules/bonfire/bonfire.rb +60 -0
- data/modules/bonfire/bonfire.sfp +9 -0
- data/modules/bonfire/config.yml +4 -0
- data/modules/bonfire/helper.rb +149 -0
- data/modules/bonfire/stresstest.rb +144 -0
- data/modules/bonfire/test.sfp +8 -0
- data/modules/client/client.rb +22 -0
- data/modules/client/client.sfp +14 -0
- data/modules/cloud/cloud.rb +11 -0
- data/modules/cloud/cloud.sfp +26 -0
- data/modules/file/file.rb +91 -0
- data/modules/file/file.sfp +9 -0
- data/modules/hadoop1/core-site.xml +17 -0
- data/modules/hadoop1/hadoop-env.sh +55 -0
- data/modules/hadoop1/hadoop1.rb +384 -0
- data/modules/hadoop1/hadoop1.sfp +93 -0
- data/modules/hadoop1/hdfs-site.xml +16 -0
- data/modules/hadoop1/mapred-site.xml +17 -0
- data/modules/hadoop2/core-site.xml +31 -0
- data/modules/hadoop2/hadoop-env.sh +77 -0
- data/modules/hadoop2/hadoop2.rb +401 -0
- data/modules/hadoop2/hadoop2.sfp +114 -0
- data/modules/hadoop2/hdfs-site.xml +47 -0
- data/modules/hadoop2/mapred-site.xml +71 -0
- data/modules/hadoop2/ports +14 -0
- data/modules/hadoop2/yarn-env.sh +112 -0
- data/modules/hadoop2/yarn-site.xml +107 -0
- data/modules/hpcloud/.gitignore +2 -0
- data/modules/hpcloud/README.md +16 -0
- data/modules/hpcloud/config.yml +3 -0
- data/modules/hpcloud/example.sfp +18 -0
- data/modules/hpcloud/hpcloud.rb +241 -0
- data/modules/hpcloud/hpcloud.sfp +22 -0
- data/modules/hpcloud/test.sfp +5 -0
- data/modules/install_module +65 -0
- data/modules/machine/machine.rb +95 -0
- data/modules/machine/machine.sfp +9 -0
- data/modules/mockcloud/mockcloud.rb +20 -0
- data/modules/mockcloud/mockcloud.sfp +6 -0
- data/modules/mysql/mysql.rb +118 -0
- data/modules/mysql/mysql.sfp +38 -0
- data/modules/mysql/test.sfp +3 -0
- data/modules/node/node.rb +8 -0
- data/modules/node/node.sfp +7 -0
- data/modules/object/object.rb +7 -0
- data/modules/object/object.sfp +1 -0
- data/modules/os/os.rb +38 -0
- data/modules/os/os.sfp +11 -0
- data/modules/package/package.rb +26 -0
- data/modules/package/package.sfp +22 -0
- data/modules/package/test.sfp +6 -0
- data/modules/service/model.json +1 -0
- data/modules/service/service.rb +50 -0
- data/modules/service/service.sfp +46 -0
- data/modules/service/test.sfp +6 -0
- data/modules/tarpackage/tarpackage.rb +93 -0
- data/modules/tarpackage/tarpackage.sfp +5 -0
- data/modules/vm/vm.rb +8 -0
- data/modules/vm/vm.sfp +18 -0
- data/modules/wordpress/wordpress.rb +98 -0
- data/modules/wordpress/wordpress.sfp +34 -0
- data/modules/wordpresscluster/wordpresscluster.rb +150 -0
- data/modules/wordpresscluster/wordpresscluster.sfp +74 -0
- data/nuri.gemspec +26 -0
- metadata +281 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
schema ServiceState
|
2
|
+
uninstalled isa ServiceState { }
|
3
|
+
installed isa ServiceState { }
|
4
|
+
running isa ServiceState { }
|
5
|
+
|
6
|
+
schema VHost {
|
7
|
+
serverName = ""
|
8
|
+
port = 80
|
9
|
+
documentRoot = ""
|
10
|
+
serverAdmin = ""
|
11
|
+
}
|
12
|
+
|
13
|
+
schema Apache {
|
14
|
+
state = uninstalled
|
15
|
+
version = "latest"
|
16
|
+
module_php = false
|
17
|
+
module_php_mysql = false
|
18
|
+
|
19
|
+
default isa VHost {
|
20
|
+
serverName = "*"
|
21
|
+
port = 80
|
22
|
+
document = "/var/www"
|
23
|
+
serverAdmin = "webmaster@localhost"
|
24
|
+
}
|
25
|
+
|
26
|
+
sub install {
|
27
|
+
condition {
|
28
|
+
this.state = uninstalled
|
29
|
+
}
|
30
|
+
effect {
|
31
|
+
this.state = installed
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
sub uninstall {
|
36
|
+
condition {
|
37
|
+
this.state = installed
|
38
|
+
}
|
39
|
+
effect {
|
40
|
+
this.state = uninstalled
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
sub start {
|
45
|
+
condition {
|
46
|
+
this.state = installed
|
47
|
+
}
|
48
|
+
effect {
|
49
|
+
this.state = running
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
sub stop {
|
54
|
+
condition {
|
55
|
+
this.state = running
|
56
|
+
}
|
57
|
+
effect {
|
58
|
+
this.state = uninstalled
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
sub install_module_php {
|
63
|
+
condition {
|
64
|
+
this.installed = true
|
65
|
+
this.running = false
|
66
|
+
}
|
67
|
+
effect {
|
68
|
+
this.module_php = true
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
sub uninstall_module_php {
|
73
|
+
condition {
|
74
|
+
this.running = false
|
75
|
+
}
|
76
|
+
effect {
|
77
|
+
this.php_module = false
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
sub install_module_php_mysql {
|
82
|
+
condition {
|
83
|
+
this.module_php = true
|
84
|
+
this.installed = true
|
85
|
+
this.running = false
|
86
|
+
}
|
87
|
+
effect {
|
88
|
+
this.module_php_mysql = true
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
sub uninstall_module_php_mysql {
|
93
|
+
condition {
|
94
|
+
this.running = false
|
95
|
+
}
|
96
|
+
effect {
|
97
|
+
this.module_php_mysql = false
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<VirtualHost *:80>
|
2
|
+
ProxyRequests off
|
3
|
+
ServerName <server_name>
|
4
|
+
|
5
|
+
<Proxy balancer://nuricluster>
|
6
|
+
### Balancer Members ###
|
7
|
+
Order Deny,Allow
|
8
|
+
Deny from none
|
9
|
+
Allow from all
|
10
|
+
ProxySet lbmethod=byrequests
|
11
|
+
</Proxy>
|
12
|
+
<Location /balancer-manager>
|
13
|
+
SetHandler balancer-manager
|
14
|
+
Order Deny,Allow
|
15
|
+
Allow from all
|
16
|
+
</Location>
|
17
|
+
ProxyPass /balancer-manager !
|
18
|
+
ProxyPass / balancer://nuricluster/
|
19
|
+
</VirtualHost>
|
20
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Object":{"_self":"Object","_context":"class"},"Package":{"_self":"Package","_context":"class","package_name":"","installed":false,"version":"","install":{"_self":"install","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.installed":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.installed":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall":{"_self":"uninstall","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.installed":{"_context":"mutation","_type":"equals","_value":false}}},"_extends":"$.Object","_super":["$.Object"]},"Service":{"_self":"Service","_context":"class","_extends":"$.Package","service_name":"","running":false,"uninstall":{"_self":"uninstall","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false},"$.this.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.installed":{"_context":"mutation","_type":"equals","_value":false}}},"start":{"_self":"start","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.running":{"_context":"mutation","_type":"equals","_value":true}}},"stop":{"_self":"stop","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.running":{"_context":"mutation","_type":"equals","_value":false}}},"package_name":"","installed":false,"version":"","install":{"_self":"install","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.installed":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.installed":{"_context":"mutation","_type":"equals","_value":true}}},"_super":["$.Object","$.Package"]},"Apache":{"_self":"Apache","_context":"class","_extends":"$.Service","package_name":"apache2","service_name":"apache2","port":80,"document_root":"/var/www","php_module":false,"php_mysql_module":false,"server_name":"","libaugeas_ruby":{"_self":"libaugeas_ruby","_context":"object","_isa":"$.Package","_is_array":false,"package_name":"libaugeas-ruby","installed":true,"version":"","install":{"_self":"install","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.installed":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.installed":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall":{"_self":"uninstall","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.installed":{"_context":"mutation","_type":"equals","_value":false}}},"_classes":["$.Object","$.Package"]},"install":{"_self":"install","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":false},"$.this.libaugeas.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.installed":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall":{"_self":"uninstall","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false},"$.this.php_module":{"_context":"constraint","_type":"equals","_value":false},"$.this.php_mysql_module":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.installed":{"_context":"mutation","_type":"equals","_value":false}}},"set_document_root":{"_self":"set_document_root","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false},"$.this.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.document_root":{"_context":"mutation","_type":"equals","_value":"$.target"}},"target":{"_context":"null","_isa":"$.String"}},"set_server_name":{"_self":"set_server_name","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false},"$.this.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.server_name":{"_context":"mutation","_type":"equals","_value":"$.target"}},"target":{"_context":"null","_isa":"$.String"}},"install_php_module":{"_self":"install_php_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_module":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall_php_module":{"_self":"uninstall_php_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_module":{"_context":"mutation","_type":"equals","_value":false}}},"install_php_mysql_module":{"_self":"install_php_mysql_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.php_module":{"_context":"constraint","_type":"equals","_value":true},"$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_mysql_module":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall_php_mysql_module":{"_self":"uninstall_php_mysql_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_mysql_module":{"_context":"mutation","_type":"equals","_value":false}}},"running":false,"start":{"_self":"start","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.running":{"_context":"mutation","_type":"equals","_value":true}}},"stop":{"_self":"stop","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.running":{"_context":"mutation","_type":"equals","_value":false}}},"installed":false,"version":"","_super":["$.Object","$.Package","$.Service"]},"apache":{"_self":"apache","_context":"object","_isa":"$.Apache","_is_array":false,"package_name":"apache2","service_name":"apache2","port":80,"document_root":"/var/www","php_module":false,"php_mysql_module":false,"server_name":"","libaugeas_ruby":{"_self":"libaugeas_ruby","_context":"object","_isa":"$.Package","_is_array":false,"package_name":"libaugeas-ruby","installed":true,"version":"","install":{"_self":"install","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.installed":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.installed":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall":{"_self":"uninstall","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.installed":{"_context":"mutation","_type":"equals","_value":false}}},"_classes":["$.Object","$.Package"]},"install":{"_self":"install","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":false},"$.this.libaugeas.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.installed":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall":{"_self":"uninstall","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false},"$.this.php_module":{"_context":"constraint","_type":"equals","_value":false},"$.this.php_mysql_module":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.installed":{"_context":"mutation","_type":"equals","_value":false}}},"set_document_root":{"_self":"set_document_root","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false},"$.this.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.document_root":{"_context":"mutation","_type":"equals","_value":"$.target"}},"target":{"_context":"null","_isa":"$.String"}},"set_server_name":{"_self":"set_server_name","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false},"$.this.installed":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.server_name":{"_context":"mutation","_type":"equals","_value":"$.target"}},"target":{"_context":"null","_isa":"$.String"}},"install_php_module":{"_self":"install_php_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_module":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall_php_module":{"_self":"uninstall_php_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_module":{"_context":"mutation","_type":"equals","_value":false}}},"install_php_mysql_module":{"_self":"install_php_mysql_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.php_module":{"_context":"constraint","_type":"equals","_value":true},"$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_mysql_module":{"_context":"mutation","_type":"equals","_value":true}}},"uninstall_php_mysql_module":{"_self":"uninstall_php_mysql_module","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.php_mysql_module":{"_context":"mutation","_type":"equals","_value":false}}},"running":false,"start":{"_self":"start","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.installed":{"_context":"constraint","_type":"equals","_value":true},"$.this.running":{"_context":"constraint","_type":"equals","_value":false}},"_effect":{"_context":"effect","_type":"and","$.this.running":{"_context":"mutation","_type":"equals","_value":true}}},"stop":{"_self":"stop","_context":"procedure","_cost":1,"_condition":{"_context":"constraint","_type":"and","$.this.running":{"_context":"constraint","_type":"equals","_value":true}},"_effect":{"_context":"effect","_type":"and","$.this.running":{"_context":"mutation","_type":"equals","_value":false}}},"installed":false,"version":"","_classes":["$.Object","$.Package","$.Service","$.Apache"]}}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class Sfp::Module::AptPackage
|
2
|
+
include Sfp::Resource
|
3
|
+
|
4
|
+
def update_state
|
5
|
+
to_model
|
6
|
+
|
7
|
+
@state['installed'] = installed?
|
8
|
+
@state['version'] = version?
|
9
|
+
end
|
10
|
+
|
11
|
+
##############################
|
12
|
+
#
|
13
|
+
# Action methods (see TarPackage.sfp)
|
14
|
+
#
|
15
|
+
##############################
|
16
|
+
|
17
|
+
def install(p={})
|
18
|
+
Sfp::Module::AptPackage.install(@model['package_name'].to_s.strip)
|
19
|
+
end
|
20
|
+
|
21
|
+
def uninstall(p={})
|
22
|
+
Sfp::Module::AptPackage.uninstall(@model['package_name'].to_s.strip)
|
23
|
+
end
|
24
|
+
|
25
|
+
##############################
|
26
|
+
#
|
27
|
+
# Helper methods
|
28
|
+
#
|
29
|
+
##############################
|
30
|
+
|
31
|
+
def self.installed?(package)
|
32
|
+
package = package.to_s.strip
|
33
|
+
return false if package.length <= 0
|
34
|
+
data = `/usr/bin/dpkg-query -W #{package} 2> /dev/null`.strip.chop.split(' ')
|
35
|
+
return true if data[0].to_s == package
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.version?(package)
|
40
|
+
package = package.to_s.strip
|
41
|
+
return nil if package.length <= 0
|
42
|
+
data = `/usr/bin/dpkg-query -W #{package} 2> /dev/null`.strip.chop.split(' ')
|
43
|
+
return data[1] if data[0].to_s == package
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.install(package)
|
48
|
+
return false if not package.is_a?(String) or package.length <= 0
|
49
|
+
return true if Sfp::Module::Package.installed?(package)
|
50
|
+
system("dpkg --configure -a")
|
51
|
+
system("apt-get -y --purge autoremove")
|
52
|
+
return true if system("apt-get -y install #{package}")
|
53
|
+
system("dpkg --configure -a")
|
54
|
+
system("apt-get -y update")
|
55
|
+
!!system("apt-get -y install #{package}")
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.uninstall(package)
|
59
|
+
return false if not package.is_a?(String) or package.length <= 0
|
60
|
+
return true if not Sfp::Module::Package.installed?(package)
|
61
|
+
system("dpkg --configure -a")
|
62
|
+
system("apt-get -y --purge autoremove")
|
63
|
+
return (!!system("sudo apt-get -y --purge remove #{package}") and
|
64
|
+
!!system("sudo apt-get -y --purge autoremove") and
|
65
|
+
!!system("sudo apt-get -y --purge autoremove"))
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
def installed?
|
70
|
+
Sfp::Module::AptPackage.installed?(@model['package_name'].to_s.strip)
|
71
|
+
end
|
72
|
+
|
73
|
+
def version?
|
74
|
+
package = @model['package_name'].to_s.strip
|
75
|
+
return nil if package.length <= 0
|
76
|
+
installed = `apt-cache policy #{package} | grep Installed`.strip.split(' ', 2)[1].to_s.strip
|
77
|
+
return "" if installed.length <= 0
|
78
|
+
candidate = `apt-cache policy #{package} | grep Candidate`.strip.split(' ', 2)[1].to_s.strip
|
79
|
+
return "latest" if candidate == installed
|
80
|
+
installed
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
BonFIRE Module
|
2
|
+
==============
|
3
|
+
|
4
|
+
Required Gems
|
5
|
+
-------------
|
6
|
+
- restfully
|
7
|
+
- restfully-addons
|
8
|
+
|
9
|
+
Additional Files
|
10
|
+
----------------
|
11
|
+
- bonfire.pem : A private key file to access your BonFIRE account. This file should be put in module's directory.
|
12
|
+
- config.yml : The username and password of your BonFIRE account should be defined in this file.
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'restfully'
|
2
|
+
require 'restfully/addons/bonfire'
|
3
|
+
|
4
|
+
load File.expand_path(File.dirname(__FILE__)) + "/helper.rb"
|
5
|
+
|
6
|
+
class Sfp::Module::Bonfire
|
7
|
+
include Sfp::Resource
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@home_dir = File.expand_path(File.dirname(__FILE__))
|
11
|
+
@session = @experiment = @location = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def update_state
|
15
|
+
to_model
|
16
|
+
@state['running'] = self.open_connection
|
17
|
+
@state['vms'] = self.get_vms
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_vm(p={})
|
21
|
+
name = p['vm'].to_s.strip
|
22
|
+
return false if name == ''
|
23
|
+
|
24
|
+
begin
|
25
|
+
name.sub!(/^\$\./, '')
|
26
|
+
server = self.create_server({
|
27
|
+
:name => name,
|
28
|
+
:image => @model['image_name'],
|
29
|
+
:wan => @model['wan_name'],
|
30
|
+
})
|
31
|
+
if !server.nil?
|
32
|
+
if !self.install_agent(server)
|
33
|
+
delete_vm(p)
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
return true
|
37
|
+
end
|
38
|
+
rescue Exception => e
|
39
|
+
Sfp::Agent.logger.error "Delete VM [Failed] #{e}\n#{e.backtrace.join("\n")}"
|
40
|
+
end
|
41
|
+
false
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete_vm(p={})
|
45
|
+
name = p['vm'].to_s.strip
|
46
|
+
return false if name == ''
|
47
|
+
|
48
|
+
begin
|
49
|
+
name.sub!(/^\$\./, '')
|
50
|
+
return self.delete_server({
|
51
|
+
:name => name
|
52
|
+
})
|
53
|
+
rescue Exception => e
|
54
|
+
Sfp::Agent.logger.error "Delete VM [Failed] #{e}\n#{e.backtrace.join("\n")}"
|
55
|
+
end
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
include Sfp::Module::BonfireHelper
|
60
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'restfully'
|
3
|
+
require 'restfully/addons/bonfire'
|
4
|
+
|
5
|
+
module Sfp::Module::BonfireHelper
|
6
|
+
def open_connection
|
7
|
+
return true if not @session.nil?
|
8
|
+
|
9
|
+
begin
|
10
|
+
@session = Restfully::Session.new(
|
11
|
+
:configuration_file => @home_dir + '/config.yml',
|
12
|
+
:gateway => @model['gateway'],
|
13
|
+
:keys => @home_dir + '/bonfire.pem',
|
14
|
+
:cache => false,
|
15
|
+
:logger => Sfp::Agent.logger
|
16
|
+
) if @session.nil?
|
17
|
+
|
18
|
+
@experiment = (@session.root.experiments.find { |e|
|
19
|
+
e['name'] == @model['experiment'] && e['status'] == 'running'
|
20
|
+
} || false) if @experiment.nil? and !@session.nil?
|
21
|
+
|
22
|
+
@location = @session.root.locations[@model['location'].to_sym] if
|
23
|
+
@location.nil? and !@session.nil?
|
24
|
+
|
25
|
+
return (!@session.nil? and !@experiment.nil? and !@location.nil?)
|
26
|
+
rescue Exception => e
|
27
|
+
Sfp::Agent.logger.warn "Cannot open connection! #{e}\n#{e.backtrace.join("\n")}"
|
28
|
+
end
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
def running?(vm)
|
33
|
+
(vm.reload['state'] == 'ACTIVE' || vm.reload['state'] == 'RUNNING' ||
|
34
|
+
vm.reload['state'] == 'up')
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_server(p={})
|
38
|
+
open_connection
|
39
|
+
|
40
|
+
name = p[:name]
|
41
|
+
image_name = p[:image]
|
42
|
+
wan_name = p[:wan]
|
43
|
+
|
44
|
+
@session.logger.info "Launching #{name} in #{@location['name']}..."
|
45
|
+
server = @experiment.computes.find { |vm|
|
46
|
+
vm['name'] == name
|
47
|
+
} || @experiment.computes.submit(
|
48
|
+
:name => name,
|
49
|
+
:instance_type => "small",
|
50
|
+
:disk => [{
|
51
|
+
:storage => @location.storages.find { |s|
|
52
|
+
s['name'] == image_name
|
53
|
+
},
|
54
|
+
:type => "OS"
|
55
|
+
}],
|
56
|
+
:nic => [
|
57
|
+
{:network => @location.networks.find { |n| n['name'] == wan_name }}
|
58
|
+
],
|
59
|
+
:location => @location
|
60
|
+
)
|
61
|
+
server_ip = server['nic'][0]['ip']
|
62
|
+
@session.logger.info "#{name} IP=#{server_ip}"
|
63
|
+
|
64
|
+
@experiment.update(:status => "running")
|
65
|
+
|
66
|
+
@session.logger.info "#{name} is not ready. Waiting..."
|
67
|
+
wait_time = 3600 # 1-hour
|
68
|
+
tries = wait_time # 30 # 10 minutes
|
69
|
+
until [server].all? { |vm|
|
70
|
+
tries <= 0 || (running?(vm) && vm.ssh.accessible?)
|
71
|
+
} do
|
72
|
+
fail "#{name} has failed" if [server].any? { |vm|
|
73
|
+
vm['state'] == "FAILED"
|
74
|
+
}
|
75
|
+
sleep 1 #20
|
76
|
+
tries -= 1
|
77
|
+
end
|
78
|
+
fail "Cannot create #{name}: too long waiting!" if !running?(server)
|
79
|
+
|
80
|
+
server.ssh do |ssh|
|
81
|
+
@session.logger.info "Setting hostname..."
|
82
|
+
output = ssh.exec! "hostname"
|
83
|
+
if output.chop != name
|
84
|
+
ssh.exec! "/bin/echo #{name} > /etc/hostname"
|
85
|
+
ssh.exec! "/etc/init.d/hostname.sh start"
|
86
|
+
ssh.exec! "/bin/sed -i 's/#{name}.*/#{name}/g' /etc/hosts"
|
87
|
+
ssh.exec! "/bin/echo '127.0.0.1 #{name}' >> /etc/hosts"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
@session.logger.info "VM:#{server['name']} is READY! IP: #{server['nic'][0]['ip']}"
|
92
|
+
|
93
|
+
server
|
94
|
+
end
|
95
|
+
|
96
|
+
def install_agent(server)
|
97
|
+
begin
|
98
|
+
@session.logger.info "Installing agent to #{server['name']}:#{server['nic'][0]['ip']}"
|
99
|
+
server.ssh do |ssh|
|
100
|
+
ssh.exec! 'apt-get update; apt-get -y install sudo ruby1.9.1 ruby1.9.1-dev libz-dev libaugeas-ruby1.9.1 make gcc libxml2-dev libxslt-dev libreadline-dev'
|
101
|
+
ssh.exec! 'ln -sf /usr/bin/ruby1.9.1 /usr/bin/ruby'
|
102
|
+
ssh.exec! 'ln -sf /usr/bin/gem1.9.1 /usr/bin/gem'
|
103
|
+
ssh.exec! 'gem install sfp sfpagent fog restfully restfully-addons --no-ri --no-rdoc'
|
104
|
+
ssh.exec! 'ln -sf /var/lib/gems/1.9.1/bin/sfpagent /usr/local/bin/sfpagent'
|
105
|
+
ssh.exec! 'sfpagent -t ; sfpagent -s'
|
106
|
+
end
|
107
|
+
return true
|
108
|
+
rescue Exception => e
|
109
|
+
Sfp::Agent.logger.error "Cannot install the agent. #{e}\n#{e.backtrace.join("\n")}"
|
110
|
+
end
|
111
|
+
false
|
112
|
+
end
|
113
|
+
|
114
|
+
def delete_server(p={})
|
115
|
+
open_connection
|
116
|
+
name = p[:name]
|
117
|
+
|
118
|
+
server = @experiment.computes.find { |vm|
|
119
|
+
vm['name'] == name
|
120
|
+
} || (return true)
|
121
|
+
@session.logger.info "Deleting #{name} ..."
|
122
|
+
server.delete
|
123
|
+
tries = 30
|
124
|
+
until [server].all? { |vm|
|
125
|
+
tries > 0 && !running?(vm)
|
126
|
+
} do
|
127
|
+
@session.logger.info "#{name} is not deleted. Waiting..."
|
128
|
+
sleep 10
|
129
|
+
tries -= 1
|
130
|
+
end
|
131
|
+
!running?(server)
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_vms(p={})
|
135
|
+
open_connection
|
136
|
+
|
137
|
+
vms = {}
|
138
|
+
@experiment.computes.each { |server|
|
139
|
+
if server.uri.to_s =~ /\/locations\/#{@model['location']}\/computes\//
|
140
|
+
vms[ server['name'] ] = {
|
141
|
+
'running' => running?(server),
|
142
|
+
'ip' => server['nic'][0]['ip'],
|
143
|
+
'uri' => server.uri,
|
144
|
+
}
|
145
|
+
end
|
146
|
+
} if @experiment
|
147
|
+
vms
|
148
|
+
end
|
149
|
+
end
|