import os import os.path import re import sys import logging import httplib2 import socket import struct import select from socket import inet_aton, inet_ntoa from struct import unpack, pack from xen.xend.XendLogging import log_netctl, init from xen.xend.ConfigUtil import getConfigVar init("/var/log/xen/Netctl.log", "DEBUG", log_netctl) log = log_netctl # 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) # return logger # log = get_logger("Netctl") #try: # import MySQLdb #except ImportError, e:
import os import re from xen.xend.XendLogging import log_license, init init("/var/log/xen/license.log", "DEBUG", log_license) log = log_license KEY = 10 DEV = "ovs0" TWO_YEARS = 712 LICENSE_FILE = "/etc/xen/license" def gen_license(period): mac_of_eth0 = get_MAC_of_eth0() code = "".join([str(mac_of_eth0), str(period)]) return encrypt(code) def verify_licence_from_local(): if os.path.exists(LICENSE_FILE): fileHandle = open(LICENSE_FILE, 'r') else: log.error("verify license failed!") print("Please activate BeyondSphere first!") return False try: line = fileHandle.readline().strip() except Exception, exn: log.exception("read license from file failed! %s" % exn) return False finally: fileHandle.close()
import uuid from XendError import XendError from XendVDI import * from XendNode import XendNode 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 XendNode import XendNode from xen.xend import sxp from xen.xend.XendConstants import DEFAULT_HA_PATH from xen.xend.XendLogging import log_ha, init init("/var/log/xen/ha.log", "DEBUG", log_ha) log = log_ha KB = 1024 MB = 1024 * 1024 GB = 1024 * 1024 * 1024 TB = 1024 * 1024 * 1024 * 1024 PB = 1024 * 1024 * 1024 * 1024 * 1024 VG_BINARY = "/sbin/vgs" LV_CREATE_BINARY = "/sbin/lvcreate" DF_COMMAND = "df" STORAGE_LOCATION = "/home" SXP_FILE = ".sxp" XML_FILE = ".xml" VDI_TYPE = "tap:aio:"
from xen.util import mkdir 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 xen.xend.XendLogging import log_iso, init init("/var/log/xen/iso.log", "DEBUG", log_iso) log = log_iso KB = 1024 MB = 1024 * 1024 GB = 1024 * 1024 * 1024 TB = 1024 * 1024 * 1024 * 1024 PB = 1024 * 1024 * 1024 * 1024 * 1024 STORAGE_LOCATION = "/home" FILE_EXT = ".iso" VDI_TYPE = "tap:aio:" # log = logging.getLogger("GPFS_ISO") # file_h = logging.FileHandler("/var/log/xen/gpfs_iso.log") # log.addHandler(file_h) # log.setLevel(logging.DEBUG)
from tools import * from default_record import * from xen.xend import uuid from xen.xend import XendDomain, XendNode from xen.xend import BNVMAPI, BNStorageAPI from xen.xend.server.netif import randomMAC from xen.xend.ConfigUtil import getConfigVar from xen.xend.XendAPIConstants import * from xen.xend.XendAuthSessions import instance as auth_manager from xen.xend.XendLogging import log_unittest, init 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'):