예제 #1
0
파일: fault.py 프로젝트: 4383/tobiko
 def run_fault(self, fault):
     """Executes given fault."""
     if self.scenarios:
         os_faults.human_api(self.cloud, fault)
     else:
         LOG.debug("Skipped fault: '{}' since".format(fault),
                   " scenarios are not defined.")
예제 #2
0
    def run(self):
        LOG.debug("Injecting fault: %s", self.config["action"])
        injector = os_faults.connect()

        try:
            os_faults.human_api(injector, self.config["action"])
            self.set_status(consts.HookStatus.SUCCESS)
        except Exception as e:
            self.set_status(consts.HookStatus.FAILED)
            self.set_error(exception_name=type(e),
                           description='Fault injection failure',
                           details=str(e))
예제 #3
0
    def run(self):
        LOG.debug("Injecting fault: %s", self.config["action"])
        injector = os_faults.connect()

        try:
            os_faults.human_api(injector, self.config["action"])
            self.set_status(consts.HookStatus.SUCCESS)
        except Exception as e:
            self.set_status(consts.HookStatus.FAILED)
            self.set_error(exception_name=type(e),
                           description='Fault injection failure',
                           details=str(e))
예제 #4
0
    def run(self):
        # get cloud configuration
        cloud_config = self.get_cloud_config()

        # connect to the cloud
        injector = os_faults.connect(cloud_config)

        # verify that all nodes are available
        if self.config.get("verify"):
            injector.verify()

        LOG.debug("Injecting fault: %s", self.config["action"])
        os_faults.human_api(injector, self.config["action"])
예제 #5
0
    def run(self):
        # get cloud configuration
        cloud_config = self.get_cloud_config()

        # connect to the cloud
        injector = os_faults.connect(cloud_config)

        # verify that all nodes are available
        if self.config.get("verify"):
            injector.verify()

        LOG.debug("Injecting fault: %s", self.config["action"])
        os_faults.human_api(injector, self.config["action"])
예제 #6
0
파일: _execute.py 프로젝트: 4383/tobiko
def os_faults_execute(command, cloud_management=None, config_filename=None,
                      **kwargs):
    cloud_management = (
        cloud_management or
        _cloud.get_os_fault_cloud_managenemt(
            config_filename=config_filename))
    if kwargs:
        command = command.format(**kwargs)
    return os_faults.human_api(cloud_management, command)
예제 #7
0
def main():
    parser = argparse.ArgumentParser(
        prog='os-inject-fault',
        usage=USAGE,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=_make_epilog())
    parser.add_argument('-c',
                        '--config',
                        dest='config',
                        help='path to os-faults cloud connection config')
    parser.add_argument('-d', '--debug', dest='debug', action='store_true')
    parser.add_argument('-v',
                        '--verify',
                        action='store_true',
                        help='verify connection to the cloud')
    parser.add_argument('command',
                        nargs='*',
                        help='fault injection command, e.g. "restart keystone '
                        'service"')
    args = parser.parse_args()

    debug = args.debug
    logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
                        level=logging.DEBUG if debug else logging.INFO)

    config = args.config
    command = args.command

    if not command and not args.verify:
        parser.print_help()
        sys.exit(0)

    destructor = os_faults.connect(config_filename=config)

    if args.verify:
        destructor.verify()

    if command:
        command = ' '.join(command)
        os_faults.human_api(destructor, command)