0

I am trying to create a javascript file that is invoked by mysql-shell that can automatically

  1. test, using dba.checkInstanceConfiguration("user@mysql-node:3306"), if instance is ready for cluster devlopment

  2. if not invoke dba.configureInstance("user@mysql-node:3306")

  3. if instance is ready for cluster development, invoke:

    shell.connect("user@mysql-node:3306") cdCluster = dba.createCluster("cd-cluster"); cdCluster = dba.getCluster("cd-cluster"); cdCluster.addInstance("user@mysql-node:3306");

When we invoke:

dba.checkInstanceConfiguration("user@mysql-node:3306")

The resulting text contain either:

{
    "status": "ok"
}

or something like

{
    "config_errors": [
        {
            "action": "server_update", 
            "current": "COMMIT_ORDER", 
            "option": "binlog_transaction_dependency_tracking", 
            "required": "WRITESET"
        }, 
        {
            "action": "server_update+restart", 
            "current": "OFF", 
            "option": "enforce_gtid_consistency", 
            "required": "ON"
        }, 
        {
            "action": "server_update+restart", 
            "current": "OFF", 
            "option": "gtid_mode", 
            "required": "ON"
        }, 
        {
            "action": "server_update+restart", 
            "current": "1", 
            "option": "server_id", 
            "required": "<unique ID>"
        }
    ], 
    "status": "error"
}

as part of the response. Is there a way one can get the json response for use in a javascript function that can be used to dynamically react by either invoking:

dba.configureInstance("root@mysql-pri:3306");

or

cdCluster = dba.createCluster("cd-cluster");

The documentation for dba.checkInstanceConfiguration("user@mysql-node:3306") suggest, the return is JSON. When I do:

ret =  dba.checkInstanceConfiguration("user@mysql-node:3306")
console.log(ret)

..nothing is retured but I can see the text output. Can someone help please?

1 Answer 1

0

I have since discovered my mistake. Earlier I used:

const ret = dba.checkInstanceConfiguration("root@mysql-pri:3306")
console.log('ret:', ret);

I have since replaced console.log with print. I am now able to assign the json return and use it appropriately:

print('ret:')
print(ret.status);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.