def run_command(args): command_class = {} command_imports = ( ('apispec', 'zato.cli.apispec.APISpec'), ('ca_create_ca', 'zato.cli.ca_create_ca.Create'), ('ca_create_lb_agent', 'zato.cli.ca_create_lb_agent.Create'), ('ca_create_scheduler', 'zato.cli.ca_create_scheduler.Create'), ('ca_create_server', 'zato.cli.ca_create_server.Create'), ('ca_create_web_admin', 'zato.cli.ca_create_web_admin.Create'), ('cache_delete', 'zato.cli.cache.CacheDelete'), ('cache_get', 'zato.cli.cache.CacheGet'), ('cache_set', 'zato.cli.cache.CacheSet'), ('check_config', 'zato.cli.check_config.CheckConfig'), ('component_version', 'zato.cli.component_version.ComponentVersion'), ('create_cluster', 'zato.cli.create_cluster.Create'), ('create_lb', 'zato.cli.create_lb.Create'), ('create_odb', 'zato.cli.create_odb.Create'), ('create_scheduler', 'zato.cli.create_scheduler.Create'), ('create_server', 'zato.cli.create_server.Create'), ('create_secret_key', 'zato.cli.crypto.CreateSecretKey'), ('create_user', 'zato.cli.web_admin_auth.CreateUser'), ('create_web_admin', 'zato.cli.create_web_admin.Create'), ('crypto_create_secret_key', 'zato.cli.crypto.CreateSecretKey'), ('delete_odb', 'zato.cli.delete_odb.Delete'), ('decrypt', 'zato.cli.crypto.Decrypt'), ('encrypt', 'zato.cli.crypto.Encrypt'), ('enmasse', 'zato.cli.enmasse.Enmasse'), ('from_config', 'zato.cli.FromConfig'), ('hash_get_rounds', 'zato.cli.crypto.GetHashRounds'), ('info', 'zato.cli.info.Info'), ('migrate', 'zato.cli.migrate.Migrate'), ('reset_totp_key', 'zato.cli.web_admin_auth.ResetTOTPKey'), ('quickstart_create', 'zato.cli.quickstart.Create'), ('service_invoke', 'zato.cli.service.Invoke'), ('set_admin_invoke_password', 'zato.cli.web_admin_auth.SetAdminInvokePassword'), ('sso_change_user_password', 'zato.cli.sso.ChangeUserPassword'), ('sso_create_odb', 'zato.cli.sso.CreateODB'), ('sso_create_user', 'zato.cli.sso.CreateUser'), ('sso_create_super_user', 'zato.cli.sso.CreateSuperUser'), ('sso_delete_user', 'zato.cli.sso.DeleteUser'), ('sso_login', 'zato.cli.sso.Login'), ('sso_logout', 'zato.cli.sso.Logout'), ('sso_lock_user', 'zato.cli.sso.LockUser'), ('sso_reset_totp_key', 'zato.cli.sso.ResetTOTPKey'), ('sso_reset_user_password', 'zato.cli.sso.ResetUserPassword'), ('sso_unlock_user', 'zato.cli.sso.UnlockUser'), ('start', 'zato.cli.start.Start'), ('stop', 'zato.cli.stop.Stop'), ('update_password', 'zato.cli.web_admin_auth.UpdatePassword'), ('wait', 'zato.cli.wait.Wait'), ) for k, v in command_imports: command_class[k] = import_string(v) command_class[args.command](args).run(args)
def run_command(args): # Zato from zato.common.util.import_ import import_string for command_name, class_dotted_name in command_imports: if command_name == args.command: class_ = import_string(class_dotted_name) instance = class_(args) return instance.run(args)
def run_command(args): # Zato from zato.common.util.import_ import import_string # This may be needed in two places. sorted_command_imports = sorted(command_imports) # Iterate over all the commands that we know .. for command_name, class_dotted_name in sorted_command_imports: # Try to match the command given with our configuration .. if command_name == args.command: class_ = import_string(class_dotted_name) instance = class_(args) # .. we found a match so we can run the command. return instance.run(args) # .. if we are here, it means that configuration from zato_command.py does not much our. else: raise Exception('Could not find `{}` among `{}`'.format(args.command, [elem[0] for elem in sorted_command_imports]))