Example: Creating a replication link
Here’s a sample PUT request that creates an active/active link named MA-CA between the local HCP system, hcp-ma.example.com, and a remote HCP system named hcp-ca.example.com. The link definition is in an XML file named MA-CA.xml. The request is made using a system-level user account that includes the administrator role.
Request body in XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <link> <name>MA-CA</name> <description>Active/active link between systems in MA and CA</description> <type>ACTIVE_ACTIVE</type> <connection> <remoteHost>replication.admin.hcp-ca.example.com</remoteHost> </connection> <compression>false</compression> <encryption>false</encryption> <priority>OLDEST_FIRST</priority> <failoverSettings> <local> <autoFailover>true</autoFailover> <autoFailoverMinutes>60</autoFailoverMinutes> </local> <remote> <autoFailover>true</autoFailover> <autoFailoverMinutes>60</autoFailoverMinutes> </remote> </failoverSettings> </link>
Request with cURL command line
curl -k -iT MA-CA.xml -H "Content-Type: application/xml" -H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382" "https://admin.hcp-ma.example.com:9090/mapi/services/replication/links"
Request in Python using PycURL
import pycurl import os filehandle = open("MA-CA.xml", 'rb') curl = pycurl.Curl() curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml", "Authorization: HCP \ YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"]) curl.setopt(pycurl.URL, "https://admin.hcp-ma.example.com:9090/mapi/services/" + "replication/links") curl.setopt(pycurl.SSL_VERIFYPEER, 0) curl.setopt(pycurl.SSL_VERIFYHOST, 0) curl.setopt(pycurl.UPLOAD, 1) curl.setopt(pycurl.INFILESIZE, os.path.getsize("MA-CA.xml")) curl.setopt(pycurl.READFUNCTION, filehandle.read) curl.perform() print curl.getinfo(pycurl.RESPONSE_CODE) curl.close() filehandle.close()
Request headers
PUT /mapi/services/replication/links HTTP/1.1 Host: admin.hcp-ma.example.com:9090 Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382 Content-Type: application/xml Content-Length: 648
Response headers
HTTP/1.1 200 OK X-HCP-SoftwareVersion: 9.0.0.2 Content-Length: 0