Registering a vSphere Replication Server instance into a vCloud Availability for vCloud Director deployment uses multiple steps and calls to the Web service API.

About this task

The following steps show the sample process using a combination of the curl tool and shell variables to compose the required requests to register a new vSphere Replication Server instance.

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 variables that you use in the rest of the registration process:
    VCD_IP=<IP address or FQDN for the vCD host>
    VRS_IP=<IP address or FQDN for the VRS host>
    VRS_THUMBPRINT=`openssl s_client -connect $VRS_IP:5480 \
        -tls1 -verify 0 </dev/null 2>/dev/null | \
    openssl x509 -fingerprint -noout | grep Fingerprint | \
    head -n1 | \awk -F= '{print $2}'`
    

    This step configures the IP address of the vSphere Replication Server instance, and the fingerprint required to access the information.

  2. Generate variables to be used to hold information for the first access to the API:
    CONTENT="regVRS-content.txt"
    HEADERS="regVRS-headers.txt"
    ACCEPT='Accept: application/*+xml;version=5.6'
    USER='root@system'
    PASS='ca$hc0w'

    The $CONTENT variable is a file, to which the information is returned. The $HEADERS is the header material used to supply authentication and supported returned types.

  3. Authenticate with the vCD API by using curl with the previously set variables.
    $ curl -k -o "$CONTENT" -D "$HEADERS" -X POST --user "$USER:$PASS" -H "$ACCEPT" "https://${VCD_IP}/api/sessions"

    The information returned from this call is placed into the two files reference by the variables. One containing the headers, and the other the body.

  4. You can confirm that the process finishes successfully by checking the content of the header file:
    $ head -n1 $HEADERS

    The returned header contains a successful HTTP result code 200, for example HTTP/1.1 200 OK.

  5. Extract the authorization code from the returned header information. The code must be provided in future requests to authenticate the operations.
    $ grep x-vcloud-authorization "$HEADERS" | awk -F : '{print $2}' | tr -d ' '
  6. Create a variable containing the return authorization code:
    $ VCD_COOKIE=93f2f3f0c07a4355b3466812ddf9987e
  7. Obtain the URL for the VIM server by submitting another curl request, using the authorization code:
    $ curl -k -o "$CONTENT" -D "$HEADERS" \
        -H "x-vcloud-authorization: $VCD_COOKIE" \
        -H "$ACCEPT" \
        https://${VCD_IP}/api/admin/extension/vimServerReferences

    The returned header contains a successful HTTP result code 200.

  8. Extract the VimServerReference from the returned data:
    $ cat $CONTENT | grep "vmext:VimServerReference" | awk -F\" '{print $2}'
  9. Set the returned value into a variable:
    $VIM_URL=https://10.158.12.163/api/admin/extension/vimServer/f88ce1f6-f8f3-489b-9f32-fac50b035f2b
  10. Build the request body:
    ACCEPT='Accept: application/*+xml;version=6.0;vr-version=3.0'
    REGVRS_BODY="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
    <ns2:ManageVrServerParams xmlns=\"http://www.vmware.com/vcloud/v1.5\" xmlns:ns2=\"http://www.vmware.com/vr/v6.0\">
        <ns2:VrThumbprint>${VRS_THUMBPRINT}</ns2:VrThumbprint>
        <ns2:VrManagementURI>https://${VRS_IP}:8123</ns2:VrManagementURI>
    <ns2:VrTrafficPort>31031</ns2:VrTrafficPort>
    </ns2:ManageVrServerParams>"
  11. Submit the request using the compiled request body:
    $ curl -k -o "$CONTENT" -D "$HEADERS" \
        -X POST --data-binary "$REGVRS_BODY" \
        -H "x-vcloud-authorization: $VCD_COOKIE" \
        -H "Content-Type: application/vnd.vmware.hcs.registerVrServerParams+xml" \
        -H "$ACCEPT" ${VIM_URL}/action/registerVrServer

    The returned header contains a successful HTTP result code 200.

  12. Extract the URL required to perform the registration:
    $ cat $CONTENT | grep Link | grep "application/vnd.vmware.vcloud.task+xml" | awk -F\" '{print $4}'
    # TASK_URL=https://10.158.12.163/api/task/49e6347e-0382-4843-b494-2eea01e77229
  13. To perform the registration, submit the final request:
    $ curl -k -o "$CONTENT" -D "$HEADERS" \
        -H "x-vcloud-authorization: $VCD_COOKIE" -H "$ACCEPT" $TASK_URL

    The returned header contains a successful HTTP result code 200.

What to do next

Examine the content of the returned information and verify that the progress is 100 and that there are no errors listed.