def my_plugin(): mock_module = MagicMock() mock_module.generated.definitions = fake_generated_definitions modules = { 'generated': mock_module, 'generated.definitions': mock_module.generated.definitions } with patch.dict('sys.modules', modules): from dlpx.virtualization.platform import Plugin yield Plugin()
def my_upgrade(): from dlpx.virtualization.platform import Plugin yield Plugin().upgrade
# # Copyright (c) 2020 by Delphix. All rights reserved. # # from dlpx.virtualization.platform import Mount, MountSpecification, Plugin, Status from operations import discovery, linked, virtual from utils import setup_logger from db_commands.constants import EVICTION_POLICY plugin = Plugin() setup_logger._setup_logger() # # Below is an example of the repository discovery operation. # # NOTE: The decorators are defined on the 'plugin' object created above. # # Mark the function below as the operation that does repository discovery. @plugin.discovery.repository() def repository_discovery(source_connection): # # This is an object generated from the repositoryDefinition schema. # In order to use it locally you must run the 'build -g' command provided # by the SDK tools from the plugin's root directory. # return discovery.find_repos(source_connection) @plugin.discovery.source_config()
# # Copyright (c) 2019 by Delphix. All rights reserved. # # flake8: noqa from dlpx.virtualization.platform import Plugin, Status direct = Plugin() @direct.discovery.repository() def repository_discovery(source_connection): return [] @direct.discovery.source_config() def source_config_discovery(source_connection, repository): return [] @direct.linked.pre_snapshot() def direct_pre_snapshot(direct_source, repository, source_config): return @direct.linked.post_snapshot() def direct_post_snapshot(direct_source, repository, source_config): return None @direct.virtual.configure() def configure(virtual_source, repository, snapshot):
# # Copyright (c) 2019 by Delphix. All rights reserved. # # flake8: noqa from __future__ import print_function import logging from dlpx.virtualization.platform import Plugin logger = logging.getLogger() logger.setLevel(logging.NOTSET) staged = Plugin() # Renamed source_connection to connection to test if named arg check detects. @staged.discovery.repository() def repository_discovery(connection): return [] @staged.discovery.source_config() def source_config_discovery(source_connection, repository): return [] @staged.linked.mount_specification() def staged_mount_specification(staged_source, repository): return None
# # Copyright (c) 2019 by Delphix. All rights reserved. # # flake8: noqa from dlpx.virtualization.platform import Plugin, Status vfiles = Plugin() @vfiles.discovery.repository() def repository_discovery(source_connection): return [] @vfiles.discovery.source_config() def source_config_discovery(source_connection, repository): return [] @vfiles.linked.pre_snapshot() def direct_pre_snapshot(direct_source, repository, source_config): return @vfiles.linked.post_snapshot() def direct_post_snapshot(direct_source, repository, source_config): return None @vfiles.virtual.configure() def configure(virtual_source, repository, snapshot):
def my_plugin(): from dlpx.virtualization.platform import Plugin yield Plugin()