CLI and REST API calls are giving different results for /sourconfig

  • 0
  • 1
  • Problem
  • Updated 1 year ago
  • Solved
I am not getting some values in the API response /resources/json/delphix/sourceconfig?environment=UNIX_HOST_ENVIRONMENT-14 however they were shown when executed in CLI.
When provisioning mysql vdb, db expects unique portno. I wanted to run through all existing ports and pick next port(3312; assuming i have ports from 3308 to 3311) by calling REST API 
Eg: 
API Response: 
{"type":"ListResult","status":"OK","result":[{"type":"SourceConfig","reference":"MYSQL_SERVER_CONFIG-22","namespace":null,"name":"/var/tmp/delphix/provision/VNTLS_QA_MYSQL_SRC-FVK/datafile","linkingEnabled":true,"discovered":false,"environmentUser":"HOST_USER-28","repository":"MYSQL_INSTALL-4"},
.....}

CLI Response:
{    "type": "ListResult",
    "status": "OK",
    "result": [
        {
            "type": "MySQLServerConfig",
            "reference": "MYSQL_SERVER_CONFIG-22",
            "namespace": null,
            "name": "/var/tmp/delphix/provision/VNTLS_QA_MYSQL_SRC-FVK/datafile",
            "linkingEnabled": true,
            "discovered": false,
            "environmentUser": "HOST_USER-28",
            "repository": "MYSQL_INSTALL-4",
            "dataDirectory": "/var/tmp/delphix/provision/VNTLS_QA_MYSQL_SRC-FVK/datafile",
            "port": 3308,
            "user": "xxxxx",
            "credentials": {
                "type": "PasswordCredential",
                "password": "***********"
            }
        },
......}
From the above 2 results, portno, user, etc are missing in API. 
We are using DE 5.0.2.3 version. Is this a bug in this version?
Photo of Viswas Patnala

Viswas Patnala

  • 492 Points 250 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Neal Stack

Neal Stack, Official Rep

  • 2,392 Points 2k badge 2x thumb
Official Response
Hi Viswas,

Do you set the current API version in your script? Check what the current version is from the CLI with `/version`.

For example, I have:

#!/bin/bash# Set API version
curl -s -X POST -k --data @- http://nstack503.dcenter.delphix.com/resources/json/delphix/session \
    -c ~/cookies.txt -H "Content-Type: application/json" <<EOF
{
    "type": "APISession",
    "version": {
        "type": "APIVersion",
        "major": 1,
        "minor": 8,
        "micro": 1
    }
}
EOF

# Login
echo -e "\n"
curl -s -X POST -k --data @- http://nstack503.dcenter.delphix.com/resources/json/delphix/login \
    -b ~/cookies.txt -H "Content-Type: application/json" <<EOF
{
    "type": "LoginRequest",
    "username": "delphix_admin",
    "password": "delphix"
}
EOF

# List MySQL sourceconfig
echo -e "\n\nListing MySQL sourceconfig..."
curl -X GET -k http://nstack503.dcenter.delphix.com/resources/json/delphix/sourceconfig/MYSQL_SERVER_CONFIG-18 \
    -b ~/cookies.txt -H "Content-Type: application/json"

Which results in:

Listing MySQL sourceconfig...
{"type":"OKResult","status":"OK","result":{"type":"MySQLServerConfig","reference":"MYSQL_SERVER_CONFIG-18","namespace":null,"name":"/opt/mysql57/mysql-5.7.10-linux-glibc2.5-x86_64_e/data","linkingEnabled":true,"discovered":true,"environmentUser":"HOST_USER-45","repository":"MYSQL_INSTALL-16","dataDirectory":"/opt/mysql57/mysql-5.7.10-linux-glibc2.5-x86_64_e/data","port":3321,"user":"delphix1","credentials":{"type":"PasswordCredential","password":"********"}},"job":null,"action":null}

I tested with Delphix 5.1.3 but sometimes not setting the API version correctly produces different results.

Thanks,
  Neal
Photo of Viswas Patnala

Viswas Patnala

  • 492 Points 250 badge 2x thumb
Hi Neal, Thanks for quick response and resolution. You are correct. We were using old API version in our code. We got all values in the response after updating the version. 
Thanks a bunch!
Photo of Adam Bowen

Adam Bowen, Official Rep

  • 17,418 Points 10k badge 2x thumb
Yep. I would say you are probably setting your version as 1.6.0 in your api session
Photo of Viswas Patnala

Viswas Patnala

  • 492 Points 250 badge 2x thumb
I was using 1.4.3 in my session earlier, now changed to 1.7.0. Is this going to impact my other functionalities or API responses?
Photo of Ranzo Taylor

Ranzo Taylor, Employee

  • 1,572 Points 1k badge 2x thumb
You would definitely need to QA your code after going up in versions.  Delphix supports old versions in API calls so that your code is stable.  But...you wouldn't get new API calls, and the output might change as you saw.  

We typically don't retire old API calls, so it's very unlikely that something you're using has "disappeared".

We recommend trying to stay current, but you definitely need to test. A common problem is expecting a certain piece of output to be in "column number 4" and it has moved, or expecting a certain statement to return a certain number of columns in it's response.  Unless your code relies on some tricks like that, you should be OK coming up to the latest.
(Edited)