2017-05-10 63 views
0

我想使用python客户端创建一个Nessus Security Scanner并通过getStatus检查状态并通过getReport方法获取结果。虽然,我读过这些帮助通过PHP(SoftLayer API Nessus Scan Status/Report via PHP)。但是,我怎么可以通过Python客户端使用这些? 当我打电话的setInitParameter(SCAN_ID)的蟒蛇,异常的流: SoftLayerAPIError(客户端):功能(“setInitParameter”),是不是这个服务SoftLayer API Nessus扫描状态/通过python报告

+0

AHA,我可以通过导引设置参数id = scan_id来设置id为getStatus或getReport方法。 –

+0

client ['SoftLayer_Network_Security_Scanner_Request']。getStatus(id = 15326); #漏洞扫描的ID –

回答

0

我建议你阅读客户端的文档的有效方法第一:

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

初始化参数被设定如下:

clientService.getObject(id=myInitParameter) 

在这里你可以找到更多的例子使用客户端:

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

在这里你可以找到更多的文档:

http://sldn.softlayer.com/blog

而且renember与不像PHP客户端的数据SoftLayer的Python客户端正在发送json格式的请求:

$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"; 
    } 

会是l ike 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)