本文整理汇总了Python中azure.servicemanagement.ServiceManagementService.restart_role方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceManagementService.restart_role方法的具体用法?Python ServiceManagementService.restart_role怎么用?Python ServiceManagementService.restart_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.servicemanagement.ServiceManagementService
的用法示例。
在下文中一共展示了ServiceManagementService.restart_role方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import restart_role [as 别名]
#.........这里部分代码省略.........
return '-'.join((os_user, utils.generate_random_name(6)))
@utils.resource_not_found_handler
def get_virtual_machine_info(self, service_name, vm_name):
vm_info = {}
deploy_info = self.sms.get_deployment_by_name(service_name, vm_name)
if deploy_info and deploy_info.role_instance_list:
vm_info = deploy_info.role_instance_list[0].__dict__
return vm_info
def list_virtual_machines(self):
vm_list = []
services = self.sms.list_hosted_services()
for service in services:
deploys = service.deployments
if deploys and deploys.role_instance_list:
vm_name = deploys.role_instance_list[0].instance_name
vm_list.append(vm_name)
return vm_list
def power_on(self, service_name, vm_name):
resp = self.sms.start_role(service_name, vm_name, vm_name)
return resp.request_id
def power_off(self, service_name, vm_name):
resp = self.sms.shutdown_role(service_name, vm_name, vm_name)
return resp.request_id
def soft_reboot(self, service_name, vm_name):
resp = self.sms.restart_role(service_name, vm_name, vm_name)
return resp.request_id
def hard_reboot(self, service_name, vm_name):
resp = self.sms.reboot_role_instance(service_name, vm_name, vm_name)
return resp.request_id
def attach_volume(self, service_name, vm_name, size, lun):
disk_name = utils.generate_random_name(5, vm_name)
media_link = self._get_media_link(vm_name, disk_name)
self.sms.add_data_disk(service_name,
vm_name,
vm_name,
lun,
host_caching='ReadWrite',
media_link=media_link,
disk_name=disk_name,
logical_disk_size_in_gb=size)
def detach_volume(self, service_name, vm_name, lun):
self.sms.delete_data_disk(service_name, vm_name, vm_name, lun, True)
def get_available_lun(self, service_name, vm_name):
try:
role = self.sms.get_role(service_name, vm_name, vm_name)
except Exception:
return 0
disks = role.data_virtual_hard_disks
luns = [disk.lun for disk in disks].sort()
for i in range(1, 16):