def vdb_enable (virtual_connection,parameters,repository,source_config, snapshot): logger = setupLogger._setup_logger(__name__) env = { "DLPX_TOOLKIT_NAME" : "Oracle on Windows", "DLPX_TOOLKIT_WORKFLOW" : "vdb_enable", "DLPX_TOOLKIT_PATH" : repository.delphix_tookit_path, "ORACLE_HOME" : repository.ora_home, "ORACLE_BASE" : repository.ora_base, "ORACLE_INST" : parameters.instance_name, "ORACLE_USER" : parameters.username, "ORACLE_PASSWD" : parameters.password, "VDB_MNT_PATH" : parameters.mount_path, "ORA_UNQ_NAME" : parameters.dbunique_name, "ORA_DB_NAME" : parameters.db_name } logger.debug("Virtual Parameters: {}".format(parameters)) logger.debug("Virtual Repository Parameters: {}".format(repository)) logger.debug("Source Config Parameters: {}".format(source_config)) logger.debug("Snapshot Parameters: {}".format(snapshot)) enable_vdb = executeScript.execute_powershell(virtual_connection,'vdb_enable.ps1',env) logger.debug("Enable VDB: {}".format(enable_vdb)) db_name = parameters.db_name db_uniq_name = parameters.dbunique_name db_identity_name = parameters.instance_name return SourceConfigDefinition(db_name=db_name, db_uniq_name=db_uniq_name,db_identity_name=db_identity_name)
def configure(virtual_source, repository, snapshot): helpers._record_hook("virtual configure", virtual_source.connection) helpers._set_running(virtual_source.connection, virtual_source.guid) virtual_source.mongo_install_path = repository.mongo_install_path virtual_source.mongo_shell_path = repository.mongo_shell_path logger.info("snapshot:{}".format(snapshot)) logger.info("d_source_type:{}".format(snapshot.d_source_type)) d_source_type = snapshot.d_source_type if d_source_type in [ "nonshardedsource", "offlinemongodump", "onlinemongodump", "seed", "stagingpush", "extendedcluster" ]: virtual_source.parameters.mongos_port = virtual_source.parameters.start_portpool common.setup_dataset(virtual_source, 'Virtual', snapshot, d_source_type) logger.debug("End of virtual configure") logger.debug(" ") discovery_type = "Auto" pretty_name = "{}-{}-{}".format(d_source_type, virtual_source.parameters.mount_path, virtual_source.parameters.start_portpool) return SourceConfigDefinition(discovery_type=discovery_type, pretty_name=pretty_name)
def _source_config(virtual_source, repository=None, source_config=None, snapshot=None): port = virtual_source.parameters.couchbase_port mount_path = virtual_source.parameters.mount_path host = virtual_source.connection.environment.host.name pretty_name = "Couchbase:" + str(port) + " - " + mount_path return SourceConfigDefinition(couchbase_src_host=host, couchbase_src_port=port, pretty_name=pretty_name, db_path=mount_path)
def reconfigure(virtual_source, repository, source_config, snapshot): logger.debug("virtual.reconfigure > Start") start(virtual_source, repository, source_config) logger.debug(source_config) logger.debug("Snapshot") logger.debug(snapshot) #srcConfig = configure(virtual_source,snapshot,repository) logger.debug("virtual.reconfigure > End") virtual_status(virtual_source, repository, source_config) return SourceConfigDefinition(db_name="output", base_dir=virtual_source.parameters.base_dir, port=virtual_source.parameters.port, data_dir=virtual_source.mounts[0].mount_path)
def initial_provision(virtual_connection, parameters, snapshot, repository): logger = setupLogger._setup_logger(__name__) env = { "DLPX_TOOLKIT_NAME": "Oracle on Windows", "DLPX_TOOLKIT_WORKFLOW": "initial_provision", "DLPX_TOOLKIT_PATH": repository.delphix_tookit_path, "ORACLE_HOME": repository.ora_home, "ORACLE_BASE": repository.ora_base, "ORACLE_INST": parameters.instance_name, "ORACLE_USER": parameters.username, "ORACLE_PASSWD": parameters.password, "VDB_MNT_PATH": parameters.mount_path, "ORA_UNQ_NAME": parameters.dbunique_name, "ORA_DB_NAME": parameters.db_name, "ARCHIVE_LOG_MODE": str(parameters.archivelog_mode), "CUSTOM_INIT_PARAMS": str(parameters.custom_init_params), "CUSTOM_INIT_PARAMS_FILE": parameters.custom_init_params_file, "ORA_SRC": snapshot.ora_src, "ORA_STG": snapshot.ora_inst, "ORA_SRC_TYPE": snapshot.src_type, "ORA_VDB_SRC": snapshot.ora_unq } logger.debug("Virtual Parameters: {}".format(parameters)) logger.debug("Virtual Repository Parameters: {}".format(repository)) logger.debug("Snapshot Parameters: {}".format(snapshot)) crt_svc = executeScript.execute_powershell(virtual_connection, 'crtOraSvc.ps1', env) logger.debug("Creating Service: {}".format(crt_svc)) copy_to_vdbdir = executeScript.execute_powershell( virtual_connection, 'vdb_copy_to_vdbdir.ps1', env) logger.debug("Copying dSource to VDB Dir: {}".format(copy_to_vdbdir)) crt_dirs = executeScript.execute_powershell(virtual_connection, 'vdb_crtDirectories.ps1', env) logger.debug("Creating Directories: {}".format(crt_dirs)) vdb_prep_pfile = executeScript.execute_powershell(virtual_connection, 'vdb_prep_pfile.ps1', env) logger.debug("VDB Prep pFile: {}".format(vdb_prep_pfile)) if (snapshot.src_type == 'dSource'): vdb_startup_mount = executeScript.execute_powershell( virtual_connection, 'vdb_startup_mount.ps1', env) logger.debug("VDB StartUp Mount: {}".format(vdb_startup_mount)) vdb_rename_files = executeScript.execute_powershell( virtual_connection, 'vdb_rename_files.ps1', env) logger.debug("VDB Rename Files: {}".format(vdb_rename_files)) vdb_configure = executeScript.execute_powershell( virtual_connection, 'vdb_configure.ps1', env) logger.debug("VDB Configure: {}".format(vdb_configure)) vdb_change_dbname_dbid = executeScript.execute_powershell( virtual_connection, 'vdb_change_dbname_dbid.ps1', env) logger.debug("VDB Change DB ID: {}".format(vdb_change_dbname_dbid)) vdb_finalize = executeScript.execute_powershell( virtual_connection, 'vdb_finalize.ps1', env) logger.debug("VDB Finalize: {}".format(vdb_finalize)) else: ### snapshot.src_type=='VDB' child_vdb_provision = executeScript.execute_powershell( virtual_connection, 'vdb_childProvision.ps1', env) logger.debug("Child VDB Provision: {}".format(child_vdb_provision)) if (str(parameters.archivelog_mode) == 'True'): vdb_disable_archivelog = executeScript.execute_powershell( virtual_connection, 'vdb_disable_archivelog.ps1', env) logger.debug( "VDB Disable Archive Log: {}".format(vdb_disable_archivelog)) db_name = parameters.db_name db_uniq_name = parameters.dbunique_name db_identity_name = parameters.instance_name return SourceConfigDefinition(db_name=db_name, db_uniq_name=db_uniq_name, db_identity_name=db_identity_name)
def configure(virtual_source, snapshot, repository): logger.debug("virtual.configure") binary_path = virtual_source.connection.environment.host.binary_path library_script = pkgutil.get_data('resources', 'library.sh') mount_path = virtual_source.mounts[0].mount_path vdbConn = build_lua_connect_string(virtual_source.parameters.vdb_user, "localhost") logger.debug("Mount Path:" + mount_path) logger.debug("Snapshot Settings:") logger.debug(snapshot) logger.debug("Snapshot_id" + snapshot.snapshot_id) logger.debug("Config Settings: ") config_settings_prov = virtual_source.parameters.config_settings_prov logger.debug(config_settings_prov) config_params = "" ################################################################### # TODO: Operation fails if there are config settings. Must revisit. ################################################################### if len(config_settings_prov) > 0: for config_setting in config_settings_prov: logger.debug("PropertyName") logger.debug(config_setting['propertyName']) logger.debug("Value") logger.debug(config_setting['value']) config_params += config_setting['propertyName'] config_params += "=" config_params += config_setting['value'] config_params += "\n" logger.debug("config_params:" + config_params) logger.debug("config_params:" + config_params) ################################################################### environment_vars = { "DLPX_LIBRARY_SOURCE": library_script, "DLPX_DATA_DIRECTORY": mount_path, "DLPX_BIN": binary_path, "MYSQLD": repository.install_path, "MYSQLVER": repository.version, "VDBCONN": vdbConn, "VDBPASS": virtual_source.parameters.vdb_pass, "MYBASEDIR": virtual_source.parameters.base_dir, "PORT": virtual_source.parameters.port, "SERVERID": virtual_source.parameters.server_id, "MYCONFIG": config_params, #"STAGED_HOST":snapshot.snap_host, "STAGED_PORT": snapshot.snap_port, "STAGED_DATADIR": snapshot.snap_data_dir, "CONFIG_BASEDIR": snapshot.snap_base_dir, "STAGED_ROOT_PASS": snapshot.snap_pass, "STAGED_BACKUP": snapshot.snap_backup_path } configure_script = pkgutil.get_data('resources', 'provision.sh') result = libs.run_bash(virtual_source.connection, configure_script, environment_vars, check=False) logger.debug(result) output = result.stdout.strip() std_err = result.stderr.strip() exit_code = result.exit_code if exit_code == 0: logger.debug("Pre-Snapshot/Restore_DB successful " + output) else: err = utils.process_exit_codes(exit_code, "PROVISION", std_err) logger.debug( "There was an error while provisioning.Check error.log for details." ) logger.error(err) raise err return SourceConfigDefinition(db_name=output, base_dir=virtual_source.parameters.base_dir, port=virtual_source.parameters.port, data_dir=mount_path)