record_dict['reg-researchers'] = options.reg_researchers
if hasattr(options, 'email') and options.email:
record_dict['email'] = options.email
- if hasattr(options, 'pis') and options.pis:
- record_dict['pi'] = options.pis
+ if hasattr(options, 'reg_pis') and options.reg_pis:
+ record_dict['reg-pis'] = options.reg_pis
# handle extra settings
record_dict.update(options.extras)
return new_method
return wrap
+
+def remove_none_fields (record):
+ none_fields=[ k for (k,v) in record.items() if v is None ]
+ for k in none_fields: del record[k]
+
##########
class Sfi:
parser.add_option('-r', '--researchers', dest='reg_researchers', metavar='<researchers>',
help='Set/replace slice researchers - use -r none to reset', default=None, type="str", action='callback',
callback=optparse_listvalue_callback)
- parser.add_option('-p', '--pis', dest='pis', metavar='<PIs>', help='Set/replace Principal Investigators/Project Managers',
+ parser.add_option('-p', '--pis', dest='reg_pis', metavar='<PIs>', help='Set/replace Principal Investigators/Project Managers',
default='', type="str", action='callback', callback=optparse_listvalue_callback)
parser.add_option ('-X','--extra',dest='extras',default={},type='str',metavar="<EXTRA_ASSIGNS>",
action="callback", callback=optparse_dictvalue_callback, nargs=1,
metavar="slice_hrn", help="delegate cred. for slice HRN")
parser.add_option("-a", "--auths", dest='delegate_auths',action='append',default=[],
metavar='auth_hrn', help="delegate cred for auth HRN")
- # this primarily is a shorthand for -a my_hrn
+ # this primarily is a shorthand for -A my_hrn^
parser.add_option("-p", "--pi", dest='delegate_pi', default=None, action='store_true',
- help="delegate your PI credentials, so s.t. like -a your_hrn^")
+ help="delegate your PI credentials, so s.t. like -A your_hrn^")
parser.add_option("-A","--to-authority",dest='delegate_to_authority',action='store_true',default=False,
help="""by default the mandatory argument is expected to be a user,
use this if you mean an authority instead""")
# don't translate into an object, as this would possibly distort
# user-provided data; e.g. add an 'email' field to Users
- if record_dict['type'] == "user":
+ if record_dict['type'] in ['user']:
if record_dict['hrn'] == self.user:
cred = self.my_credential_string
else:
cred = self.my_authority_credential_string()
- elif record_dict['type'] in ["slice"]:
+ elif record_dict['type'] in ['slice']:
try:
cred = self.slice_credential_string(record_dict['hrn'])
except ServerException, e:
cred = self.my_authority_credential_string()
else:
raise
- elif record_dict['type'] in ["authority"]:
+ elif record_dict['type'] in ['authority']:
cred = self.my_authority_credential_string()
- elif record_dict['type'] == 'node':
+ elif record_dict['type'] in ['node']:
cred = self.my_authority_credential_string()
else:
raise "unknown record type" + record_dict['type']
api_options = {'call_id': unique_call_id(),
'cached': True,
- #'info': options.info,
+ 'info': options.info,
'list_leases': options.list_leases,
'geni_rspec_version': {'type': 'geni', 'version': '3'},
}
api_options['geni_rspec_version'] = version_manager.get_version(options.rspec_version).to_dict()
else:
api_options['geni_rspec_version'] = {'type': 'geni', 'version': '3'}
- urn = Xrn(args[0], type='slice').get_urn()
+ urn = Xrn(args[0], type='slice').get_urn()
+ remove_none_fields(api_options)
result = server.Describe([urn], creds, api_options)
value = ReturnValue.get_value(result)
if self.options.raw:
if options.file is not None:
save_rspec_to_file(value['geni_rspec'], options.file)
if (self.options.raw is None) and (options.file is None):
- display_rspec(value, options.format)
+ display_rspec(value['geni_rspec'], options.format)
return
sfa_users = []
geni_users = []
slice_records = self.registry().Resolve(slice_urn, [self.my_credential_string])
+ remove_none_fields(slice_records[0])
if slice_records and 'reg-researchers' in slice_records[0] and slice_records[0]['reg-researchers']!=[]:
slice_record = slice_records[0]
user_hrns = slice_record['reg-researchers']
print value
return value
- @declare_command("slice_hrn [<sliver_urn>...] time","")
+ @declare_command("slice_hrn [<sliver_urn>...] time","sfi renew onelab.ple.heartbeat 2015-04-31")
def renew(self, options, args):
"""
renew slice (Renew)