X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmanagers%2Faggregate_manager_max.py;h=f289e7d061ee0f4face1005d731cc3b8f5d4b194;hb=4ff67c801ceeb1d0c7ca2863c2b7bf8152182b8f;hp=e4ff71a7388c8059ee2ea69bea0c7fdfe902bd5e;hpb=c6808303b7564ed7ba3bc888c4f6e56167a83e2a;p=sfa.git diff --git a/sfa/managers/aggregate_manager_max.py b/sfa/managers/aggregate_manager_max.py index e4ff71a7..f289e7d0 100644 --- a/sfa/managers/aggregate_manager_max.py +++ b/sfa/managers/aggregate_manager_max.py @@ -1,20 +1,23 @@ #!/usr/bin/python -from sfa.util.rspec import RSpec import sys import pdb -from sfa.util.misc 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' @@ -22,15 +25,15 @@ SFA_MAX_CANNED_RSPEC = '/etc/sfa/max_physical_canned.xml' topology = {} -class GeniOutOfResource(GeniFault): +class SfaOutOfResource(SfaFault): def __init__(self, interface): faultString = "Interface " + interface + " not available" - GeniFault.__init__(self, 100, faultString, '') + SfaFault.__init__(self, 100, faultString, '') -class GeniNoPairRSpec(GeniFault): +class SfaNoPairRSpec(SfaFault): def __init__(self, interface, interface2): faultString = "Interface " + interface + " should be paired with " + interface2 - GeniFault.__init__(self, 100, faultString, '') + SfaFault.__init__(self, 100, faultString, '') # Returns a mapping from interfaces to the nodes they lie on and their peer interfaces # i -> node,i_peer @@ -140,14 +143,15 @@ def alloc_nodes(api,hrn, requested_ifs): # Taken from slices.py def create_slice_max_aggregate(api, hrn, nodes): - # Get the slice record from geni + # Get the slice record global topology topology = get_interface_map() slice = {} 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() @@ -164,7 +168,8 @@ def create_slice_max_aggregate(api, hrn, nodes): 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) @@ -193,7 +198,8 @@ def create_slice_max_aggregate(api, hrn, nodes): 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 @@ -248,7 +254,11 @@ def create_slice_max_aggregate(api, hrn, nodes): 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 @@ -261,8 +271,11 @@ def get_rspec(api, hrn): 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 False + global topology + hrn = urn_to_hrn(xrn)[0] topology = get_interface_map() # Check if everything in rspec is either allocated by hrn @@ -288,9 +301,9 @@ def create_slice(api, hrn, rspec_xml): for a in requested_interfaces: if (a not in current_hrn_interfaces and a in current_interfaces): - raise GeniOutOfResource(a) + raise SfaOutOfResource(a) if (topology[a][1] not in requested_interfaces): - raise GeniNoPairRSpec(a,topology[a][1]) + raise SfaNoPairRSpec(a,topology[a][1]) # Request OK # Allocations to delete @@ -324,8 +337,8 @@ def main(): 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()