from sfa.client.candidates import Candidates
from sfa.client.manifolduploader import ManifoldUploader
-CM_PORT=12346
+CM_PORT = 12346
+DEFAULT_RSPEC_VERSION = "GENI 3"
from sfa.client.common import optparse_listvalue_callback, optparse_dictvalue_callback, \
terminal_render, filter_records
def credential_printable (cred):
- credential=Credential(cred=cred)
+ credential = Credential(cred=cred)
result=""
- result += credential.get_summary_tostring()
+ result += credential.pretty_cred()
result += "\n"
rights = credential.get_privileges()
result += "type=%s\n" % credential.type
result += "version=%s\n" % credential.version
- result += "rights=%s\n"%rights
+ result += "rights=%s\n" % rights
return result
def show_credentials (cred_s):
return re.match(good_ssh_key, key, re.IGNORECASE)
# load methods
+def normalize_type (type):
+ if type.startswith('au'):
+ return 'authority'
+ elif type.startswith('us'):
+ return 'user'
+ elif type.startswith('sl'):
+ return 'slice'
+ elif type.startswith('no'):
+ return 'node'
+ else:
+ return None
+
def load_record_from_opts(options):
record_dict = {}
+ if hasattr(options, 'type'):
+ options.type = normalize_type(options.type)
if hasattr(options, 'xrn') and options.xrn:
if hasattr(options, 'type') and options.type:
xrn = Xrn(options.xrn, options.type)
record_dict['reg-researchers'] = options.reg_researchers
if hasattr(options, 'email') and options.email:
record_dict['email'] = options.email
+ # authorities can have a name for standalone deployment
+ if hasattr(options, 'name') and options.name:
+ record_dict['name'] = options.name
if hasattr(options, 'reg_pis') and options.reg_pis:
record_dict['reg-pis'] = options.reg_pis
parser.add_option('-x', '--xrn', dest='xrn', metavar='<xrn>', help='object hrn/urn (mandatory)')
parser.add_option('-t', '--type', dest='type', metavar='<type>', help='object type', default=None)
parser.add_option('-e', '--email', dest='email', default="", help="email (mandatory for users)")
+ parser.add_option('-n', '--name', dest='name', default="", help="name (optional for authorities)")
parser.add_option('-k', '--key', dest='key', metavar='<key>', help='public key string or file',
default=None)
parser.add_option('-s', '--slices', dest='slices', metavar='<slices>', help='Set/replace slice xrns',
help="call Resolve without the 'details' option")
if canonical in ("resources", "describe"):
# rspec version
- parser.add_option("-r", "--rspec-version", dest="rspec_version", default="GENI 3",
- help="schema type and version of resulting RSpec")
+ parser.add_option("-r", "--rspec-version", dest="rspec_version", default=DEFAULT_RSPEC_VERSION,
+ help="schema type and version of resulting RSpec (default:{})".format(DEFAULT_RSPEC_VERSION))
# disable/enable cached rspecs
parser.add_option("-c", "--current", dest="current", default=False,
action="store_true",
# init self-signed cert, user credentials and gid
def bootstrap (self):
+ if self.options.verbose:
+ self.logger.info("Initializing SfaClientBootstrap with {}".format(self.reg_url))
client_bootstrap = SfaClientBootstrap (self.user, self.reg_url, self.options.sfi_dir,
logger=self.logger)
# if -k is provided, use this to initialize private key
if options:
record_dict.update(load_record_from_opts(options).todict())
# at the very least we need 'type' here
- if 'type' not in record_dict:
+ if 'type' not in record_dict or record_dict['type'] is None:
self.print_help()
sys.exit(1)
elif record_dict['type'] in ['node']:
cred = self.my_authority_credential_string()
else:
- raise "unknown record type" + record_dict['type']
+ raise Exception("unknown record type {}".format(record_dict['type']))
if options.show_credential:
show_credentials(cred)
update = self.registry().Update(record_dict, cred)
# ==================================================================
# show rspec for named slice
- @declare_command("","")
+ @declare_command("","",['discover'])
def resources(self, options, args):
"""
discover available resources (ListResources)