VMWare vRA 7.x Removing a VM and related deployment from vRA after it is accidentally deleted using vsphere client

From Notes_Wiki
Revision as of 09:18, 7 April 2022 by Saurabh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Home > VMWare platform > vRealize Automation or VMWare Cloud > VMWare vRA 7.x Removing a VM and related deployment from vRA after it is accidentally deleted using vsphere client

For deleting a VM from vRA refer https://kb.vmware.com/s/article/2144269

After downloading and installing cloud client as suggested at above KB article, example commands that can be run in cloud client are:

vra login userpass --user configurationadmin --tenant vsphere.local --server vra.rnd.com --password Rnd@1234

vra login iaas --user tenantadmin --domain rnd.com --server iaas.rnd.com --password Rnd@1234

vra machines forceunregister --name Rnd-test-lo-t1


Sample input/output while using above steps:

Microsoft Windows [Version 10.0.16299.309]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\Saurabh.Rnd>java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -client       to select the "client" VM
    -server       to select the "server" VM
                  The default VM is client.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

C:\Users\Saurabh.Rnd>cd Downloads

C:\Users\Saurabh.Rnd\Downloads>cd VMware_vRealize_CloudClient-4.3.0-4665091


C:\Users\Saurabh.Rnd\Downloads\VMware_vRealize_CloudClient-4.3.0-4665091>cd VMware_vRealize_CloudClient-4.3.0-4665091\bin

C:\Users\Saurabh.Rnd\Downloads\VMware_vRealize_CloudClient-4.3.0-4665091\VMware_vRealize_CloudClient-4.3.0-4665091\bin>dir
 Volume in drive C is Windows
 Volume Serial Number is 9408-BF43

 Directory of C:\Users\Saurabh.Rnd\Downloads\VMware_vRealize_CloudClient-4.3.0-4665091\VMware_vRealize_CloudClient-4.3.0-4665091\bin

17-11-2016  17:31    <DIR>          .
17-11-2016  17:31    <DIR>          ..
17-11-2016  17:31            35,898 cloudclient.bat
17-11-2016  17:31            34,338 cloudclient.sh
               2 File(s)         70,236 bytes
               2 Dir(s)  84,821,598,208 bytes free

C:\Users\Saurabh.Rnd\Downloads\VMware_vRealize_CloudClient-4.3.0-4665091\VMware_vRealize_CloudClient-4.3.0-4665091\bin>cloudclient.bat
VMWARE END USER LICENSE AGREEMENT

....Many lines of license agreement....

California 94304, United States of America, Attention: Legal Department.


Do you accept the terms of license agreement? (Y)es/(N)o:Y
CloudClient Truststore password is stored at C:\Users\Saurabh.Rnd\.cloudclient\cloudclient.secure.truststore.password
===================================================
 _____ _                 _ _____ _ _            _
/  __ \ |               | /  __ \ (_)          | |
| /  \/ | ___  _   _  __| | /  \/ |_  ___ _ __ | |_
| |   | |/ _ \| | | |/ _` | |   | | |/ _ \ '_ \| __|
| \__/\ | (_) | |_| | (_| | \__/\ | |  __/ | | | |_
 \____/_|\___/ \__,_|\__,_|\____/_|_|\___|_| |_|\__|


===================================================
Version : 4.3.0
*Tip* : You can hit tab to move through commands and arguments
*Tip* : You can autologon with a CloudClient.properties file

Welcome to the VMware CloudClient
CloudClient>vra login userpass --user configurationadmin --tenant vsphere.local --server vra.rnd.com --password Rnd@1234
The authenticity of vRealize Automation host ?vra.rnd.com' can't be established. The certificate information is as follows:
...Certificate lines...
Trust the certificate and continue connecting (Y/N)?Y
Added certificate to keystore 'C:\Users\Saurabh.Rnd\.cloudclient\cloudclient.secure.truststore' using alias 'vRealizeAutomation:vra.rnd.com'
The authenticity of IaaS host ?iaas.rnd.com' can't be established. The certificate information is as follows:
...Certificate lines...
Trust the certificate and continue connecting (Y/N)?Y
Added certificate to keystore 'C:\Users\Saurabh.Rnd\.cloudclient\cloudclient.secure.truststore' using alias 'IaaS:iaas.rnd.com'
vRA 7.3 login: [ACTIVE], session: [INACTIVE], user=[configurationadmin], server=[https://vra.rnd.com], tenant=[vsphere.local]
IaaS Model Manager login: [INACTIVE]
CloudClient>vra login iaas --user vmadmin --domain rnd.com --server iaas.rnd.com --password Rnd@1234
Authentication Success : IaaS Service.
vRA 7.3 login: [ACTIVE], session: [INACTIVE], user=[configurationadmin], server=[https://vra.rnd.com], tenant=[vsphere.local]
IaaS Model Manager login: [ACTIVE], session: [INACTIVE], user=[vmadmin], server=[iaas.rnd.com]
CloudClient>vra machines forceunregister --name Rnd-test-lo-t1
Successfully submitted IaaS request to unregister machine [name=Rnd-test-lo-t1] from vRA. Please wait 5-10 minutes for the backend to process this request. If it still exists, check IaaS's ManagerService.log for details.
CloudClient>

Since this did not work, took backup of IAAS/vRA database and tried to execute stored procedure available in zip file in same KB article. After executing stored procedure in vRA SQL server the VM disappears from Infrastructure -> Managed machines but is still visible under Items. For that logging into vRA appliance and executing postgreSQL query suggested in the same KB's zip file readme text file works.


This has removed the VM from vRA but deployment still exists. For deleting deployment we need to follow: https://kb.vmware.com/s/article/2148996

As part of this take snapshot of vRA appliance from vcenter without taking memory snapshot. Then use the above link to download a zip file. Extract zip file to get delete-deployment.sh shell script. Host shell script on a webserver or a Linux VM. Copy shell script to vra using scp/rsync/wget. Note that vra appliance does not has sftp subsystem so winscp/filezilla etc. wont work.

Then use article: https://kb.vmware.com/s/article/2144071 to obtain postgresql password for vcac user and vcac database using:

  1. Search for encrypted password in server.xml file
    grep password="*" /etc/vcac/server.xml > enc_pass.txt
  2. Open enc_pass.txt in vim and delete everything else apart from encrypted password. Also delete sorrounding double quotes.
  3. Then use following command to decrypt password and store it in text file
    /usr/lib/vcac/tools/config/bin/vcac-config prop-util -d --p $(cat enc_pass.txt) > postgresql_pass.txt
  4. Then use following command to store decrypted password in PGPASSWORD environment variable
    export PGPASSWORD=echo $(cat postgresql_pass.txt)
  5. Test with "echo $PGPASSWORD"

Finally delete delployment using:

 ./delete-deployment.sh "Name of deployment"

Here, "Name of deployment" should be taken from "Items" list of vRA.



Home > VMWare platform > vRealize Automation or VMWare Cloud > VMWare vRA 7.x Removing a VM and related deployment from vRA after it is accidentally deleted using vsphere client