#!/usr/bin/python
-from sfa.util.rspec import RSpec
import sys
import pdb
-from sfa.util.namespace import *
+import xml.dom.minidom
+
+from sfa.util.rspec import RSpec
+from sfa.util.xrn import urn_to_hrn, hrn_to_urn, get_authority
+from sfa.util.plxrn import hrn_to_pl_slicename
+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.storage import *
from sfa.util.policy import Policy
-from sfa.util.debug import log
from sfa.server.aggregate import Aggregates
from sfa.server.registry import Registries
from sfa.util.faults import *
+from sfa.util.callids import Callids
-import xml.dom.minidom
SFA_MAX_CONF_FILE = '/etc/sfa/max_allocations'
SFA_MAX_DEFAULT_RSPEC = '/etc/sfa/max_physical.xml'
registries = Registries(api)
registry = registries[api.hrn]
credential = api.getCredential()
- records = registry.resolve(credential, hrn)
+ urn = hrn_to_urn(hrn, 'slice')
+ records = registry.Resolve(urn, credential)
for record in records:
if record.get_type() in ['slice']:
slice = record.as_dict()
sites = api.plshell.GetSites(api.plauth, [login_base])
if not sites:
authority = get_authority(hrn)
- site_records = registry.resolve(credential, authority)
+ authority_urn = hrn_to_urn(authority, 'authority')
+ site_records = registry.Resolve(authority_urn, credential)
site_record = {}
if not site_records:
raise RecordNotFound(authority)
researchers = record.get('researcher', [])
for researcher in researchers:
person_record = {}
- person_records = registry.resolve(credential, researcher)
+ researcher_urn = hrn_to_urn(researcher, 'user')
+ person_records = registry.Resolve(researcher_urn, credential)
for record in person_records:
if record.get_type() in ['user']:
person_record = record
return 1
-def get_rspec(api, hrn):
+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)
# Eg. config line:
# plc.princeton.sapan vlan23,vlan45
return (ret_rspec)
-def create_slice(api, hrn, rspec_xml):
+def CreateSliver(api, xrn, creds, rspec_xml, users, call_id):
+ if Callids().already_handled(call_id): return ""
+
global topology
+ hrn = urn_to_hrn(xrn)[0]
topology = get_interface_map()
# Check if everything in rspec is either allocated by hrn
unlock_state_file()
- return True
+ # xxx - should return altered rspec
+ # with enough data for the client to understand what's happened
+ return rspec_xml
def rspec_to_allocations(rspec):
ifs = []
t = get_interface_map()
r = RSpec()
rspec_xml = open(sys.argv[1]).read()
- #get_rspec(None,'foo')
- create_slice(None, "plc.princeton.sap0", rspec_xml)
+ #ListResources(None,'foo')
+ CreateSliver(None, "plc.princeton.sap0", rspec_xml, 'call-id-sap0')
if __name__ == "__main__":
main()