sfp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/src/build.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ antlr4ruby SfpLang.g
4
+
5
+ rm -f SfpLang.tokens
6
+ mv -f SfpLangLexer.rb ../lib
7
+ mv -f SfpLangParser.rb ../lib
@@ -0,0 +1,77 @@
1
+ class Machine {
2
+ running is false
3
+ address is ""
4
+
5
+ procedure start {
6
+ conditions {
7
+ this.running is false
8
+ }
9
+ effects {
10
+ this.running is true
11
+ }
12
+ }
13
+ procedure stop {
14
+ conditions {
15
+ this.running is true
16
+ }
17
+ effects {
18
+ this.running is false
19
+ }
20
+ }
21
+ }
22
+
23
+ class VM extends Machine {
24
+ created is false
25
+
26
+ procedure start {
27
+ conditions {
28
+ this.created is true
29
+ }
30
+ effects {
31
+ this.running is true
32
+ }
33
+ }
34
+ procedure stop {
35
+ conditions {
36
+ this.created is true
37
+ }
38
+ effects {
39
+ this.running is false
40
+ }
41
+ }
42
+ }
43
+
44
+ class Cloud {
45
+ running is false
46
+
47
+ procedure create_vm(vm isref VM) {
48
+ conditions {
49
+ this.running is true
50
+ vm.created is false
51
+ }
52
+ effects {
53
+ vm.created is true
54
+ }
55
+ }
56
+ procedure delete_vm(vm isref VM) {
57
+ conditions {
58
+ this.running is true
59
+ vm.created is true
60
+ }
61
+ effects {
62
+ vm.created is false
63
+ }
64
+ }
65
+ }
66
+
67
+ class Client {
68
+ refer isref Service
69
+
70
+ procedure redirect (s isref Service) {
71
+ conditions {
72
+ }
73
+ effects {
74
+ this.refer is s
75
+ }
76
+ }
77
+ }
data/test/cloud1.sfp ADDED
@@ -0,0 +1,33 @@
1
+ include "service-classes.sfp"
2
+
3
+ // generate all possible states with constraint solver
4
+ initial state {
5
+ cloud1 isa Cloud {
6
+ running either ( true, false )
7
+ }
8
+ cloud2 isa Cloud {
9
+ running either ( true, false )
10
+ }
11
+
12
+ vm1 isa VM
13
+ vm2 isa VM
14
+
15
+ s1 isa Service
16
+ s2 isa Service
17
+ }
18
+
19
+ goal constraint {
20
+ s1 {
21
+ running is true
22
+ on_machine is vm1
23
+ }
24
+
25
+ s2 {
26
+ running is true
27
+ on_machine is vm2
28
+ }
29
+ }
30
+
31
+ global constraint {
32
+ if s2.running then s1.running
33
+ }
data/test/cloud2.sfp ADDED
@@ -0,0 +1,41 @@
1
+ include "service-classes.sfp"
2
+
3
+ // generate all possible states with constraint solver
4
+ initial state {
5
+ cloud1 isa Cloud {
6
+ running either ( true, false )
7
+ }
8
+ cloud2 isa Cloud {
9
+ running either ( true, false )
10
+ }
11
+
12
+ vm1 isa VM
13
+ vm2 isa VM
14
+ vm3 isa VM
15
+
16
+ lb isa Service
17
+ ws isa Service
18
+ db isa Service
19
+ }
20
+
21
+ goal constraint {
22
+ lb {
23
+ running is true
24
+ on_machine is vm1
25
+ }
26
+
27
+ ws {
28
+ running is true
29
+ on_machine is vm2
30
+ }
31
+
32
+ db {
33
+ running is true
34
+ on_machine is vm3
35
+ }
36
+ }
37
+
38
+ global constraint {
39
+ if lb.running then ws.running
40
+ if ws.running then db.running
41
+ }
data/test/cloud3.sfp ADDED
@@ -0,0 +1,42 @@
1
+ include "service-classes.sfp"
2
+
3
+ // generate all possible states with constraint solver
4
+ initial state {
5
+ /*cloud1 isa Cloud {
6
+ running either ( true, false )
7
+ }
8
+ cloud2 isa Cloud {
9
+ running either ( true, false )
10
+ }*/
11
+ mycloud isa Cloud {
12
+ running is true
13
+ }
14
+
15
+ vm1 isa VM
16
+ vm2 isa VM
17
+ vm3 isa VM
18
+
19
+ lb1 isa LoadBalancer
20
+ //ws1 isa WebService
21
+ app1 isa AppService
22
+ db1 isa DatabaseService
23
+ }
24
+
25
+ goal constraint {
26
+ lb1 {
27
+ installed is true
28
+ on_machine is vm1
29
+ }
30
+ //ws1.installed is true
31
+ app1 {
32
+ installed is true
33
+ on_machine is vm3
34
+ }
35
+ db1 {
36
+ running is true
37
+ on_machine is vm4
38
+ }
39
+ }
40
+
41
+ global constraint {
42
+ }
@@ -0,0 +1,151 @@
1
+ include "cloud-classes.sfp"
2
+
3
+ class Service {
4
+ installed is false
5
+ running is false
6
+ on_machine isref Machine
7
+
8
+ procedure install ( m isref Machine ) {
9
+ conditions {
10
+ m.running is true
11
+ this.installed is false
12
+ }
13
+ effects {
14
+ this.on_machine is m
15
+ this.installed is true
16
+ }
17
+ }
18
+ procedure uninstall {
19
+ conditions {
20
+ this.on_machine.running is true
21
+ this.installed is true
22
+ }
23
+ effects {
24
+ this.on_machine is null
25
+ this.installed is false
26
+ }
27
+ }
28
+
29
+ procedure start {
30
+ conditions {
31
+ this.installed is true
32
+ this.running is false
33
+ }
34
+ effects {
35
+ this.running is true
36
+ }
37
+ }
38
+ procedure stop {
39
+ conditions {
40
+ this.installed is true
41
+ this.running is true
42
+ }
43
+ effects {
44
+ this.running is false
45
+ }
46
+ }
47
+ }
48
+
49
+ class LoadBalancer extends Service {
50
+ webs isset WebService
51
+
52
+ procedure start {
53
+ conditions {
54
+ this.installed is true
55
+ this.running is false
56
+ exist (this.webs as web) {
57
+ web.running is true
58
+ }
59
+ }
60
+ effects {
61
+ this.running is true
62
+ }
63
+ }
64
+ }
65
+
66
+ class WebService extends Service {
67
+ depend_on isref AppService
68
+
69
+ procedure redirect ( app isref AppService ) {
70
+ conditions {
71
+ this.installed is true
72
+ app.running is true
73
+ }
74
+ effects {
75
+ this.depend_on is app
76
+ }
77
+ }
78
+ procedure start {
79
+ conditions {
80
+ this.installed is true
81
+ this.running is false
82
+ this.depend_on.running is true
83
+ }
84
+ effects {
85
+ this.running is true
86
+ }
87
+ }
88
+ procedure stop {
89
+ conditions {
90
+ this.installed is true
91
+ this.running is true
92
+ forall (LoadBalancer as lb) {
93
+ if lb.webs has this then lb.running is false
94
+ }
95
+ }
96
+ effects {
97
+ this.running is false
98
+ }
99
+ }
100
+ }
101
+
102
+ class AppService extends Service {
103
+ depend_on isref DatabaseService
104
+
105
+ procedure redirect ( db isref DatabaseService ) {
106
+ conditions {
107
+ this.installed is true
108
+ db.running is true
109
+ }
110
+ effects {
111
+ this.depend_on is db
112
+ }
113
+ }
114
+ procedure start {
115
+ conditions {
116
+ this.installed is true
117
+ this.running is false
118
+ this.depend_on.running is true
119
+ }
120
+ effects {
121
+ this.running is true
122
+ }
123
+ }
124
+ procedure stop {
125
+ conditions {
126
+ this.installed is true
127
+ this.running is true
128
+ forall (WebService as ws) {
129
+ if ws.depend_on is this then ws.running is false
130
+ }
131
+ }
132
+ effects {
133
+ this.running is false
134
+ }
135
+ }
136
+ }
137
+
138
+ class DatabaseService extends Service {
139
+ procedure stop {
140
+ conditions {
141
+ this.installed is true
142
+ this.running is true
143
+ forall (AppService as app) {
144
+ if app.depend_on is this then app.running is false
145
+ }
146
+ }
147
+ effects {
148
+ this.running is false
149
+ }
150
+ }
151
+ }
data/test/service1.sfp ADDED
@@ -0,0 +1,24 @@
1
+ //include "cloud-classes.sfp"
2
+ include "service-classes.sfp"
3
+
4
+ initial state {
5
+ s1 isa Service {
6
+ installed is true
7
+ running either (true, false)
8
+ }
9
+ s2 isa Service {
10
+ installed is true
11
+ running either (true, false)
12
+ }
13
+ pc isa Client {
14
+ refer either (s1, s2)
15
+ }
16
+ }
17
+ goal constraint {
18
+ s1.running is false
19
+ s2.running is true
20
+ pc.refer is s2
21
+ }
22
+ global constraint {
23
+ pc.refer.running is true
24
+ }
data/test/service3.sfp ADDED
@@ -0,0 +1,27 @@
1
+ include "service-classes.sfp"
2
+
3
+ // generate all possible states with constraint solver
4
+ initial state {
5
+ s1 isa Service {
6
+ installed is true
7
+ running either (true, false)
8
+ }
9
+ s2 isa Service {
10
+ installed is true
11
+ running either (true, false)
12
+ }
13
+ s3 isa Service {
14
+ installed is true
15
+ running either (true, false)
16
+ }
17
+ pc isa Client {
18
+ installed is true
19
+ refer either (s1, s2)
20
+ }
21
+ }
22
+ goal constraint {
23
+ pc.refer.running is true
24
+ }
25
+ global constraint {
26
+ pc.refer.running is true
27
+ }
data/test/task.sfp ADDED
@@ -0,0 +1,22 @@
1
+ include "types.sfp"
2
+
3
+ initial state {
4
+ a isa Service {
5
+ running is true
6
+ }
7
+
8
+ b isa Service // with "running" is false
9
+
10
+ pc isa Client {
11
+ refer is a
12
+ }
13
+ }
14
+
15
+ goal constraint {
16
+ pc.refer is b
17
+ a.running is false
18
+ }
19
+
20
+ global constraint {
21
+ pc.refer.running is true
22
+ }
data/test/test.inc ADDED
@@ -0,0 +1,9 @@
1
+ class S {
2
+ foo is true
3
+ procedure change {
4
+ conditions { }
5
+ effects {
6
+ this.foo is false
7
+ }
8
+ }
9
+ }
data/test/test.sfp ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env sfp
2
+
3
+ include "test.inc"
4
+
5
+ initial state {
6
+ a isa S
7
+ b isa S
8
+ }
9
+
10
+ goal constraint {
11
+ a.foo is false
12
+ b.foo is false
13
+ }
data/test/test1.sfp ADDED
@@ -0,0 +1,19 @@
1
+ class S {
2
+ foo is true
3
+ procedure change {
4
+ conditions { }
5
+ effects {
6
+ this.foo is false
7
+ }
8
+ }
9
+ }
10
+
11
+ initial state {
12
+ a isa S
13
+ b isa S
14
+ }
15
+
16
+ goal constraint {
17
+ a.foo is false
18
+ b.foo is false
19
+ }
data/test/test2.inc ADDED
@@ -0,0 +1,40 @@
1
+ class Service {
2
+ installed is false
3
+ running is false
4
+
5
+ procedure install {
6
+ conditions {
7
+ this.installed is false
8
+ }
9
+ effects {
10
+ this.installed is true
11
+ }
12
+ }
13
+ procedure uninstall {
14
+ conditions {
15
+ this.installed is true
16
+ }
17
+ effects {
18
+ this.installed is false
19
+ }
20
+ }
21
+
22
+ procedure start {
23
+ conditions {
24
+ this.installed is true
25
+ this.running is false
26
+ }
27
+ effects {
28
+ this.running is true
29
+ }
30
+ }
31
+ procedure stop {
32
+ conditions {
33
+ this.installed is true
34
+ this.running is true
35
+ }
36
+ effects {
37
+ this.running is false
38
+ }
39
+ }
40
+ }
data/test/test2.sfp ADDED
@@ -0,0 +1,17 @@
1
+ include "test2.inc"
2
+
3
+ // generate all possible states with constraint solver
4
+ initial state {
5
+ s1 isa Service
6
+ s2 isa Service
7
+ s3 isa Service
8
+ }
9
+ goal constraint {
10
+ s1.running
11
+ s2.running
12
+ s3.running
13
+ }
14
+ global constraint {
15
+ if s1.running then s2.running
16
+ if s2.running then s3.running
17
+ }
data/test/types.sfp ADDED
@@ -0,0 +1,28 @@
1
+ class Service {
2
+ running is false
3
+ procedure start {
4
+ conditions {
5
+ this.running is false
6
+ }
7
+ effects {
8
+ this.running is true
9
+ }
10
+ }
11
+ procedure stop {
12
+ conditions {
13
+ this.running is true
14
+ }
15
+ effects {
16
+ this.running is false
17
+ }
18
+ }
19
+ }
20
+ class Client {
21
+ refer isref Service
22
+ procedure redirect(s isref Service) {
23
+ conditions { }
24
+ effects {
25
+ this.refer is s
26
+ }
27
+ }
28
+ }
data/test/v1.1.sfp ADDED
@@ -0,0 +1,22 @@
1
+ schema S {
2
+ foo = true
3
+
4
+ procedure change {
5
+ conditions { }
6
+ effects {
7
+ this.foo is false
8
+ }
9
+ }
10
+ }
11
+
12
+ a extends S
13
+ b extends S
14
+
15
+ constraint goal {
16
+ a.foo is false
17
+ b.foo is false
18
+ }
19
+
20
+ constraint global {
21
+ a.foo is false
22
+ }
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sfp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Herry
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &6400440 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.7.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *6400440
25
+ - !ruby/object:Gem::Dependency
26
+ name: antlr3
27
+ requirement: &6399940 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.12
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *6399940
36
+ description: A Ruby gem that provides a Ruby interface to parse SFP language. It also
37
+ provides a Ruby interface for a solver to generate a workflow for a planning task
38
+ written in SFP language.
39
+ email: herry13@gmail.com
40
+ executables:
41
+ - sfp
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitignore
46
+ - LICENSE
47
+ - README.md
48
+ - bin/sfp
49
+ - bin/solver/linux/downward
50
+ - bin/solver/linux/preprocess
51
+ - bin/solver/macos/downward
52
+ - bin/solver/macos/preprocess
53
+ - lib/sfp.rb
54
+ - lib/sfp/SfpLangLexer.rb
55
+ - lib/sfp/SfpLangParser.rb
56
+ - lib/sfp/Sfplib.rb
57
+ - lib/sfp/parser.rb
58
+ - lib/sfp/planner.rb
59
+ - lib/sfp/sas.rb
60
+ - lib/sfp/sas_translator.rb
61
+ - lib/sfp/sfw2graph.rb
62
+ - lib/sfp/visitors.rb
63
+ - sfp.gemspec
64
+ - src/SfpLang.g
65
+ - src/build.sh
66
+ - test/cloud-classes.sfp
67
+ - test/cloud1.sfp
68
+ - test/cloud2.sfp
69
+ - test/cloud3.sfp
70
+ - test/service-classes.sfp
71
+ - test/service1.sfp
72
+ - test/service3.sfp
73
+ - test/task.sfp
74
+ - test/test.inc
75
+ - test/test.sfp
76
+ - test/test1.sfp
77
+ - test/test2.inc
78
+ - test/test2.sfp
79
+ - test/types.sfp
80
+ - test/v1.1.sfp
81
+ homepage: https://github.com/herry13/sfp-ruby
82
+ licenses: []
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.11
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: SFP Parser and Planner
105
+ test_files:
106
+ - test/cloud-classes.sfp
107
+ - test/cloud1.sfp
108
+ - test/cloud2.sfp
109
+ - test/cloud3.sfp
110
+ - test/service-classes.sfp
111
+ - test/service1.sfp
112
+ - test/service3.sfp
113
+ - test/task.sfp
114
+ - test/test.inc
115
+ - test/test.sfp
116
+ - test/test1.sfp
117
+ - test/test2.inc
118
+ - test/test2.sfp
119
+ - test/types.sfp
120
+ - test/v1.1.sfp