Problems with setup system and connect it to NX Cloud using API
AnsweredHi,
I want to setup new system and connect it to the NX Cloud, using the API, in my python script.
I was helped the "Connecting a System to NX Cloud using the API" article, but I still have some problems.
I wanted to setup new system, change it's system name and admin password, and after that connect it to the NX Cloud. In the article I mentioned above, there is an API command called '/api/saveCloudSystemCredentials' that supposed to do that, but it didn't work for me and it seems that this command is not available anymore in the API commands list.
I tried to find if there is another command for attach existing system to NX Cloud, but I didn't find. Is there any command for that?
I also tried another way - attach new system to NX Cloud and then configure it's system name and admin password. I succeeded change the system name using the '/api/systemSettings' command, but when I tried to change the admin password, it didn't work (I tried to change it by using the 'api/configure' command. I connected to the NX Client and I saw that the admin user disabled. Why this is happened?
I would like to get solution for these problems.
Thanks!
-
Hello Shani Sh ,
I wanted to setup new system, change it's system name and admin password, and after that connect it to the NX Cloud.
Here is the procedure.
1. Install VMS.
The Server process starts automatically after the installation.
2. Configure the System with api/setupLocalSystem with default credentials admin/admin.
Here is an example
curl -k -X POST --digest "http://admin:admin@localhost:7001/api/setupLocalSystem" -H "Content-Type: application/json" --data-binary ./system_settings.json
the system_settings.json
{
"password":"your new password",
"systemName":"vms_system"
}3. Apply licenses (if you need to) with /api/activateLicense
JSON example
{
"licenseKey": "XXXX-YYYY-ZZZZ-FFFF"
}4. Proceed with the "Connecting a System to NX Cloud using the API" article to connect the system to the cloud.
0 -
Hi Andrey!
I did steps 1 and 2 and it works well for me.
Then, I tried to do step 4. I did the part of "connect an existing system to cloud" as mentioned in the article, but when I used the '/api/saveCloudSystemCredentials' command, I got the following error:
b'{"error":"3","errorString":"Method GET is not allowed for /api/saveCloudSystemCredentials","reply":null}'
I wrote it exactly like in the article and I also used POST request.
Thanks a lot!
0 -
Hi Shani Sh ,
Could you share your code, please?
b'{"error":"3","errorString":"Method GET is not allowed for /api/saveCloudSystemCredentials","reply":null}'
This error makes me think you are using GET HTTP method. The article mentioned in the "To Connect an Existing System to Cloud" gives this piece of code
s = requests.post(SERVER_URL + "/api/saveCloudSystemCredentials",
json={
"cloudAuthKey": jsonData["authKey"],
"cloudSystemID": jsonData["id"],
"cloudAccountName": jsonData["ownerAccountEmail"]
},
auth=requests.auth.HTTPDigestAuth(SYSTEM_LOGIN, SYSTEM_PASSWORD))which demonstrates utilization of the POST HTTP method.
0 -
Hi Andrey,
This is my code for configuring new system name and password, and then adding it to the NX Cloud:
cmd = '''curl -k -X POST --digest "http://admin:admin@localhost:7001/api/setupLocalSystem" -H "Content-Type: application/json" --data-binary @system_settings.json'''
args = shlex.split(cmd)
process = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
json_data = json.loads(stdout.decode("utf-8"))
# This returns the cloudAuthKey and the cloudSystemID we will need for /api/setupCloudSystem
r = requests.post(CLOUD_URL + "/cdb/system/bind",
json={
"name": SYSTEM_NAME,
"customization": CUSTOMIZATION
},
auth=requests.auth.HTTPDigestAuth(CLOUD_USER, CLOUD_PASS), verify=False)
jsonData = r.json()
# This will take the above information and attach this system to the cloud
s = requests.post(SERVER_URL + "/api/saveCloudSystemCredentials",
json={
"cloudAuthKey": jsonData["authKey"],
"cloudSystemID": jsonData["id"],
"cloudAccountName": jsonData["ownerAccountEmail"]
},
auth=requests.auth.HTTPDigestAuth(SYSTEM_LOGIN, SYSTEM_PASSWORD), verify=False)
print(s.content)The part of the system name and password configuration works well.
The part of getting the cloud auth key and cloud system ID also works well.
As you can see, I used POST request and I still got this message.
Thanks!
0 -
I copied your code, reproduced the issue and fixed it.
The only thing I changed is putting HTTPS in the variable.
SERVER_URL = "https://localhost:7001"
I corrected the article. It will be updated soon.
Thank you for pointing out the issue.
Starting with certain build, HTTPS is the recommended protocol for all API invocations.
0
Please sign in to leave a comment.
Comments
5 comments