How to unapply VM extensions from a job
search cancel

How to unapply VM extensions from a job

book

Article ID: 293440

calendar_today

Updated On:

Products

Operations Manager

Issue/Introduction

Suppose that you want to delete the existing VM extensions from your job such as in the following om command line:
om -k -t pcf.myenv.mydomain -u admin -p myadminpassword curl  \
-p "/api/v0/staged/vm_extensions/<your existing vm extensions name>" \
-x DELETE

This operation may fail with the following error:
{
  "errors": {
    "vm_extension": [
      "cf-a*88e**e*0a5d381*3** is using \"<your existing vm extensions name>\" in vm_extensions"
    ]
  }
}

This error means that the target, VM extensions, is applied to an existing job and it can't be deleted. You need to unapply the target, VM extensions, from a job before deleting it. This article describes how to unapply VM extensions from a job.

Resolution

Step 1

You need to get the products' GUID with the following om command line:
om -k -t pcf.myenv.mydomain.com -u admin -p myadminpassword curl \
-p "/api/v0/deployed/products" -x GET

Get the GUID value from the guid section of the target product, which runs the target job to unapply the target, VM extensions.
 

Step 2

You need to get the target job's GUID with the following om command line. You need to specify the products' GUID, which you extracted at in Step 1:
om -k -t pcf.myenv.mydomain.com -u admin -p myadminpassword curl \
-p "/api/v0/staged/products/<Products' GUID from Step 1>/jobs" -x GET

Get the GUID value from guid section of the target job.


Step 3

You need to extract the current resource config of the target job with the specifying GUIDs extracted at the previous steps, as shown below:
om -k -t pcf.myenv.mydomain -u admin -p myadminpassword curl \
-p "/api/v0/staged/products/<Products' GUID from Step 1>/jobs/<Target job's GUID from Step 2>/resource_config" \
-x GET

Then, you'll receive the following kind response:
{
  "instance_type": {
    "id": "automatic"
  },
  "instances": 2,
  "additional_networks": [],
  "internet_connected": false,
  "elb_names": [
    "alb:akta-ssh-tg"
  ],
  "additional_vm_extensions": [
    "ssh-lb-security-groups"
  ],
  "swap_as_percent_of_memory_size": "automatic"
}


Step 4

Modify the response extracted during Step 3. Make it blank at the "additional_vm_extensions" section and apply it in the following om command line:
om -k -t pcf.myenv.mydomain.com -u admin -p myadminpassword curl \
-p "/api/v0/staged/products/<Products' GUID from Step 1>/jobs/<Target job's GUID from Step 2>/resource_config" -x PUT \
-H "Content-Type: application/json" \
-d '{
  "instance_type": {
    "id": "automatic"
  },
  "instances": 2,
  "additional_networks": [],
  "internet_connected": false,
  "elb_names": [
    "alb:akta-ssh-tg"
  ],
  "additional_vm_extensions": [],
  "swap_as_percent_of_memory_size": "automatic"
}'

As a result, you can now unapply the VM extensions from the target job.