X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fsfi.py;h=e55753727ad47afc9643bab2fd6e2c77171113ca;hb=38a5b91de2913a5a5501b3b5a74ec01e3b3be3b7;hp=2f47839d068577cef84885769b28f9069cdb6201;hpb=c57557c0d8d65c7343bca9029dc41ce130e6fc64;p=sfa.git diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index 2f47839d..e5575372 100644 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -387,13 +387,15 @@ class Sfi: help='how myslice config variables as well') if command in ("version"): - parser.add_option("-R","--registry-version", - action="store_true", dest="version_registry", default=False, - help="probe registry version instead of sliceapi") parser.add_option("-l","--local", action="store_true", dest="version_local", default=False, help="display version of the local client") + if command in ("version", "trusted"): + parser.add_option("-R","--registry_interface", + action="store_true", dest="registry_interface", default=False, + help="target the registry interface instead of slice interface") + if command in ("add", "update"): parser.add_option('-x', '--xrn', dest='xrn', metavar='', help='object hrn/urn (mandatory)') parser.add_option('-t', '--type', dest='type', metavar='', help='object type', default=None) @@ -878,7 +880,7 @@ use this if you mean an authority instead""") if options.version_local: version=version_core() else: - if options.version_registry: + if options.registry_interface: server=self.registry() else: server = self.sliceapi() @@ -1095,7 +1097,7 @@ use this if you mean an authority instead""") 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['geni_rspec'], options.file) + save_rspec_to_file(value, options.file) if (self.options.raw is None) and (options.file is None): display_rspec(value, options.format) @@ -1142,10 +1144,10 @@ use this if you mean an authority instead""") return - @register_command("slice_hrn","") + @register_command("slice_hrn [ ... ]","") 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() @@ -1153,6 +1155,13 @@ use this if you mean an authority instead""") 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] @@ -1162,7 +1171,7 @@ use this if you mean an authority instead""") 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) @@ -1227,15 +1236,21 @@ use this if you mean an authority instead""") return value - @register_command("slice_hrn","") + @register_command("slice_hrn [ ... ]","") 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)] @@ -1276,7 +1291,7 @@ use this if you mean an authority instead""") 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) @@ -1289,7 +1304,7 @@ use this if you mean an authority instead""") @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() @@ -1315,17 +1330,23 @@ use this if you mean an authority instead""") # Thierry: seemed to be missing return value - @register_command("slice_hrn action","") + @register_command("slice_hrn [ ... ] 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] @@ -1333,7 +1354,7 @@ use this if you mean an authority instead""") 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) @@ -1341,18 +1362,26 @@ use this if you mean an authority instead""") print value return value - @register_command("slice_hrn time","") + @register_command("slice_hrn [ ... ] 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]) @@ -1362,7 +1391,7 @@ use this if you mean an authority instead""") 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) @@ -1616,7 +1645,15 @@ $ sfi m -b http://mymanifold.foo.com:7080/ """ return the trusted certs at this interface (get_trusted_certs) """ - trusted_certs = self.registry().get_trusted_certs() + if options.registry_interface: + server=self.registry() + else: + server = self.sliceapi() + cred = self.my_authority_credential_string() + trusted_certs = server.get_trusted_certs(cred) + if not options.registry_interface: + trusted_certs = ReturnValue.get_value(trusted_certs) + for trusted_cert in trusted_certs: print "\n===========================================================\n" gid = GID(string=trusted_cert)