使用 Python API 启用 VLAN 生成
Enable VLAN Spanning with Python API
我想通过 SoftLayer Python API 进行 REST api 调用以启用帐户的 VLAN 生成。我找到了 following link 并且我正在尝试将其内容调整为我认为调用的样子,我目前所拥有的:
url = 'https://' + username + ':' + api_key +'@api.service.softlayer.com/rest/v3/SoftLayer_Account/' + account_id + '/setVlanSpan.json'
data = '{"parameters":[[{"enabled": "True"}]]}'
response = requests.post(url, data=data)
除此之外我的问题是 where/how 获取 account_id
以便将其提供给 post 请求中的 URL?如果 python API 有更好的方法来完成此任务,那也行!
无需为 SoftLayer_Account::setVlanSpan 方法指定 accountId。
尝试在您的代码中进行以下更改:
url = 'https://' + username + ':' + api_key +'@api.service.softlayer.com/rest/v3/SoftLayer_Account/setVlanSpan.json'
data = '{"parameters":["True"]}'
无论如何,您可以通过以下请求获取accountId:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getObject
Method: Get
响应中的 "id" 属性 指的是 accountId。
我想通过 SoftLayer Python API 进行 REST api 调用以启用帐户的 VLAN 生成。我找到了 following link 并且我正在尝试将其内容调整为我认为调用的样子,我目前所拥有的:
url = 'https://' + username + ':' + api_key +'@api.service.softlayer.com/rest/v3/SoftLayer_Account/' + account_id + '/setVlanSpan.json'
data = '{"parameters":[[{"enabled": "True"}]]}'
response = requests.post(url, data=data)
除此之外我的问题是 where/how 获取 account_id
以便将其提供给 post 请求中的 URL?如果 python API 有更好的方法来完成此任务,那也行!
无需为 SoftLayer_Account::setVlanSpan 方法指定 accountId。
尝试在您的代码中进行以下更改:
url = 'https://' + username + ':' + api_key +'@api.service.softlayer.com/rest/v3/SoftLayer_Account/setVlanSpan.json'
data = '{"parameters":["True"]}'
无论如何,您可以通过以下请求获取accountId:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getObject
Method: Get
响应中的 "id" 属性 指的是 accountId。