def use(management_ip, rest_port): logger = get_logger() # first check this server is available. client = utils.get_rest_client( manager_ip=management_ip, rest_port=rest_port) try: status_result = client.manager.get_status() except CloudifyClientError: status_result = None if not status_result: msg = ("Can't use management server {0}: No response." .format(management_ip)) raise CloudifyCliError(msg) # check if cloudify was initialized. if not utils.is_initialized(): utils.dump_cloudify_working_dir_settings() utils.dump_configuration_file() try: response = utils.get_rest_client( management_ip).manager.get_context() provider_context = response['context'] except CloudifyClientError: provider_context = None with utils.update_wd_settings() as wd_settings: wd_settings.set_management_server(management_ip) wd_settings.set_provider_context(provider_context) wd_settings.set_rest_port(rest_port) logger.info('Using management server {0} with port {1}' .format(management_ip, rest_port)) # delete the previous manager deployment if exists. bs.delete_workdir()
def init(blueprint_path, inputs, install_plugins): if os.path.isdir(_storage_dir()): shutil.rmtree(_storage_dir()) if not utils.is_initialized(): cfy_init(reset_config=False, skip_logging=True) try: common.initialize_blueprint( blueprint_path=blueprint_path, name=_NAME, inputs=inputs, storage=_storage(), install_plugins=install_plugins, resolver=utils.get_import_resolver() ) except ImportError as e: # import error indicates # some plugin modules are missing # TODO - consider adding an error code to # TODO - all of our exceptions. so that we # TODO - easily identify them here e.possible_solutions = [ "Run `cfy local init --install-plugins -p {0}`" .format(blueprint_path), "Run `cfy local install-plugins -p {0}`" .format(blueprint_path) ] raise get_logger().info("Initiated {0}\nIf you make changes to the " "blueprint, run `cfy local init -p {0}` " "again to apply them".format(blueprint_path))
def use(management_ip, provider, rest_port): logger = get_logger() # first check this server is available. client = utils.get_rest_client(manager_ip=management_ip, rest_port=rest_port) try: status_result = client.manager.get_status() except CloudifyClientError: status_result = None if not status_result: msg = ("Can't use management server {0}: No response.".format( management_ip)) raise CloudifyCliError(msg) # check if cloudify was initialized. if not utils.is_initialized(): utils.dump_cloudify_working_dir_settings() utils.dump_configuration_file() try: response = utils.get_rest_client(management_ip).manager.get_context() provider_name = response['name'] provider_context = response['context'] except CloudifyClientError: provider_name = None provider_context = None with utils.update_wd_settings() as wd_settings: wd_settings.set_management_server(management_ip) wd_settings.set_provider_context(provider_context) wd_settings.set_provider(provider_name) wd_settings.set_rest_port(rest_port) wd_settings.set_is_provider_config(provider) logger.info('Using management server {0} with port {1}'.format( management_ip, rest_port))
def configure_loggers(): warnings.simplefilter(action='once', category=InsecurePlatformWarning) # first off, configure defaults # to enable the use of the logger # even before the init was executed. _configure_defaults() from cloudify_cli import utils if utils.is_initialized(): # init was already called # use the configuration file. _configure_from_file() global _lgr _lgr = logging.getLogger('cloudify.cli.main') # configuring events/logs loggers # (this will also affect local workflow loggers, which don't use # the get_events_logger method of this module) if utils.is_use_colors(): logs.EVENT_CLASS = ColorfulEvent # refactor this elsewhere if colorama is further used in CLI colorama.init(autoreset=True)
def configure_loggers(): warnings.simplefilter(action='once', category=InsecurePlatformWarning) # first off, configure defaults # to enable the use of the logger # even before the init was executed. _configure_defaults() from cloudify_cli import utils if utils.is_initialized(): # init was already called # use the configuration file. _configure_from_file() global _lgr _lgr = logging.getLogger('cloudify.cli.main') # configuring events/logs loggers # (this will also affect local workflow loggers, which don't use # the get_events_logger method of this module) if utils.is_use_colors(): logs.EVENT_CLASS = ColorfulEvent # refactor this elsewhere if colorama is further used in CLI colorama.init(autoreset=True)
def init(blueprint_path, inputs, install_plugins_): if os.path.isdir(_storage_dir()): shutil.rmtree(_storage_dir()) if not utils.is_initialized(): cfy_init(reset_config=False, skip_logging=True) try: common.initialize_blueprint(blueprint_path=blueprint_path, name=_NAME, inputs=inputs, storage=_storage(), install_plugins=install_plugins_, resolver=utils.get_import_resolver()) except ImportError as e: # import error indicates # some plugin modules are missing # TODO - consider adding an error code to # TODO - all of our exceptions. so that we # TODO - easily identify them here e.possible_solutions = [ "Run 'cfy local init --install-plugins -p {0}'".format( blueprint_path), "Run 'cfy local install-plugins -p {0}'".format(blueprint_path) ] raise get_logger().info("Initiated {0}\nIf you make changes to the " "blueprint, " "run 'cfy local init -p {0}' " "again to apply them".format(blueprint_path))
def configure_loggers(): # first off, configure defaults # to enable the use of the logger # even before the init was executed. _configure_defaults() from cloudify_cli import utils if utils.is_initialized(): # init was already called # use the configuration file. _configure_from_file() global _lgr _lgr = logging.getLogger('cloudify.cli.main')
def use(management_ip, rest_port): logger = get_logger() # determine SSL mode by port if rest_port == constants.SECURED_REST_PORT: protocol = constants.SECURED_PROTOCOL else: protocol = constants.DEFAULT_PROTOCOL client = utils.get_rest_client(manager_ip=management_ip, rest_port=rest_port, protocol=protocol) try: # first check this server is available. client.manager.get_status() except UserUnauthorizedError: msg = "Can't use management server {0}: User is unauthorized.".format( management_ip) raise CloudifyCliError(msg) except CloudifyClientError: msg = "Can't use management server {0}: No response.".format( management_ip) raise CloudifyCliError(msg) # check if cloudify was initialized. if not utils.is_initialized(): utils.dump_cloudify_working_dir_settings() utils.dump_configuration_file() try: response = client.manager.get_context() provider_context = response['context'] except CloudifyClientError: provider_context = None with utils.update_wd_settings() as wd_settings: wd_settings.set_management_server(management_ip) wd_settings.set_provider_context(provider_context) wd_settings.set_rest_port(rest_port) wd_settings.set_protocol(protocol) logger.info('Using management server {0} with port {1}'.format( management_ip, rest_port)) # delete the previous manager deployment if exists. bs.delete_workdir()
def use(management_ip, rest_port): logger = get_logger() # check if cloudify was initialized. if not utils.is_initialized(): utils.dump_cloudify_working_dir_settings() utils.dump_configuration_file() # determine SSL mode by port if rest_port == constants.SECURED_REST_PORT: protocol = constants.SECURED_PROTOCOL else: protocol = constants.DEFAULT_PROTOCOL client = utils.get_rest_client( rest_host=management_ip, rest_port=rest_port, rest_protocol=protocol, skip_version_check=True) try: # first check this server is available. client.manager.get_status() except UserUnauthorizedError: msg = "Can't use manager {0}: User is unauthorized.".format( management_ip) raise CloudifyCliError(msg) except CloudifyClientError as e: msg = "Can't use manager {0}: {1}".format(management_ip, str(e)) raise CloudifyCliError(msg) try: response = client.manager.get_context() provider_context = response['context'] except CloudifyClientError: provider_context = None with utils.update_wd_settings() as wd_settings: wd_settings.set_management_server(management_ip) wd_settings.set_provider_context(provider_context) wd_settings.set_rest_port(rest_port) wd_settings.set_rest_protocol(protocol) logger.info('Using management server {0} with port {1}' .format(management_ip, rest_port)) # delete the previous manager deployment if exists. bs.delete_workdir()