softlayer-java icon indicating copy to clipboard operation
softlayer-java copied to clipboard

getTagReferences() for each virtual guest returns nothing

Open avik1988 opened this issue 10 years ago • 4 comments

It will return null or zero. However gettags() works well which help to retrieve all tags in an account.

avik1988 avatar Jun 18 '16 08:06 avik1988

Could you provide more detail? Adding the following code to the listServers example for guests seems to work without issue:


Guest.Service guestService = guest.asService(client);
for (Reference tagRef : guestService.getTagReferences()) {
    Tag tag = tagRef.getTag();
    System.out.format("Tag: %s\n", tag.getName());
}

Are you sure your guests have tags? If not, have you tried using setTags? An example:


Guest.Service guestService = guest.asService(client);
guestService.setTags("hi,hello,hola");

If you use that example, the above output for the same guest should be:

Tag: hello
Tag: hola
Tag: hi

camporter avatar Jun 22 '16 19:06 camporter

for (Guest g: guests) { List<Reference> tagRefs = g.getTagReferences(); logger.info(g.getHostname()); for(Reference tagRef : tagRefs){ Tag tag = tagRef.getTag(); logger.info(tag.getName()); } } I am able to get the guest hostname but not the tags for each guest.The tags are there as I can see the tags which I have set through SoftLayer UI.

avik1988 avatar Jun 25 '16 19:06 avik1988

If you haven't masked tagReferences on the guest objects, calling getTagReferences() on a Guest won't return anything since that wasn't returned by the API.

If you call getTagReferences() on a Guest.Service object (see my example above), that will make a request to the API to get the tag references for you.

camporter avatar Jun 26 '16 05:06 camporter

Closing issue due to lack of updates.

camporter avatar Nov 06 '16 21:11 camporter