本文整理汇总了Python中libvirt.VIR_DOMAIN_PAUSED属性的典型用法代码示例。如果您正苦于以下问题:Python libvirt.VIR_DOMAIN_PAUSED属性的具体用法?Python libvirt.VIR_DOMAIN_PAUSED怎么用?Python libvirt.VIR_DOMAIN_PAUSED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类libvirt
的用法示例。
在下文中一共展示了libvirt.VIR_DOMAIN_PAUSED属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_state
# 需要导入模块: import libvirt [as 别名]
# 或者: from libvirt import VIR_DOMAIN_PAUSED [as 别名]
def get_state(state):
dom_state = ''
if state == libvirt.VIR_DOMAIN_NOSTATE:
dom_state = 'nostate'
elif state == libvirt.VIR_DOMAIN_RUNNING:
dom_state = 'running'
elif state == libvirt.VIR_DOMAIN_BLOCKED:
dom_state = 'blocked'
elif state == libvirt.VIR_DOMAIN_PAUSED:
dom_state = 'paused'
elif state == libvirt.VIR_DOMAIN_SHUTDOWN:
dom_state = 'shutdown'
elif state == libvirt.VIR_DOMAIN_SHUTOFF:
dom_state = 'shutoff'
elif state == libvirt.VIR_DOMAIN_CRASHED:
dom_state = 'crashed'
else:
dom_state = 'no sure'
return dom_state
示例2: check_dom_state
# 需要导入模块: import libvirt [as 别名]
# 或者: from libvirt import VIR_DOMAIN_PAUSED [as 别名]
def check_dom_state(domobj):
state = domobj.info()[0]
expect_states = [libvirt.VIR_DOMAIN_PAUSED, libvirt.VIR_DOMAIN_RUNNING]
if state in expect_states:
return state
return 0
示例3: check_domain_state
# 需要导入模块: import libvirt [as 别名]
# 或者: from libvirt import VIR_DOMAIN_PAUSED [as 别名]
def check_domain_state(*args):
""" check if the domain state after revert """
(flagn, domobj, snapshot) = args
state = domobj.info()[0]
if snapshot.isCurrent(0):
logger.info("Successfull revert to given snapshotname")
# The passed flags include "running"
if (flagn == 1) or (flagn == 5):
logger.info("After reverting, change state to running")
expect_states = [libvirt.VIR_DOMAIN_RUNNING,
libvirt.VIR_DOMAIN_RUNNING_FROM_SNAPSHOT,
libvirt.VIR_DOMAIN_RUNNING_BOOTED]
if state in expect_states:
logger.info("Successful revert.The domain state is running.")
return True
else:
logger.error("Failed to revert.The domain state isn't running")
return False
# The passed flags include "paused"
elif (flagn == 2) or (flagn == 6):
expect_states = [libvirt.VIR_DOMAIN_PAUSED,
libvirt.VIR_DOMAIN_PAUSED_FROM_SNAPSHOT,
libvirt.VIR_DOMAIN_PAUSED_SNAPSHOT]
if state in expect_states:
logger.info("Successful revert.The domain state is paused.")
return True
else:
logger.error("Failed to revert.The domain state isn't paused")
return False
else:
logger.error("Failed to revert to given snapshotname ")
return False
示例4: check_dom_state
# 需要导入模块: import libvirt [as 别名]
# 或者: from libvirt import VIR_DOMAIN_PAUSED [as 别名]
def check_dom_state(domobj):
state = domobj.info()[0]
expect_states = [libvirt.VIR_DOMAIN_PAUSED, libvirt.VIR_DOMAIN_RUNNING]
if state in expect_states:
return state
return -1
示例5: update_servers_status
# 需要导入模块: import libvirt [as 别名]
# 或者: from libvirt import VIR_DOMAIN_PAUSED [as 别名]
def update_servers_status(self):
# # virDomainState
# VIR_DOMAIN_NOSTATE = 0
# VIR_DOMAIN_RUNNING = 1
# VIR_DOMAIN_BLOCKED = 2
# VIR_DOMAIN_PAUSED = 3
# VIR_DOMAIN_SHUTDOWN = 4
# VIR_DOMAIN_SHUTOFF = 5
# VIR_DOMAIN_CRASHED = 6
# VIR_DOMAIN_PMSUSPENDED = 7 #TODO suspended
if self.test or len(self.server_status)==0:
return
try:
conn = libvirt.open("qemu+ssh://"+self.user+"@"+self.host+"/system")
domains= conn.listAllDomains()
domain_dict={}
for domain in domains:
uuid = domain.UUIDString() ;
libvirt_status = domain.state()
#print libvirt_status
if libvirt_status[0] == libvirt.VIR_DOMAIN_RUNNING or libvirt_status[0] == libvirt.VIR_DOMAIN_SHUTDOWN:
new_status = "ACTIVE"
elif libvirt_status[0] == libvirt.VIR_DOMAIN_PAUSED:
new_status = "PAUSED"
elif libvirt_status[0] == libvirt.VIR_DOMAIN_SHUTOFF:
new_status = "INACTIVE"
elif libvirt_status[0] == libvirt.VIR_DOMAIN_CRASHED:
new_status = "ERROR"
else:
new_status = None
domain_dict[uuid] = new_status
conn.close
except libvirt.libvirtError as e:
print self.name, ": get_state() Exception '", e.get_error_message()
return
for server_id, current_status in self.server_status.iteritems():
new_status = None
if server_id in domain_dict:
new_status = domain_dict[server_id]
else:
new_status = "INACTIVE"
if new_status == None or new_status == current_status:
continue
if new_status == 'INACTIVE' and current_status == 'ERROR':
continue #keep ERROR status, because obviously this machine is not running
#change status
print self.name, ": server ", server_id, "status change from ", current_status, "to", new_status
STATUS={'progress':100, 'status':new_status}
if new_status == 'ERROR':
STATUS['last_error'] = 'machine has crashed'
self.db_lock.acquire()
r,_ = self.db.update_rows('instances', STATUS, {'uuid':server_id}, log=False)
self.db_lock.release()
if r>=0:
self.server_status[server_id] = new_status
示例6: suspend
# 需要导入模块: import libvirt [as 别名]
# 或者: from libvirt import VIR_DOMAIN_PAUSED [as 别名]
def suspend(params):
"""Suspend domain
Argument is a dictionary with two keys:
{'logger': logger, 'guestname': guestname}
logger -- an object of utils/log.py
guestname -- same as the domain name
Return 0 on SUCCESS or 1 on FAILURE
"""
domname = params['guestname']
logger = params['logger']
conn = sharedmod.libvirtobj['conn']
domobj = conn.lookupByName(domname)
# Suspend domain
logger.info('suspend domain')
try:
domobj.suspend()
except libvirtError as e:
logger.error("API error message: %s, error code is %s"
% (e.get_error_message(), e.get_error_code()))
return 1
time.sleep(1)
state = domobj.info()[0]
if state != libvirt.VIR_DOMAIN_PAUSED:
logger.error('The domain state is not equal to "paused"')
return 1
mac = utils.get_dom_mac_addr(domname)
time.sleep(3)
logger.info("get ip by mac address")
ip = utils.mac_to_ip(mac, 10)
time.sleep(10)
logger.info('ping guest')
if utils.do_ping(ip, 20):
logger.error('The guest is still active, IP: ' + str(ip))
return 1
logger.info('PASS')
return 0
示例7: get_monitoring_info
# 需要导入模块: import libvirt [as 别名]
# 或者: from libvirt import VIR_DOMAIN_PAUSED [as 别名]
def get_monitoring_info(self):
"""return montioring information including
1) base vm hash list
2) used/freed disk block list
3) freed memory page
"""
time1 = time.time()
# do not pause VM since we're doing semi-live migration
# this will be done by qmp
# if self.machine is not None:
# vm_state, reason = self.machine.state(0)
# if vm_state != libvirt.VIR_DOMAIN_PAUSED:
# self.machine.suspend()
time2 = time.time()
# 2. get dma & discard information
if self.options.TRIM_SUPPORT:
dma_dict, trim_dict = disk.parse_qemu_log(
self.qemu_logfile, Const.CHUNK_SIZE)
if len(trim_dict) == 0:
LOG.warning("No TRIM Discard, Check /etc/fstab configuration")
else:
trim_dict = dict()
free_memory_dict = dict()
time3 = time.time()
# 3. get used sector information from x-ray
used_blocks_dict = None
if self.options.XRAY_SUPPORT:
import xray
used_blocks_dict = xray.get_used_blocks(modified_disk)
info_dict = dict()
info_dict[_MonitoringInfo.DISK_USED_BLOCKS] = used_blocks_dict
info_dict[_MonitoringInfo.DISK_FREE_BLOCKS] = trim_dict
info_dict[_MonitoringInfo.MEMORY_FREE_BLOCKS] = free_memory_dict
time4 = time.time()
# mark the modifid disk area at original VM overlay as modified
if self.dirty_disk_chunks is not None:
for dirty_chunk in self.dirty_disk_chunks:
self.modified_disk_queue.put((dirty_chunk, 1.0))
info_dict[
_MonitoringInfo.DISK_MODIFIED_BLOCKS] = self.modified_disk_queue
time5 = time.time()
LOG.debug(
"consumed time %f, %f, %f, %f" %
((time5-time4), (time4-time3), (time3-time2), (time2-time1)))
self.monitoring_info = _MonitoringInfo(info_dict)
return self.monitoring_info