+ return value
+
+ def allocate(self, options, args):
+ server = self.sliceapi()
+ server_version = self.get_cached_server_version(server)
+ slice_hrn = args[0]
+ slice_urn = Xrn(slice_hrn, type='slice').get_urn()
+
+ # credentials
+ creds = [self.slice_credential(slice_hrn)]
+
+ delegated_cred = None
+ if server_version.get('interface') == 'slicemgr':
+ # delegate our cred to the slice manager
+ # do not delegate cred to slicemgr...not working at the moment
+ pass
+ #if server_version.get('hrn'):
+ # delegated_cred = self.delegate_cred(slice_cred, server_version['hrn'])
+ #elif server_version.get('urn'):
+ # delegated_cred = self.delegate_cred(slice_cred, urn_to_hrn(server_version['urn']))
+
+ if options.show_credential:
+ show_credentials(creds)
+
+ # rspec
+ rspec_file = self.get_rspec_file(args[1])
+ rspec = open(rspec_file).read()
+ api_options = {}
+ api_options ['call_id'] = unique_call_id()
+ result = server.Allocate(slice_urn, creds, rspec, api_options)
+ value = ReturnValue.get_value(result)
+ if self.options.raw:
+ save_raw_to_file(result, self.options.raw, self.options.rawformat, self.options.rawbanner)
+ if options.file is not None:
+ save_rspec_to_file (value, options.file)
+ if (self.options.raw is None) and (options.file is None):
+ print value
+
+ return value
+
+
+ def provision(self, options, args):
+ server = self.sliceapi()
+ server_version = self.get_cached_server_version(server)
+ slice_hrn = args[0]
+ slice_urn = Xrn(slice_hrn, type='slice').get_urn()
+
+ # credentials
+ creds = [self.slice_credential(slice_hrn)]
+ delegated_cred = None
+ if server_version.get('interface') == 'slicemgr':
+ # delegate our cred to the slice manager
+ # do not delegate cred to slicemgr...not working at the moment
+ pass
+ #if server_version.get('hrn'):
+ # delegated_cred = self.delegate_cred(slice_cred, server_version['hrn'])
+ #elif server_version.get('urn'):
+ # delegated_cred = self.delegate_cred(slice_cred, urn_to_hrn(server_version['urn']))
+
+ if options.show_credential:
+ show_credentials(creds)
+
+ api_options = {}
+ api_options ['call_id'] = unique_call_id()
+
+ # set the requtested rspec version
+ version_manager = VersionManager()
+ rspec_version = version_manager._get_version('geni', '3.0').to_dict()
+ api_options['geni_rspec_version'] = rspec_version
+
+ # users
+ # need to pass along user keys to the aggregate.
+ # users = [
+ # { urn: urn:publicid:IDN+emulab.net+user+alice
+ # keys: [<ssh key A>, <ssh key B>]
+ # }]
+ users = []
+ slice_records = self.registry().Resolve(slice_urn, [self.my_credential_string])
+ if slice_records and 'researcher' in slice_records[0] and slice_records[0]['researcher']!=[]:
+ slice_record = slice_records[0]
+ user_hrns = slice_record['researcher']
+ user_urns = [hrn_to_urn(hrn, 'user') for hrn in user_hrns]
+ user_records = self.registry().Resolve(user_urns, [self.my_credential_string])
+ users = pg_users_arg(user_records)
+
+ api_options['geni_users'] = users
+ result = server.Provision([slice_urn], creds, api_options)
+ value = ReturnValue.get_value(result)
+ if self.options.raw:
+ save_raw_to_file(result, self.options.raw, self.options.rawformat, self.options.rawbanner)
+ if options.file is not None:
+ save_rspec_to_file (value, options.file)
+ if (self.options.raw is None) and (options.file is None):
+ print value
+ return value
+