0
votes

I want to use python client to create a Nessus Security Scanner and check the status by getStatus and get the result by getReport method. While, I have read these helps by php(SoftLayer API Nessus Scan Status / Report via PHP). But how can i use these by python client? When I call setInitParameter(scan_id) in by python, the exception as flows: SoftLayerAPIError(Client): Function ("setInitParameter") is not a valid method for this service

1
AHA, I can get set the id to getStatus or getReport method by directorly set the params id = scan_id. - Lippman S
client['SoftLayer_Network_Security_Scanner_Request'].getStatus(id=15326); # The id of the vulnerability scan - Lippman S

1 Answers

0
votes

i recomend you to read documentation of the client first:

https://github.com/softlayer/softlayer-python https://softlayer-api-python-client.readthedocs.io/en/latest/

the init parameters are set like this:

clientService.getObject(id=myInitParameter)

here you can find more examples using the client:

https://softlayer.github.io/python/

Here you can find additional documentation:

http://sldn.softlayer.com/blog

And renember that with the Softlayer's python client unlike the php client the data are sending in json format so the request:

$client = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey);

    $accountInfo = $client->getObject();
    $hardware = $client->getHardware();

    foreach ($hardware as $server){
        $scanclient = SoftLayer_SoapClient::getClient('SoftLayer_Network_Security_Scanner_Request', '', $apiUsername, $apiKey)  



$scantemplate = new stdClass();
    $scantemplate->accountId = $accountInfo->id;
    $scantemplate->hardwareId = $server->id;
    $scantemplate->ipAddress = $server->primaryIpAddress;
    try{
            // Successfully creates new scan
            $scan = $scanclient->createObject($scantemplate);
    } catch (Exception $e){
            echo $e->getMessage() . "\n\r";
    }

would be like this:

clientAccount = client['SoftLayer_Account']
accountInfo = clientAccount.getObject()   #for this case we do not need init parameter
hardware = clientAccount.getHardware()    #for this case we do not need init parameter

for server in hardware:

    scanclient = client['SoftLayer_Network_Security_Scanner_Request']

    scantemplate = {
       "accountId": accountInfo["id"],
       "hardwareId": server["id"],
      "ipAddress": server["primaryIpAddress"]
   }

   scanclient.createObject(scantemplate)