在SoftLayer

时间:2017-03-10 12:40:17

标签: python ibm-cloud-infrastructure

我们在SoftLayer中有一个代理帐户,通过该帐户创建了多个客户帐户。我试图在客户帐户上进行一些操作,但API不允许任何操作,因为我的SoftLayer Python客户端使用代理帐户的用户名/密码。

我浏览了很多帖子并模仿了客户帐户的“SoftLayer_User_Customer”作为可能的解决方案,但没有详细说明如何使用它。我能够使用getImpersanationToken调用来获取令牌,但我不确定如何使用它。

是否有任何关于如何从主品牌帐户登录(使用模仿或其他方式)作为客户用户的示例?

我正在使用Softlayer Python API,但也尝试使用SOAP调用。

1 个答案:

答案 0 :(得分:1)

你需要的方法就是这个:

http://sldn.softlayer.com/reference/services/SoftLayer_Brand/getToken

使用python客户端你会得到这样的东西:

    token = client['SoftLayer_Brand'].getToken(userID, id=brandID)

其中userID是您要获取令牌的用户的ID,而brandId是您帐户的品牌ID

您需要使用这样的SOAP请求:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.service.softlayer.com/soap/v3/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Header>
    <ns1:clientLegacySession>
      <userId>$USERID</userId>
      <authToken>$TOKEN</authToken>
    </ns1:clientLegacySession>
    <ns1:SoftLayer_User_CustomerInitParameters>
      <id>$USERID</id>
    </ns1:SoftLayer_User_CustomerInitParameters>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:addApiAuthenticationKey/>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

上面的soap为前一个请求中获得令牌的用户调用方法http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/addApiAuthenticationKey

不要忘记在SOAP

中替换值$ USERID和$ TOKEN

此致