-### $Id: slices.py 15842 2009-11-22 09:56:13Z anil $
-### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/plc/slices.py $
-
import datetime
import time
import traceback
import sys
from types import StringTypes
-from sfa.util.namespace import *
+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.plc.api import SfaAPI
from sfa.plc.slices import *
from sfa.managers.aggregate_manager_pl import __get_registry_objects, __get_hostnames
+from sfa.util.version import version_core
+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 (
-start_slice, stop_slice, renew_slice, reset_slice, get_slices, get_ticket)
-
+start_slice, stop_slice, renew_slice, reset_slice, get_slices, get_ticket, slice_status)
-def get_version():
- version = {}
- version['geni_api'] = 1
- version['sfa'] = 1
- return version
-
-def slice_status(api, slice_xrn, creds):
- result = {}
- result['geni_urn'] = slice_xrn
- result['geni_status'] = 'unknown'
- result['geni_resources'] = {}
- return result
+def GetVersion(api):
+ xrn=Xrn(api.hrn)
+ return version_core({'interface':'aggregate',
+ 'testbed':'myplc.vini',
+ 'hrn':xrn.get_hrn(),
+ })
def delete_slice(api, xrn, creds):
hrn, type = urn_to_hrn(xrn)
api.plshell.DeleteSliceFromNodes(api.plauth, slicename, slice['node_ids'])
return 1
-def create_slice(api, xrn, creds, xml, users):
+def create_slice(api, xrn, creds, xml, users, call_id):
"""
Verify HRN and initialize the slice record in PLC if necessary.
"""
+ if Callids().already_handled(call_id): return False
+
hrn, type = urn_to_hrn(xrn)
peer = None
- reg_objects = __get_registry_objects(slice_xrn, creds, users)
+ reg_objects = __get_registry_objects(xrn, creds, users)
slices = Slices(api)
peer = slices.get_peer(hrn)
sfa_peer = slices.get_sfa_peer(hrn)
return True
-def get_rspec(api, creds, options):
+def get_rspec(api, creds, options,call_id):
+ if Callids().already_handled(call_id): return ""
# get slice's hrn from options
- xrn = options.get('geni_slice_urn', None)
+ xrn = options.get('geni_slice_urn', '')
hrn, type = urn_to_hrn(xrn)
# look in cache first
def main():
api = SfaAPI()
"""
- #rspec = get_rspec(api, None, None)
- rspec = get_rspec(api, "plc.princeton.iias", None)
+ #rspec = get_rspec(api, None, None,)
+ rspec = get_rspec(api, "plc.princeton.iias", None, 'vini_test')
print rspec
"""
f = open(sys.argv[1])
xml = f.read()
f.close()
- create_slice(api, "plc.princeton.iias", xml)
+ create_slice(api, "plc.princeton.iias", xml, 'call-id-iias')
if __name__ == "__main__":
main()