How to forcefully remove the Network Director app from the MySQL database in Junos Space?
On some occasions, after an upgrade, the Network Director app is not upgraded simultaneously, the app was deleted from the WebUI but some entries were not removed as expected, or the app simply needs to be deleted for business reasons, so this article is meant to delete the Network director app from the Junos Space MySQL build_db database.
For performing this process, we would recommend the below steps, please start with steps from Option 1, if you have difficulties run the steps from Option 2 or Option 3:
[Option 1] We need to first try to delete the app directly from the Junos Space WebUI: Uninstalling a Junos Space Application
[Option 2] Delete the Network Director App from the CLI:
2.1 Take a Database backup, so this could be used if necessary to recover the Junos Space server.
2.2 Login into Space CLI and execute below script files from the path [/var/www/cgi-bin/secure]:
cd /var/www/cgi-bin/secure perl uninstall_cm.pl perl uninstall_mssosadapter.pl perl deleteModule.pl module=CM ear=cm appTitle=NetworkDirector delDb=yes
2.3 Login to the MySQL database:
mysql -ujboss build_db -p$(grep mysql.jboss /etc/sysconfig/JunosSpace/pwd | awk -F= '{print $2}')
2.4 Check if there is information from the Network Director app still in the database since it should be empty at this point:
mysql> select paradigmModule from AppVersionInfo; mysql> select id as ID2,name,module_id as ID1 from RBAC_ROLE where module_id=(select id from PARADIGM_MODULE where appName='CM');
[Option 3] If you receive an error while attempting to delete the Network Director app using the prior steps, or you still see entries in the output from the command 2.4, then we can use the below steps to forcefully delete the app from the MySQL database:
Note: If you took a backup in step 2.1, you can skip step 3.1.
3.1 Take a Database backup, so this could be used if necessary to recover the Junos Space server.
3.2 Login to the MySQL database.
3.3 Use the below command to extract the Network Director ID2, and ID1 columns as they are important for the next steps and they may vary so make sure you use the values received by your MySQL database, otherwise other information could be compromised.
mysql> select id as ID2,name,module_id as ID1 from RBAC_ROLE where module_id=(select id from PARADIGM_MODULE where appName='CM'); +-----+--------------------------------+------+ | ID2 | name | ID1 | +-----+--------------------------------+------+ | 43 | NetworkMonitorAdminRole | 10 | | 45 | CloudAdminRole | 10 | | 46 | NetworkImageAdminRole | 10 | | 47 | NetworkConfigAdminRole | 10 | | 48 | NetworkAdminRole | 10 | | 49 | NetworkConfigApprovalAdminRole | 10 | | 50 | NetworkEngineerRole | 10 | +-----+--------------------------------+------+ 7 rows in set (0.00 sec)
3.4 We need to delete from the RBAC_ROLE_RBAC_CAPABILITY table the roles_id that are associated with [ NetworkMonitorAdminRole, CloudAdminRole, NetworkImageAdminRole, NetworkConfigAdminRole, NetworkAdminRole, NetworkConfigApprovalAdminRole, NetworkEngineerRole ] using the respective ID2 column from the command taken from your Junos Space on step 2.2 of this guide.
mysql>delete from RBAC_ROLE_RBAC_CAPABILITY where roles_id=43; mysql>delete from RBAC_ROLE_RBAC_CAPABILITY where roles_id=45; mysql>delete from RBAC_ROLE_RBAC_CAPABILITY where roles_id=46; mysql>delete from RBAC_ROLE_RBAC_CAPABILITY where roles_id=47; mysql>delete from RBAC_ROLE_RBAC_CAPABILITY where roles_id=48; mysql>delete from RBAC_ROLE_RBAC_CAPABILITY where roles_id=49; mysql>delete from RBAC_ROLE_RBAC_CAPABILITY where roles_id=50;
3.5 Delete from the following tables [ RBAC_ROLE, PARADIGM_TASK, PARADIGM_WORKSPACE_PARADIGM_MODULE, RBAC_CAPABILITY, PARADIGM_MODULE] using the ID1 value from the command taken from your Junos Space on step 2.2 of this guide.
mysql>delete from RBAC_ROLE where module_id=10; mysql>delete from PARADIGM_TASK where module_id=10; mysql>delete from PARADIGM_WORKSPACE_PARADIGM_MODULE where modules_id=10; mysql>delete from RBAC_CAPABILITY where module_id=10; mysql>delete from PARADIGM_MODULE where id=10;
3.6 Delete from the AppVersionInfo table the app named "cm":
mysql>delete from AppVersionInfo where appName="cm";
3.7 Exit the MySQL database:
mysql>\q