Problems with setup system and connect it to NX Cloud using API

Answered

Comments

5 comments

  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink
  • Avatar
    Shani Sh

    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
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink
  • Avatar
    Shani Sh

    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
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi Shani Sh,

    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
    Comment actions Permalink

Please sign in to leave a comment.