Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
onelab
myslicelib
Commits
c2ee0f27
Commit
c2ee0f27
authored
9 years ago
by
Loic Baron
Browse files
Options
Download
Email Patches
Plain Diff
Leases handled
parent
c05032c7
Pipeline
#78
failed with stage
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
myslicelib/model/lease.py
+23
-0
myslicelib/model/lease.py
myslicelib/model/slice.py
+21
-0
myslicelib/model/slice.py
myslicelib/query/lease.py
+1
-1
myslicelib/query/lease.py
myslicelib/util/sfabuilder/ple.py
+4
-3
myslicelib/util/sfabuilder/ple.py
myslicelib/util/sfaparser/iotlab.py
+1
-1
myslicelib/util/sfaparser/iotlab.py
myslicelib/util/sfaparser/omf.py
+3
-3
myslicelib/util/sfaparser/omf.py
testapi.py
+26
-7
testapi.py
with
79 additions
and
15 deletions
+79
-15
myslicelib/model/lease.py
+
23
-
0
View file @
c2ee0f27
...
...
@@ -7,3 +7,26 @@ class Lease(Entity):
_class
=
"Lease"
_type
=
"lease"
_collection
=
"Leases"
def
__init__
(
self
,
data
=
None
):
super
().
__init__
(
data
)
if
data
is
None
:
self
.
resources
=
[]
def
addResource
(
self
,
resource
):
self
.
resources
.
append
(
resource
.
id
)
return
self
def
addResources
(
self
,
resources
):
for
r
in
resources
:
self
.
addResource
(
r
)
return
self
def
removeResource
(
self
,
resource
):
self
.
resources
=
list
(
set
(
self
.
resources
)
-
set
(
resource
.
id
))
return
self
def
removeResources
(
self
):
self
.
resources
=
[]
return
self
This diff is collapsed.
Click to expand it.
myslicelib/model/slice.py
+
21
-
0
View file @
c2ee0f27
...
...
@@ -43,7 +43,28 @@ class Slice(Entity):
def
addResource
(
self
,
resource
):
self
.
resources
.
append
(
resource
.
attributes
())
return
self
def
addResources
(
self
,
resources
):
for
r
in
resources
:
self
.
addResource
(
r
)
return
self
def
removeResource
(
self
,
resource
):
self
.
resources
=
list
(
filter
(
lambda
x
:
x
[
'id'
]
==
resource
.
id
,
self
.
resources
))
return
self
def
removeResources
(
self
):
self
.
resources
=
[]
return
self
def
addLease
(
self
,
lease
):
self
.
leases
.
append
(
lease
.
attributes
())
return
self
def
removeLease
(
self
,
lease
):
raise
NotImplemented
(
"not implemented yet"
)
def
removeLeases
(
self
,
lease
):
self
.
leases
=
[]
return
self
This diff is collapsed.
Click to expand it.
myslicelib/query/lease.py
+
1
-
1
View file @
c2ee0f27
from
myslicelib.query
import
Query
class
LeaseQuery
(
Query
):
raise
NotImplementedError
(
"Not yet implemented"
)
pass
This diff is collapsed.
Click to expand it.
myslicelib/util/sfabuilder/ple.py
+
4
-
3
View file @
c2ee0f27
...
...
@@ -21,9 +21,10 @@ class Ple(SfaBuilder):
<rspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.geni.net/resources/rspec/3" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" type="request" xsi:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd" expires="2016-03-18T12:26:50Z" generated="2016-03-18T11:26:50Z">'
for
r
in
record_dict
[
'resources'
]:
rspec
+=
'<node component_manager_id="urn:publicid:IDN+ple+authority+cm" component_id="'
+
r
[
'id'
]
+
'" component_name="'
+
r
[
'id'
].
split
(
'+'
)[
-
1
]
+
'">'
rspec
+=
'<sliver_type name="plab-vserver"/>'
rspec
+=
'</node>'
if
r
[
'testbed'
]
==
'ple'
:
rspec
+=
'<node component_manager_id="urn:publicid:IDN+ple+authority+cm" component_id="'
+
r
[
'id'
]
+
'" component_name="'
+
r
[
'id'
].
split
(
'+'
)[
-
1
]
+
'">'
rspec
+=
'<sliver_type name="plab-vserver"/>'
rspec
+=
'</node>'
rspec
+=
'</rspec>'
...
...
This diff is collapsed.
Click to expand it.
myslicelib/util/sfaparser/iotlab.py
+
1
-
1
View file @
c2ee0f27
...
...
@@ -17,7 +17,7 @@ class Iotlab(SfaParser):
'end_time'
:
int
(
lease
.
attrib
[
'start_time'
])
+
\
int
(
lease
.
attrib
[
'duration'
]),
'
nod
es'
:
[
node
.
attrib
[
'component_id'
]
for
node
in
list
(
lease
)],
'
resourc
es'
:
[
node
.
attrib
[
'component_id'
]
for
node
in
list
(
lease
)],
}
result
.
append
(
lease
)
return
result
...
...
This diff is collapsed.
Click to expand it.
myslicelib/util/sfaparser/omf.py
+
3
-
3
View file @
c2ee0f27
...
...
@@ -27,7 +27,7 @@ class Omf(SfaParser):
'start_time'
:
start_time
,
'end_time'
:
end_time
,
'duration'
:
duration
,
'
nod
es'
:
[],
'
resourc
es'
:
[],
}
for
node
in
nodes
:
leases_in_node
=
node
.
findall
(
'{http://nitlab.inf.uth.gr/schema/sfa/rspec/1}lease_ref'
)
...
...
@@ -36,7 +36,7 @@ class Omf(SfaParser):
else
:
for
lease_in_node
in
leases_in_node
:
if
l
[
'lease_id'
]
==
lease_in_node
.
attrib
[
'id_ref'
]:
l
[
'
nod
es'
].
append
(
node
.
attrib
[
'component_id'
])
l
[
'
resourc
es'
].
append
(
node
.
attrib
[
'component_id'
])
result
.
append
(
l
)
return
result
...
...
@@ -78,4 +78,4 @@ class Omf(SfaParser):
# ' <ol:channel '
# 'component_id="urn:publicid:IDN+omf:paris.fit-nitos.fr+channel+channel1" '
# 'component_manager_id="urn:publicid:IDN+omf:paris.fit-nitos.fr+authority+cm" '
# 'component_name="channel1" frequency="2.412GHz"/>\n'
\ No newline at end of file
# 'component_name="channel1" frequency="2.412GHz"/>\n'
This diff is collapsed.
Click to expand it.
testapi.py
+
26
-
7
View file @
c2ee0f27
...
...
@@ -7,7 +7,7 @@ from myslicelib.api import Api
from
myslicelib
import
setup
as
s
from
myslicelib.model.resource
import
Resources
,
Resource
from
myslicelib.model.lease
import
Leases
from
myslicelib.model.lease
import
Leases
,
Lease
from
myslicelib.model.slice
import
Slices
,
Slice
from
myslicelib.model.user
import
Users
,
User
from
myslicelib.model.authority
import
Authorities
,
Authority
...
...
@@ -17,7 +17,7 @@ from pprint import pprint
s
.
endpoints
=
[
Endpoint
(
url
=
"https://sfa3.planet-lab.eu:12346"
,
type
=
"AM"
),
#
Endpoint(url="https://194.199.16.164:12346",type="AM"),
Endpoint
(
url
=
"https://194.199.16.164:12346"
,
type
=
"AM"
),
#Endpoint(url="https://www.wilab2.ilabt.iminds.be:12369/protogeni/xmlrpc/am/3.0",type="AM"),
#Endpoint(url="https://fuseco.fokus.fraunhofer.de/api/sfa/am/v3",type="AM"),
#Endpoint(url="https://griffin.ipv6.lip6.fr:8001/RPC2",type="AM"),
...
...
@@ -107,11 +107,17 @@ s.credential = Credential(hrn=hrn, email=email, certificate=cert, private_key=pk
# s.save()
#r = q(Resource).filter('country','Germany').get()
r
=
q
(
Resource
).
filter
(
'country'
,
[
'Germany'
,
'France'
]).
get
()
r
=
q
(
Resource
).
filter
(
'country'
,
[
'Germany'
,
'France'
]).
filter
(
'name'
,
'plab-vserver'
).
get
()
#
r = q(Resource).filter('country', ['Germany', 'France']).get()
#
r = q(Resource).filter('country', ['Germany', 'France']).filter('name','plab-vserver').get()
#r = q(Resource).filter('country','Spain').filter('name','planetlab2.upc.es').get().first()
r
=
q
(
Resource
).
filter
(
'country'
,
'Spain'
).
filter
(
'version'
,
'f22'
).
get
()
#ls = q(Lease).get()
#pprint(ls)
r
=
q
(
Resource
).
filter
(
'name'
,
'wsn430-27.grenoble.iot-lab.info'
).
get
()
r1
=
q
(
Resource
).
filter
(
'country'
,
'Spain'
).
filter
(
'name'
,
'planetlab2.upc.es'
).
get
()
r
.
update
(
r1
)
#r = q(Resource).filter('country','Spain').filter('version','f22').get()
u
=
q
(
User
).
id
(
'urn:publicid:IDN+onelab:upmc+user+joshzhou16'
).
get
().
first
()
u1
=
q
(
User
).
id
(
'urn:publicid:IDN+onelab:upmc+user+loic_baron'
).
get
().
first
()
s
=
Slice
()
...
...
@@ -124,9 +130,22 @@ s.addUser(u1)
pprint
(
s
)
s
.
removeUser
(
u1
)
pprint
(
s
)
# XXX In builder check that resources belong to the right testbed
s
.
addResources
(
r
)
pprint
(
s
)
##s.resources.append('urn:publicid:IDN+ple:uitple+node+planetlab1.cs.uit.no')
l
=
Lease
()
l
.
slice_id
=
s
.
id
l
.
start_time
=
1458320400
l
.
duration
=
3600
l
.
end_time
=
1458324000
# XXX In builder check that resources belong to the right testbed
l
.
addResources
(
r
)
pprint
(
l
)
s
.
addLease
(
l
)
pprint
(
s
)
s
=
s
.
save
()
pprint
(
s
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets