git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://git.onelab.eu/git/sfa
[sfa.git]
/
sfa
/
managers
/
aggregate_manager_vini.py
diff --git
a/sfa/managers/aggregate_manager_vini.py
b/sfa/managers/aggregate_manager_vini.py
index
e16d201
..
88c4438
100644
(file)
--- a/
sfa/managers/aggregate_manager_vini.py
+++ b/
sfa/managers/aggregate_manager_vini.py
@@
-6,17
+6,17
@@
import sys
from types import StringTypes
from sfa.util.xrn import urn_to_hrn, Xrn
from sfa.util.plxrn import hrn_to_pl_slicename
from types import StringTypes
from sfa.util.xrn import urn_to_hrn, Xrn
from sfa.util.plxrn import hrn_to_pl_slicename
-from sfa.util.rspec import *
-from sfa.util.specdict import *
from sfa.util.faults import *
from sfa.util.record import SfaRecord
from sfa.util.policy import Policy
from sfa.util.record import *
from sfa.util.faults import *
from sfa.util.record import SfaRecord
from sfa.util.policy import Policy
from sfa.util.record import *
-from sfa.
util
.sfaticket import SfaTicket
+from sfa.
trust
.sfaticket import SfaTicket
from sfa.server.registry import Registries
from sfa.plc.slices import Slices
import sfa.plc.peers as peers
from sfa.managers.vini.vini_network import *
from sfa.server.registry import Registries
from sfa.plc.slices import Slices
import sfa.plc.peers as peers
from sfa.managers.vini.vini_network import *
+from sfa.plc.vini_aggregate import ViniAggregate
+from sfa.rspecs.version_manager import VersionManager
from sfa.plc.api import SfaAPI
from sfa.plc.slices import *
from sfa.managers.aggregate_manager_pl import __get_registry_objects, __get_hostnames
from sfa.plc.api import SfaAPI
from sfa.plc.slices import *
from sfa.managers.aggregate_manager_pl import __get_registry_objects, __get_hostnames
@@
-26,7
+26,7
@@
from sfa.util.callids import Callids
# VINI aggregate is almost identical to PLC aggregate for many operations,
# so lets just import the methods form the PLC manager
from sfa.managers.aggregate_manager_pl import (
# VINI aggregate is almost identical to PLC aggregate for many operations,
# so lets just import the methods form the PLC manager
from sfa.managers.aggregate_manager_pl import (
-start_slice, stop_slice,
renew_slice, reset_slice, get_slices, get_ticket, slice_s
tatus)
+start_slice, stop_slice,
RenewSliver, reset_slice, ListSlices, get_ticket, SliverS
tatus)
def GetVersion(api):
def GetVersion(api):
@@
-36,8
+36,9
@@
def GetVersion(api):
'hrn':xrn.get_hrn(),
})
'hrn':xrn.get_hrn(),
})
-def delete_slice(api, xrn, creds):
- hrn, type = urn_to_hrn(xrn)
+def DeleteSliver(api, xrn, creds, call_id):
+ if Callids().already_handled(call_id): return ""
+ (hrn, type) = urn_to_hrn(xrn)
slicename = hrn_to_pl_slicename(hrn)
slices = api.plshell.GetSlices(api.plauth, {'name': slicename})
if not slices:
slicename = hrn_to_pl_slicename(hrn)
slices = api.plshell.GetSlices(api.plauth, {'name': slicename})
if not slices:
@@
-47,11
+48,13
@@
def delete_slice(api, xrn, creds):
api.plshell.DeleteSliceFromNodes(api.plauth, slicename, slice['node_ids'])
return 1
api.plshell.DeleteSliceFromNodes(api.plauth, slicename, slice['node_ids'])
return 1
-def
create_slice(api, xrn, creds, xml, users
):
+def
CreateSliver(api, xrn, creds, xml, users, call_id
):
"""
Verify HRN and initialize the slice record in PLC if necessary.
"""
"""
Verify HRN and initialize the slice record in PLC if necessary.
"""
+ if Callids().already_handled(call_id): return ""
+
hrn, type = urn_to_hrn(xrn)
peer = None
reg_objects = __get_registry_objects(xrn, creds, users)
hrn, type = urn_to_hrn(xrn)
peer = None
reg_objects = __get_registry_objects(xrn, creds, users)
@@
-85,29
+88,30
@@
def create_slice(api, xrn, creds, xml, users):
api.plshell.DeleteSliceFromNodes(api.plauth, slice.name, deleted_nodes)
network.updateSliceTags()
api.plshell.DeleteSliceFromNodes(api.plauth, slice.name, deleted_nodes)
network.updateSliceTags()
- # print network.toxml()
+ # xxx - check this holds enough data for the client to understand what's happened
+ return network.toxml()
- return True
-
-def get_rspec(api, creds, options,call_id):
- if not Callids().should_handle_call_id(call_id): return ""
+def ListResources(api, creds, options,call_id):
+ if Callids().already_handled(call_id): return ""
# get slice's hrn from options
xrn = options.get('geni_slice_urn', '')
hrn, type = urn_to_hrn(xrn)
# get slice's hrn from options
xrn = options.get('geni_slice_urn', '')
hrn, type = urn_to_hrn(xrn)
+
+ version_manager = VersionManager()
+ # get the rspec's return format from options
+ rspec_version = version_manager.get_version(options.get('rspec_version'))
+ version_string = "rspec_%s" % (rspec_version.to_string())
# look in cache first
if api.cache and not xrn:
# look in cache first
if api.cache and not xrn:
- rspec = api.cache.get(
'nodes'
)
+ rspec = api.cache.get(
version_string
)
if rspec:
if rspec:
+ api.logger.info("aggregate.ListResources: returning cached value for hrn %s"%hrn)
return rspec
return rspec
- network = ViniNetwork(api)
- if (hrn):
- if network.get_slice(api, hrn):
- network.addSlice()
-
- rspec = network.toxml()
-
+ aggregate = ViniAggregate(api, options)
+ rspec = aggregate.get_rspec(slice_xrn=xrn, version=rspec_version)
+
# cache the result
if api.cache and not xrn:
api.cache.add('nodes', rspec)
# cache the result
if api.cache and not xrn:
api.cache.add('nodes', rspec)
@@
-117,14
+121,14
@@
def get_rspec(api, creds, options,call_id):
def main():
api = SfaAPI()
"""
def main():
api = SfaAPI()
"""
- #rspec =
get_rspec
(api, None, None,)
- rspec =
get_rspec
(api, "plc.princeton.iias", None, 'vini_test')
+ #rspec =
ListResources
(api, None, None,)
+ rspec =
ListResources
(api, "plc.princeton.iias", None, 'vini_test')
print rspec
"""
f = open(sys.argv[1])
xml = f.read()
f.close()
print rspec
"""
f = open(sys.argv[1])
xml = f.read()
f.close()
-
create_slice(api, "plc.princeton.iias", xml
)
+
CreateSliver(api, "plc.princeton.iias", xml, 'call-id-iias'
)
if __name__ == "__main__":
main()
if __name__ == "__main__":
main()