-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add parameter to not create additional users on cloudstack-setup-databases
#9969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lucas-a-martins
wants to merge
4
commits into
apache:main
Choose a base branch
from
scclouds:new-param-to-not-auto-create-db-users
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -72,6 +72,7 @@ class DBDeployer(object): | |||||||
magicString = 'This_is_a_magic_string_i_think_no_one_will_duplicate' | ||||||||
tmpMysqlFile = os.path.join(os.path.expanduser('~/'), 'cloudstackmysql.tmp.sql') | ||||||||
mysqlBinPath = None | ||||||||
skipUsersAutoCreation = False | ||||||||
|
||||||||
def preRun(self): | ||||||||
def backUpDbDotProperties(): | ||||||||
|
@@ -219,6 +220,17 @@ for full help | |||||||
""), | ||||||||
) | ||||||||
|
||||||||
queriesToSkip = ( | ||||||||
"CREATE USER cloud@`localhost` identified by 'cloud';", | ||||||||
"CREATE USER cloud@`%` identified by 'cloud';", | ||||||||
"GRANT ALL ON cloud.* to cloud@`localhost`;", | ||||||||
"GRANT ALL ON cloud.* to cloud@`%`;", | ||||||||
"GRANT ALL ON cloud_usage.* to cloud@`localhost`;", | ||||||||
"GRANT ALL ON cloud_usage.* to cloud@`%`;", | ||||||||
"GRANT process ON *.* TO cloud@`localhost`;", | ||||||||
"GRANT process ON *.* TO cloud@`%`;", | ||||||||
) | ||||||||
|
||||||||
scriptsToRun = ["create-database","create-schema", "create-database-premium","create-schema-premium"] | ||||||||
if self.options.schemaonly: | ||||||||
scriptsToRun = ["create-schema", "create-schema-premium"] | ||||||||
|
@@ -227,6 +239,8 @@ for full help | |||||||
p = os.path.join(self.dbFilesPath,"%s.sql"%f) | ||||||||
if not os.path.exists(p): continue | ||||||||
text = open(p).read() | ||||||||
if self.options.skipUsersAutoCreation: | ||||||||
for t in queriesToSkip: text = text.replace(t,"") | ||||||||
for t, r in replacements: text = text.replace(t,r) | ||||||||
self.info("Applying %s"%p) | ||||||||
self.runMysql(text, p, self.rootuser != None) | ||||||||
|
@@ -470,6 +484,8 @@ for example: | |||||||
self.encryptionJarPath = self.options.encryptionJarPath | ||||||||
if self.options.mysqlbinpath: | ||||||||
self.mysqlBinPath = self.options.mysqlbinpath | ||||||||
if self.options.skipUsersAutoCreation: | ||||||||
self.skipUsersAutoCreation = self.options.skipUsersAutoCreation | ||||||||
Comment on lines
+489
to
+490
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The flag is checked in multiple locations; consider consolidating the handling of skipUsersAutoCreation to ensure consistency and reduce potential duplication of logic.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||
|
||||||||
if self.options.encryptorVersion: | ||||||||
self.encryptorVersion = "--encryptorversion %s" % self.options.encryptorVersion | ||||||||
|
@@ -610,6 +626,9 @@ for example: | |||||||
self.parser.add_option("-g", "--encryptor-version", action="store", dest="encryptorVersion", default="V2", | ||||||||
help="The encryptor version to be used to encrypt the values in db.properties") | ||||||||
self.parser.add_option("-b", "--mysql-bin-path", action="store", dest="mysqlbinpath", help="The mysql installed bin path") | ||||||||
self.parser.add_option("-u", "--skip-users-auto-creation", action="store_true", dest="skipUsersAutoCreation", | ||||||||
help="Indicates whether to skip the auto-creation of users in the database. Use this flag when your database users " \ | ||||||||
"are already configured and you only want to populate the db.properties file.") | ||||||||
(self.options, self.args) = self.parser.parse_args() | ||||||||
parseCasualCredit() | ||||||||
parseOtherOptions() | ||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.