Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, just want to ask if it's possible to import and export an endpoint similar to import and export functionality for replicate task? This might be needed for deployment from DEV to PROD. or for now the only option is to manually create the endpoints in PROD? Thanks!
I would like to answer this one since I got the answer from one of Qlik replicate consultants. Endpoints are already included when we import or export a replicate task so no need to concern us with this.
I would like to answer this one since I got the answer from one of Qlik replicate consultants. Endpoints are already included when we import or export a replicate task so no need to concern us with this.
It is possible to extract endpoint configuration from let say task or whole repository export,
Then you will need to construct correct JSON format and then you can use the file with json which defines endpoint only and using import you can bring it to another server.
Here is sample python code which uses AEM api, extracts required endpoint into json file and imports to destination replicate:
import os
import requests
import json
aemserver='FQDN-OR-IP-OF-AEM'
SourceReplicate='local-replicate'
TargetReplicate='remore-replicate'
endpoint = 'endpoint-you-need-to-copy'
work_dir = 'C:\\temp\\'
username = 'DOMAIN\\aem-admin-user'
password = 'aem-admin-user-passwd'
from requests.auth import HTTPBasicAuth
req = requests.get('https://' + aemserver + '/attunityenterprisemanager/api/v1/login', auth=(username, password),verify=False)
headers=req.headers
# Get JSON for all objects in repository and write it to file
url="https://" + aemserver + "/attunityenterprisemanager/api/v1/servers/" + SourceReplicate + "/?action=export"
r = requests.get(url,verify=False,headers=headers)
r.text
json_data = r.text
encoded_str = json_data
file = work_dir + 'repo.json'
f = open(file,'w')
f.write(encoded_str)
f.flush()
os.fsync(f.fileno())
f.close
#################################################################################
## The below section is required only for Replicate version less then 6.5
## Read repository JSON
#from_file = open(file,mode="r")
## Get the first line from it
#line = from_file.readline()
#from_file.close
## Replace this line with NULL
#encoded_str = encoded_str.replace(line,'')
###############################################################################3
# Load JSON to DICT in order to parse it
string = json.loads(encoded_str)
# Get Endpoint definitions as a list
dbs = string['cmd.replication_definition']['databases']
# Go through the list and get one you need
for i in range(len(dbs)):
if dbs[i]['name'] in endpoint:
my_endpoint = dbs[i]
# Create JSON for endpoint to be imported
with open(work_dir + 'result1.json', 'w') as fp:
fp.write('{' + "\n")
fp.write('"name": ' + '"' + endpoint +'"' + ',' + "\n")
fp.write('"cmd.replication_definition":' + "\n")
fp.write("\n")
fp.write('{' + "\n")
fp.write('"databases": [' + "\n")
my_endpoint_str = json.dumps(my_endpoint,sort_keys=True,indent=4)
fp.write(my_endpoint_str + ']' + "\n")
fp.write('}' + "\n")
fp.write('}' + "\n")
fp.flush()
fp.close();
# This part can be changed to redirect
# Import Endpoint
url="https://" + aemserver + "/attunityenterprisemanager/api/v1/servers/" + TargetReplicate + "/?action=import"
file = work_dir + 'result1.json'
with open(file, 'r') as content_file:
body = content_file.read();
r = requests.request('POST',url,verify=False,headers=headers,data=body)
print (r.status_code)
Thank you AlexeySosnovskih,
Do you know if repctl command works for importing end points . Iam trying but no luck. If possible can you please sample json file for end point. Thank you for your support.
Narsimha
Never mind , I was able to figure it out. Thank you.