- # if we are directly connected to the aggregate then we can just
- # send them the rspec. if not, then we may be connected to an sm
- # thats connected to the aggregate
- if net_hrn in aggregates:
- # send the whloe rspec to the local aggregate
- if net_hrn in [api.hrn]:
- aggregates[net_hrn].create_slice(credential, xrn, rspec, \
- origin_hrn)
- else:
- aggregates[net_hrn].create_slice(credential, xrn, \
- rspecs[net_hrn], origin_hrn)
- else:
- # lets forward this rspec to a sm that knows about the network
- for aggregate in aggregates:
- network_found = aggregates[aggregate].get_aggregates(credential, net_hrn)
- if network_found:
- aggregates[aggregate].create_slice(credential, xrn, \
- rspecs[net_hrn], origin_hrn)
-
- except:
- print >> log, "Error creating slice %(hrn)s at aggregate %(net_hrn)s" % \
- locals()
- traceback.print_exc()
+ tree = etree.parse(StringIO(rspec))
+ except etree.XMLSyntaxError:
+ message = str(sys.exc_info()[1])
+ raise InvalidRSpec(message)
+
+ relaxng_doc = etree.parse(schema)
+ relaxng = etree.RelaxNG(relaxng_doc)
+
+ if not relaxng(tree):
+ error = relaxng.error_log.last_error
+ message = "%s (line %s)" % (error.message, error.line)
+ raise InvalidRSpec(message)
+
+ # get the callers hrn
+ valid_cred = api.auth.checkCredentials(creds, 'createsliver', hrn)[0]
+ caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
+
+ # attempt to use delegated credential first
+ credential = api.getDelegatedCredential(creds)
+ if not credential:
+ credential = api.getCredential()
+ threads = ThreadManager()
+ for aggregate in api.aggregates:
+ # prevent infinite loop. Dont send request back to caller
+ # unless the caller is the aggregate's SM
+ if caller_hrn == aggregate and aggregate != api.hrn:
+ continue
+
+ # Just send entire RSpec to each aggregate
+ server = api.aggregates[aggregate]
+ threads.run(server.CreateSliver, xrn, credential, rspec, users)
+
+ results = threads.get_results()
+ merged_rspec = merge_rspecs(results)
+ return merged_rspec
+
+def renew_slice(api, xrn, creds, expiration_time):
+ # get the callers hrn
+ valid_cred = api.auth.checkCredentials(creds, 'renewesliver', hrn)[0]
+ caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
+
+ # attempt to use delegated credential first
+ credential = api.getDelegatedCredential(creds)
+ if not credential:
+ credential = api.getCredential()
+ threads = ThreadManager()
+ for aggregate in api.aggregates:
+ # prevent infinite loop. Dont send request back to caller
+ # unless the caller is the aggregate's SM
+ if caller_hrn == aggregate and aggregate != api.hrn:
+ continue
+
+ server = api.aggregates[aggregate]
+ threads.run(server.RenewSliver, xrn, credential, expiration_time)
+ threads.get_results()