VMware Cloud Foundation APIs: Deploying VCF Operations for Networks
Your VMware Cloud Foundation platforms capabilities can be further enhanced with the deployment of VCF Operations for Networks which can be utilized to provides a comprehensive overview of the platforms network health and issues. Using VCF Operations for Networks you can analyzes you current vSphere network traffic and configurations, map out dependencies to transition workloads smoothly and continuously monitors the health, logs, and metrics.
In this post we will look at how the VCF Operations for Networks component can be deployed using the public APIs, this is achieved via the VCF Fleet Lifecycle Service which is tightly integrated into VCF Operations.
VCF Fleet Lifecycle Service APIs Used
- POST /api/v1/identity/token
- GET /fleet-lcm/v1/sddc-lcms
- POST /fleet-lcm/v1/components/validations
- POST /fleet-lcm/v1/components
- GET /fleet-lcm/v1/tasks/{taskId}
Procedure
Connect to a system that has access to the infrastructure and is capable of running CURL.
Replace the values in the sample code with values for your VCF Fleet Lifecycle Service and paste the commands in the console. If your not sure which endpoint this FQDN should be log into VCF Operations, go to Build > Lifecycle > VCF Management and select the Components tab and locate the component named Fleet lifecycle the FQDN is shown in the FQDN column.
1export vcfFleetLifecycleFqdn='flt-fc01.rainpole.io'
2export vcfFleetLifecycleUser='[email protected]'
3export vcfFleetLifecyclePass='VMw@re1!VMw@re1!'
- Authenticate to the VCF Fleet Lifecycle Service and obtain a token by running the following command:
1vcfFleetLifecycleToken=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/api/v1/identity/token" \
2 -H 'Content-Type: application/x-www-form-urlencoded' \
3 --data "grant_type=password" \
4 --data "username=$vcfFleetLifecycleUser" \
5 --data "password=$vcfFleetLifecyclePass" \
6 | jq -r '.access_token')
- Verify you successfully obtained an authentication token by running the following command:
1echo $vcfFleetLifecycleToken
Example Output:
1eyJhbGciOiJFZERTQSIsImtpZCI6Ilg4Mk5veGNJRlVCVEFiY0xPM1NUdU12UTF6Qlo4d01xeUxDTGNuOGZYdFUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2ZsdC1mYzAxLnJhaW5wb2xlLmlvIiwic3ViIjoiYWRtaW5AdnNwLmxvY2FsIiwiYXVkIjpbInZzcCJdLCJleHAiOjE3ODM0MzU1NTIsImlhdCI6MTc4MzQyMTE1MiwianRpIjoiMjA3OTg0MDgtZGE3OC00N2UzLTgxMDctNDAyMThkNjM1ZThmIiwiYXpwIjoicGFzc3dvcmRfZ3JhbnRfY2xpZW50IiwiYWNjdCI6ImFkbWluQHZzcC5sb2NhbCIsImF1dGhvcml6YXRpb25fZGV0YWlscyI6bnVsbH0.OsXjW3cgwZaEMXwZC6MOqOped5MX1wdf3wpUmjZLaRiXeug4rtm9dnWHvPrp5pM74MNsVEjhbeT3u0TJjgIIBQ
- First we retrieve the unique ID of the SDDC instance by running the following command:
1primarySddcLcms=$(curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/sddc-lcms" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq -r '.sddcLcms[] | select(.isPrimary == true) | .id')
- Verify you successfully obtained the SDDC instance by running the following command:
1echo $primarySddcLcms
Example Output:
13e8d0034-906b-49cb-9c47-3afa8d919192
- Replace the values in the sample code with values for the deployment of your VCF Operations for Networks instance and paste the commands in the console.
1export opsNetworksPlatformFqdn='flt-net01a.rainpole.io'
2export opsNetworksPlatformIp='10.11.10.62'
3export opsNetworksPlatformSize='medium'
4export opsNetworksPlatformPass='VMw@re1!VMw@re1!'
5export opsNetworksControllerFqdn='sfo-netc01.sfo.rainpole.io'
6export opsNetworksControllerIp='10.11.10.14'
7export opsNetworksControllerSize='medium'
8export opsNetworksControllerPass='VMw@re1!VMw@re1!'
9export opsNetworksAdminPassword='VMw@re1!VMw@re1!'
- Create the JSON payload for the VCF Operations for Networks instance deployment by running the following command:
1cat << EOF > ops-networks-deploy.json
2{
3 "componentSpecs": [
4 {
5 "sddcLcmId": "${primarySddcLcms}",
6 "componentType": "OPS_NETWORKS",
7 "deploymentType": "OvaComponentSpec",
8 "nodeSpecs": [
9 {
10 "nodeType": "PLATFORM",
11 "version": "9.1.0.0",
12 "deploymentSpec": {
13 "fqdn": "${opsNetworksPlatformFqdn}",
14 "deploymentOption": "${opsNetworksPlatformSize}",
15 "password": "${opsNetworksPlatformPass}",
16 "ipv4Settings": {
17 "address": "${opsNetworksPlatformIp}"
18 }
19 }
20 },
21 {
22 "nodeType": "COLLECTOR",
23 "version": "9.1.0.0",
24 "deploymentSpec": {
25 "fqdn": "${opsNetworksControllerFqdn}",
26 "deploymentOption": "${opsNetworksControllerSize}",
27 "password": "${opsNetworksControllerPass}",
28 "ipv4Settings": {
29 "address": "${opsNetworksControllerIp}"
30 }
31 }
32 }
33 ],
34 "configSpec": {
35 "adminPassword": "${opsNetworksAdminPassword}"
36 }
37 }
38 ]
39}
40EOF
- Verify the JSON payload has been populated correctly by running the following command:
1cat ops-networks-deploy.json
Example Output:
1{
2 "componentSpecs": [
3 {
4 "sddcLcmId": "e35632dc-2777-432e-8985-7e1f0a32acf3",
5 "componentType": "OPS_NETWORKS",
6 "deploymentType": "OvaComponentSpec",
7 "nodeSpecs": [
8 {
9 "nodeType": "PLATFORM",
10 "version": "9.1.0.0",
11 "deploymentSpec": {
12 "fqdn": "flt-net01a.rainpole.io",
13 "deploymentOption": "medium",
14 "password": "VMw@re1!VMw@re1!",
15 "ipv4Settings": {
16 "address": "10.11.10.62"
17 }
18 }
19 },
20 {
21 "nodeType": "COLLECTOR",
22 "version": "9.1.0.0",
23 "deploymentSpec": {
24 "fqdn": "sfo-netc01.sfo.rainpole.io",
25 "deploymentOption": "medium",
26 "password": "VMw@re1!VMw@re1!",
27 "ipv4Settings": {
28 "address": "10.11.10.14"
29 }
30 }
31 }
32 ],
33 "configSpec": {
34 "adminPassword": "VMw@re1!VMw@re1!"
35 }
36 }
37 ]
38}
- Validate the JSON payload by running the following command:
1validationId=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/components/validations" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 -d @ops-networks-deploy.json | jq -r ".id")
- Check the status of the validation by running the following command:
1curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$validationId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq
- The command in step 11 may need to be run multiple times, alternatively you can run the command over and over by running the following command:
1while curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$validationId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq '{status: .status}' \
6 | grep -q "RUNNING"; do
7 echo "Still in 'RUNNING' state... waiting 2 seconds."
8 sleep 2
9done
- Start the deployment by running the following command:
1deploymentId=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/components" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 -d @ops-networks-deploy.json | jq -r ".id")
- Check the status of the deployment by running the following command:
1curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$deploymentId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq
- The command in step 11 would need to be run multiple times, alternatively you can run the command over and over by running the following command:
1while curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$deploymentId" \
2 --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3 --header "Accept: application/json" \
4 --header "Content-Type: application/json" \
5 | jq '{status: .status}' \
6 | grep -q "RUNNING"; do
7 echo "Still in 'RUNNING' state... waiting 60 seconds."
8 sleep 60
9done