Вы можете проверить, что было упомянуто ранее, поменяв указанные свойства («virtualGhest» против «hardware») и проверить результаты для этих свойств после размещения заказа (используйте для этого verifyOrder) ».
ользую API-интерфейс Softlayer и скрипт Python для заказа виртуальных машин в моей учетной записи SL. В сценарии я определяю VLAN, в которой должны быть размещены машины. В моей учетной записи я вижу частную подсеть / 26 в этой VLAN. Сценарий работает нормально, когда я развертываю 2-3 машины одновременно. Однако, если я использую тот же сценарий для развертывания 60 виртуальных машин, каким-то образом большинство машин будет помещено в новую VLAN с разными IP-адресами, даже если указанная VLAN была пустой во время выполнения сценария. Обычно это не проблема, но я использую Vyatta для создания туннеля IPsec, и поэтому мне нужно указать, какая VLAN / подсеть может использовать туннель. Есть ли что-то, что должно быть изменено в скрипте?
createoder.py
import SoftLayer
import ast
from pprint import pprint as pp
templateId = 1631417 #Template ID which has been retrieved prior to executing the script
quantity = 60 #Number of VMs to deploy
#Create client and manager for further commands
client = SoftLayer.create_client_from_env(username='myuser' ,
api_key='myapikey') #masked for publishing reasons
mgr = SoftLayer.VSManager(client)
#Display available templates within account
mask = "mask[id,name,note]"
imageTemplates =
client['SoftLayer_Account'].getPrivateBlockDeviceTemplateGroups(mask=mask)
print("ID - Name - Note")
for template in imageTemplates:
try:
print("%s - %s - %s" % (template['id'], template['name'],
template['note']))
except KeyError:
print("%s - %s - %s" % (template['id'], template['name'], 'None'))
#Prepare and execute order
for x in range(1, quantity+1): #Loop for creating the defined amount of VMs
order = {
'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest',
'quantity': 1,
'useHourlyPricing': True,
'virtualGuests': [
{'hostname': 'VM%d' % (x), 'domain': 'mydomain.com', 'privateNetworkOnlyFlag': True, 'primaryBackendNetworkComponent': {'networkVlanId': 1706321 }}
],
'location': 449506, # Frankfurt 02
'packageId': 46, # Virtual Cloud Server
'prices': [
{'id': 52307}, # 2 x 2.0 GHz Core private
{'id': 51491}, # 4 GB RAM
{'id': 905}, # Reboot / Remote Console
#{'id': 26737}, # 100 Mbps Public & Private Networks
{'id': 52429}, # 1 GB Private Network Uplink
{'id': 1800}, # 0 GB Public Bandwidth
{'id': 21}, # 1 IP Address
{'id': 13887}, # 100 GB (Local)
{'id': 55}, # Host Ping Monitoring
{'id': 57}, # Email and Ticket Notifications
{'id': 58}, # Automated Notification Response
{'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
{'id': 418}, # Nessus Vulnerability Assessment & Reporting
{'id': 175797}, # Microsoft Windows Server 2012R2 Standard
#{'id': 29642}, # Microsoft Windows Firewall
],
'imageTemplateId': templateId
}
#result = client['SoftLayer_Product_Order'].verifyOrder(order)
result = client['SoftLayer_Product_Order'].placeOrder(order)
pp(result)
pp(x)