def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) senlin_client = self.app.client_manager.clustering try: if not parsed_args.force and sys.stdin.isatty(): sys.stdout.write( _("Are you sure you want to delete this profile(s)" " [y/N]?")) prompt_response = sys.stdin.readline().lower() if not prompt_response.startswith('y'): return except KeyboardInterrupt: # Ctrl-c self.log.info(_LI('Ctrl-c detected.')) return except EOFError: # Ctrl-d self.log.info(_LI('Ctrl-d detected')) return failure_count = 0 for pid in parsed_args.profile: try: senlin_client.delete_profile(pid, False) except Exception as ex: failure_count += 1 print(ex) if failure_count: raise exc.CommandError( _('Failed to delete %(count)s of the ' '%(total)s specified profile(s).') % { 'count': failure_count, 'total': len(parsed_args.profile) }) print('Profile deleted: %s' % parsed_args.profile)
def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) senlin_client = self.app.client_manager.clustering try: if not parsed_args.force and sys.stdin.isatty(): sys.stdout.write( _("Are you sure you want to delete this node(s)" " [y/N]?")) prompt_response = sys.stdin.readline().lower() if not prompt_response.startswith('y'): return except KeyboardInterrupt: # Ctrl-c self.log.info(_LI('Ctrl-c detected.')) return except EOFError: # Ctrl-d self.log.info(_LI('Ctrl-d detected')) return failure_count = 0 for nid in parsed_args.node: try: senlin_client.delete_node(nid, False) except Exception as ex: failure_count += 1 print(ex) if failure_count: raise exc.CommandError(_('Failed to delete %(count)s of the ' '%(total)s specified node(s).') % {'count': failure_count, 'total': len(parsed_args.node)}) print('Request accepted')
def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) senlin_client = self.app.client_manager.clustering try: if not parsed_args.force and sys.stdin.isatty(): sys.stdout.write( _("Are you sure you want to delete this node(s)" " [y/N]?")) prompt_response = sys.stdin.readline().lower() if not prompt_response.startswith('y'): return except KeyboardInterrupt: # Ctrl-c self.log.info(_LI('Ctrl-c detected.')) return except EOFError: # Ctrl-d self.log.info(_LI('Ctrl-d detected')) return result = {} for nid in parsed_args.node: try: node = senlin_client.delete_node(nid, False) result[nid] = ('OK', node.location.split('/')[-1]) except Exception as ex: result[nid] = ('ERROR', six.text_type(ex)) for rid, res in result.items(): senlin_utils.print_action_result(rid, res)