createVmWithLocalSnapshot.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/python
  2. #coding=utf-8
  3. #属性解释
  4. '''
  5. InstanceName 主机名称
  6. DataDiskSize 数据盘大小 注意和快照大小一致
  7. LocalVolumeSnapshotId 本地盘快照ID
  8. InstancePassword 主机密码
  9. SubnetId 子网ID
  10. SecurityGroupId 安全组ID
  11. ImageId 镜像ID
  12. InstanceType 机型信息 必须是本地数据盘支持的机型
  13. '''
  14. from kscore.session import get_session
  15. ak ='ak'
  16. sk = 'sk'
  17. region = 'cn-beijing-6'
  18. if __name__ == '__main__':
  19. s = get_session()
  20. s.set_credentials(ak, sk)
  21. client = s.create_client("kec", region, use_ssl=True)
  22. param = {
  23. "MaxCount": "1",
  24. "MinCount": "1",
  25. "ImageId": "d3290df6-3597-4f83-b5ae-48356e91ad46",
  26. "SubnetId": "d72361fe-837b-4676-85ff-faa3b0b4ef73",
  27. "InstanceName": "TEST",
  28. "InstancePassword": "Aa123456",
  29. "SecurityGroupId": "e470911a-6ae7-481e-adc6-299ce3c932bc",
  30. "DataDiskGb": "20",
  31. "ChargeType": "Daily",
  32. "InstanceType": "S3.1A",
  33. "LocalVolumeSnapshotId": "e4189c4e-0a92-43a1-9b04-26a25184f3b7"
  34. }
  35. client.run_instances(**param)