How to use the workflows.cloudify_system_workflows.snapshots.constants function in workflows

To help you get started, we’ve selected a few workflows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / snapshot_create.py View on Github external
def _dump_metadata(self,
                       metadata,
                       manager_version,
                       schema_revision,
                       stage_schema_revision,
                       composer_schema_revision):
        ctx.logger.info('Dumping metadata')
        metadata[constants.M_VERSION] = str(manager_version)
        metadata[constants.M_SCHEMA_REVISION] = schema_revision
        if stage_schema_revision:
            metadata[constants.M_STAGE_SCHEMA_REVISION] = stage_schema_revision
        if composer_schema_revision:
            metadata[constants.M_COMPOSER_SCHEMA_REVISION] = \
                composer_schema_revision
        metadata_filename = os.path.join(
            self._tempdir,
            constants.METADATA_FILENAME
        )
        with open(metadata_filename, 'w') as f:
            json.dump(metadata, f)
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / snapshot_create.py View on Github external
def create(self):
        self._tempdir = tempfile.mkdtemp('-snapshot-data')
        metadata = dict()
        try:
            manager_version = utils.get_manager_version(self._client)
            schema_revision = utils.db_schema_get_current_revision(
                config=self._config)
            stage_schema_revision = \
                utils.stage_db_schema_get_current_revision()
            composer_schema_revision = \
                utils.composer_db_schema_get_current_revision()

            utils.sudo(constants.ALLOW_DB_CLIENT_CERTS_SCRIPT)
            self._dump_files()
            utils.sudo(constants.DENY_DB_CLIENT_CERTS_SCRIPT)
            self._dump_postgres()
            self._dump_networks()
            self._dump_credentials(manager_version)
            self._dump_metadata(metadata,
                                manager_version,
                                schema_revision,
                                stage_schema_revision,
                                composer_schema_revision)
            self._dump_agents(manager_version)

            self._create_archive()
            self._update_snapshot_status(self._config.created_status)
            ctx.logger.info('Snapshot created successfully')
        except BaseException as e:
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / snapshot_create.py View on Github external
metadata,
                       manager_version,
                       schema_revision,
                       stage_schema_revision,
                       composer_schema_revision):
        ctx.logger.info('Dumping metadata')
        metadata[constants.M_VERSION] = str(manager_version)
        metadata[constants.M_SCHEMA_REVISION] = schema_revision
        if stage_schema_revision:
            metadata[constants.M_STAGE_SCHEMA_REVISION] = stage_schema_revision
        if composer_schema_revision:
            metadata[constants.M_COMPOSER_SCHEMA_REVISION] = \
                composer_schema_revision
        metadata_filename = os.path.join(
            self._tempdir,
            constants.METADATA_FILENAME
        )
        with open(metadata_filename, 'w') as f:
            json.dump(metadata, f)
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / utils.py View on Github external
def get_dep_contexts(version):
    deps = {}
    tenants = [get_tenant_name()] if version < snapshot_constants.V_4_0_0 \
        else get_tenants_list()
    for tenant_name in tenants:
        # Temporarily assign the context a different tenant name so that
        # we can retrieve that tenant's deployment contexts
        with internal_utils._change_tenant(ctx, tenant_name):
            # We have to zero this out each time or the cached version for
            # the previous tenant will be used
            ctx._dep_contexts = None

            # Get deployment contexts for this tenant
            deps[tenant_name] = ctx.deployments_contexts
    return deps.items()
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / utils.py View on Github external
def get_tenants_list():
    client = manager.get_rest_client(snapshot_constants.DEFAULT_TENANT_NAME)
    version = client.manager.get_version()
    if version['edition'] != 'premium':
        return [snapshot_constants.DEFAULT_TENANT_NAME]
    tenants = client.tenants.list(_include=['name'], _get_all_results=True)
    return [tenant.name for tenant in tenants]
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / snapshot_create.py View on Github external
def _dump_metadata(self,
                       metadata,
                       manager_version,
                       schema_revision,
                       stage_schema_revision,
                       composer_schema_revision):
        ctx.logger.info('Dumping metadata')
        metadata[constants.M_VERSION] = str(manager_version)
        metadata[constants.M_SCHEMA_REVISION] = schema_revision
        if stage_schema_revision:
            metadata[constants.M_STAGE_SCHEMA_REVISION] = stage_schema_revision
        if composer_schema_revision:
            metadata[constants.M_COMPOSER_SCHEMA_REVISION] = \
                composer_schema_revision
        metadata_filename = os.path.join(
            self._tempdir,
            constants.METADATA_FILENAME
        )
        with open(metadata_filename, 'w') as f:
            json.dump(metadata, f)
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / snapshot_create.py View on Github external
def _dump_metadata(self,
                       metadata,
                       manager_version,
                       schema_revision,
                       stage_schema_revision,
                       composer_schema_revision):
        ctx.logger.info('Dumping metadata')
        metadata[constants.M_VERSION] = str(manager_version)
        metadata[constants.M_SCHEMA_REVISION] = schema_revision
        if stage_schema_revision:
            metadata[constants.M_STAGE_SCHEMA_REVISION] = stage_schema_revision
        if composer_schema_revision:
            metadata[constants.M_COMPOSER_SCHEMA_REVISION] = \
                composer_schema_revision
        metadata_filename = os.path.join(
            self._tempdir,
            constants.METADATA_FILENAME
        )
        with open(metadata_filename, 'w') as f:
            json.dump(metadata, f)
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / utils.py View on Github external
os.path.join(path, tenant_name)
                # Plugins are an exception as they are all stored in one path
                # under UUIDs without tenant names
                if path != constants.FILE_SERVER_PLUGINS_FOLDER else path,
                # The path of the file type in the snapshot
                path,
            ) for path in data_to_copy
        ]
    else:
        # This is a 4.x+ install, files go where they went.
        data_to_copy = [(path, path) for path in data_to_copy]

    local_cert_dir = os.path.dirname(get_local_rest_certificate())
    if to_archive:
        data_to_copy.append((local_cert_dir,
                             snapshot_constants.ARCHIVE_CERT_DIR))
        data_to_copy.append((SECURITY_FILE_LOCATION, SECURITY_FILENAME))

    ctx.logger.info(str(data_to_copy))
    for p1, p2 in data_to_copy:
        # first expand relative paths
        if p1[0] != '/':
            p1 = os.path.join(config.file_server_root, p1)
        if p2[0] != '/':
            p2 = os.path.join(archive_root, p2)

        # make p1 to always point to source and p2 to target of copying
        if not to_archive:
            p1, p2 = p2, p1

        copy_snapshot_path(p1, p2)
github cloudify-cosmo / cloudify-manager / workflows / cloudify_system_workflows / snapshots / snapshot_create.py View on Github external
def _dump_metadata(self,
                       metadata,
                       manager_version,
                       schema_revision,
                       stage_schema_revision,
                       composer_schema_revision):
        ctx.logger.info('Dumping metadata')
        metadata[constants.M_VERSION] = str(manager_version)
        metadata[constants.M_SCHEMA_REVISION] = schema_revision
        if stage_schema_revision:
            metadata[constants.M_STAGE_SCHEMA_REVISION] = stage_schema_revision
        if composer_schema_revision:
            metadata[constants.M_COMPOSER_SCHEMA_REVISION] = \
                composer_schema_revision
        metadata_filename = os.path.join(
            self._tempdir,
            constants.METADATA_FILENAME
        )
        with open(metadata_filename, 'w') as f:
            json.dump(metadata, f)