# Uninstalling from RHOSO

## 1] Uninstall TVO Control Plane Services

Delete tvocontrolplane resource

```
cd triliovault-cfg-scripts/redhat-director-scripts/rhosp18/ctlplane-scripts/
./uninstall_tvo_control_plane.sh
```

## 1.1] Uninstall operator - tvo-operator

```
cd triliovault-cfg-scripts/redhat-director-scripts/rhosp18/ctlplane-scripts/
./uninstall_operator.sh <TVO_OPERATOR_CONTAINER_IMAGE_URL>
```

## 1.2] Delete old trilio-galera cluster pvcs and pv

Use the following command

```
oc -n trilio-openstack get pvc
oc -n trilio-openstack delete pvc <pvc0> <pvc1> <pvc2>
```

## 1.3] Unmount the backup targets

List openshift trilio control plane nodes

```
oc get nodes -l trilio-control-plane=enabled
Example:- 
[openstackdev@localhost dataplane-scripts]$ oc get nodes -l trilio-control-plane=enabled
NAME      STATUS   ROLES                         AGE   VERSION
master1   Ready    control-plane,master,worker   90d   v1.31.6
master2   Ready    control-plane,master,worker   90d   v1.31.6
master3   Ready    control-plane,master,worker   90d   v1.31.6

```

SSH Login to all these nodes and unmount the backup targets used by Trilio control plane services

```
oc debug node/master1
chroot /host
 
 ## List NFS backup target mounts
 mount | grep nfs
 
 ## Unmount all shares listed in above command output
 umount -l <NFS_Share>
 
 ## Verify that trilio nfs backup target is listed in command output
 mount  | grep nfs
 
 ## Unmount S3 backup target mounts
 ls -ll /var/lib/trilio/triliovault-mounts/
 
 ## If there is any S3 backup target mounted inside above director, abobve command will 
 ## fail and will provide mount point information.
 ## You need to copy those mount points and do unmount
 umount /var/lib/trilio/triliovault-mounts/<mount_point>
 
 ## After unmounting all backup targets, you will be able to run following command successfully
 ls -ll /var/lib/trilio/triliovault-mounts/
 
 ## Remove triliovault-mounts directory
 rm -rf /var/lib/trilio/triliovault-mounts/
```

## 2] Uninstall TVO Data Plane Services

Delete dataplane trilio resources from openshift

```
cd triliovault-cfg-scripts/redhat-director-scripts/rhosp18/dataplane-scripts
./uninstall.sh
```

## 2.1] Log into each compute node, then stop and disable all Trilio services using the approach outlined below.

```
ssh root@<compute_ip>

Example:-
systemctl list-units | grep trilio
  edpm_triliovault-datamover.service                                                                                                   loaded active running   triliovault-datamover container
  edpm_triliovault-object-store-BT1_S3.service                                                                                         loaded active running   triliovault-object-store-BT1_S3 container

systemctl stop edpm_triliovault-datamover.service
systemctl disable edpm_triliovault-datamover.service
Removed "/etc/systemd/system/multi-user.target.wants/edpm_triliovault-datamover.service".

```

## 2.2] Clean Trilio Keystone resources

Trilio registers services and users in Keystone. Those need to be unregistered and deleted.

```
openstack service delete dmapi
openstack user delete dmapi
openstack service delete TrilioVaultWLM
openstack user delete triliovault
```

## 2.3] Clean Trilio database resources

Trilio creates databases for dmapi and workloadmgr services. These databases need to be cleaned.

Login into the database cluster

```
oc exec -it openstack-galera-0 -n openstack bash
mysql -u root -p<password>
```

Run the following SQL statements to clean the database.

```
## Clean database
DROP DATABASE dmapi;

## Clean dmapi user
=> List 'dmapi' user accounts
MariaDB [(none)]> select user, host from mysql.user where user='dmapi';
+-------+------+
| User  | Host |
+-------+------+
| dmapi | %    |
+-------+------+
1 row in set (0.001 sec)

=> Delete those user accounts
MariaDB [(none)]> DROP USER dmapi@'%';
Query OK, 0 rows affected (0.011 sec)

=> Verify that dmapi user got cleaned
MariaDB [(none)]> select user, host from mysql.user where user='dmapi';
Empty set (0.001 sec)

## Clean database
DROP DATABASE workloadmgr;

## Clean workloadmgr user
=> List 'workloadmgr' user accounts
MariaDB [(none)]> select user, host from mysql.user where user='workloadmgr';
+-------------+------+
| User        | Host |
+-------------+------+
| workloadmgr | %    |
+-------------+------+
1 row in set (0.001 sec)

=> Delete those user accounts
MariaDB [(none)]> DROP USER workloadmgr@'%';
Query OK, 0 rows affected (0.008 sec)

=> Verify that workloadmgr user got cleaned
MariaDB [(none)]> select user, host from mysql.user where user='workloadmgr';
Empty set (0.001 sec)

```
