Softlayer : tagging device

偶尔善良 提交于 2019-12-20 04:53:55

问题


I couldn't find any option to Tag a device while creating the device in Customer portal, so I am Using SoftLayer_Tag::setTags Rest API to tag a device:

POST: https://Username:API_KEY@api.softlayer.com/rest/v3/SoftLayer_Tag/setTags.json
BODY: 
resourceTableId : 29756959
keyName : march22

But getting error saying:

{ "error": "You do not have permissions to tag this object.",
"code": "SoftLayer_Exception_PermissionDenied" }


回答1:


There is a mistake in the way that you are sending the body(tags parameter is missing and there is a wrong value for keyName), try this:

Virtual Guests

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Tag/setTags

Method: Post

{  
   "parameters":[  
      "tag1,tag2",
      "GUEST",
      29756959
   ]
}

Hardware

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Tag/setTags

Method: Post

{  
   "parameters":[  
      "tag1,tag2",
      "HARDWARE",
      29756959
   ]
}

Updated

To set tags you need to check the following:

  1. Access to device
  2. Permission enabled for Device Type (Vsi/Hardware):

    • Hardware -> View Hardware Details
    • VSI -> View Virtual Server Details

There is no way to set tags at the moment to place the order, you can set them after submit the order

Devices >> Device List >> Search the device (e.g: rcvtagtest)

Another way would be to place the order through API, in which it's possible to set tags through it at the moment to create the server, here an example for VSI:

  • Setting Tags in JSON Order Softlayer API Python

Updated2


The SoftLayer_Tag::getTagByTagName method provides information about the tag, not the devices which have being tagged with this.

It will provide information from the tag based on tag name, so it's not necessary to send an identifier, so the correct way for this is:

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Tag/getTagByTagName

Method: Post

{  
   "parameters":[  
      "test1,test2"
   ]
}

Replace: $user, $apiKey with you own information and test1 and test2 with the tag names that you would like to retrieve

In case that you would like to retrieve devices, take a look this forum(for Vsis, the same idea should be applied for BMS):

  • How to get SoftLayer virtual guest by tags, what's the mask for tags?

If this doesn't help you, please provide more information about your requirements, in order that I can help you



来源:https://stackoverflow.com/questions/42945216/softlayer-tagging-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!