- if peer:
- self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
-
- self.api.plshell.AddSliceToNodes(self.api.plauth, slicename, added_nodes)
-
- # Add recognized slice tags
- for node_name in node_names:
- node = nodes[node_name]
- for slice_tag in node.keys():
- value = node[slice_tag]
- if (isinstance(value, list)):
- value = value[0]
-
- self.api.plshell.AddSliceTag(self.api.plauth, slicename, slice_tag, value, node_name)
-
- self.api.plshell.DeleteSliceFromNodes(self.api.plauth, slicename, deleted_nodes)
- if peer:
- self.api.plshell.BindObjectToPeer(self.api.plauth, 'slice', slice['slice_id'], peer, slice['peer_slice_id'])
-
- return 1
-
- def create_slice_smgr(self, hrn, rspec):
- spec = RSpec()
- tempspec = RSpec()
- spec.parseString(rspec)
- slicename = hrn_to_pl_slicename(hrn)
- specDict = spec.toDict()
- if specDict.has_key('RSpec'): specDict = specDict['RSpec']
- if specDict.has_key('start_time'): start_time = specDict['start_time']
- else: start_time = 0
- if specDict.has_key('end_time'): end_time = specDict['end_time']
- else: end_time = 0
-
- rspecs = {}
- aggregates = Aggregates(self.api)
- credential = self.api.getCredential()
-
- # split the netspecs into individual rspecs
- netspecs = spec.getDictsByTagName('NetSpec')
- for netspec in netspecs:
- net_hrn = netspec['name']
- resources = {'start_time': start_time, 'end_time': end_time, 'networks': netspec}
- resourceDict = {'RSpec': resources}
- tempspec.parseDict(resourceDict)
- rspecs[net_hrn] = tempspec.toxml()
-
- # send each rspec to the appropriate aggregate/sm
- caller_cred = self.caller_cred
- for net_hrn in rspecs:
- try:
- # 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 [self.api.hrn]:
- try:
- request_hash = None
- aggregates[net_hrn].create_slice(credential, hrn, rspec, request_hash, caller_cred)
- except:
- arg_list = [credential,hrn,rspec]
- request_hash = self.api.key.compute_hash(arg_list)
- aggregates[net_hrn].create_slice(credential, hrn, rspec, request_hash, caller_cred)
- else:
- try:
- request_hash = None
- aggregates[net_hrn].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred)
- except:
- arg_list = [credential,hrn,rspecs[net_hrn]]
- request_hash = self.api.key.compute_hash(arg_list)
- aggregates[net_hrn].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred)
- else:
- # lets forward this rspec to a sm that knows about the network
- arg_list = [credential, net_hrn]
- request_hash = self.api.compute_hash(arg_list)
- for aggregate in aggregates:
- try:
- network_found = aggregates[aggregate].get_aggregates(credential, net_hrn)
- except:
- network_found = aggregates[aggregate].get_aggregates(credential, net_hrn, request_hash)
- if network_networks:
- try:
- request_hash = None
- aggregates[aggregate].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred)
- except:
- arg_list = [credential, hrn, rspecs[net_hrn]]
- request_hash = self.api.key.compute_hash(arg_list)
- aggregates[aggregate].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred)
-
- except:
- print >> log, "Error creating slice %(hrn)s at aggregate %(net_hrn)s" % locals()
- traceback.print_exc()
- return 1