Пример #1
0
from xen.xend.xenstore.xstransact import xstransact
from xen.xend.xenstore.xswatch import xswatch
from xen.xend import arch
from xen.xend import XendOptions
from xen.util import oshelp
from xen.util import utils
from xen.xend import osdep
from xen.xend.ConfigUtil import getConfigVar

try:
    xc = xen.lowlevel.xc.xc()
except Exception:
    print >>sys.stderr, ('xend/image.py: Error connecting to hypervisor')
    os._exit(1)

init("/var/log/xen/image.log", "DEBUG", log_image)
log = log_image

if getConfigVar('virtualization', 'QEMU', 'enable_qemu_xen'):
    enable_qemu_xen = getConfigVar('virtualization', 'QEMU', 'enable_qemu_xen', True)
else:
    enable_qemu_xen = False
    
MAX_GUEST_CMDLINE = 1024

if enable_qemu_xen:
    sentinel_path_prefix = '/var/run/xend/qdisk-'
else:
    sentinel_path_prefix = '/var/run/xend/dm-'
sentinel_fifos_inuse = { }
Пример #2
0
import xml.dom.minidom as Dom
import time
import os
import signal
from xen.xend import XendDomain, XendNode, XendAPIStore, XendPIFMetrics
from P_Table import *
from InitDB import Session
from sqlalchemy import func
from sqlalchemy import distinct
from P_Maintenance import RunMa
from XendLogging import log_performance, init
from xen.util import Netctl

init("/var/log/xen/Performance.log", "DEBUG", log_performance)
log = log_performance

# def get_logger(logname):
#     logger = logging.getLogger(logname)
#     file_handler = logging.FileHandler("/var/log/xen/" + logname + ".log")
#     fmt = '[%(asctime)s] %(levelname)s (%(filename)s:%(lineno)s) %(message)s' 
#     formatter = logging.Formatter(fmt)
#     file_handler.setFormatter(formatter)
#     logger.addHandler(file_handler)
#     logger.setLevel(logging.DEBUG)
# #    logger.debug(logname + " log here")
#     return logger
# 
# log = get_logger("p_datacollect")

KB = 1024
DOM0_UUID = "00000000-0000-0000-0000-000000000000"
Пример #3
0
#! /usr/bin/python
#-*- coding: utf-8 -*-  

from xen.xend.XendConstants import XEND_CONFIG_FILE
from XendLogging import log_config, init

init("/var/log/xen/setting.log", "DEBUG", log_config)
log = log_config

partLable = ("<",">")
sectionLable = ("[","]")
# endlineLable = "\r\n" # Windows
endlineLable = "\n"   # Linux
equalLable = "=" 
noteLable = '#'

def getPlatformMap(strtmp,lable1 = partLable,lable2 = sectionLable):
    tmp = strtmp.split(lable1[0])
    tmp = [elem for elem in tmp if len(elem) > 1]
    tmp = [elem for elem in tmp if elem.rfind(lable1[1]) > 0]
    platdict = {}
    for elem in tmp:
        key = elem[0:elem.find(lable1[1]):]
        value = elem[elem.find(lable2[0])::]
        platdict[key] = value
    return platdict

def getSectionMap(strtmp,lable1 = sectionLable):
    tmp = strtmp.split(lable1[0])
    tmp = [elem for elem in tmp if len(elem) > 1]
    tmp = [elem for elem in tmp if elem.rfind(lable1[1]) > 0]
Пример #4
0
import os
import time
import re

from xen.util.xpopen import xPopen3
from XendLogging import log_io_controller, init
from xen.util import blkif

init("/var/log/xen/io_controller.log", "DEBUG", log_io_controller)
log = log_io_controller

MB = 1024*1024
DRIVER = 'blkback'
GROUP_NAME = 'xend'

def doexec(args, inputtext=None):
    """Execute a subprocess, then return its return code, stdout and stderr"""
    proc = xPopen3(args, True)
    if inputtext != None:
        proc.tochild.write(inputtext)
    stdout = proc.fromchild
    stderr = proc.childerr
    rc = proc.wait()
    return (rc, stdout, stderr)

def doexec_timeout(cmd, timeout=3):
    if isinstance(cmd, basestring):
        cmd = ['/bin/sh', '-c', cmd]
    import subprocess, datetime, time, signal
    start = datetime.datetime.now()
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
Пример #5
0
from RecordCollector import RecordCollecter
import threading
import time
import json
from xen.xend.ConfigUtil import getConfigVar
from SendMsg import SendMsg
from XendLogging import log_sync, init

init("/var/log/xen/Sync.log", "DEBUG", log_sync)
log = log_sync

msg_ip='127.0.0.1'
msg_port=5672
msg_user='******'
msg_pwd='onceas'

if getConfigVar('plug-in', 'Sync_MSG', 'msg_ip'):
    msg_ip = getConfigVar('plug-in', 'Sync_MSG', 'msg_ip')
if getConfigVar('plug-in', 'Sync_MSG', 'msg_port'):
    msg_port = int(getConfigVar('plug-in', 'Sync_MSG', 'msg_port'))
if getConfigVar('plug-in', 'Sync_MSG', 'msg_user'):
    msg_user = getConfigVar('plug-in', 'Sync_MSG', 'msg_user')
if getConfigVar('plug-in', 'Sync_MSG', 'msg_pwd'):
    msg_pwd = getConfigVar('plug-in', 'Sync_MSG', 'msg_pwd')


class Msg:
    
    def __init__(self, hostuuid, vm_pre, vm_cur):
        
        self.rc = RecordCollecter(5)
import uuid
from XendError import XendError
from XendVDI import *
from XendTask import XendTask
from XendStorageRepository import XendStorageRepository
from XendStateStore import XendStateStore
from XendOptions import instance as xendoptions
from xen.util.xpopen import xPopen3
from XendPBD import XendPBD
from xen.xend import ssh
from xen.xend import encoding
from XendNode import XendNode
from XendLogging import log_ocfs2, init
from xen.xend.ConfigUtil import getConfigVar

init("/var/log/xen/ocfs2.log", "DEBUG", log_ocfs2)
log = log_ocfs2

KB = 1024
MB = 1024 * 1024
GB = 1024 * 1024 * 1024
TB = 1024 * 1024 * 1024 * 1024
PB = 1024 * 1024 * 1024 * 1024 * 1024
STORAGE_LOCATION = "/ocfs2"
FILE_EXT = ".img"
DEFAULT_FILE_NAME = "disk.vhd"
SNAPSHOT_ROOT_DIR = '.snapshot'


if getConfigVar('compute', 'VM', 'backend_driver_type'):
    VDI_TYPE = "%s:" % getConfigVar('compute', 'VM', 'backend_driver_type')