在Softlayer中使用GatewayId获取deviceId

时间:2016-06-01 16:03:36

标签: ibm-cloud-infrastructure

有没有办法让设备ID运行哪个网关(vyatta)? 我有网关ID,这是我尝试过的代码,但它会返回帐户中的所有硬件。

    private void getDeviceIdWithGwId(){

        Gateway.Service gservice = Gateway.service(client, 18612llll);
        gservice.withMask().account().hardware();
        Gateway gw = gservice.getObject();

        Account account = gw.getAccount();

        List<Hardware> hdList = account.getHardware();

        System.out.println("size of hardware : " + hdList.size());
        for(Hardware hardware:hdList){
            System.out.println("hardware ID : " + hardware.getId());
        }

    }

1 个答案:

答案 0 :(得分:0)

使用此方法列出帐户中的所有vyatta服务器:

http://sldn.softlayer.com/reference/services/SoftLayer_Account/getNetworkGateways

但您需要确保您有足够的权限来列出vyatta服务器。

为了获得hardwareIds,你可以使用这样的掩码:

objectMask=mask[members[hardware]]

使用REST查看此示例,列出所有svyatta服务器及其硬件:

GET https://api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkGateways?objectMask=mask[members[hardware]]

此示例将列出给定vyatta服务器的所有硬件:

GET https://api.softlayer.com/rest/v3/SoftLayer_Network_Gateway/$GatwayID/getObject?objectMask=mask[members[hardware]]

此致