Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 1bf0754

Browse files
authored
Merge pull request #22 from delphix/develop
Merging develop branch to main branch for Security Release
2 parents 989335f + 630f1e7 commit 1bf0754

17 files changed

+87
-502
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ This software is provided as-is, without warranty of any kind or commercial supp
6464

6565
### <a id="license"></a>License
6666

67-
This is code is licensed under the Apache License 2.0. Full license is available [here](./LICENSE).
67+
This is code is licensed under the Apache License 2.0. Full license is available [here](./LICENSE)

mysql_artifact_v2.0.26.json

-391
This file was deleted.

plugin_config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ pluginType: STAGED
77
entryPoint: plugin_runner:plugin
88
srcDir: src
99
schemaFile: schema.json
10-
buildNumber: 2.0.26
10+
buildNumber: 2.1.0

schema.json

+22-5
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@
7979
"prettyName": "DB User",
8080
"description": "DB user for the virtual database",
8181
"default": "delphixdb"
82-
},
82+
},
8383
"vdbPass": {
8484
"type": "string",
8585
"format": "password",
86+
"pattern" : "^[^\"\\'\\s]*$",
8687
"prettyName": "DB Password",
87-
"description": "DB user password for the virtual database",
88+
"description": "DB user password for the virtual database. Double quote, single quote or space characters are not valid.",
8889
"default": "Delphix@123"
8990
},
9091
"baseDir": {
@@ -199,8 +200,9 @@
199200
"sourcePass": {
200201
"type": "string",
201202
"format": "password",
203+
"pattern" : "^[^\"\\'\\s]*$",
202204
"prettyName": "Source Connection Password",
203-
"description": "* Required if Delphix is taking backups",
205+
"description": "* Required if Delphix is taking backups. Double quote, single quote or space characters are not valid.",
204206
"default": "Delphix@123"
205207
},
206208
"databaseList": {
@@ -224,15 +226,17 @@
224226
"replicationPass": {
225227
"type": "string",
226228
"format": "password",
229+
"pattern" : "^[^\"\\'\\s]*$",
227230
"prettyName": "Replication User's Password",
228-
"description": "* Required if using Replication Method with LogSync",
231+
"description": "* Required if using Replication Method with LogSync. Double quote, single quote or space characters are not valid.",
229232
"default": "Delphix@123"
230233
},
231234
"stagingPass": {
232235
"type": "string",
233236
"format": "password",
237+
"pattern" : "^[^\"\\'\\s]*$",
234238
"prettyName": "Staging Initialization Password",
235-
"description": "root user password to use while initializing Staging DB.",
239+
"description": "root user password to use while initializing Staging DB. Double quote, single quote or space characters are not valid.",
236240
"default": "Delphix@123"
237241
},
238242
"serverId": {
@@ -306,5 +310,18 @@
306310
"description": "Time when the snapshot was taken."
307311
}
308312
}
313+
},
314+
"snapshotParametersDefinition": {
315+
"type" : "object",
316+
"additionalProperties" : false,
317+
"required": ["resync"],
318+
"properties" : {
319+
"resync" : {
320+
"type": "boolean",
321+
"default": true,
322+
"prettyName": "Resynchronize dSource",
323+
"description": "Before taking a snapshot will refresh the staging database to update its data. Unselect this option if you wish to snapshot the staging database in its current state."
324+
}
325+
}
309326
}
310327
}

src/common/utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#
2+
# Copyright (c) 2021, 2023 by Delphix. All rights reserved.
3+
#
4+
15
import logging
26
import random
37
import time

src/dboperations/dboperations.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#
2+
# Copyright (c) 2021, 2023 by Delphix. All rights reserved.
3+
#
4+
15
import logging
26
import random
37
import time
@@ -37,7 +41,6 @@ def stop_mysql(port,connection,baseDir,vdbConn,pwd):
3741
if(port_stat == Status.ACTIVE):
3842
logger.debug("DB is Running. Shutting down.")
3943
shutdown_cmd = "%s/bin/mysqladmin %s'%s' --protocol=TCP --port=%s shutdown" % (baseDir,vdbConn,pwd,port)
40-
logger.debug("Shutdown Command: {}".format(shutdown_cmd))
4144
result = libs.run_bash(connection, shutdown_cmd,environment_vars,check=True)
4245
output = result.stdout.strip()
4346
error = result.stderr.strip()
@@ -46,7 +49,7 @@ def stop_mysql(port,connection,baseDir,vdbConn,pwd):
4649
logger.debug("There was an error trying to shutdown the database : "+error)
4750
raise MySQLShutdownException(error)
4851
else:
49-
logger.debug("Output: "+output)
52+
logger.debug("DB shutdown completed")
5053
time.sleep(25)
5154
if(Status.ACTIVE == get_port_status(port,connection)):
5255
logger.debug("KILL")
@@ -97,7 +100,6 @@ def get_port_status(port,connection):
97100
except Exception as err:
98101
logger.debug("Port Check Failed for second cmd: "+err.message)
99102
logger.debug("Port Status Response >")
100-
logger.debug(output)
101103

102104
if output== "":
103105
logger.debug("MySQL DB is NOT RUNNING at Port:"+myport)
@@ -130,7 +132,6 @@ def start_mysql(installPath,baseDir,mountPath,port,serverId,connection):
130132
if(port_stat == Status.INACTIVE):
131133
logger.debug("DB is not running. Starting the MySQL DB")
132134
start_cmd=get_start_cmd(installPath,baseDir,mountPath,port,serverId)
133-
logger.debug("Startup Command: {}".format(start_cmd))
134135
result = libs.run_bash(connection, start_cmd,environment_vars,check=True)
135136
output = result.stdout.strip()
136137
error = result.stderr.strip()
@@ -139,7 +140,7 @@ def start_mysql(installPath,baseDir,mountPath,port,serverId,connection):
139140
logger.debug("There was an error trying to start the DB : "+error)
140141
raise MySQLStartupException(error)
141142
else:
142-
logger.debug("Output: "+output)
143+
logger.debug("DB Started")
143144
time.sleep(25)
144145
if(Status.ACTIVE == get_port_status(port,connection)):
145146
logger.debug("DB Started Successfully")
@@ -168,12 +169,11 @@ def start_slave(connection,installPath,port,connString,username,pwd,hostIp):
168169
raise Exception("One of the required params for MySQL Connection is empty")
169170
else:
170171
start_slave_cmd=CommandFactory.start_replication(connection,installPath,port,connString,username,pwd,hostIp)
171-
logger.debug("Connection String with {}".format(start_slave_cmd))
172172
try:
173173
logger.debug("Starting Slave")
174174
result = libs.run_bash(connection, start_slave_cmd,environment_vars,check=True)
175175
output = result.stdout.strip()
176-
logger.debug("Start Slave Output: {}".format(output))
176+
logger.debug("Start Slave Completed")
177177
except Exception as err:
178178
logger.debug("Starting Slave Failed: "+err.message)
179179
raise err
@@ -187,17 +187,16 @@ def stop_slave(connection,installPath,port,connString,username,pwd,hostIp):
187187
raise Exception("One of the required params for MySQL Connection is empty")
188188
else:
189189
stop_slave_cmd=CommandFactory.stop_replication(connection,installPath,port,connString,username,pwd,hostIp)
190-
logger.debug("Connection String with {}".format(stop_slave_cmd))
191190
try:
192191
logger.debug("Stopping Replication")
193192
result = libs.run_bash(connection, stop_slave_cmd,environment_vars,check=True)
194193
_output=result.stdout.strip()
195194
_bashErrMsg=result.stderr.strip()
196195
_bashErrCode=result.exit_code
197196
if _bashErrCode!=0:
198-
logger.debug("Stopping Slave was not succesful")
197+
logger.debug("Stopping Slave was not successful")
199198
raise Exception(_bashErrMsg)
200-
logger.debug("Start Slave Response: {}".format(_output))
199+
logger.debug("Stop Replication successful")
201200
except Exception as err:
202201
logger.debug("Stop Replication Failed Due To: "+err.message)
203202
logger.debug("Ignoring and continuing")
@@ -213,7 +212,6 @@ def get_connection_cmd(installPath,port,connString,username,pwd,hostIp):
213212
raise ValueError("One of the required params for MySQL Connection is empty")
214213
else:
215214
connection_cmd=CommandFactory.connect_to_mysql(installPath,port,connString,username,pwd,hostIp)
216-
logger.debug("connaction_cmd >"+connection_cmd)
217215
return connection_cmd
218216

219217
def get_start_cmd(installPath,baseDir,mountPath,port,serverId):

src/plugin_runner.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#
2+
# Copyright (c) 2021, 2023 by Delphix. All rights reserved.
3+
#
4+
15
import pkgutil
26
import logging
37
import sys
@@ -75,16 +79,16 @@ def stop_staging(staged_source, repository, source_config):
7579
pluginops.stop_staging(staged_source, repository, source_config)
7680

7781
@plugin.linked.pre_snapshot()
78-
def linked_pre_snapshot(staged_source, repository, source_config, snapshot_parameters):
82+
def linked_pre_snapshot(staged_source, repository, source_config, optional_snapshot_parameters):
7983
logger.debug("linked_pre_snapshot > Start ")
8084
# Start Staging if not already running.
81-
pluginops.linked_pre_snapshot(staged_source, repository, source_config, snapshot_parameters)
85+
pluginops.linked_pre_snapshot(staged_source, repository, source_config, optional_snapshot_parameters)
8286
logger.debug(" linked_pre_snapshot > End ")
8387

8488
@plugin.linked.post_snapshot()
85-
def linked_post_snapshot(staged_source,repository,source_config,snapshot_parameters):
89+
def linked_post_snapshot(staged_source,repository,source_config,optional_snapshot_parameters):
8690
logger.debug("linked_post_snapshot - Start ")
87-
snapshot = pluginops.linked_post_snapshot(staged_source,repository,source_config,snapshot_parameters)
91+
snapshot = pluginops.linked_post_snapshot(staged_source,repository,source_config,optional_snapshot_parameters)
8892
linked_status(staged_source, repository, source_config)
8993
logger.debug("linked_post_snapshot - End ")
9094
return snapshot
@@ -105,9 +109,6 @@ def configure(virtual_source, snapshot, repository):
105109
def reconfigure(virtual_source, repository, source_config, snapshot):
106110
logger.debug("virtual.reconfigure > Start")
107111
start(virtual_source, repository, source_config)
108-
logger.debug(source_config)
109-
logger.debug("Snapshot")
110-
logger.debug(snapshot)
111112
#srcConfig = configure(virtual_source,snapshot,repository)
112113
logger.debug("virtual.reconfigure > End")
113114
virtual_status(virtual_source, repository, source_config)
@@ -140,7 +141,6 @@ def virtual_post_snapshot(virtual_source, repository, source_config):
140141
snapshot.snap_backup_path=""
141142
snapshot.snap_time=utils.get_current_time()
142143
logger.debug("SnapShot Definition Created")
143-
logger.debug(snapshot)
144144
return snapshot
145145

146146
@plugin.virtual.start()

0 commit comments

Comments
 (0)