Example #1
0
def init(reset_config, skip_logging=False):
    if os.path.exists(os.path.join(
            utils.get_cwd(),
            constants.CLOUDIFY_WD_SETTINGS_DIRECTORY_NAME,
            constants.CLOUDIFY_WD_SETTINGS_FILE_NAME)):
        if not reset_config:
            msg = 'Current directory is already initialized'
            error = exceptions.CloudifyCliError(msg)
            error.possible_solutions = [
                "Run 'cfy init -r' to force re-initialization "
                "(might overwrite existing "
                "configuration files if exist) "
            ]
            raise error
        else:
            shutil.rmtree(os.path.join(
                utils.get_cwd(),
                constants.CLOUDIFY_WD_SETTINGS_DIRECTORY_NAME))

    settings = utils.CloudifyWorkingDirectorySettings()
    utils.dump_cloudify_working_dir_settings(settings)
    utils.dump_configuration_file()
    configure_loggers()
    if not skip_logging:
        get_logger().info('Initialization completed successfully')
Example #2
0
 def _create_cosmo_wd_settings(self, settings=None):
     directory_settings = utils.CloudifyWorkingDirectorySettings()
     directory_settings.set_management_server('localhost')
     utils.delete_cloudify_working_dir_settings()
     utils.dump_cloudify_working_dir_settings(
         settings or directory_settings, update=False)
     utils.dump_configuration_file()