-
- # delete named slice
- def delete(self,opts, args):
- slice_hrn = args[0]
- server = self.slicemgr
- # direct connection to the nodes component manager interface
- if opts.component:
- server = self.get_component_server_from_hrn(opts.component)
-
- slice_cred = self.get_slice_cred(slice_hrn).save_to_string(save_parents=True)
- request_hash=None
- if self.hashrequest:
- arg_list = [slice_cred, slice_hrn]
- request_hash = self.key.compute_hash(arg_list)
- return server.delete_slice(slice_cred, slice_hrn, request_hash)
-
- # start named slice
- def start(self,opts, args):
- slice_hrn = args[0]
- server = self.slicemgr
- # direct connection to the nodes component manager interface
- if opts.component:
- server = self.get_component_server_from_hrn(opts.component)
-
- slice_cred = self.get_slice_cred(args[0])
- request_hash=None
- if self.hashrequest:
- arg_list = [slice_cred, slice_hrn]
- request_hash = self.key.compute_hash(arg_list)
- return server.start_slice(slice_cred, slice_hrn, request_hash)
-
- # stop named slice
- def stop(self,opts, args):
- slice_hrn = args[0]
- server = self.slicemgr
- # direct connection to the nodes component manager interface
- if opts.component:
- server = self.get_component_server_from_hrn(opts.component)
-
- slice_cred = self.get_slice_cred(args[0]).save_to_string(save_parents=True)
- request_hash=None
- if self.hashrequest:
- arg_list = [slice_cred, slice_hrn]
- request_hash = self.key.compute_hash(arg_list)
- return server.stop_slice(slice_cred, slice_hrn, request_hash)
-
- # reset named slice
- def reset(self,opts, args):
- slice_hrn = args[0]
- server = self.slicemgr
- # direct connection to the nodes component manager interface
- if opts.component:
- server = self.get_component_server_from_hrn(opts.component)
- slice_cred = self.get_slice_cred(args[0]).save_to_string(save_parents=True)
- request_hash=None
- if self.hashrequest:
- arg_list = [slice_cred, slice_hrn]
- request_hash = self.key.compute_hash(arg_list)
- return server.reset_slice(slice_cred, slice_hrn, request_hash)
-
- #
- # Main: parse arguments and dispatch to command
- #
- def main(self):
- parser = self.create_parser()
- (options, args) = parser.parse_args()
- self.options = options
-
- if options.hashrequest:
- self.hashrequest=True
-
- if len(args) <= 0:
- print "No command given. Use -h for help."
- return -1
-
- command = args[0]
- (cmd_opts, cmd_args) = self.create_cmd_parser(command).parse_args(args[1:])
- if self.options.verbose :
- print "Registry %s, sm %s, dir %s, user %s, auth %s" % (options.registry, options.sm,
- options.sfi_dir, options.user,
- options.auth)
- print "Command %s" %command
- if command in ("resources"):
- print "resources cmd_opts %s" %cmd_opts.format
- elif command in ("list","show","remove"):
- print "cmd_opts.type %s" %cmd_opts.type
- print "cmd_args %s" %cmd_args
-
- self.set_servers()
-
- try:
- self.dispatch(command, cmd_opts, cmd_args)
- except KeyError:
- raise
- print "Command not found:", command