Search code examples
ibm-cloud-infrastructure

Getting deviceId with GatewayId in Softlayer


Is there any way to get a device Id which gateway(vyatta) is running? I have the gateway Id and this is the code I've tried, but it returns all hardwares in account.

    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());
        }

    }

Solution

  • Use this method to list all vyatta servers in your account :

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

    but you need to make sure you have enough permissions to list the vyatta servers.

    In order to get the hardwareIds you can use a mask like this:

    objectMask=mask[members[hardware]]
    

    see this example using REST to list all the svyatta servers and its hardware:

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

    this example will list all the hardwareids of given a vyatta server:

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

    Regards