omf_sfa 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/.gitignore +24 -0
  2. data/Gemfile +6 -0
  3. data/README.md +211 -0
  4. data/Rakefile +23 -0
  5. data/bin/parse_rspec.rb +167 -0
  6. data/etc/omf-sfa/omf-sfa-am.yaml +12 -0
  7. data/examples/exogeni5nodemanifest.rspec +105 -0
  8. data/examples/instageni5nodemanifest.rspec +150 -0
  9. data/lib/omf-sfa/am/am-rest/REST_API.md +301 -0
  10. data/lib/omf-sfa/am/am-rest/account_handler.rb +145 -0
  11. data/lib/omf-sfa/am/am-rest/am_rest_server.rb +255 -0
  12. data/lib/omf-sfa/am/am-rest/api_template.html +48 -0
  13. data/lib/omf-sfa/am/am-rest/config.ru +110 -0
  14. data/lib/omf-sfa/am/am-rest/resource_handler.rb +178 -0
  15. data/lib/omf-sfa/am/am-rest/rest_handler.rb +573 -0
  16. data/lib/omf-sfa/am/am-rest/session_authenticator.rb +130 -0
  17. data/lib/omf-sfa/am/am-rpc/abstract_rpc_service.rb +60 -0
  18. data/lib/omf-sfa/am/am-rpc/am_authorizer.rb +161 -0
  19. data/lib/omf-sfa/am/am-rpc/am_rpc_api.rb +450 -0
  20. data/lib/omf-sfa/am/am-rpc/am_rpc_service.rb +402 -0
  21. data/lib/omf-sfa/am/am_liaison.rb +93 -0
  22. data/lib/omf-sfa/am/am_manager.rb +859 -0
  23. data/lib/omf-sfa/am/am_runner.rb +108 -0
  24. data/lib/omf-sfa/am/am_scheduler.rb +146 -0
  25. data/lib/omf-sfa/am/am_server.rb +194 -0
  26. data/lib/omf-sfa/am/config.ru +122 -0
  27. data/lib/omf-sfa/am/credential.rb +145 -0
  28. data/lib/omf-sfa/am/default_authorizer.rb +44 -0
  29. data/lib/omf-sfa/am/privilege_credential.rb +76 -0
  30. data/lib/omf-sfa/am/signature.rb +37 -0
  31. data/lib/omf-sfa/am/user_credential.rb +56 -0
  32. data/lib/omf-sfa/am.rb +7 -0
  33. data/lib/omf-sfa/model/abstract_prop_description.rb +87 -0
  34. data/lib/omf-sfa/model/model_class_description.rb +145 -0
  35. data/lib/omf-sfa/model/model_data_prop_description.rb +28 -0
  36. data/lib/omf-sfa/model/model_obj_prop_description.rb +49 -0
  37. data/lib/omf-sfa/model/ontology.rb +169 -0
  38. data/lib/omf-sfa/resource/README.md +24 -0
  39. data/lib/omf-sfa/resource/channel.rb +49 -0
  40. data/lib/omf-sfa/resource/comp_group.rb +41 -0
  41. data/lib/omf-sfa/resource/component_lease.rb +10 -0
  42. data/lib/omf-sfa/resource/constants.rb +24 -0
  43. data/lib/omf-sfa/resource/group_component.rb +35 -0
  44. data/lib/omf-sfa/resource/group_membership.rb +17 -0
  45. data/lib/omf-sfa/resource/gurn.rb +187 -0
  46. data/lib/omf-sfa/resource/interface.rb +78 -0
  47. data/lib/omf-sfa/resource/ip.rb +48 -0
  48. data/lib/omf-sfa/resource/link.rb +29 -0
  49. data/lib/omf-sfa/resource/node.rb +75 -0
  50. data/lib/omf-sfa/resource/oaccount.rb +94 -0
  51. data/lib/omf-sfa/resource/ocomponent.rb +134 -0
  52. data/lib/omf-sfa/resource/ogroup.rb +106 -0
  53. data/lib/omf-sfa/resource/olease.rb +61 -0
  54. data/lib/omf-sfa/resource/oproperty.rb +178 -0
  55. data/lib/omf-sfa/resource/oreference.rb +15 -0
  56. data/lib/omf-sfa/resource/oresource.rb +491 -0
  57. data/lib/omf-sfa/resource/project.rb +28 -0
  58. data/lib/omf-sfa/resource/project_membership.rb +13 -0
  59. data/lib/omf-sfa/resource/sfa_base.rb +544 -0
  60. data/lib/omf-sfa/resource/user.rb +25 -0
  61. data/lib/omf-sfa/resource.rb +20 -0
  62. data/lib/omf-sfa/util/create_sample_testbed.rb +68 -0
  63. data/lib/omf-sfa/util/load_from_sfa_xml.rb +65 -0
  64. data/lib/omf-sfa/version.rb +4 -0
  65. data/lib/omf_sfa.rb +5 -0
  66. data/omf_sfa.gemspec +46 -0
  67. data/owl/README +3 -0
  68. data/owl/ben-6509.rdf +1377 -0
  69. data/owl/ben-dell.rdf +586 -0
  70. data/owl/ben-dtn.rdf +1698 -0
  71. data/owl/ben.rdf +1335 -0
  72. data/owl/collections.owl +309 -0
  73. data/owl/compute.owl +1486 -0
  74. data/owl/domain.owl +444 -0
  75. data/owl/dtn.owl +1165 -0
  76. data/owl/ec2.owl +385 -0
  77. data/owl/ethernet.owl +466 -0
  78. data/owl/eucalyptus.owl +431 -0
  79. data/owl/id-mp-Request1.rdf +247 -0
  80. data/owl/itu-grid.owl +147 -0
  81. data/owl/kansei.owl +511 -0
  82. data/owl/layer.owl +645 -0
  83. data/owl/location.owl +117 -0
  84. data/owl/mass.rdf +608 -0
  85. data/owl/nlr.rdf +901 -0
  86. data/owl/orca.owl +181 -0
  87. data/owl/planetlab.owl +124 -0
  88. data/owl/protogeni.owl +467 -0
  89. data/owl/request-6509-2.rdf +150 -0
  90. data/owl/request-6509-3.rdf +158 -0
  91. data/owl/request-6509.rdf +199 -0
  92. data/owl/request.owl +222 -0
  93. data/owl/storage.owl +511 -0
  94. data/owl/topology.owl +608 -0
  95. data/schema/rspec-v3/ad-common.xsd +269 -0
  96. data/schema/rspec-v3/ad-reservation.rnc +12 -0
  97. data/schema/rspec-v3/ad-reservation.rng +28 -0
  98. data/schema/rspec-v3/ad-reservation.xsd +13 -0
  99. data/schema/rspec-v3/ad.rnc +151 -0
  100. data/schema/rspec-v3/ad.xsd +77 -0
  101. data/schema/rspec-v3/any-extension-schema.xsd +38 -0
  102. data/schema/rspec-v3/any-extension.rnc +30 -0
  103. data/schema/rspec-v3/common.rnc +185 -0
  104. data/schema/rspec-v3/manifest-common.xsd +244 -0
  105. data/schema/rspec-v3/manifest-request.xsd +95 -0
  106. data/schema/rspec-v3/manifest.rnc +62 -0
  107. data/schema/rspec-v3/manifest.xsd +34 -0
  108. data/schema/rspec-v3/request-common.xsd +219 -0
  109. data/schema/rspec-v3/request-reservation.rnc +12 -0
  110. data/schema/rspec-v3/request-reservation.xsd +13 -0
  111. data/schema/rspec-v3/request.rnc +118 -0
  112. data/schema/rspec-v3/request.xsd +94 -0
  113. data/share/assets/css/default.css +147 -0
  114. data/share/assets/css/rest_api.css +0 -0
  115. data/share/assets/network.html +28 -0
  116. data/share/assets/network.js +82 -0
  117. data/spec/am/am-rest/common.rb +29 -0
  118. data/spec/am/am-rest/resource_group_handler_XspecX.rb +97 -0
  119. data/spec/am/am-rest/resource_handler_spec.rb +204 -0
  120. data/spec/am/am-rpc/sfa_methods_spec.rb +150 -0
  121. data/spec/am/am_manager_spec.rb +307 -0
  122. data/spec/am/am_scheduler_spec.rb +57 -0
  123. data/spec/am/common.rb +24 -0
  124. data/spec/resource/common.rb +31 -0
  125. data/spec/resource/node_spec.rb +171 -0
  126. data/spec/resource/oaccount_spec.rb +92 -0
  127. data/spec/resource/ocomponent_spec.rb +225 -0
  128. data/spec/resource/ogroup_spec.rb +93 -0
  129. data/spec/resource/oresource_spec.rb +208 -0
  130. data/spec/resource_and_leases_spec.rb +377 -0
  131. data/test/OLD_FILES/assertion1.xml +117 -0
  132. data/test/OLD_FILES/greeter_spec.rb +15 -0
  133. data/test/OLD_FILES/mongo_test.rb +45 -0
  134. data/test/OLD_FILES/req-sfa-2.xml +6 -0
  135. data/test/OLD_FILES/req-sfa-g.xml +8 -0
  136. data/test/OLD_FILES/req-sfa-g2.xml +10 -0
  137. data/test/OLD_FILES/req-sfa-g3.xml +14 -0
  138. data/test/OLD_FILES/req-sfa.xml +6 -0
  139. data/test/OLD_FILES/req1.xml +22 -0
  140. data/test/OLD_FILES/req1b.xml +15 -0
  141. data/test/OLD_FILES/rspec-test.xml +1867 -0
  142. data/test/OLD_FILES/test.rb +67 -0
  143. data/test/OLD_FILES/test2.rb +32 -0
  144. data/test/am/am_manager_rspec_tests.rb +378 -0
  145. data/test/am/am_manager_tests.rb +518 -0
  146. data/test/am/am_scheduler_tests.rb +173 -0
  147. data/test/resource/olease_test.rb +74 -0
  148. data/test/sfa_requests/request.xml +5 -0
  149. data/test/sfa_requests/request1.xml +5 -0
  150. data/test/sfa_requests/request2.xml +5 -0
  151. data/test/sfa_requests/request3.xml +5 -0
  152. metadata +601 -0
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+ .rspec
20
+ .settings/org.eclipse.core.resources.prefs
21
+ Gemfile.lock
22
+ .project
23
+ .DS_Store
24
+ *.original
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+
5
+ # Specify your gem's dependencies in omf_sfa.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,211 @@
1
+ This directory contains the implementations of various SFA APIs and services.
2
+
3
+ Aggregate Manager
4
+ =================
5
+
6
+ Installation
7
+ ------------
8
+
9
+ At this stage the best course of action is to clone the repository
10
+
11
+ % git clone https://github.com/mytestbed/omf_sfa.git
12
+ % cd omf_sfa
13
+ % export OMF_SFA_HOME=`pwd`
14
+ % bundle install
15
+
16
+ Also make sure you define the correct paths of the credentials in "etc/omf-sfa/omf-sfa-am.yaml"
17
+
18
+ Starting a Test AM
19
+ ------------------
20
+
21
+ To start an AM with a some pre-populated resources ('--test-load-am') from this directory, run the following:
22
+
23
+ % cd $OMF_SFA_HOME
24
+ % bundle exec ruby -I lib lib/omf-sfa/am/am_server.rb --dm-db sqlite:/tmp/test.sq3 --dm-auto-upgrade --test-load-am start
25
+
26
+ which should result into something like:
27
+
28
+ DEBUG AMServer: options: {:app_name=>"am_server", :chdir=>"/Users/max/src/omf_sfa", :environment=>"development", :address=>"0.0.0.0", :port=>8001, :timeout=>30, :log=>"/tmp/am_server_thin.log", :pid=>"/tmp/am_server.pid", :max_conns=>1024, :max_persistent_conns=>512, :require=>[], :wait=>30, :rackup=>"/Users/max/src/omf_sfa/lib/omf-sfa/am/config.ru", :static_dirs=>["./resources", "/Users/max/src/omf_sfa/lib/omf_common/thin/../../../share/htdocs"], :static_dirs_pre=>["./resources", "/Users/max/src/omf_sfa/lib/omf_common/thin/../../../share/htdocs"], :handlers=>{:pre_rackup=>#<Proc:0x007fd254b979a8@/Users/max/src/omf_sfa/lib/omf-sfa/am/am_server.rb:116 (lambda)>, :pre_parse=>#<Proc:0x007fd254b97980@/Users/max/src/omf_sfa/lib/omf-sfa/am/am_server.rb:118 (lambda)>, :pre_run=>#<Proc:0x007fd254b97958@/Users/max/src/omf_sfa/lib/omf-sfa/am/am_server.rb:127 (lambda)>}, :dm_db=>"sqlite:/tmp/test.sq3", :dm_log=>"/tmp/am_server-dm.log", :load_test_am=>true, :dm_auto_upgrade=>true, :ssl=>true, :ssl_key_file=>"/Users/max/.gcf/am-key.pem", :ssl_cert_file=>"/Users/max/.gcf/am-cert.pem", :ssl_verify=>true}
29
+ INFO Server: >> Thin web server (v1.3.1 codename Triple Espresso)
30
+ DEBUG Server: >> Debugging ON
31
+ DEBUG Server: >> Tracing ON
32
+ INFO Server: >> Maximum connections set to 1024
33
+ INFO Server: >> Listening on 0.0.0.0:8001, CTRL+C to stop
34
+
35
+ Testing REST API
36
+ ----------------
37
+
38
+ The easiest way to interact with the AM is through it's REST API. Start with listing all resources:
39
+
40
+ $ curl -k https://localhost:8001/resources
41
+ {
42
+ "resource_response": {
43
+ "resources": [
44
+ {
45
+ "uuid": "c76a1862-d9ff-40d3-bb7d-3e480624864f",
46
+ "href": "/resources/c76a1862-d9ff-40d3-bb7d-3e480624864f",
47
+ "name": "l",
48
+ "type": "link",
49
+ ...
50
+
51
+ Please note the -k (or --insecure) option as we are using SSL but the server by default is not using a
52
+ cert signed by a public CA.
53
+
54
+ To list information about a specific resource 'node1', use the following:
55
+
56
+ $ curl -k https://localhost:8001/resources/node1
57
+ {
58
+ "resource_response": {
59
+ "resource": {
60
+ "uuid": "ddb2170e-e4aa-45c8-bb63-242134e98a11",
61
+ "href": "/resources/ddb2170e-e4aa-45c8-bb63-242134e98a11",
62
+ "name": "node1",
63
+ "type": "node",
64
+ "available": true,
65
+ "interfaces": [
66
+ {
67
+ "uuid": "fd527e07-7a9a-45dd-b6f3-dcc2abeb6e75",
68
+ "href": "/resources/fd527e07-7a9a-45dd-b6f3-dcc2abeb6e75",
69
+ "name": "node1:if0",
70
+ "type": "interface"
71
+ }
72
+ ],
73
+ "domain": "mytestbed.net",
74
+ "status": "unknown"
75
+ },
76
+ "about": "/resources/node1"
77
+ }
78
+ }
79
+
80
+ Listing all slices can be achieved through:
81
+
82
+ $ curl -k https://localhost:8001/slices
83
+ {
84
+ "accounts_response": {
85
+ "about": "/slices",
86
+ "accounts": [
87
+ {
88
+ "name": "foo",
89
+ "urn": "urn:publicid:IDN+mytestbed.net+foo",
90
+ "uuid": "97019720-601a-4a08-9888-a17d32e2105d",
91
+ "href": "/slices/97019720-601a-4a08-9888-a17d32e2105d"
92
+ }
93
+ ]
94
+ }
95
+ }
96
+
97
+ Ignore the references to 'accounts'. The resource model in OMF has no notion of 'slice', but it's 'account'
98
+ is the most closest.
99
+
100
+ Like with resources, getting more information on a slice maps into:
101
+
102
+ $ curl -k https://localhost:8001/slices/foo
103
+ {
104
+ "account_response": {
105
+ "about": "/slices/97019720-601a-4a08-9888-a17d32e2105d",
106
+ "type": "account",
107
+ "properties": {
108
+ "expires_at": "Tue, 04 Jun 2013 09:33:44 +1000"
109
+ },
110
+ "resources": {
111
+ "href": "/slices/97019720-601a-4a08-9888-a17d32e2105d/resources"
112
+ },
113
+ "policies": {
114
+ "href": "/slices/97019720-601a-4a08-9888-a17d32e2105d/policies"
115
+ },
116
+ "assertion": {
117
+ "href": "/slices/97019720-601a-4a08-9888-a17d32e2105d/assertion"
118
+ }
119
+ }
120
+ }
121
+
122
+ Please note that resources can reliably be referred to by their 'uuid', but using their 'name' will work
123
+ in most cases as long as the name is unique in the particular context.
124
+
125
+ Testing with GCF
126
+ ----------------
127
+
128
+ To test the AM, you can use the GPO's GCF. However, please be aware that 'gcf-test' is not really meant to be a
129
+ validation test for AMs and is not always kept up-to-date with evolving APIs. In other words, a failing 'gcf-test'
130
+ may not necessarily mean the the AM implementation is wrong.
131
+
132
+ In a shell start the CF (make sure you installed the credentials in ~/.gcf):
133
+
134
+ $ src/gcf-ch.py
135
+ INFO:cred-verifier:Will accept credentials signed by any of 1 root certs found in ~/.gcf/trusted_roots: ['~/.gcf/trusted_roots/ch-cert.pem']
136
+ INFO:gcf-ch:Registering AM urn:publicid:IDN+geni:gpo:gcf:am1+authority+am at http://localhost:8001
137
+ INFO:cred-verifier:Adding trusted cert file ch-cert.pem
138
+ INFO:cred-verifier:Combined dir of 1 trusted certs ~/.gcf/trusted_roots into file ~/.gcf/trusted_roots/CATedCACerts.pem for Python SSL support
139
+ INFO:gcf-ch:GENI CH Listening on port 8000...
140
+
141
+ Then run the AM acceptance tests. Follow the instructions in gcf's Readme files to make sure you have set up 'omni' correctly and then run the tests. Don't forger to set your enviroment variable before running the acceptance tests. You should also copy the "requests" found under "$OMF_HOME/omf_sfa/test/sfa_requests/"
142
+
143
+ export PYTHONPATH=$PYTHONPATH:$GCF/src
144
+
145
+ python am_api_accept.py -a https://0.0.0.0:8001/RPC2
146
+ .............
147
+ ----------------------------------------------------------------------
148
+ Ran 13 tests in 959.389s
149
+
150
+ OK
151
+
152
+ Using OMNI
153
+ ==========
154
+
155
+ Create Sliver
156
+ -------------
157
+
158
+ $ python src/omni.py -a https://0.0.0.0:8001 -q createsliver test1 $OMF_HOME/omf_sfa/test/sfa_requests/request.xml
159
+ ...
160
+ INFO:omni:Got return from CreateSliver for slice test1 at https://0.0.0.0:8001:
161
+ INFO:omni:<?xml version="1.0"?>
162
+ INFO:omni: <!-- Reserved resources for:
163
+ Slice: test1
164
+ at AM:
165
+ URN: unspecified_AM_URN
166
+ URL: https://0.0.0.0:8001
167
+ -->
168
+ INFO:omni:
169
+ <rspec xmlns="http://www.geni.net/resources/rspec/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:omf="http://nitlab.inf.uth.gr/schema/sfa/rspec/1" xsi:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/manifest.xsd http://nitlab.inf.uth.gr/schema/sfa/rspec/1 http://nitlab.inf.uth.gr/schema/sfa/rspec/1/ad-reservation.xsd" type="manifest" generated="2013-04-12T19:46:05+03:00" expires="2013-04-12T19:56:05+03:00">
170
+ <node client_id="node0" component_id="urn:publicid:IDN+omf:nitos+node+node0" component_manager_id="urn:publicid:IDN+omf:nitos+authority+am" component_name="node0" exclusive="true">
171
+ <available now="true"/>
172
+ </node>
173
+ </rspec>
174
+
175
+ Sliver Status
176
+ -------------
177
+
178
+ $ python src/omni.py -a https://0.0.0.0:8001 -q sliverstatus test1
179
+ INFO:omni:Sliver status for Slice urn:publicid:IDN+geni:gpo:gcf+slice+test1 at AM URL https://0.0.0.0:8001
180
+ INFO:omni:{
181
+ "geni_urn": "urn:publicid:IDN+geni:gpo:gcf+slice+test1",
182
+ "geni_resources": [
183
+ {
184
+ "geni_urn": "urn:publicid:IDN+omf:nitos+node+node0",
185
+ "geni_error": "",
186
+ "geni_status": "unknown"
187
+ }
188
+ ],
189
+ "omf_expires_at": "20130412154532Z",
190
+ "geni_status": "unknown"
191
+ }
192
+
193
+
194
+ Debugging hints
195
+ ===============
196
+
197
+ Use the following command to show the content of a cert in a human readable form:
198
+
199
+ $ openssl x509 -in ~/.gcf/alice-cert.pem -text
200
+
201
+ To verify certificates, use openssl to set up a simple SSL server as well as
202
+ connect to it.
203
+
204
+ Server:
205
+
206
+ % openssl s_server -cert ~/.gcf/am-cert.pem -key ~/.gcf/am-key.pem -verify on
207
+
208
+ Client:
209
+
210
+ % openssl s_client -cert ~/.gcf/alice-cert.pem -key ~/.gcf/alice-key.pem
211
+ % openssl s_client -connect 127.0.0.1:8001 -key ~/.gcf/alice-key.pem -cert ~/.gcf/alice-cert.pem -CAfile ~/.gcf/trusted_roots/CATedCACerts.pem
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+
2
+ require 'rubygems'
3
+ #require 'rake/testtask'
4
+ require "bundler/gem_tasks"
5
+ require 'rspec/core/rake_task'
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
9
+
10
+ desc "Run specs"
11
+ RSpec::Core::RakeTask.new do |t|
12
+ t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
13
+ t.pattern = "./spec/am/*_spec.rb"
14
+ t.verbose = true
15
+ # Put spec opts in a file named .rspec in root
16
+ end
17
+
18
+ desc "Generate code coverage"
19
+ RSpec::Core::RakeTask.new(:coverage) do |t|
20
+ t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
21
+ t.rcov = true
22
+ t.rcov_opts = ['--exclude', 'spec']
23
+ end
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ DESCR = %{
4
+ Read Rspec file and create internal object representation
5
+ }
6
+
7
+ BIN_DIR = File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__)
8
+ TOP_DIR = File.join(BIN_DIR, '..')
9
+ $: << File.join(TOP_DIR, 'lib')
10
+
11
+ require 'rubygems'
12
+ require 'optparse'
13
+ require 'dm-core'
14
+ require 'nokogiri'
15
+ require 'omf_common/lobject'
16
+ require 'json'
17
+
18
+ $verbose = false
19
+ $debug = false
20
+ $out_file_name = nil
21
+ $out_mode = 'dump'
22
+
23
+ op = OptionParser.new
24
+ op.banner = "Usage: #{op.program_name} [options] rspec_file\n#{DESCR}\n"
25
+ op.on '-r', '--resource-url URL', "URL of resource (e.g. xmpp://my.server.com/topic1)" do |url|
26
+ resource_url = url
27
+ end
28
+ op.on '-m', '--out-mode MODE', "Mode determining what is being written out [#{$out_mode}]" do |mode|
29
+ $out_mode = mode
30
+ end
31
+ op.on '-o', '--out OUT_FILE', "File to write result into [STDOUT]" do |fn|
32
+ $out_file_name = fn
33
+ end
34
+ op.on '-d', '--debug', "Set log level to DEBUG" do
35
+ $debug = true
36
+ end
37
+ op.on '-v', '--verbose', "Print out rspec snippets as we go along" do
38
+ $verbose = true
39
+ end
40
+ op.on_tail('-h', "--help", "Show this message") { $stderr.puts op; exit }
41
+ rest = op.parse(ARGV) || []
42
+
43
+ OMF::Common::Loggable.init_log 'parse_rspec'
44
+
45
+ unless in_file_name = (rest || [])[0]
46
+ abort "Missing rspec file"
47
+ end
48
+ unless File.readable?(in_file_name)
49
+ abort "Can't read file '#{in_file_name}"
50
+ end
51
+
52
+ rspec = Nokogiri::XML.parse(File.read(in_file_name)).root
53
+ #puts rspec
54
+
55
+ unless rspec.name.downcase == 'rspec'
56
+ abort "Expected RSPEC, but document started with '#{rspec.name}"
57
+ end
58
+
59
+ # Initialise DataMapper
60
+ DataMapper::Logger.new($stdout, :debug)
61
+ DataMapper.setup(:default, :adapter => :in_memory)
62
+
63
+ #require 'json'
64
+ require 'omf-sfa/resource'
65
+ include OMF::SFA::Resource
66
+
67
+ DataMapper.finalize
68
+
69
+ # Process RSPEC
70
+ resources = []
71
+ context = {}
72
+ rspec.children.each do |el|
73
+ next if el.is_a? Nokogiri::XML::Text
74
+ if $verbose
75
+ puts '------------------'
76
+ puts el
77
+ end
78
+ n = nil
79
+ begin
80
+ n = OMF::SFA::Resource::OComponent.from_sfa(el, context)
81
+ rescue Exception => ex
82
+ puts "WARN: Couldn't parse '#{el.to_s[0 .. 30]}' - #{ex}"
83
+ puts ex.backtrace
84
+ exit
85
+ end
86
+ if n
87
+ resources << n
88
+ puts n.inspect if $verbose
89
+ n.save
90
+ end
91
+ #n.create_from_xml(el, {})
92
+ end
93
+
94
+ def print_advertisement(resources)
95
+ puts resources.inspect
96
+ r = resources[0]
97
+ puts r.save
98
+ puts OMF::SFA::Resource::OComponent.sfa_advertisement_xml(resources)
99
+ #puts r.to_sfa_xml
100
+ end
101
+
102
+ def interface_to_hash(interface)
103
+ h = {node: interface.node.uuid}
104
+ if interface.ip_addresses && interface.ip_addresses.length > 0
105
+ h[:ip_address] = interface.ip_addresses[0].address
106
+ end
107
+ h
108
+ end
109
+
110
+ def print_json(resources)
111
+ resources.each do |r|
112
+ puts '================='
113
+ r.urn
114
+ #puts "#{r.type} (#{r.inspect})"\n
115
+ puts "#{r.type}"
116
+ r.to_sfa_hash.each do |k, v|
117
+ puts " #{k}: #{v}"
118
+ end
119
+ end
120
+ end
121
+
122
+ res = {}
123
+ case $out_mode.to_sym
124
+ when :dump
125
+ resources = {}
126
+ opts = {max_level: 3}
127
+ res = OMF::SFA::Resource::OComponent.find_all.map do |r|
128
+ next if resources.include?(r)
129
+ r.to_hash(resources, opts)
130
+ end.compact
131
+
132
+ when :monitor
133
+ resources = {}
134
+ opts = {}
135
+ res[:nodes] = OMF::SFA::Resource::Node.find_all.map do |r|
136
+ h = r.to_hash(resources, opts)
137
+ h.delete(:href)
138
+ h.delete(:interfaces)
139
+ h
140
+ end
141
+ #opts = {max_level: 3}
142
+ res[:links] = OMF::SFA::Resource::Link.find_all.map do |r|
143
+ from, to = r.interfaces
144
+ puts from.node
145
+ h = r.to_hash(resources, opts)
146
+ h.delete(:href)
147
+ h.delete(:interfaces)
148
+ h[:from] = interface_to_hash(from)
149
+ h[:to] = interface_to_hash(to)
150
+ h
151
+ end
152
+
153
+ else
154
+ puts "ERROR: Unknown output mode '#{$out_mode}'"
155
+ end
156
+
157
+ out = JSON.pretty_generate(res)
158
+ if $out_file_name
159
+ puts "Writing result to '#{$out_file_name}'"
160
+ f = File.open($out_file_name, 'w')
161
+ f.write out
162
+ else
163
+ puts '=========================='
164
+ puts out
165
+ end
166
+
167
+
@@ -0,0 +1,12 @@
1
+
2
+ omf_sfa_am:
3
+ name: urn:xxx
4
+
5
+ endpoints:
6
+ -
7
+ type: xmlrpc
8
+ port: 8001
9
+ ssl:
10
+ cert_chain_file: ~/.omf/am-cert.pem
11
+ private_key_file: ~/.omf/am-key.pem
12
+ trusted_roots: ~/.omf/trusted_roots
@@ -0,0 +1,105 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <rspec type="manifest" xsi:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/manifest.xsd http://hpn.east.isi.edu/rspec/ext/stitch/0.1/ http://hpn.east.isi.edu/rspec/ext/stitch/0.1/stitch-schema.xsd http://groups.geni.net/exogeni/attachment/wiki/RspecExtensions/slice-info/1 http://groups.geni.net/exogeni/attachment/wiki/RspecExtensions/slice-info/1/slice_info.xsd?format=raw http://groups.geni.net/exogeni/attachment/wiki/RspecExtensions/sliver-info/1 http://groups.geni.net/exogeni/attachment/wiki/RspecExtensions/sliver-info/1/sliver_info.xsd?format=raw" xmlns:ns2="http://hpn.east.isi.edu/rspec/ext/stitch/0.1/" xmlns="http://www.geni.net/resources/rspec/3" xmlns:ns4="http://groups.geni.net/exogeni/attachment/wiki/RspecExtensions/sliver-info/1" xmlns:ns3="http://groups.geni.net/exogeni/attachment/wiki/RspecExtensions/slice-info/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <node sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#nodeA" exclusive="false" component_name="orca-vm-cloud" component_manager_id="urn:publicid:IDN+exogeni.net:rcivmsite+authority+am" component_id="urn:publicid:IDN+exogeni.net:rcivmsite+node+orca-vm-cloud" client_id="nodeA">
4
+ <sliver_type name="m1.small">
5
+ <disk_image version="de35e71b31771870bcdfcccb4dee11657ba145b8" name="http://emmy9.casa.umass.edu/Disk_Images/ExoGENI/exogeni-umass-ovs-1.0.2.xml"/>
6
+ </sliver_type>
7
+ <services/>
8
+ <interface client_id="VM-0:if0">
9
+ <ip type="ipv4" address="192.168.4.11"/>
10
+ </interface>
11
+ <interface client_id="VM-0:if1">
12
+ <ip type="ipv4" address="192.168.5.11"/>
13
+ </interface>
14
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
15
+ </node>
16
+ <node sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#nodeE" exclusive="false" component_name="orca-vm-cloud" component_manager_id="urn:publicid:IDN+exogeni.net:rcivmsite+authority+am" component_id="urn:publicid:IDN+exogeni.net:rcivmsite+node+orca-vm-cloud" client_id="nodeE">
17
+ <sliver_type name="m1.small">
18
+ <disk_image version="de35e71b31771870bcdfcccb4dee11657ba145b8" name="http://emmy9.casa.umass.edu/Disk_Images/ExoGENI/exogeni-umass-ovs-1.0.2.xml"/>
19
+ </sliver_type>
20
+ <services/>
21
+ <interface client_id="VM-3:if0">
22
+ <ip type="ipv4" address="192.168.6.14"/>
23
+ </interface>
24
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
25
+ </node>
26
+ <node sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#nodeC" exclusive="false" component_name="orca-vm-cloud" component_manager_id="urn:publicid:IDN+exogeni.net:rcivmsite+authority+am" component_id="urn:publicid:IDN+exogeni.net:rcivmsite+node+orca-vm-cloud" client_id="nodeC">
27
+ <sliver_type name="m1.small">
28
+ <disk_image version="de35e71b31771870bcdfcccb4dee11657ba145b8" name="http://emmy9.casa.umass.edu/Disk_Images/ExoGENI/exogeni-umass-ovs-1.0.2.xml"/>
29
+ </sliver_type>
30
+ <services/>
31
+ <interface client_id="VM-2:if0">
32
+ <ip type="ipv4" address="192.168.3.12"/>
33
+ </interface>
34
+ <interface client_id="VM-2:if3">
35
+ <ip type="ipv4" address="192.168.2.12"/>
36
+ </interface>
37
+ <interface client_id="VM-2:if1">
38
+ <ip type="ipv4" address="192.168.5.12"/>
39
+ </interface>
40
+ <interface client_id="VM-2:if2">
41
+ <ip type="ipv4" address="192.168.6.12"/>
42
+ </interface>
43
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
44
+ </node>
45
+ <node sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#nodeB" exclusive="false" component_name="orca-vm-cloud" component_manager_id="urn:publicid:IDN+exogeni.net:rcivmsite+authority+am" component_id="urn:publicid:IDN+exogeni.net:rcivmsite+node+orca-vm-cloud" client_id="nodeB">
46
+ <sliver_type name="m1.small">
47
+ <disk_image version="de35e71b31771870bcdfcccb4dee11657ba145b8" name="http://emmy9.casa.umass.edu/Disk_Images/ExoGENI/exogeni-umass-ovs-1.0.2.xml"/>
48
+ </sliver_type>
49
+ <services/>
50
+ <interface client_id="VM:if0">
51
+ <ip type="ipv4" address="192.168.4.10"/>
52
+ </interface>
53
+ <interface client_id="VM:if1">
54
+ <ip type="ipv4" address="192.168.1.10"/>
55
+ </interface>
56
+ <interface client_id="VM:if2">
57
+ <ip type="ipv4" address="192.168.2.10"/>
58
+ </interface>
59
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
60
+ </node>
61
+ <node sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#nodeD" exclusive="false" component_name="orca-vm-cloud" component_manager_id="urn:publicid:IDN+exogeni.net:rcivmsite+authority+am" component_id="urn:publicid:IDN+exogeni.net:rcivmsite+node+orca-vm-cloud" client_id="nodeD">
62
+ <sliver_type name="m1.small">
63
+ <disk_image version="de35e71b31771870bcdfcccb4dee11657ba145b8" name="http://emmy9.casa.umass.edu/Disk_Images/ExoGENI/exogeni-umass-ovs-1.0.2.xml"/>
64
+ </sliver_type>
65
+ <services/>
66
+ <interface client_id="VM-1:if1">
67
+ <ip type="ipv4" address="192.168.3.13"/>
68
+ </interface>
69
+ <interface client_id="VM-1:if0">
70
+ <ip type="ipv4" address="192.168.1.13"/>
71
+ </interface>
72
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
73
+ </node>
74
+ <link vlantag="unknown" sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#link3" client_id="link3">
75
+ <interface_ref client_id="VM-2:if1"/>
76
+ <interface_ref client_id="VM-0:if1"/>
77
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
78
+ </link>
79
+ <link vlantag="unknown" sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#link2" client_id="link2">
80
+ <interface_ref client_id="VM-1:if1"/>
81
+ <interface_ref client_id="VM-2:if0"/>
82
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
83
+ </link>
84
+ <link vlantag="unknown" sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#link0" client_id="link0">
85
+ <interface_ref client_id="VM-0:if0"/>
86
+ <interface_ref client_id="VM:if0"/>
87
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
88
+ </link>
89
+ <link vlantag="unknown" sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#link4" client_id="link4">
90
+ <interface_ref client_id="VM-2:if2"/>
91
+ <interface_ref client_id="VM-3:if0"/>
92
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
93
+ </link>
94
+ <link vlantag="unknown" sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#link1" client_id="link1">
95
+ <interface_ref client_id="VM-1:if0"/>
96
+ <interface_ref client_id="VM:if1"/>
97
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
98
+ </link>
99
+ <link vlantag="unknown" sliver_id="urn:publicid:IDN+exogeni.net:rcivmsite+sliver+0faa1d2e-0c95-4422-b52f-03ac5ce9c92d#link5" client_id="link5">
100
+ <interface_ref client_id="VM-2:if3"/>
101
+ <interface_ref client_id="VM:if2"/>
102
+ <ns4:geni_sliver_info state="Nascent" start_time="2013-05-21T15:59:27.596Z" expiration_time="2013-05-22T15:59:27.596Z" creation_time="2013-05-21T15:59:27.596Z" creator_urn="dbhat@engin.umass.edu, urn:publicid:IDN+panther+user+dbhat"/>
103
+ </link>
104
+ <ns3:geni_slice_info state="configuring" uuid="2127113a-474f-4a9e-aad0-d4e7b22267ca" urn="urn:publicid:IDN+panther:GIMITesting+slice+dbhatexo5node"/>
105
+ </rspec>