如何通过标签获取SoftLayer虚拟访客,标签的遮罩是什么? [英] How to get SoftLayer virtual guest by tags, what's the mask for tags?

查看:42
本文介绍了如何通过标签获取SoftLayer虚拟访客,标签的遮罩是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过"id","hostname","primaryIpAddress"等掩码获取虚拟访客. 但是,我需要为虚拟来宾添加特定的标签. 用来检索标记的虚拟访客的掩码是什么?

I can get virtual guests by masks like "id", "hostname", "primaryIpAddress" etc. However, I need to get virtual guests with specific tags. What's the mask to use to retrieve tagged virtual guests?

推荐答案

我得到了一些帮助.这是执行此操作的Ruby代码:

I got some help. Here is the Ruby code to do it:

client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
account_service = client['SoftLayer_Account']
object_filter = SoftLayer::ObjectFilter.new
object_filter.set_criteria_for_key_path(
'virtualGuests.tagReferences.tag.name', 'operation' => 'in',
'options' => [{
'name' => 'data',
'value' => tagsToFind
}])
mask = 'mask[tagReferences[tag[name]]]'
result = account_service.object_mask(mask).
object_filter(object_filter).getVirtualGuests

这篇关于如何通过标签获取SoftLayer虚拟访客,标签的遮罩是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆