AVX::OUTPUT

This task is used within the Script task to record the output of the script execution logic.
  • AVX::OUTPUT takes the following arguments - dictionary, a string
  • Another usage takes an additional ‘integer’ argument which represents the execution state (1-Success, 2-Failed).

Usage:

AVX::OUTPUT(config_dict) / AVX::OUTPUT(error_data, 2) 
mgmt_interface=mgmt_interface,add_interface=add_interface)

    #print(cmd)
    AVX::LOG(cmd)
    stdin_vm, stdout_vm, stderr_vm = ssh.exec_command(cmd)
    outJson = {"mgmt_interface":mgmt_interface,'add_interface':add_interface}
    if (stdout_vm.channel.recv_exit_status() == 0):
        AVX::LOG("Creation of Virtual Machine Completed Successfully")
        AVX::OUTPUT(outJson)

    else:
        AVX::LOG("Disk and VM Creation Failed"+str(stderr_vm.read().decode()))
        AVX::OUTPUT(outJson,2)
    ssh.close()
if __name__ == '__main__':
    ip,cmd=execute_command()
    outJson = {'ip':ip,'prov_modules':prov_modules,'commands':cmd,'host':host_name,'timezone':time_zone,'vlan':vlan_name}
    AVX::LOG("Device has been provisioned with the information given as the input")
    AVX::OUTPUT(outJson)
AVX::OUTPUT usage with failover options:

Script with ‘try-except’:

def check_login():
    import socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    outJson={'Success':'Success'}
    try:
        s.connect((ip, 22))
        #print "Port 22 reachable"
        #print json.dumps({"status":"success", "conditions":{ "login_success": "login_success"}})
        # dataJson = {}
        # dataJson["data"] = {"outputData":"Success"}
        # dataJson["status"] = "success"
        # dataJson['state'] = 1
        # dataJson["logs"] = [{"message": "Status of the VM with IP {ip} is checked and the VM is UP and RUNNING".format(ip=ip)}]
        # print(json.dumps(dataJson))
        AVX::LOG("Status of the VM with IP {ip} is checked and the VM is UP and RUNNING".format(ip=ip))
        AVX::OUTPUT(outJson)
    except socket.error as e:
        #print json.dumps({"status":"failure", "conditions":{ "failure": "failure"}})
        # dataJson = {}
        # dataJson["data"] = {"outputData":"Failure"}
        # dataJson["status"] = "failure"
        # dataJson['state'] = 2
        # dataJson["logs"] = [{"message": "Status of the VM with IP {ip} is checked and the VM is still not UP".format(ip=ip)}]
        # print(json.dumps(dataJson))
        AVX::LOG( "Status of the VM with IP {ip} is checked and the VM is still not UP".format(ip=ip))
        AVX::OUTPUT(outJson,2)
    s.close()
Note: In case of using ‘try-except’ in the python script, you must include ‘AVX::OUTPUT with state 2’ to record script failure actions. Try-except is used to handle errors and exceptions.