return 'slice'
elif type.startswith('no'):
return 'node'
+ elif type.startswith('ag'):
+ return 'aggregate'
+ elif type.startswith('al'):
+ return 'all'
else:
+ print 'unknown type {} - should start with one of au|us|sl|no|ag|al'.format(type)
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)
if canonical in ("register", "update"):
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('-t', '--type', dest='type', metavar='<type>', help='object type (2 first chars is enough)', 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',
help="renew as long as possible")
# registy filter option
if canonical in ("list", "show", "remove"):
- parser.add_option("-t", "--type", dest="type", type="choice",
- help="type filter ([all]|user|slice|authority|node|aggregate)",
- choices=("all", "user", "slice", "authority", "node", "aggregate"),
- default="all")
+ parser.add_option("-t", "--type", dest="type", metavar="<type>",
+ default="all",
+ help="type filter - 2 first chars is enough ([all]|user|slice|authority|node|aggregate)")
if canonical in ("show"):
parser.add_option("-k","--key",dest="keys",action="append",default=[],
help="specify specific keys to be displayed from record")
sys.exit(1)
self.command_options = command_options
+ # allow incoming types on 2 characters only
+ if hasattr(command_options, 'type'):
+ command_options.type = normalize_type(command_options.type)
+ if not command_options.type:
+ sys.exit(1)
+
self.read_config ()
self.bootstrap ()
self.logger.debug("Command={}".format(self.command))
"""
server = self.sliceapi()
server_version = self.get_cached_server_version(server)
+ if len(args) != 2:
+ self.print_help()
+ sys.exit(1)
slice_hrn = args[0]
+ rspec_file = self.get_rspec_file(args[1])
+
slice_urn = Xrn(slice_hrn, type='slice').get_urn()
# credentials
show_credentials(creds)
# rspec
- rspec_file = self.get_rspec_file(args[1])
- rspec = open(rspec_file).read()
api_options = {}
api_options ['call_id'] = unique_call_id()
# users
api_options['sfa_users'] = sfa_users
api_options['geni_users'] = geni_users
- allocate = server.Allocate(slice_urn, creds, rspec, api_options)
+ with open(rspec_file) as rspec:
+ rspec_xml = rspec.read()
+ allocate = server.Allocate(slice_urn, creds, rspec_xml, api_options)
value = ReturnValue.get_value(allocate)
if self.options.raw:
save_raw_to_file(allocate, self.options.raw, self.options.rawformat, self.options.rawbanner)