Skip to content

Commit f699fd4

Browse files
committed
CLOUDSTACK-9463: Fix dynamic-roles migrate script for old format
The old commands.properties format included the full class name such as: createAccount=com.cloud.api.commands.CreateAccountCmd;1 The migration script did not consider this format and fails. With this fix the migration script will process both the formats, including processing a commands.properties file with mixed format, for example: $ cat commands.properties ### Account commands createAccount=1 deleteAccount=2 markDefaultZoneForAccount=com.cloud.api.commands.MarkDefaultZoneForAccountCmd;3 $ python scripts/util/migrate-dynamicroles.py -d -f commands.properties Apache CloudStack Role Permission Migration Tool (c) Apache CloudStack Authors and the ASF, under the Apache License, Version 2.0 Running this migration tool will remove any default-role permissions from cloud.role_permissions. Do you want to continue? [y/N]y The commands.properties file has been deprecated and moved at: commands.properties.deprecated Running SQL query: DELETE FROM `cloud`.`role_permissions` WHERE `role_id` in (1,2,3,4); Running SQL query: INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 1, '*', 'ALLOW', 0); Running SQL query: INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'deleteAccount', 'ALLOW', 0); Running SQL query: INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'markDefaultZoneForAccount', 'ALLOW', 1); Static role permissions from commands.properties have been migrated into the db Running SQL query: UPDATE `cloud`.`configuration` SET value='true' where name='dynamic.apichecker.enabled' Dynamic role based API checker has been enabled! Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent bdc409c commit f699fd4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

scripts/util/migrate-dynamicroles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ def main():
107107
apiMap = {}
108108
with open(options.commandsfile) as f:
109109
for line in f.readlines():
110-
if not line or line == '' or line == '\n' or line.startswith('#'):
110+
if not line or line == '' or line == '\n' or line == '\r\n' or line.startswith('#'):
111111
continue
112112
name, value = line.split('=')
113-
apiMap[name.strip()] = value.strip()
113+
apiMap[name.strip()] = value.strip().split(';')[-1]
114114

115115
# Rename and deprecate old commands.properties file
116116
if not dryrun:

0 commit comments

Comments
 (0)