Esempio n. 1
0
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 = { }

def cleanup_stale_sentinel_fifos():
    for path in glob.glob(sentinel_path_prefix + '*.fifo'):
        if path in sentinel_fifos_inuse: continue
Esempio n. 2
0
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from xen.xend.ConfigUtil import getConfigVar

user = '******'
pwd = ''
db_server = ''
db_port = '3306'
db_name = ''
db_charset = 'utf8'
if getConfigVar('monitor', 'DB_User', 'user'):
    user = getConfigVar('monitor', 'DB_User', 'user')
if getConfigVar('monitor', 'DB_User', 'pwd'):
    pwd = getConfigVar('monitor', 'DB_User', 'pwd')
if getConfigVar('monitor', 'DB', 'db_server'):
    db_server = getConfigVar('monitor', 'DB', 'db_server')
if getConfigVar('monitor', 'DB', 'db_port'):
    db_port = getConfigVar('monitor', 'DB', 'db_port')
if getConfigVar('monitor', 'DB', 'db_name'):
    db_name = getConfigVar('monitor', 'DB', 'db_name')
if getConfigVar('monitor', 'DB', 'db_charset'):
    db_charset = getConfigVar('monitor', 'DB', 'db_charset')
    

MYSQL_CONNECT_STRING = "mysql://%s:%s@%s:%s/%s?charset=%s&use_unicode=0" % (user, \
                                                                         pwd, db_server, db_port, db_name, db_charset)
mysql_engine = create_engine(MYSQL_CONNECT_STRING,echo = False)

Session = sessionmaker(bind=mysql_engine)

Esempio n. 3
0
import os
import re
import socket
import struct
import errno

from xen.xend.ConfigUtil import getConfigVar

if getConfigVar('network', 'Host_interface', 'eth'):
    HOST_INTERFACE = getConfigVar('network', 'Host_interface', 'eth')
else:
    HOST_INTERFACE = 'ovs0'

##### Networking-related functions

def get_defaultroute():

    return ["0.0.0.0", HOST_INTERFACE]

    fd = os.popen('/sbin/ip route list 2>/dev/null')
    for line in fd.readlines():
        m = re.search('^default via ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) dev ([^ ]*)',
                      line)
        if m:
            return [m.group(1), m.group(2)]
    return [None, None]

def get_current_ipaddr(dev='defaultroute'):
    """Get the primary IP address for the given network interface.

    dev     network interface (default: default route device)
Esempio n. 4
0
#     logger.addHandler(file_handler)
#     logger.setLevel(logging.DEBUG)
#     return logger
# log = get_logger("Netctl")

#try:
#    import MySQLdb
#except ImportError, e:
#    log.debug(e)

    
gateway_ip = "127.0.0.1"
gateway_port = "9090"
gateway_eth = "eth0"

if getConfigVar("network", "Gateway", "ip"):
    gateway_ip = getConfigVar("network", "Gateway", "ip")
if getConfigVar("network", "Gateway", "port"):
    gateway_port = getConfigVar("network", "Gateway", "port")
if getConfigVar("network", "Gateway", "eth"):
    gateway_eth = getConfigVar("network", "Gateway", "eth")

gateway_url = "http://%s:%s" % (gateway_ip, gateway_port)


CMD_IPADDR   = '/bin/ipaddr'
CMD_ADDNAT   = '/bin/addnat'
CMD_DELNAT   = '/bin/delnat'
CMD_LISTNAT  = '/bin/listnat'
CMD_ADDBIND  = '/bin/bindipmac'
CMD_DELBIND  = '/bin/unbindipmac'
Esempio n. 5
0
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)
        self.hostuuid = hostuuid
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')
else:
    VDI_TYPE = "tap:aio:"

if getConfigVar('compute', 'VM', 'full_copy'):
    FULL_COPY = getConfigVar('compute', 'VM', 'full_copy', True)
else:
    FULL_COPY = False
    
if getConfigVar('compute', 'VM', 'full_copy_timeout'):
    FULL_COPY_TIMEOUT = int(getConfigVar('compute', 'VM', 'full_copy_timeout'))
else:
    FULL_COPY_TIMEOUT = 600 #second

# def get_logger(logname):
Esempio n. 7
0
init("/var/log/xen/unittest.log", "DEBUG", log_unittest)
log = log_unittest

MB = 1024 * 1024
XEND_NODE = XendNode.instance()
XEND_DOMAIN = XendDomain.instance()
VMAPI = BNVMAPI.instance()
STORAGEAPI = BNStorageAPI.instance()
SESSION = "SessionForTest"
# SESSION = VMAPI.session_login_with_password('root', 'onceas').get('Value')
SR_TYPE = 'ocfs2'
ISO_SR_TYPE = 'gpfs_iso'
VM_VDI_MAP = {}

if getConfigVar('compute', 'VM', 'disk_limit'):
    DISK_LIMIT = int(getConfigVar('compute', 'VM', 'disk_limit'))
else:
    DISK_LIMIT = 6
    
if getConfigVar('compute', 'VM', 'interface_limit'):
    INTERFACE_LIMIT = int(getConfigVar('compute', 'VM', 'interface_limit'))
else:
    INTERFACE_LIMIT = 6

def _get_ocfs2_SR():
    sr = XEND_NODE.get_sr_by_type(SR_TYPE)
    if not sr:
        raise Exception("We need ocfs2 SR_ref here!")
    else:
        return sr[0]