Moti Asayag has uploaded a new change for review.

Change subject: engine: Maintain NetworkUser role id for VnicProfileUser
......................................................................

engine: Maintain NetworkUser role id for VnicProfileUser

The role id of the NetworkUser should be preserved for
VnicProfileUser so the same resource could be reachable
via the api.

Change-Id: I10ae120a9af5e79a2d9ddb7d2c94dda128e11ea4
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PredefinedRoles.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/auth/ApplicationGuids.java
A 
packaging/dbscripts/upgrade/03_03_0760_preserve_network_user_id_for_vnic_profile.sql
3 files changed, 39 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/18019/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PredefinedRoles.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PredefinedRoles.java
index 18dd7d9..b411274 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PredefinedRoles.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PredefinedRoles.java
@@ -21,7 +21,7 @@
     VM_CREATOR(new Guid("DEF0000A-0000-0000-0000-DEF00000000D")),
     TEMPLATE_CREATOR(new Guid("DEF0000A-0000-0000-0000-DEF00000000E")),
     TEMPLATE_OWNER(new Guid("DEF0000A-0000-0000-0000-DEF00000000F")),
-    VNIC_PROFILE_USER(new Guid("DEF00020-0000-0000-0000-DEF000000010"));
+    VNIC_PROFILE_USER(new Guid("DEF0000A-0000-0000-0000-DEF000000010"));
 
     private Guid id;
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/auth/ApplicationGuids.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/auth/ApplicationGuids.java
index 905657f..788af26 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/auth/ApplicationGuids.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/auth/ApplicationGuids.java
@@ -13,7 +13,7 @@
     userTemplateBasedVM(new Guid("def00009-0000-0000-0000-def000000009")), 
//$NON-NLS-1$
     quotaConsumer(new Guid("def0000a-0000-0000-0000-def00000000a")), 
//$NON-NLS-1$
     dataCenterAdmin(new Guid("def00002-0000-0000-0000-def000000002")), 
//$NON-NLS-1$
-    vnicProfileUser(new Guid("def00020-0000-0000-0000-def000000010")), 
//$NON-NLS-1$
+    vnicProfileUser(new Guid("DEF0000A-0000-0000-0000-DEF000000010")), 
//$NON-NLS-1$
 
     // ad_groups
     everyone(new Guid("eee00000-0000-0000-0000-123456789eee")); //$NON-NLS-1$
diff --git 
a/packaging/dbscripts/upgrade/03_03_0760_preserve_network_user_id_for_vnic_profile.sql
 
b/packaging/dbscripts/upgrade/03_03_0760_preserve_network_user_id_for_vnic_profile.sql
new file mode 100644
index 0000000..282da58
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_03_0760_preserve_network_user_id_for_vnic_profile.sql
@@ -0,0 +1,37 @@
+Create or replace FUNCTION __temp_preserve_network_user_role_id()
+RETURNS VOID
+AS $procedure$
+DECLARE
+    v_VNIC_PROFILE_USER_ID UUID;
+    v_NETWORK_USER_ID UUID;
+
+BEGIN
+    v_VNIC_PROFILE_USER_ID := 'DEF00020-0000-0000-0000-DEF000000010';
+    v_NETWORK_USER_ID := 'DEF0000A-0000-0000-0000-DEF000000010';
+
+------------------------------------------------------
+-- Update VnicProfileUser roleId to NetworkUser roleId
+------------------------------------------------------
+    ALTER TABLE roles_groups DROP CONSTRAINT fk_roles_groups_action_id;
+    ALTER TABLE permissions DROP CONSTRAINT fk_permissions_roles;
+
+    UPDATE roles
+    SET id = v_NETWORK_USER_ID
+    WHERE id = v_VNIC_PROFILE_USER_ID;
+
+    UPDATE permissions
+    SET role_id = v_NETWORK_USER_ID
+    WHERE role_id = v_VNIC_PROFILE_USER_ID;
+
+    UPDATE roles_groups
+    SET role_id = v_NETWORK_USER_ID
+    WHERE role_id = v_VNIC_PROFILE_USER_ID;
+
+    ALTER TABLE roles_groups ADD CONSTRAINT fk_roles_groups_action_id FOREIGN 
KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE;
+    ALTER TABLE permissions ADD CONSTRAINT fk_permissions_roles FOREIGN KEY 
(role_id) REFERENCES roles(id) ON DELETE CASCADE;
+
+END; $procedure$
+LANGUAGE plpgsql;
+
+SELECT __temp_preserve_network_user_role_id();
+DROP FUNCTION __temp_preserve_network_user_role_id();


-- 
To view, visit http://gerrit.ovirt.org/18019
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I10ae120a9af5e79a2d9ddb7d2c94dda128e11ea4
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to