Enabling replication for a virtual machine a vCloud Availability for vCloud Director deployment uses multiple steps and calls to the Web service API.

About this task

During the replication enablement process, the steps are completed by a vCloud Director administrator.

Note:

The following procedure contains long, single commands that should be run as one. There are breaks in the command for better visibility marked with "\". "#" marks the beginning of a new command.

Prerequisites

When using the Web services API, you can use any tool that can set and request the required information. In the example below, the command-line tool curl. The process requires multiple steps, first to obtain the authorization, then the registration URL, and finally the call that performs the registration.

Procedure

  1. Create some variables that are used in the rest of the process:
    CONTENT="regOrg-content.txt"
    HEADERS="regOrg-headers.txt"
    ACCEPT='Accept: application/*+xml;version=5.6'
    USER='administrator@System'
    PASS='.s3cr3tP@ssw0rd!'
    VCD_IP=10.158.12.128
  2. Authenticate with the vCD API by using curl with the previously set variables. You use the authorization token returned in all further commands.
    # curl -k -o "$CONTENT" -D "$HEADERS" -X POST --user "$USER:$PASS" \
     -H "$ACCEPT" "https://${VCD_IP}/api/sessions"
  3. Extract the authorization code from the returned header information:
    # head -n1 $HEADERS
    
    # grep x-vcloud-authorization "$HEADERS" | awk -F : '{print $2}' | tr -d ' '
    
  4. Set a variable to contain the authorization code:
    # VCD_COOKIE=93f2f3f0c07a4355b3466812ddf9987e
    
  5. To identify the correct organization where the replication will be enabled, obtain a list of configured organizations:
    # curl -k -o "$CONTENT" -D "$HEADERS" \
     -H "x-vcloud-authorization: $VCD_COOKIE" \
     -H "$ACCEPT" https://${VCD_IP}/api/org
  6. Extract the organization:
    # head -n1 $HEADERS
    
    # cat $CONTENT | grep "application/vnd.vmware.vcloud.org+xml" | awk -F\" '{print $4 ":" $2}'
  7. Obtain a list of the VDCs within the organization:
    # curl -k -o "$CONTENT" -D "$HEADERS" -H "x-vcloud-authorization: $VCD_COOKIE" \
      -H "$ACCEPT" https://10.158.12.163/api/org/0be6ca24-5769-413e-b121-2d7290310dcb
    
    # head -n1 $HEADERS
    
    # cat $CONTENT | grep "application/vnd.vmware.vcloud.vdc+xml" | awk -F\" '{print $6 ":" $4}'
  8. To enable a replication to the selected organization, obtain the registration URL required:
    # curl -k -o "$CONTENT" -D "$HEADERS" -H "x-vcloud-authorization: $VCD_COOKIE" \
      -H "$ACCEPT" https://10.158.12.163/api/vdc/0de76523-a3ec-4b90-878d-007527127ce0
    
    # head -n1 $HEADERS
    
    # cat $CONTENT | grep "enableReplication" | awk -F\" '{print $4}'
  9. Enable a replication by submitting a POST request using the URL retrieved in the previous step.
    # curl -k -o "$CONTENT" -D "$HEADERS" -X POST -H "x-vcloud-authorization: $VCD_COOKIE" \
      -H "$ACCEPT" \
      https://10.158.12.163/api/vdc/0de76523-a3ec-4b90-878d-007527127ce0/action/enableReplication
    
    # head -n1 $HEADERS
    
    # cat $CONTENT | grep Link | grep "application/vnd.vmware.vcloud.task+xml" | \
      awk -F\" '{print $4}'
  10. Confirm that the task finishes successfully to enable a replication.
    # curl -k -o "$CONTENT" -D "$HEADERS" -H "x-vcloud-authorization: $VCD_COOKIE" \
      -H "$ACCEPT" https://10.158.12.163/api/task/49e6347e-0382-4843-b494-2eea01e77229
    
    # head -n1 $HEADERS
    
    # cat $CONTENT

Results

Replication is now be enabled. If the task fails, look for the error, correct, and try to enable a replication again.