API/Python/Open-Source Solutions

Expand all | Collapse all

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

Jump to Best Answer
  • 1.  CLI and REST API calls are giving different results for /sourconfig

    Posted 01-25-2017 09:00:00 PM
    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?


  • 2.  RE: CLI and REST API calls are giving different results for /sourconfig
    Best Answer

    Posted 01-25-2017 09:16:00 PM
    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


  • 3.  RE: CLI and REST API calls are giving different results for /sourconfig

    Posted 01-25-2017 09:26:00 PM
    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!


  • 4.  RE: CLI and REST API calls are giving different results for /sourconfig

    Posted 01-25-2017 09:27:00 PM
    Yep. I would say you are probably setting your version as 1.6.0 in your api session


  • 5.  RE: CLI and REST API calls are giving different results for /sourconfig

    Posted 01-25-2017 09:29:00 PM
    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?


  • 6.  RE: CLI and REST API calls are giving different results for /sourconfig

    Posted 01-25-2017 10:35:00 PM
    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.