return
- @register_command("slice_hrn","")
+ @register_command("slice_hrn [<sliver_urn> ... <sliver_urn>]","")
def delete(self, options, args):
"""
- de-allocate and de-provision all or named slivers of the slice (Delete)
+ de-allocate and de-provision all or named slivers of the named slice (Delete)
"""
server = self.sliceapi()
slice_hrn = args[0]
slice_urn = hrn_to_urn(slice_hrn, 'slice')
+ if len(args) > 1:
+ # we have sliver urns
+ sliver_urns = args[1:]
+ else:
+ # we provision all the slivers of the slice
+ sliver_urns = [slice_urn]
+
# creds
slice_cred = self.slice_credential(slice_hrn)
creds = [slice_cred]
api_options ['call_id'] = unique_call_id()
if options.show_credential:
show_credentials(creds)
- result = server.Delete([slice_urn], creds, *self.ois(server, api_options ) )
+ result = server.Delete(sliver_urns, creds, *self.ois(server, 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)
return value
- @register_command("slice_hrn","")
+ @register_command("slice_hrn [<sliver_urn> ... <sliver_urn>]","")
def provision(self, options, args):
"""
- provision already allocated resources of named slice (Provision)
+ provision all or named already allocated slivers of the named slice (Provision)
"""
server = self.sliceapi()
server_version = self.get_cached_server_version(server)
slice_hrn = args[0]
slice_urn = Xrn(slice_hrn, type='slice').get_urn()
+ if len(args) > 1:
+ # we have sliver urns
+ sliver_urns = args[1:]
+ else:
+ # we provision all the slivers of the slice
+ sliver_urns = [slice_urn]
# credentials
creds = [self.slice_credential(slice_hrn)]
users = pg_users_arg(user_records)
api_options['geni_users'] = users
- result = server.Provision([slice_urn], creds, api_options)
+ result = server.Provision(sliver_urns, 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)
@register_command("slice_hrn","")
def status(self, options, args):
"""
- retrieve the status of the slivers belonging to tne named slice (Status)
+ retrieve the status of the slivers belonging to the named slice (Status)
"""
server = self.sliceapi()
# Thierry: seemed to be missing
return value
- @register_command("slice_hrn action","")
+ @register_command("slice_hrn [<sliver_urn> ... <sliver_urn>] action","")
def action(self, options, args):
"""
- Perform the named operational action on these slivers
+ Perform the named operational action on all or named slivers of the named slice
"""
server = self.sliceapi()
api_options = {}
# slice urn
slice_hrn = args[0]
- action = args[1]
- slice_urn = Xrn(slice_hrn, type='slice').get_urn()
+ slice_urn = Xrn(slice_hrn, type='slice').get_urn()
+ if len(args) > 2:
+ # we have sliver urns
+ sliver_urns = args[1:-1]
+ else:
+ # we provision all the slivers of the slice
+ sliver_urns = [slice_urn]
+ action = args[-1]
# cred
slice_cred = self.slice_credential(args[0])
creds = [slice_cred]
delegated_cred = self.delegate_cred(slice_cred, get_authority(self.authority))
creds.append(delegated_cred)
- result = server.PerformOperationalAction([slice_urn], creds, action , api_options)
+ result = server.PerformOperationalAction(sliver_urns, creds, action , 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)
print value
return value
- @register_command("slice_hrn time","")
+ @register_command("slice_hrn [<sliver_urn> ... <sliver_urn>] time","")
def renew(self, options, args):
"""
- renew slice (RenewSliver)
+ renew slice (Renew)
"""
server = self.sliceapi()
- if len(args) != 2:
+ if len(args) < 2:
self.print_help()
sys.exit(1)
- [ slice_hrn, input_time ] = args
- # slice urn
- slice_urn = hrn_to_urn(slice_hrn, 'slice')
+ slice_hrn = args[0]
+ slice_urn = Xrn(slice_hrn, type='slice').get_urn()
+
+ if len(args) > 2:
+ # we have sliver urns
+ sliver_urns = args[1:-1]
+ else:
+ # we provision all the slivers of the slice
+ sliver_urns = [slice_urn]
+ input_time = args[-1]
+
# time: don't try to be smart on the time format, server-side will
# creds
slice_cred = self.slice_credential(args[0])
api_options['call_id']=unique_call_id()
if options.show_credential:
show_credentials(creds)
- result = server.Renew([slice_urn], creds, input_time, *self.ois(server,api_options))
+ result = server.Renew(sliver_urns, creds, input_time, *self.ois(server,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)
def sliver_to_slice_xrn(self, xrn):
sliver_id_parts = Xrn(xrn).get_sliver_id_parts()
- filter = {}
+ filter = {'peer_id': None}
try:
filter['slice_id'] = int(sliver_id_parts[0])
except ValueError:
site_hrn = '.'.join(slice_cred_hrn.split('.')[:-1])
slice_part = slice_cred_hrn.split('.')[-1]
if top_auth_hrn == self.hrn:
- login_base = slice_hrn.split('.')[-2][:12]
+ login_base = slice_cred_hrn.split('.')[-2][:12]
else:
login_base = hash_loginbase(site_hrn)
sfa_peer = slices.get_sfa_peer(xrn.get_hrn())
slice_record=None
users = options.get('geni_users', [])
+
if users:
slice_record = users[0].get('slice_record', {})
slices = PlSlices(self)
aggregate = PlAggregate(self)
slivers = aggregate.get_slivers(urns)
- slice = slivers[0]
- sfa_peer = slices.get_sfa_peer(slice['hrn'])
- users = options.get('geni_users', [])
- persons = slices.verify_persons(slice['hrn'], slice, users, sfa_peer, options=options)
- # update sliver allocation states and set them to geni_provisioned
- sliver_ids = [sliver['sliver_id'] for sliver in slivers]
- dbsession=self.api.dbsession()
- SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',dbsession)
+ if not slivers:
+ sliver_id_parts = Xrn(urns[0]).get_sliver_id_parts()
+ filter = {}
+ try:
+ filter['slice_id'] = int(sliver_id_parts[0])
+ except ValueError:
+ filter['name'] = sliver_id_parts[0]
+ slices = self.shell.GetSlices(filter,['hrn'])
+ if not slices:
+ raise Forbidden("Unable to locate slice record for sliver: %s" % xrn)
+ slice = slices[0]
+ slice_urn = hrn_to_urn(slice['hrn'], type='slice')
+ urns = [slice_urn]
+ else:
+ slice_id = slivers[0]['slice_id']
+ slice_hrn = self.shell.GetSliceHrn(slice_id)
+ slice = self.shell.GetSlices({'slice_id': slice_id})[0]
+ slice['hrn'] = slice_hrn
+ sfa_peer = slices.get_sfa_peer(slice['hrn'])
+ users = options.get('geni_users', [])
+ persons = slices.verify_persons(slice['hrn'], slice, users, sfa_peer, options=options)
+ # update sliver allocation states and set them to geni_provisioned
+ sliver_ids = [sliver['sliver_id'] for sliver in slivers]
+ dbsession=self.api.dbsession()
+ SliverAllocation.set_allocations(sliver_ids, 'geni_provisioned',dbsession)
+
version_manager = VersionManager()
rspec_version = version_manager.get_version(options['geni_rspec_version'])
return self.describe(urns, rspec_version, options=options)
sliver_ids.append(sliver['sliver_id'])
# leases
- leases = self.shell.GetLeases({'name': slice_name})
+ leases = self.shell.GetLeases({'name': slice_name, 'node_id': node_ids})
leases_ids = [lease['lease_id'] for lease in leases ]
slice_hrn = self.shell.GetSliceHrn(int(slice_id))