action="store_true", dest="version_local", default=False,
help="display version of the local client")
- if canonical in ("version", "trusted"):
+ if canonical in ("version", "trusted", "introspect"):
parser.add_option("-R","--registry_interface",
action="store_true", dest="registry_interface", default=False,
help="target the registry interface instead of slice interface")
@declare_command("", "")
def config (self, options, args):
- "Display contents of current config"
+ """
+ Display contents of current config
+ """
+ if len(args) != 0:
+ self.print_help()
+ sys.exit(1)
+
print("# From configuration file {}".format(self.config_file))
flags = [ ('sfi', [ ('registry', 'reg_url'),
('auth', 'authority'),
def version(self, options, args):
"""
display an SFA server version (GetVersion)
- or version information about sfi itself
+ or version information about sfi itself
"""
+ if len(args) != 0:
+ self.print_help()
+ sys.exit(1)
+
if options.version_local:
version = version_core()
else:
if len(args) != 1:
self.print_help()
sys.exit(1)
+
hrn = args[0]
opts = {}
if options.recursive:
if len(args) != 1:
self.print_help()
sys.exit(1)
+
hrn = args[0]
# explicitly require Resolve to run in details mode
resolve_options = {}
# this historically was named 'add', it is now 'register' with an alias for legacy
@declare_command("[xml-filename]", "", ['add'])
def register(self, options, args):
- """create new record in registry (Register)
- from command line options (recommended)
- old-school method involving an xml file still supported"""
+ """
+ create new record in registry (Register)
+ from command line options (recommended)
+ old-school method involving an xml file still supported
+ """
+ if len(args) > 1:
+ self.print_help()
+ sys.exit(1)
auth_cred = self.my_authority_credential_string()
if options.show_credential:
show_credentials(auth_cred)
record_dict = {}
- if len(args) > 1:
- self.print_help()
- sys.exit(1)
if len(args) == 1:
try:
record_filepath = args[0]
@declare_command("[xml-filename]", "")
def update(self, options, args):
- """update record into registry (Update)
- from command line options (recommended)
- old-school method involving an xml file still supported"""
+ """
+ update record into registry (Update)
+ from command line options (recommended)
+ old-school method involving an xml file still supported
+ """
+ if len(args) > 1:
+ self.print_help()
+ sys.exit(1)
+
record_dict = {}
- if len(args) > 0:
+ if len(args) == 1:
record_filepath = args[0]
rec_file = self.get_record_file(record_filepath)
record_dict.update(load_record_from_file(rec_file).record_to_dict())
@declare_command("hrn", "")
def remove(self, options, args):
- "remove registry record by name (Remove)"
+ """
+ remove registry record by name (Remove)
+ """
auth_cred = self.my_authority_credential_string()
if len(args) != 1:
self.print_help()
sys.exit(1)
+
hrn = args[0]
type = options.type
if type in ['all']:
"""
discover available resources (ListResources)
"""
- server = self.sliceapi()
+ if len(args) != 0:
+ self.print_help()
+ sys.exit(1)
+ server = self.sliceapi()
# set creds
creds = [self.my_credential]
if options.delegate:
api_options['cached'] = False
else:
api_options['cached'] = True
- if options.rspec_version:
- version_manager = VersionManager()
- server_version = self.get_cached_server_version(server)
- if 'sfa' in server_version:
- # just request the version the client wants
- api_options['geni_rspec_version'] = version_manager.get_version(options.rspec_version).to_dict()
- else:
- api_options['geni_rspec_version'] = {'type': options.rspec_version}
- else:
- api_options['geni_rspec_version'] = {'type': 'geni', 'version': '3'}
+ version_manager = VersionManager()
+ api_options['geni_rspec_version'] = version_manager.get_version(options.rspec_version).to_dict()
list_resources = server.ListResources (creds, api_options)
value = ReturnValue.get_value(list_resources)
def describe(self, options, args):
"""
shows currently allocated/provisioned resources
- of the named slice or set of slivers (Describe)
+ of the named slice or set of slivers (Describe)
"""
- server = self.sliceapi()
+ if len(args) != 1:
+ self.print_help()
+ sys.exit(1)
+ server = self.sliceapi()
# set creds
creds = [self.slice_credential(args[0])]
if options.delegate:
"""
de-allocate and de-provision all or named slivers of the named slice (Delete)
"""
- server = self.sliceapi()
+ if len(args) == 0:
+ self.print_help()
+ sys.exit(1)
+ server = self.sliceapi()
# slice urn
slice_hrn = args[0]
slice_urn = hrn_to_urn(slice_hrn, 'slice')
"""
allocate resources to the named slice (Allocate)
"""
- server = self.sliceapi()
- server_version = self.get_cached_server_version(server)
if len(args) != 2:
self.print_help()
sys.exit(1)
+
+ server = self.sliceapi()
+ server_version = self.get_cached_server_version(server)
slice_hrn = args[0]
rspec_file = self.get_rspec_file(args[1])
"""
provision all or named already allocated slivers of the named slice (Provision)
"""
+ if len(args) == 0:
+ self.print_help()
+ sys.exit(1)
+
server = self.sliceapi()
server_version = self.get_cached_server_version(server)
slice_hrn = args[0]
"""
retrieve the status of the slivers belonging to the named slice (Status)
"""
- server = self.sliceapi()
+ if len(args) != 1:
+ self.print_help()
+ sys.exit(1)
+ server = self.sliceapi()
# slice urn
slice_hrn = args[0]
slice_urn = hrn_to_urn(slice_hrn, 'slice')
"""
Perform the named operational action on all or named slivers of the named slice
"""
+ if len(args) == 0:
+ self.print_help()
+ sys.exit(1)
+
server = self.sliceapi()
api_options = {}
# slice urn
"""
renew slice (Renew)
"""
- server = self.sliceapi()
if len(args) < 2:
self.print_help()
sys.exit(1)
+
+ server = self.sliceapi()
slice_hrn = args[0]
slice_urn = Xrn(slice_hrn, type='slice').get_urn()
"""
shutdown named slice (Shutdown)
"""
+ if len(args) != 1:
+ self.print_help()
+ sys.exit(1)
+
server = self.sliceapi()
# slice urn
slice_hrn = args[0]
if len(args) < 1:
self.print_help()
sys.exit(1)
+
target_hrn = args[0]
my_gid_string = open(self.client_bootstrap.my_gid()).read()
gid = self.registry().CreateGid(self.my_credential_string, target_hrn, my_gid_string)
if len(args) != 1:
self.print_help()
sys.exit(1)
+
to_hrn = args[0]
# support for several delegations in the same call
# so first we gather the things to do
* refresh all your credentials (you as a user and pi, your slices)
* upload them to the manifold backend server
for last phase, sfi_config is read to look for the [myslice] section,
- and namely the 'backend', 'delegate' and 'user' settings"""
+ and namely the 'backend', 'delegate' and 'user' settings
+ """
##########
- if len(args)>0:
+ if len(args) > 0:
self.print_help()
sys.exit(1)
# enable info by default
print("Certificate:\n{}\n\n".format(trusted_cert))
# xxx should analyze result
return 0
+
+ @declare_command("", "")
+ def introspect(self, options, args):
+ """
+ If remote server supports XML-RPC instrospection API, allows
+ to list supported methods
+ """
+ if options.registry_interface:
+ server = self.registry()
+ else:
+ server = self.sliceapi()
+ results = server.serverproxy.system.listMethods()
+ # at first sight a list here means it's fine,
+ # and a dict suggests an error (no support for introspection?)
+ if isinstance(results, list):
+ results = [ name for name in results if 'system.' not in name ]
+ results.sort()
+ print("== methods supported at {}".format(server.url))
+ if 'Discover' in results:
+ print("== has support for 'Discover' - most likely a v3")
+ else:
+ print("== has no support for 'Discover' - most likely a v2")
+ for name in results:
+ print(name)
+ else:
+ print("Got return of type {}, expected a list".format(type(results)))
+ print("This suggests the remote end does not support introspection")
+ print(results)