SL中自动缩放的详细信息 [英] Detail information for Auto Scale in SL

查看:73
本文介绍了SL中自动缩放的详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现有关使用Java API自动缩放的详细信息. 如何获取成员配置的详细信息.请参考附图中红色方框中的字段.我可以得到详细的信息.例如,我可以获得操作参考代码,它是CENTOS_6_64,但是如何获得长类型的描述,例如CentOS 6.x-最小安装(64位).

解决方案

尝试使用此对象Mask

mask[id, name, status[name, keyName], regionalGroup[id, name, description], suspendedFlag, terminationPolicy, cooldown, regionalGroupId, minimumMemberCount, maximumMemberCount, balancedTerminationFlag, networkVlans[ id, networkVlan[ id, name, vlanNumber, networkSpace, primaryRouter[id,hostname,datacenter[name,longName]],localDiskStorageCapabilityFlag,sanStorageCapabilityFlag]],virtualGuestMemberTemplate[hostname,domain,fullyQualifiedDomainName,startCpus,maxMemory,hourlyBillingFlag,localDiskFlag,operatingSystem,datacenter,privateNetworkOnlyFlag,networkComponents.maxSpeed,sshKeys,operatingSystemReferenceCode,blockDevices[device,diskImage.capacity],blockDeviceTemplateGroup.globalIdentifier,postInstallScriptUri],policies[id,cooldown,name,scaleActions[id,type[id,keyName,name],amount,scaleType],triggers[id,type],triggers(SoftLayer_Scale_Policy_Trigger_OneTime)[date],triggers(SoftLayer_Scale_Policy_Trigger_Repeating)[schedule],triggers(SoftLayer_Scale_Policy_Trigger_ResourceUse)[watches[id,algorithm,metric,operator,period,value]]],loadBalancers[id,port,healthCheck[id,attributes[value,type.keyname],type[id,keyname,name]],virtualServer[id,port,virtualIpAddress.ipAddress.ipAddress,virtualIpAddress.id,serviceGroups.routingType.name]],virtualGuestMemberCount]

这是使用python的示例:

"""
Get the scale group details (configuration).

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Scale_Group
http://sldn.softlayer.com/reference/services/SoftLayer_Scale_Group/getObject
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Scale_Group

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer
import json

USERNAME = 'set me'
API_KEY = 'set me'

scaleGroupId = 595465

# Create a SoftLayer API client object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
scaleGroupService = client['SoftLayer_Scale_Group']

objectMask = "mask[id, name, status[name, keyName], regionalGroup[id, name, description], suspendedFlag, terminationPolicy, cooldown, regionalGroupId, minimumMemberCount, maximumMemberCount, balancedTerminationFlag, networkVlans[ id, networkVlan[ id, name, vlanNumber, networkSpace, primaryRouter[id,hostname,datacenter[name,longName]],localDiskStorageCapabilityFlag,sanStorageCapabilityFlag]],virtualGuestMemberTemplate[hostname,domain,fullyQualifiedDomainName,startCpus,maxMemory,hourlyBillingFlag,localDiskFlag,operatingSystem,datacenter,privateNetworkOnlyFlag,networkComponents.maxSpeed,sshKeys,operatingSystemReferenceCode,blockDevices[device,diskImage.capacity],blockDeviceTemplateGroup.globalIdentifier,postInstallScriptUri],policies[id,cooldown,name,scaleActions[id,type[id,keyName,name],amount,scaleType],triggers[id,type],triggers(SoftLayer_Scale_Policy_Trigger_OneTime)[date],triggers(SoftLayer_Scale_Policy_Trigger_Repeating)[schedule],triggers(SoftLayer_Scale_Policy_Trigger_ResourceUse)[watches[id,algorithm,metric,operator,period,value]]],loadBalancers[id,port,healthCheck[id,attributes[value,type.keyname],type[id,keyname,name]],virtualServer[id,port,virtualIpAddress.ipAddress.ipAddress,virtualIpAddress.id,serviceGroups.routingType.name]],virtualGuestMemberCount]"

try:
    scaleGroup = scaleGroupService.getObject(id=scaleGroupId, mask=objectMask)
    config = {}
    config['groupDetails'] = {}
    config['groupDetails']['groupName'] = scaleGroup['name']
    config['groupDetails']['region'] = scaleGroup['regionalGroup']['name']
    config['groupDetails']['datacenter'] = scaleGroup['regionalGroup']['name']
    config['groupDetails']['terminationPolicy'] = scaleGroup['terminationPolicy']['name']
    config['groupSettings'] = {}
    config['groupSettings']['minimumMemberCount'] = scaleGroup['minimumMemberCount']
    config['groupSettings']['maximumMemberCount'] = scaleGroup['maximumMemberCount']
    config['groupSettings']['cooldown'] = str(scaleGroup['cooldown'] / 60) + " Minutes"
    config['memberDetails'] = {}
    config['memberDetails']['hostname'] = scaleGroup['virtualGuestMemberTemplate']['hostname']
    config['memberDetails']['domain'] = scaleGroup['virtualGuestMemberTemplate']['domain']
    config['computingInstance'] = {}
    config['computingInstance']['cores'] = str(scaleGroup['virtualGuestMemberTemplate']['startCpus']) + "x 2.0 GHz Core"
    config['computingInstance']['ram'] = str(scaleGroup['virtualGuestMemberTemplate']['maxMemory'] / 1024) + "GB"
    if 'networkComponents' in scaleGroup['virtualGuestMemberTemplate']:
        config['computingInstance']['speed'] = scaleGroup['virtualGuestMemberTemplate']['networkComponents'][0]['maxSpeed']
    else:
        config['computingInstance']['speed'] = "Default"
    if 'sshKeys' in scaleGroup['virtualGuestMemberTemplate']:
        config['computingInstance']['sshKeys'] = scaleGroup['virtualGuestMemberTemplate']['sshKeys']
    else:
        config['computingInstance']['sshKeys'] = 'None'
    config['storage'] = {}
    if scaleGroup['virtualGuestMemberTemplate']['localDiskFlag']:
        config['storage']['selectedStorage'] = 'Local Storage'
    else:
        config['storage']['selectedStorage'] = 'SAN Storage'
    config['operatingSystem'] = {}
    config['operatingSystem']['selectedOperatingSystem'] = scaleGroup['virtualGuestMemberTemplate']['operatingSystemReferenceCode']
    config['postInstallScript'] = {}
    config['postInstallScript']['url'] = scaleGroup['virtualGuestMemberTemplate']['postInstallScriptUri']
    config['policies'] = scaleGroup['policies']
    print(json.dumps(config, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to get the scale group details. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))

但是,如果您尝试复制与门户网站相同的信息,您将真的很开心:).

关于操作系统,无法通过SoftLayer_Scale_Group服务获取信息,您需要使用SoftLayer_Virtual_Guest :: getCreateObjectOptions方法.如果您看到该方法的结果,则会看到以下内容:

{
            "itemPrice": {
                "hourlyRecurringFee": "0",
                "recurringFee": "0",
                "item": {
                    "description": "CentOS 6.x - Minimal Install (64 bit)"
                }
            },
            "template": {
                "id": null,
                "operatingSystemReferenceCode": "CENTOS_6_64"
            }
        }

您可以看到结果包含"operatingSystemReferenceCode"和所需的描述,因此只需要查找与使用SoftLayer_Scale_Group :: getObject方法获得的"operatingSystemReferenceCode"值匹配的记录. /p>

关于私有网络或公共网络,在这里您只能使用以下方案: 1.-已设置公共和私人. 2.-仅已设置私人.

确定必须检查"privateNetworkOnlyFlag"属性: 1.-如果属性为true,则说明网络是私有的 2.-如果未设置该属性(默认值为false),则该网络是公共网络和私有网络.

为了获得与门户网站相同的描述,您需要使用SoftLayer_Virtual_Guest :: getCreateObjectOptions方法,这是您得到的结果:

"networkComponents": [
        {
            "itemPrice": {
                "hourlyRecurringFee": "0",
                "recurringFee": "0",
                "item": {
                    "description": "10 Mbps Public & Private Network Uplinks"
                }
            },
            "template": {
                "id": null,
                "networkComponents": [
                    {
                        "maxSpeed": 10
                    }
                ],
                "privateNetworkOnlyFlag": false
            }
        }

如您所见,这个想法与操作系统相同.

并假设数据中心为第一个可用",我猜想当您调用SoftLayer_Scale_Group :: getObject时,如果您可以将值显示为第一个,则我猜想virtualGuestMemberTemplate.datacenter属性为空或不存在"可用".

致谢

I am implementing the detail information for auto scaling using Java API. How can I get a detailed information of member configuration. Please refer to the fields in red box in the attached picture. I could get a detailed information. For example, I could get the operation reference code, which is CENTOS_6_64, but how can I get the long type of description like CentOS 6.x - Minimal Install (64bit).

解决方案

try using this object Mask

mask[id, name, status[name, keyName], regionalGroup[id, name, description], suspendedFlag, terminationPolicy, cooldown, regionalGroupId, minimumMemberCount, maximumMemberCount, balancedTerminationFlag, networkVlans[ id, networkVlan[ id, name, vlanNumber, networkSpace, primaryRouter[id,hostname,datacenter[name,longName]],localDiskStorageCapabilityFlag,sanStorageCapabilityFlag]],virtualGuestMemberTemplate[hostname,domain,fullyQualifiedDomainName,startCpus,maxMemory,hourlyBillingFlag,localDiskFlag,operatingSystem,datacenter,privateNetworkOnlyFlag,networkComponents.maxSpeed,sshKeys,operatingSystemReferenceCode,blockDevices[device,diskImage.capacity],blockDeviceTemplateGroup.globalIdentifier,postInstallScriptUri],policies[id,cooldown,name,scaleActions[id,type[id,keyName,name],amount,scaleType],triggers[id,type],triggers(SoftLayer_Scale_Policy_Trigger_OneTime)[date],triggers(SoftLayer_Scale_Policy_Trigger_Repeating)[schedule],triggers(SoftLayer_Scale_Policy_Trigger_ResourceUse)[watches[id,algorithm,metric,operator,period,value]]],loadBalancers[id,port,healthCheck[id,attributes[value,type.keyname],type[id,keyname,name]],virtualServer[id,port,virtualIpAddress.ipAddress.ipAddress,virtualIpAddress.id,serviceGroups.routingType.name]],virtualGuestMemberCount]

here an example using python:

"""
Get the scale group details (configuration).

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Scale_Group
http://sldn.softlayer.com/reference/services/SoftLayer_Scale_Group/getObject
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Scale_Group

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer
import json

USERNAME = 'set me'
API_KEY = 'set me'

scaleGroupId = 595465

# Create a SoftLayer API client object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
scaleGroupService = client['SoftLayer_Scale_Group']

objectMask = "mask[id, name, status[name, keyName], regionalGroup[id, name, description], suspendedFlag, terminationPolicy, cooldown, regionalGroupId, minimumMemberCount, maximumMemberCount, balancedTerminationFlag, networkVlans[ id, networkVlan[ id, name, vlanNumber, networkSpace, primaryRouter[id,hostname,datacenter[name,longName]],localDiskStorageCapabilityFlag,sanStorageCapabilityFlag]],virtualGuestMemberTemplate[hostname,domain,fullyQualifiedDomainName,startCpus,maxMemory,hourlyBillingFlag,localDiskFlag,operatingSystem,datacenter,privateNetworkOnlyFlag,networkComponents.maxSpeed,sshKeys,operatingSystemReferenceCode,blockDevices[device,diskImage.capacity],blockDeviceTemplateGroup.globalIdentifier,postInstallScriptUri],policies[id,cooldown,name,scaleActions[id,type[id,keyName,name],amount,scaleType],triggers[id,type],triggers(SoftLayer_Scale_Policy_Trigger_OneTime)[date],triggers(SoftLayer_Scale_Policy_Trigger_Repeating)[schedule],triggers(SoftLayer_Scale_Policy_Trigger_ResourceUse)[watches[id,algorithm,metric,operator,period,value]]],loadBalancers[id,port,healthCheck[id,attributes[value,type.keyname],type[id,keyname,name]],virtualServer[id,port,virtualIpAddress.ipAddress.ipAddress,virtualIpAddress.id,serviceGroups.routingType.name]],virtualGuestMemberCount]"

try:
    scaleGroup = scaleGroupService.getObject(id=scaleGroupId, mask=objectMask)
    config = {}
    config['groupDetails'] = {}
    config['groupDetails']['groupName'] = scaleGroup['name']
    config['groupDetails']['region'] = scaleGroup['regionalGroup']['name']
    config['groupDetails']['datacenter'] = scaleGroup['regionalGroup']['name']
    config['groupDetails']['terminationPolicy'] = scaleGroup['terminationPolicy']['name']
    config['groupSettings'] = {}
    config['groupSettings']['minimumMemberCount'] = scaleGroup['minimumMemberCount']
    config['groupSettings']['maximumMemberCount'] = scaleGroup['maximumMemberCount']
    config['groupSettings']['cooldown'] = str(scaleGroup['cooldown'] / 60) + " Minutes"
    config['memberDetails'] = {}
    config['memberDetails']['hostname'] = scaleGroup['virtualGuestMemberTemplate']['hostname']
    config['memberDetails']['domain'] = scaleGroup['virtualGuestMemberTemplate']['domain']
    config['computingInstance'] = {}
    config['computingInstance']['cores'] = str(scaleGroup['virtualGuestMemberTemplate']['startCpus']) + "x 2.0 GHz Core"
    config['computingInstance']['ram'] = str(scaleGroup['virtualGuestMemberTemplate']['maxMemory'] / 1024) + "GB"
    if 'networkComponents' in scaleGroup['virtualGuestMemberTemplate']:
        config['computingInstance']['speed'] = scaleGroup['virtualGuestMemberTemplate']['networkComponents'][0]['maxSpeed']
    else:
        config['computingInstance']['speed'] = "Default"
    if 'sshKeys' in scaleGroup['virtualGuestMemberTemplate']:
        config['computingInstance']['sshKeys'] = scaleGroup['virtualGuestMemberTemplate']['sshKeys']
    else:
        config['computingInstance']['sshKeys'] = 'None'
    config['storage'] = {}
    if scaleGroup['virtualGuestMemberTemplate']['localDiskFlag']:
        config['storage']['selectedStorage'] = 'Local Storage'
    else:
        config['storage']['selectedStorage'] = 'SAN Storage'
    config['operatingSystem'] = {}
    config['operatingSystem']['selectedOperatingSystem'] = scaleGroup['virtualGuestMemberTemplate']['operatingSystemReferenceCode']
    config['postInstallScript'] = {}
    config['postInstallScript']['url'] = scaleGroup['virtualGuestMemberTemplate']['postInstallScriptUri']
    config['policies'] = scaleGroup['policies']
    print(json.dumps(config, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to get the scale group details. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))

But if you try to copy the same information as the portal, you really will have fun :).

Regarding the OS that information cannot be get via the SoftLayer_Scale_Group service, you need to use the SoftLayer_Virtual_Guest::getCreateObjectOptions method. If you see the result of the method you will see this:

{
            "itemPrice": {
                "hourlyRecurringFee": "0",
                "recurringFee": "0",
                "item": {
                    "description": "CentOS 6.x - Minimal Install (64 bit)"
                }
            },
            "template": {
                "id": null,
                "operatingSystemReferenceCode": "CENTOS_6_64"
            }
        }

As you can see the result contains the "operatingSystemReferenceCode" and the description that you want to, so only need to look up the record which match with the "operatingSystemReferenceCode" value that you got using the SoftLayer_Scale_Group::getObject method.

Regarding the network private or public, here you only can have the scenarios: 1.- public and private has been set. 2.- only private has been set.

to determinate that you have to check the "privateNetworkOnlyFlag" property: 1.- if the property is true, the network is private 2.- if the property has not been set (the default value is false) so the network is public and private.

In order to get the same description as the portal you need to use the SoftLayer_Virtual_Guest::getCreateObjectOptions method, this is the result that you got:

"networkComponents": [
        {
            "itemPrice": {
                "hourlyRecurringFee": "0",
                "recurringFee": "0",
                "item": {
                    "description": "10 Mbps Public & Private Network Uplinks"
                }
            },
            "template": {
                "id": null,
                "networkComponents": [
                    {
                        "maxSpeed": 10
                    }
                ],
                "privateNetworkOnlyFlag": false
            }
        }

As you can see the idea is the same as with the operating system.

And regard the datacenter "First Available", I guess that when you call the SoftLayer_Scale_Group::getObject I guess that the virtualGuestMemberTemplate.datacenter property is empty or does not exist, if you see that you can display the value as "First Available".

Regards

这篇关于SL中自动缩放的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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