omf_sfa 0.1.1
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/.gitignore +24 -0
- data/Gemfile +6 -0
- data/README.md +211 -0
- data/Rakefile +23 -0
- data/bin/parse_rspec.rb +167 -0
- data/etc/omf-sfa/omf-sfa-am.yaml +12 -0
- data/examples/exogeni5nodemanifest.rspec +105 -0
- data/examples/instageni5nodemanifest.rspec +150 -0
- data/lib/omf-sfa/am/am-rest/REST_API.md +301 -0
- data/lib/omf-sfa/am/am-rest/account_handler.rb +145 -0
- data/lib/omf-sfa/am/am-rest/am_rest_server.rb +255 -0
- data/lib/omf-sfa/am/am-rest/api_template.html +48 -0
- data/lib/omf-sfa/am/am-rest/config.ru +110 -0
- data/lib/omf-sfa/am/am-rest/resource_handler.rb +178 -0
- data/lib/omf-sfa/am/am-rest/rest_handler.rb +573 -0
- data/lib/omf-sfa/am/am-rest/session_authenticator.rb +130 -0
- data/lib/omf-sfa/am/am-rpc/abstract_rpc_service.rb +60 -0
- data/lib/omf-sfa/am/am-rpc/am_authorizer.rb +161 -0
- data/lib/omf-sfa/am/am-rpc/am_rpc_api.rb +450 -0
- data/lib/omf-sfa/am/am-rpc/am_rpc_service.rb +402 -0
- data/lib/omf-sfa/am/am_liaison.rb +93 -0
- data/lib/omf-sfa/am/am_manager.rb +859 -0
- data/lib/omf-sfa/am/am_runner.rb +108 -0
- data/lib/omf-sfa/am/am_scheduler.rb +146 -0
- data/lib/omf-sfa/am/am_server.rb +194 -0
- data/lib/omf-sfa/am/config.ru +122 -0
- data/lib/omf-sfa/am/credential.rb +145 -0
- data/lib/omf-sfa/am/default_authorizer.rb +44 -0
- data/lib/omf-sfa/am/privilege_credential.rb +76 -0
- data/lib/omf-sfa/am/signature.rb +37 -0
- data/lib/omf-sfa/am/user_credential.rb +56 -0
- data/lib/omf-sfa/am.rb +7 -0
- data/lib/omf-sfa/model/abstract_prop_description.rb +87 -0
- data/lib/omf-sfa/model/model_class_description.rb +145 -0
- data/lib/omf-sfa/model/model_data_prop_description.rb +28 -0
- data/lib/omf-sfa/model/model_obj_prop_description.rb +49 -0
- data/lib/omf-sfa/model/ontology.rb +169 -0
- data/lib/omf-sfa/resource/README.md +24 -0
- data/lib/omf-sfa/resource/channel.rb +49 -0
- data/lib/omf-sfa/resource/comp_group.rb +41 -0
- data/lib/omf-sfa/resource/component_lease.rb +10 -0
- data/lib/omf-sfa/resource/constants.rb +24 -0
- data/lib/omf-sfa/resource/group_component.rb +35 -0
- data/lib/omf-sfa/resource/group_membership.rb +17 -0
- data/lib/omf-sfa/resource/gurn.rb +187 -0
- data/lib/omf-sfa/resource/interface.rb +78 -0
- data/lib/omf-sfa/resource/ip.rb +48 -0
- data/lib/omf-sfa/resource/link.rb +29 -0
- data/lib/omf-sfa/resource/node.rb +75 -0
- data/lib/omf-sfa/resource/oaccount.rb +94 -0
- data/lib/omf-sfa/resource/ocomponent.rb +134 -0
- data/lib/omf-sfa/resource/ogroup.rb +106 -0
- data/lib/omf-sfa/resource/olease.rb +61 -0
- data/lib/omf-sfa/resource/oproperty.rb +178 -0
- data/lib/omf-sfa/resource/oreference.rb +15 -0
- data/lib/omf-sfa/resource/oresource.rb +491 -0
- data/lib/omf-sfa/resource/project.rb +28 -0
- data/lib/omf-sfa/resource/project_membership.rb +13 -0
- data/lib/omf-sfa/resource/sfa_base.rb +544 -0
- data/lib/omf-sfa/resource/user.rb +25 -0
- data/lib/omf-sfa/resource.rb +20 -0
- data/lib/omf-sfa/util/create_sample_testbed.rb +68 -0
- data/lib/omf-sfa/util/load_from_sfa_xml.rb +65 -0
- data/lib/omf-sfa/version.rb +4 -0
- data/lib/omf_sfa.rb +5 -0
- data/omf_sfa.gemspec +46 -0
- data/owl/README +3 -0
- data/owl/ben-6509.rdf +1377 -0
- data/owl/ben-dell.rdf +586 -0
- data/owl/ben-dtn.rdf +1698 -0
- data/owl/ben.rdf +1335 -0
- data/owl/collections.owl +309 -0
- data/owl/compute.owl +1486 -0
- data/owl/domain.owl +444 -0
- data/owl/dtn.owl +1165 -0
- data/owl/ec2.owl +385 -0
- data/owl/ethernet.owl +466 -0
- data/owl/eucalyptus.owl +431 -0
- data/owl/id-mp-Request1.rdf +247 -0
- data/owl/itu-grid.owl +147 -0
- data/owl/kansei.owl +511 -0
- data/owl/layer.owl +645 -0
- data/owl/location.owl +117 -0
- data/owl/mass.rdf +608 -0
- data/owl/nlr.rdf +901 -0
- data/owl/orca.owl +181 -0
- data/owl/planetlab.owl +124 -0
- data/owl/protogeni.owl +467 -0
- data/owl/request-6509-2.rdf +150 -0
- data/owl/request-6509-3.rdf +158 -0
- data/owl/request-6509.rdf +199 -0
- data/owl/request.owl +222 -0
- data/owl/storage.owl +511 -0
- data/owl/topology.owl +608 -0
- data/schema/rspec-v3/ad-common.xsd +269 -0
- data/schema/rspec-v3/ad-reservation.rnc +12 -0
- data/schema/rspec-v3/ad-reservation.rng +28 -0
- data/schema/rspec-v3/ad-reservation.xsd +13 -0
- data/schema/rspec-v3/ad.rnc +151 -0
- data/schema/rspec-v3/ad.xsd +77 -0
- data/schema/rspec-v3/any-extension-schema.xsd +38 -0
- data/schema/rspec-v3/any-extension.rnc +30 -0
- data/schema/rspec-v3/common.rnc +185 -0
- data/schema/rspec-v3/manifest-common.xsd +244 -0
- data/schema/rspec-v3/manifest-request.xsd +95 -0
- data/schema/rspec-v3/manifest.rnc +62 -0
- data/schema/rspec-v3/manifest.xsd +34 -0
- data/schema/rspec-v3/request-common.xsd +219 -0
- data/schema/rspec-v3/request-reservation.rnc +12 -0
- data/schema/rspec-v3/request-reservation.xsd +13 -0
- data/schema/rspec-v3/request.rnc +118 -0
- data/schema/rspec-v3/request.xsd +94 -0
- data/share/assets/css/default.css +147 -0
- data/share/assets/css/rest_api.css +0 -0
- data/share/assets/network.html +28 -0
- data/share/assets/network.js +82 -0
- data/spec/am/am-rest/common.rb +29 -0
- data/spec/am/am-rest/resource_group_handler_XspecX.rb +97 -0
- data/spec/am/am-rest/resource_handler_spec.rb +204 -0
- data/spec/am/am-rpc/sfa_methods_spec.rb +150 -0
- data/spec/am/am_manager_spec.rb +307 -0
- data/spec/am/am_scheduler_spec.rb +57 -0
- data/spec/am/common.rb +24 -0
- data/spec/resource/common.rb +31 -0
- data/spec/resource/node_spec.rb +171 -0
- data/spec/resource/oaccount_spec.rb +92 -0
- data/spec/resource/ocomponent_spec.rb +225 -0
- data/spec/resource/ogroup_spec.rb +93 -0
- data/spec/resource/oresource_spec.rb +208 -0
- data/spec/resource_and_leases_spec.rb +377 -0
- data/test/OLD_FILES/assertion1.xml +117 -0
- data/test/OLD_FILES/greeter_spec.rb +15 -0
- data/test/OLD_FILES/mongo_test.rb +45 -0
- data/test/OLD_FILES/req-sfa-2.xml +6 -0
- data/test/OLD_FILES/req-sfa-g.xml +8 -0
- data/test/OLD_FILES/req-sfa-g2.xml +10 -0
- data/test/OLD_FILES/req-sfa-g3.xml +14 -0
- data/test/OLD_FILES/req-sfa.xml +6 -0
- data/test/OLD_FILES/req1.xml +22 -0
- data/test/OLD_FILES/req1b.xml +15 -0
- data/test/OLD_FILES/rspec-test.xml +1867 -0
- data/test/OLD_FILES/test.rb +67 -0
- data/test/OLD_FILES/test2.rb +32 -0
- data/test/am/am_manager_rspec_tests.rb +378 -0
- data/test/am/am_manager_tests.rb +518 -0
- data/test/am/am_scheduler_tests.rb +173 -0
- data/test/resource/olease_test.rb +74 -0
- data/test/sfa_requests/request.xml +5 -0
- data/test/sfa_requests/request1.xml +5 -0
- data/test/sfa_requests/request2.xml +5 -0
- data/test/sfa_requests/request3.xml +5 -0
- metadata +601 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var w = 960,
|
|
2
|
+
h = 500,
|
|
3
|
+
fill = d3.scale.category20();
|
|
4
|
+
|
|
5
|
+
var vis = d3.select("#chart")
|
|
6
|
+
.append("svg:svg")
|
|
7
|
+
.attr("width", w)
|
|
8
|
+
.attr("height", h);
|
|
9
|
+
|
|
10
|
+
d3.json("http://0.0.0.0:8001/resources?json", function(json) {
|
|
11
|
+
var resources = json['resources_response']['resources']
|
|
12
|
+
var i2n = {};
|
|
13
|
+
var nodes = _.filter(resources, function(n) {
|
|
14
|
+
if (n['sfa_class'] == "node") {
|
|
15
|
+
_.each(n['interfaces'], function(i) {
|
|
16
|
+
i2n[i['href']] = n;
|
|
17
|
+
});
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var links = _.filter(resources, function(l) {
|
|
24
|
+
if (l['sfa_class'] == "link") {
|
|
25
|
+
var src = l.interfaces[0].href;
|
|
26
|
+
var tgt = l.interfaces[1].href;
|
|
27
|
+
l.source = i2n[src];
|
|
28
|
+
l.target = i2n[tgt];
|
|
29
|
+
return l.source && l.target;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
var force = d3.layout.force()
|
|
35
|
+
.charge(-1000)
|
|
36
|
+
.distance(100)
|
|
37
|
+
.nodes(nodes)
|
|
38
|
+
.links(links)
|
|
39
|
+
.size([w, h])
|
|
40
|
+
.start();
|
|
41
|
+
|
|
42
|
+
var link = vis.selectAll("line.link")
|
|
43
|
+
.data(links)
|
|
44
|
+
.enter().append("svg:line")
|
|
45
|
+
.attr("class", "link")
|
|
46
|
+
.attr("x1", function(d) {
|
|
47
|
+
return d.source.x;
|
|
48
|
+
})
|
|
49
|
+
.attr("y1", function(d) { return d.source.y; })
|
|
50
|
+
.attr("x2", function(d) { return d.target.x; })
|
|
51
|
+
.attr("y2", function(d) { return d.target.y; });
|
|
52
|
+
|
|
53
|
+
var node = vis.selectAll("circle.node")
|
|
54
|
+
.data(nodes)
|
|
55
|
+
.enter().append("svg:circle")
|
|
56
|
+
.attr("class", "node")
|
|
57
|
+
.attr("cx", function(d) { return d.x; })
|
|
58
|
+
.attr("cy", function(d) { return d.y; })
|
|
59
|
+
.attr("r", 20)
|
|
60
|
+
.style("fill", function(d) { return fill(d.group); })
|
|
61
|
+
.call(force.drag);
|
|
62
|
+
|
|
63
|
+
node.append("svg:title")
|
|
64
|
+
.text(function(d) {
|
|
65
|
+
return d.component_name;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
vis.style("opacity", 1e-6)
|
|
69
|
+
.transition()
|
|
70
|
+
.duration(1000)
|
|
71
|
+
.style("opacity", 1);
|
|
72
|
+
|
|
73
|
+
force.on("tick", function() {
|
|
74
|
+
link.attr("x1", function(d) { return d.source.x; })
|
|
75
|
+
.attr("y1", function(d) { return d.source.y; })
|
|
76
|
+
.attr("x2", function(d) { return d.target.x; })
|
|
77
|
+
.attr("y2", function(d) { return d.target.y; });
|
|
78
|
+
|
|
79
|
+
node.attr("cx", function(d) { return d.x; })
|
|
80
|
+
.attr("cy", function(d) { return d.y; });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
require "#{File.dirname(__FILE__)}/../resource/common"
|
|
3
|
+
require 'omf-sfa/resource/oresource'
|
|
4
|
+
require 'omf-sfa/resource/ogroup'
|
|
5
|
+
require 'omf-sfa/resource/ocomponent'
|
|
6
|
+
require 'json'
|
|
7
|
+
|
|
8
|
+
class MockRequest
|
|
9
|
+
def initialize(opts = {})
|
|
10
|
+
@opts = opts
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def []=(k, v)
|
|
14
|
+
@opts[k] = v
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def [](k)
|
|
18
|
+
@opts[k]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def method_missing(name, *args, &block)
|
|
22
|
+
return @opts[name]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def create_def_opts(ropts = {})
|
|
27
|
+
req = MockRequest.new(ropts)
|
|
28
|
+
{:req => req} #, :am_mgr => @mgr}
|
|
29
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/common"
|
|
2
|
+
|
|
3
|
+
require 'omf-sfa/am/am-rest/resource_group_handler'
|
|
4
|
+
require 'omf-sfa/resource/node'
|
|
5
|
+
require 'omf-sfa/resource/group_component'
|
|
6
|
+
|
|
7
|
+
include OMF::SFA::Resource
|
|
8
|
+
include OMF::SFA::AM
|
|
9
|
+
|
|
10
|
+
describe 'ResourceGroup handler' do
|
|
11
|
+
before :all do
|
|
12
|
+
init_dm
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before :each do
|
|
16
|
+
@h = ResourceGroupHandler.new
|
|
17
|
+
@req = MockRequest.new(:path => '/slices/foo')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
it 'can list empty group' do
|
|
22
|
+
g = GroupComponent.create(:name => 'foo')
|
|
23
|
+
g.save
|
|
24
|
+
|
|
25
|
+
res = @h.on_get(g, :req => @req)
|
|
26
|
+
exp = {:group_response => {
|
|
27
|
+
:about => "/slices/foo",
|
|
28
|
+
'uuid' => g.uuid.to_s,
|
|
29
|
+
"href" => "/slices/foo",
|
|
30
|
+
"sfa_class" => "group",
|
|
31
|
+
"component_name" => "foo",
|
|
32
|
+
"component_manager_id" => "authority+am",
|
|
33
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+group+foo",
|
|
34
|
+
"components" => []
|
|
35
|
+
}}
|
|
36
|
+
res.should == exp
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'can list with node and interface' do
|
|
40
|
+
g = GroupComponent.create(:name => 'foo')
|
|
41
|
+
g.contains_resources << (n = Node.create(:name => 'n1'))
|
|
42
|
+
n.interfaces << (if1 = Interface.create(:name => 'if1'))
|
|
43
|
+
g.save
|
|
44
|
+
|
|
45
|
+
res = @h.on_get(g, :req => @req)
|
|
46
|
+
exp = {:group_response => {
|
|
47
|
+
:about => "/slices/foo",
|
|
48
|
+
'uuid' => g.uuid.to_s,
|
|
49
|
+
"href" => "/slices/foo",
|
|
50
|
+
"sfa_class" => "group",
|
|
51
|
+
"component_name" => "foo",
|
|
52
|
+
"component_manager_id" => "authority+am",
|
|
53
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+group+foo",
|
|
54
|
+
"components" => [{
|
|
55
|
+
"href" => "/slices/resources/n1",
|
|
56
|
+
"uuid"=> n.uuid.to_s,
|
|
57
|
+
"sfa_class"=>"node",
|
|
58
|
+
"component_name"=>"n1",
|
|
59
|
+
"component_manager_id"=>"authority+am",
|
|
60
|
+
"component_id"=>"urn:publicid:IDN+mytestbed.net+node+n1",
|
|
61
|
+
"available" => "true",
|
|
62
|
+
"interfaces" => [{
|
|
63
|
+
"href" => "/slices/resources/if1",
|
|
64
|
+
"uuid" => if1.uuid.to_s,
|
|
65
|
+
"component_name" => "if1",
|
|
66
|
+
"component_manager_id" => "authority+am",
|
|
67
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+interface+if1",
|
|
68
|
+
"sfa_class" => "interface"
|
|
69
|
+
}]
|
|
70
|
+
}]
|
|
71
|
+
}}
|
|
72
|
+
res.should == exp
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'can create a group on put' do
|
|
76
|
+
root = GroupComponent.create(:name => 'root')
|
|
77
|
+
|
|
78
|
+
b = '<group component_id="urn:publicid:IDN+mytestbed.net+group+g1"/>'
|
|
79
|
+
opts = create_def_opts(:path => '/slices/foo/resources/r3', :body => b)
|
|
80
|
+
|
|
81
|
+
res = @h.on_put(root.name, opts)
|
|
82
|
+
res.should == { :resource_response => {
|
|
83
|
+
:about => "/slices/foo/resources/r3",
|
|
84
|
+
"href" => "/slices/foo/resources/r3",
|
|
85
|
+
"available" => "true",
|
|
86
|
+
"uuid" => r3.uuid.to_s,
|
|
87
|
+
"component_name" => "r3",
|
|
88
|
+
"component_manager_id" => "authority+am",
|
|
89
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+node+r3",
|
|
90
|
+
"sfa_class" => "node",
|
|
91
|
+
"interfaces" => []
|
|
92
|
+
}}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/common"
|
|
2
|
+
|
|
3
|
+
require 'omf-sfa/am/am-rest/resource_handler'
|
|
4
|
+
require 'omf-sfa/resource'
|
|
5
|
+
|
|
6
|
+
include OMF::SFA::Resource
|
|
7
|
+
include OMF::SFA::AM
|
|
8
|
+
|
|
9
|
+
class CompA < OComponent
|
|
10
|
+
sfa_class 'compA'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'Resource handler' do
|
|
14
|
+
before :all do
|
|
15
|
+
OMF::Common::Loggable.init_log 'test'
|
|
16
|
+
init_dm
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
before :each do
|
|
20
|
+
@mgr = DefaultManager.new
|
|
21
|
+
@h = ResourceHandler.new @mgr
|
|
22
|
+
@opts = create_def_opts(:path => '/slices/foo/resources/moo')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def create_node(name)
|
|
27
|
+
OComponent.all(:name => name).each {|r|
|
|
28
|
+
#puts "DESTROY >>> #{r}::#{r.name}"
|
|
29
|
+
r.destroy
|
|
30
|
+
}
|
|
31
|
+
OComponent.create(:name => name)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
it 'can list basic resource' do
|
|
36
|
+
r = OResource.create(:name => 'moo')
|
|
37
|
+
@mgr.manage_resource(r)
|
|
38
|
+
|
|
39
|
+
exp = {:resource_response => {
|
|
40
|
+
:about => "/slices/foo/resources/moo",
|
|
41
|
+
:uuid => r.uuid.to_s,
|
|
42
|
+
:name => "moo",
|
|
43
|
+
:type => 'unknown'
|
|
44
|
+
}}
|
|
45
|
+
res = @h.on_get(r.uuid.to_s, @opts)
|
|
46
|
+
res.should == exp
|
|
47
|
+
|
|
48
|
+
res2 = @h.on_get({:name => r.name}, @opts)
|
|
49
|
+
res2.should == exp
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'can list basic components' do
|
|
54
|
+
r = CompA.create(:name => 'r1')
|
|
55
|
+
r.save
|
|
56
|
+
@mgr.manage_resource(r)
|
|
57
|
+
|
|
58
|
+
exp = {:resource_response => {
|
|
59
|
+
:about => "/slices/foo/resources/moo",
|
|
60
|
+
"uuid" => r.uuid.to_s,
|
|
61
|
+
"href" => "/slices/foo/resources/r1",
|
|
62
|
+
"component_name" => "r1",
|
|
63
|
+
"component_manager_id" => "authority+am",
|
|
64
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+compA+r1",
|
|
65
|
+
"sfa_class" => 'compA'
|
|
66
|
+
}}
|
|
67
|
+
res = @h.on_get(r.uuid.to_s, @opts)
|
|
68
|
+
res.should == exp
|
|
69
|
+
|
|
70
|
+
# res2 = @h.on_get(r.uuid.to_s, @opts)
|
|
71
|
+
@mgr.manage_resource(r)
|
|
72
|
+
opts = create_def_opts
|
|
73
|
+
account = opts[:account] = OAccount.new()
|
|
74
|
+
r.account = account
|
|
75
|
+
|
|
76
|
+
res2 = @h.on_get({:name => r.component_name}, @opts)
|
|
77
|
+
res2.should == exp
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'can list node with one interface' do
|
|
81
|
+
n = Node.create(:name => 'n1')
|
|
82
|
+
n.interfaces << (if1 = Interface.create(:name => 'if1'))
|
|
83
|
+
n.save
|
|
84
|
+
@mgr.manage_resource(n)
|
|
85
|
+
|
|
86
|
+
res = @h.on_get(n.uuid.to_s, @opts)
|
|
87
|
+
exp = {:resource_response => {
|
|
88
|
+
:about => "/slices/foo/resources/moo",
|
|
89
|
+
"uuid" => n.uuid.to_s,
|
|
90
|
+
"href" => "/slices/foo/resources/n1",
|
|
91
|
+
'available' => "true",
|
|
92
|
+
"component_name" => "n1",
|
|
93
|
+
"component_manager_id" => "authority+am",
|
|
94
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+node+n1",
|
|
95
|
+
"sfa_class" => "node",
|
|
96
|
+
"interfaces"=> [{
|
|
97
|
+
"href" => "/slices/foo/resources/if1",
|
|
98
|
+
"uuid" => if1.uuid.to_s,
|
|
99
|
+
"component_name" => "if1",
|
|
100
|
+
"component_manager_id" =>"authority+am",
|
|
101
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+interface+if1",
|
|
102
|
+
"sfa_class" => "interface"
|
|
103
|
+
}]
|
|
104
|
+
}}
|
|
105
|
+
res.should == exp
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'list components for various accounts' do
|
|
109
|
+
OComponent.find(:name => 'r1').each {|r| r.destroy}
|
|
110
|
+
r = OComponent.create(:name => 'r1')
|
|
111
|
+
@mgr.manage_resource(r)
|
|
112
|
+
account1 = OAccount.create()
|
|
113
|
+
r.account = account1
|
|
114
|
+
r.save
|
|
115
|
+
# account1 = opts[:account] = OAccount.new()
|
|
116
|
+
|
|
117
|
+
opts = create_def_opts(:path => '/resources/moo', :account_id => account1.uuid.to_uri)
|
|
118
|
+
@mgr.get_requester_account(opts).should == account1
|
|
119
|
+
|
|
120
|
+
r1h = {:name => 'r1'}
|
|
121
|
+
res = @h.on_get(r1h, opts)
|
|
122
|
+
|
|
123
|
+
account2 = OAccount.create()
|
|
124
|
+
opts = create_def_opts(:path => '/resources/moo', :account_id => UUIDTools::UUID.random_create.to_uri)
|
|
125
|
+
lambda do
|
|
126
|
+
res = @h.on_get(r1h, opts)
|
|
127
|
+
end.should raise_error OMF::SFA::AM::UnknownAccountException
|
|
128
|
+
|
|
129
|
+
opts = create_def_opts(:path => '/resources/moo', :account_id => account2.uuid.to_uri)
|
|
130
|
+
lambda do
|
|
131
|
+
res = @h.on_get(r1h, opts)
|
|
132
|
+
end.should raise_error OMF::SFA::AM::UnknownResourceException
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'can create a node on put' do
|
|
136
|
+
r3 = Node.create(:name => 'mytestbed.net+node+r3')
|
|
137
|
+
r3.name.should == 'mytestbed.net+node+r3'
|
|
138
|
+
@mgr.manage_resource(r3)
|
|
139
|
+
r3.account.should == @mgr.get_default_account # this test should really go somewhere else
|
|
140
|
+
|
|
141
|
+
path = '/slices/foo/resources/r3'
|
|
142
|
+
b = '<node component_id="urn:publicid:IDN+mytestbed.net+node+r3"/>'
|
|
143
|
+
opts = create_def_opts(:path => '/slices/foo/resources/mytestbed.net+node+r3', :body => b)
|
|
144
|
+
res = @h.on_put({:name => 'mytestbed.net+node+r3'}, opts)
|
|
145
|
+
res.should == { :resource_response => {
|
|
146
|
+
:about => "/slices/foo/resources/mytestbed.net+node+r3",
|
|
147
|
+
"href" => "/slices/foo/resources/mytestbed.net+node+r3",
|
|
148
|
+
"available" => "true",
|
|
149
|
+
"uuid" => r3.uuid.to_s,
|
|
150
|
+
"component_name" => "r3",
|
|
151
|
+
"component_manager_id" => "authority+am",
|
|
152
|
+
"component_id" => "urn:publicid:IDN+mytestbed.net+node+r3",
|
|
153
|
+
"sfa_class" => "node",
|
|
154
|
+
"interfaces" => []
|
|
155
|
+
}}
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it 'can create a group on put' do
|
|
159
|
+
root = OGroup.create(:name => 'root')
|
|
160
|
+
@mgr.manage_resource(root)
|
|
161
|
+
|
|
162
|
+
path = '/slices/foo/resources'
|
|
163
|
+
b = "<group uuid='#{root.uuid}'><group name='g'/></group>"
|
|
164
|
+
opts = create_def_opts(:path => path, :body => b)
|
|
165
|
+
opts[:name_prefix] = path
|
|
166
|
+
|
|
167
|
+
res = @h.on_put(root.uuid.to_s, opts)
|
|
168
|
+
g = OMF::SFA::Resource::OGroup.first(:name => 'g')
|
|
169
|
+
g.should_not nil
|
|
170
|
+
|
|
171
|
+
res.should == { :resource_response => {
|
|
172
|
+
:about=>"/slices/foo/resources",
|
|
173
|
+
:type=>"group",
|
|
174
|
+
:href=>"/slices/foo/resources",
|
|
175
|
+
:uuid => root.uuid.to_s,
|
|
176
|
+
:resources => [{
|
|
177
|
+
:type=>"group",
|
|
178
|
+
:name=>"g",
|
|
179
|
+
:href=>"/slices/foo/resources/g",
|
|
180
|
+
:uuid=> g.uuid.to_s,
|
|
181
|
+
:resources=>[]
|
|
182
|
+
}],
|
|
183
|
+
}}
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it 'can delete a node on delete' do
|
|
187
|
+
r = create_node('r1')
|
|
188
|
+
@mgr.manage_resource(r)
|
|
189
|
+
account1 = OAccount.create()
|
|
190
|
+
|
|
191
|
+
opts = create_def_opts(:path => '/resources/moo', :account_id => account1.uuid.to_uri)
|
|
192
|
+
res = @h.on_delete({:name => 'r1'}, opts)
|
|
193
|
+
|
|
194
|
+
r.account = account1
|
|
195
|
+
r.save
|
|
196
|
+
r.account.should == account1
|
|
197
|
+
opts = create_def_opts(:path => '/resources/moo', :account_id => account1.uuid.to_uri)
|
|
198
|
+
@mgr.find_resource({:name => 'r1'}, opts).should == r
|
|
199
|
+
|
|
200
|
+
res = @h.on_delete({:name => 'r1'}, opts)
|
|
201
|
+
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
end
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
require 'omf-sfa/am/am-rpc/am_rpc_service'
|
|
2
|
+
require 'omf-sfa/am/am_manager'
|
|
3
|
+
require 'dm-migrations'
|
|
4
|
+
|
|
5
|
+
include OMF::SFA::AM::RPC
|
|
6
|
+
|
|
7
|
+
def init_dm
|
|
8
|
+
#setup database
|
|
9
|
+
DataMapper::Logger.new($stdout, :info)
|
|
10
|
+
|
|
11
|
+
DataMapper.setup(:default, 'sqlite::memory:')
|
|
12
|
+
#DataMapper.setup(:default, 'sqlite:///tmp/am_test.db')
|
|
13
|
+
DataMapper::Model.raise_on_save_failure = true
|
|
14
|
+
DataMapper.finalize
|
|
15
|
+
|
|
16
|
+
DataMapper.auto_migrate!
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe AMService do
|
|
20
|
+
|
|
21
|
+
init_dm
|
|
22
|
+
|
|
23
|
+
before (:each) { DataMapper.auto_migrate! }
|
|
24
|
+
|
|
25
|
+
let (:manager) { double('am_manager') }
|
|
26
|
+
|
|
27
|
+
let(:authorizer) { double('authorizer') }
|
|
28
|
+
|
|
29
|
+
let (:am_rpc) do
|
|
30
|
+
@am_rpc = AMService.new(:manager => manager)
|
|
31
|
+
@am_rpc.authorizer = authorizer
|
|
32
|
+
@am_rpc
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'will respond to get_version' do
|
|
36
|
+
|
|
37
|
+
res = {
|
|
38
|
+
:geni_api => 1,
|
|
39
|
+
:omf_am => "0.1",
|
|
40
|
+
:ad_rspec_versions => [{
|
|
41
|
+
:type => 'ProtoGENI',
|
|
42
|
+
:version => '2',
|
|
43
|
+
:namespace => 'http://www.protogeni.net/resources/rspec/2',
|
|
44
|
+
:schema => 'http://www.protogeni.net/resources/rspec/2/ad.xsd',
|
|
45
|
+
:extensions => []
|
|
46
|
+
}]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
am_rpc.get_version.should be_eql(res)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'will return all the resources of a slice' do
|
|
53
|
+
|
|
54
|
+
account = OMF::SFA::Resource::OAccount.new(:urn => "urn:publicid:IDN+omf:test+account+1")
|
|
55
|
+
OMF::SFA::Resource::Node.create({:name => 'node1', :account => account})
|
|
56
|
+
|
|
57
|
+
authorizer.should_receive(:check_credentials).with(:ListResources, "urn:publicid:IDN+omf:test+account+1", "cred")
|
|
58
|
+
|
|
59
|
+
manager.should_receive(:find_or_create_account).with({:urn => "urn:publicid:IDN+omf:test+account+1"}, anything)
|
|
60
|
+
|
|
61
|
+
manager.stub(:find_all_components_for_account) do
|
|
62
|
+
res = OMF::SFA::Resource::OComponent.all(:account => account)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
res = am_rpc.list_resources("cred", {"geni_available" => false, "geni_compressed" => false, "geni_slice_urn" => "urn:publicid:IDN+omf:test+account+1"})
|
|
66
|
+
|
|
67
|
+
req = Nokogiri.XML(res)
|
|
68
|
+
node = req.xpath('//xmlns:node').first
|
|
69
|
+
node[:component_name].should be_eql('node1')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'will create a sliver' do
|
|
73
|
+
account = OMF::SFA::Resource::OAccount.new(:urn => "urn:publicid:IDN+omf:test+account+1")
|
|
74
|
+
OMF::SFA::Resource::Node.create({:name => 'node1', :account => account})
|
|
75
|
+
|
|
76
|
+
authorizer.should_receive(:check_credentials).with(:CreateSliver, "urn:publicid:IDN+omf:test+account+1", "cred")
|
|
77
|
+
|
|
78
|
+
manager.should_receive(:find_or_create_account).with({:urn => "urn:publicid:IDN+omf:test+account+1"}, authorizer).and_return(account)
|
|
79
|
+
|
|
80
|
+
resources = OMF::SFA::Resource::OComponent.all(:account => account)
|
|
81
|
+
manager.should_receive(:update_resources_from_rspec).and_return(resources)
|
|
82
|
+
|
|
83
|
+
res = am_rpc.create_sliver("urn:publicid:IDN+omf:test+account+1", "cred", "rspecs_here", "users")
|
|
84
|
+
|
|
85
|
+
req = Nokogiri.XML(res)
|
|
86
|
+
node = req.xpath('//xmlns:node').first
|
|
87
|
+
node[:component_name].should be_eql('node1')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "will return the status of a sliver" do
|
|
91
|
+
|
|
92
|
+
account = OMF::SFA::Resource::OAccount.new(:urn => "urn:publicid:IDN+omf:test+account+1")
|
|
93
|
+
OMF::SFA::Resource::Node.create({:name => 'node1', :account => account})
|
|
94
|
+
|
|
95
|
+
authorizer.should_receive(:check_credentials).with(:SliverStatus, "urn:publicid:IDN+omf:test+account+1", "cred")
|
|
96
|
+
|
|
97
|
+
manager.should_receive(:find_account).with({:urn => "urn:publicid:IDN+omf:test+account+1"}, authorizer).and_return(account)
|
|
98
|
+
|
|
99
|
+
manager.should_receive(:find_or_create_account).with({:urn => "urn:publicid:IDN+omf:test+account+1"}, anything)
|
|
100
|
+
|
|
101
|
+
manager.stub(:find_all_components_for_account) do
|
|
102
|
+
OMF::SFA::Resource::OComponent.all(:account => account)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
res = am_rpc.sliver_status("urn:publicid:IDN+omf:test+account+1", "cred")
|
|
106
|
+
|
|
107
|
+
res['geni_urn'].should be_eql("urn:publicid:IDN+omf:test+account+1")
|
|
108
|
+
node = res['geni_resources'].first
|
|
109
|
+
node['geni_urn'].should be_eql("urn:publicid:IDN+mytestbed.net+node+node1")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "will renew a sliver" do
|
|
113
|
+
expiration_time = DateTime.new(2014).rfc3339
|
|
114
|
+
|
|
115
|
+
authorizer.should_receive(:check_credentials).with(:RenewSliver, "urn:publicid:IDN+omf:test+account+1", "cred")
|
|
116
|
+
|
|
117
|
+
manager.should_receive(:renew_account_until).with({:urn => "urn:publicid:IDN+omf:test+account+1"}, expiration_time, authorizer)
|
|
118
|
+
|
|
119
|
+
am_rpc.renew_sliver("urn:publicid:IDN+omf:test+account+1", "cred", expiration_time)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "will delete a sliver" do
|
|
123
|
+
|
|
124
|
+
OMF::SFA::Resource::OAccount.new(:urn => "urn:publicid:IDN+omf:test+account+1")
|
|
125
|
+
|
|
126
|
+
account = authorizer.should_receive(:check_credentials).with(:DeleteSliver, "urn:publicid:IDN+omf:test+account+1", "cred")
|
|
127
|
+
|
|
128
|
+
manager.stub(:close_account) do |slice_urn, auth|
|
|
129
|
+
account = OMF::SFA::Resource::OAccount.first(slice_urn)
|
|
130
|
+
account.close
|
|
131
|
+
account.save
|
|
132
|
+
account
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
am_rpc.delete_sliver("urn:publicid:IDN+omf:test+account+1", "cred")
|
|
136
|
+
account.should be_closed
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "will shutdown sliver" do
|
|
140
|
+
|
|
141
|
+
account = OMF::SFA::Resource::OAccount.new(:urn => "urn:publicid:IDN+omf:test+account+1")
|
|
142
|
+
|
|
143
|
+
authorizer.should_receive(:check_credentials).with(:Shutdown, "urn:publicid:IDN+omf:test+account+1", "cred")
|
|
144
|
+
manager.should_receive(:find_account).and_return(account)
|
|
145
|
+
authorizer.should_receive(:can_close_account?).with(account)
|
|
146
|
+
|
|
147
|
+
am_rpc.shutdown_sliver("urn:publicid:IDN+omf:test+account+1", "cred")
|
|
148
|
+
account.should be_closed
|
|
149
|
+
end
|
|
150
|
+
end
|