This commit is contained in:
Steven Smith committed 2006-12-01 12:03:38 +00:00
commit becaa718c2
22 files changed
+295 -230

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#============================================================================
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#============================================================================
# Copyright (c) 2006 XenSource Inc.
#============================================================================
import errno
import os
import os.path
import stat
def parents(dir, perms, enforcePermissions = False):
"""
Ensure that the given directory exists, creating it if necessary, but not
complaining if it's already there.
@param dir The directory name.
@param perms One of the stat.S_ constants.
@param enforcePermissions Enforce our ownership and the given permissions,
even if the directory pre-existed with different ones.
"""
# Catch the exception here, rather than checking for the directory's
# existence first, to avoid races.
try:
os.makedirs(dir, perms)
except OSError, exn:
if exn.args[0] != errno.EEXIST or not os.path.isdir(dir):
raise
if enforcePermissions:
os.chown(dir, os.geteuid(), os.getegid())
os.chmod(dir, stat.S_IRWXU)
+5 -8
View File
@@ -30,6 +30,8 @@ from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
import SocketServer
import xmlrpclib, socket, os, stat
import mkdir
from xen.web import connection
from xen.xend.XendLogging import log
@@ -234,14 +236,9 @@ class UnixXMLRPCServer(TCPXMLRPCServer):
address_family = socket.AF_UNIX
def __init__(self, addr, allowed, logRequests = 1):
parent = os.path.dirname(addr)
if os.path.exists(parent):
os.chown(parent, os.geteuid(), os.getegid())
os.chmod(parent, stat.S_IRWXU)
if self.allow_reuse_address and os.path.exists(addr):
os.unlink(addr)
else:
os.makedirs(parent, stat.S_IRWXU)
mkdir.parents(os.path.dirname(addr), stat.S_IRWXU, True)
if self.allow_reuse_address and os.path.exists(addr):
os.unlink(addr)
TCPXMLRPCServer.__init__(self, addr, allowed,
UnixXMLRPCRequestHandler, logRequests)
+5 -7
View File
@@ -22,6 +22,8 @@ import os.path
import socket
import stat
from xen.util import mkdir
import connection
@@ -30,13 +32,9 @@ def bind(path):
created such that only the current user may access it."""
parent = os.path.dirname(path)
if os.path.exists(parent):
os.chown(parent, os.geteuid(), os.getegid())
os.chmod(parent, stat.S_IRWXU)
if os.path.exists(path):
os.unlink(path)
else:
os.makedirs(parent, stat.S_IRWXU)
mkdir.parents(parent, stat.S_IRWXU, True)
if os.path.exists(path):
os.unlink(path)
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(path)
+10 -8
View File
@@ -185,20 +185,22 @@ LEGACY_IMAGE_HVM_CFG = [
('vncconsole', int),
('pae', int),
('apic', int),
('acpi', int),
('serial', str),
]
LEGACY_IMAGE_HVM_DEVICES_CFG = [
('acpi', int),
('boot', str),
('fda', str),
('fdb', str),
('soundhw', str),
('isa', str),
('vcpus', int),
('acpi', int),
('keymap', str),
('localtime', str),
('serial', str),
('stdvga', int),
('soundhw', str),
('usb', str),
('usbdevice', str),
('usbdevice', str),
('vcpus', int),
]
@@ -985,12 +987,12 @@ class XendConfig(dict):
if 'hvm' in self['image']:
for arg, conv in LEGACY_IMAGE_HVM_CFG:
if self['image']['hvm'].has_key(arg):
if self['image']['hvm'].get(arg):
image.append([arg, self['image']['hvm'][arg]])
if 'hvm' in self['image'] and 'devices' in self['image']['hvm']:
for arg, conv in LEGACY_IMAGE_HVM_DEVICES_CFG:
if self['image']['hvm']['devices'].has_key(arg):
if self['image']['hvm']['devices'].get(arg):
image.append([arg,
self['image']['hvm']['devices'][arg]])
+13 -24
View File
@@ -23,6 +23,7 @@
"""
import os
import stat
import shutil
import socket
import threading
@@ -44,7 +45,7 @@ from xen.xend.XendDevices import XendDevices
from xen.xend.xenstore.xstransact import xstransact
from xen.xend.xenstore.xswatch import xswatch
from xen.util import security
from xen.util import mkdir, security
from xen.xend import uuid
xc = xen.lowlevel.xc.xc()
@@ -99,11 +100,7 @@ class XendDomain:
"""Singleton initialisation function."""
dom_path = self._managed_path()
try:
os.stat(dom_path)
except OSError:
log.info("Making %s", dom_path)
os.makedirs(dom_path, 0755)
mkdir.parents(dom_path, stat.S_IRWXU)
xstransact.Mkdir(XS_VMROOT)
xstransact.SetPermissions(XS_VMROOT, {'dom': DOM0_ID})
@@ -271,25 +268,17 @@ class XendDomain:
domains_dir = self._managed_path()
dom_uuid = dominfo.get_uuid()
domain_config_dir = self._managed_path(dom_uuid)
# make sure the domain dir exists
if not os.path.exists(domains_dir):
os.makedirs(domains_dir, 0755)
elif not os.path.isdir(domains_dir):
log.error("xend_domain_dir is not a directory.")
raise XendError("Unable to save managed configuration "
"because %s is not a directory." %
domains_dir)
if not os.path.exists(domain_config_dir):
def make_or_raise(path):
try:
os.makedirs(domain_config_dir, 0755)
except IOError:
log.exception("Failed to create directory: %s" %
domain_config_dir)
raise XendError("Failed to create directory: %s" %
domain_config_dir)
mkdir.parents(path, stat.S_IRWXU)
except:
log.exception("%s could not be created." % path)
raise XendError("%s could not be created." % path)
make_or_raise(domains_dir)
make_or_raise(domain_config_dir)
try:
sxp_cache_file = open(self._managed_config_path(dom_uuid),'w')
prettyprint(dominfo.sxpr(), sxp_cache_file, width = 78)
+4 -1
View File
@@ -16,13 +16,15 @@
# Copyright (C) 2005, 2006 XenSource Ltd.
#============================================================================
import os
import stat
import tempfile
import types
import logging
import logging.handlers
import fcntl
from xen.util import mkdir
from xen.xend.server import params
@@ -80,6 +82,7 @@ def init(filename, level):
global logfilename
def openFileHandler(fname):
mkdir.parents(os.path.dirname(fname), stat.S_IRWXU)
return XendRotatingFileHandler(fname, mode = 'a',
maxBytes = MAX_BYTES,
backupCount = BACKUP_COUNT)
@@ -19,10 +19,12 @@
# The default QCOW Xen API Storage Repository
#
import os
import commands
import os
import stat
import threading
from xen.util import mkdir
from xen.xend import uuid
from xen.xend.XendError import XendError
from xen.xend.XendVDI import *
@@ -98,10 +100,7 @@ class XendStorageRepository:
"""
self.lock.acquire()
try:
# create directory if /var/lib/xend/storage does not exist
if not os.path.exists(XEND_STORAGE_DIR):
os.makedirs(XEND_STORAGE_DIR)
os.chmod(XEND_STORAGE_DIR, 0700)
mkdir.parents(XEND_STORAGE_DIR, stat.S_IRWXU)
# scan the directory and populate self.images
total_used = 0
+2 -3
View File
@@ -277,8 +277,9 @@ class HVMImageHandler(ImageHandler):
self.dmargs += self.configVNC(imageConfig)
self.pae = imageConfig['hvm'].get('pae', 0)
self.acpi = imageConfig['hvm'].get('acpi', 0)
self.apic = imageConfig['hvm'].get('apic', 0)
self.acpi = imageConfig['hvm']['devices'].get('acpi', 0)
def buildDomain(self):
store_evtchn = self.vm.getStorePort()
@@ -317,8 +318,6 @@ class HVMImageHandler(ImageHandler):
for a in dmargs:
v = hvmDeviceConfig.get(a)
if a == 'vcpus':
v = hvmDeviceConfig.get('vcpus_number')
# python doesn't allow '-' in variable names
if a == 'stdvga': a = 'std-vga'
+2 -2
View File
@@ -21,6 +21,7 @@ import xen.lowlevel.xc
from xen.xend.XendLogging import log
from xen.xend import osdep
from xen.util import mkdir
import relocate
import SrvServer
@@ -108,8 +109,7 @@ class Daemon:
# so _before_ we close stderr.
try:
parent = os.path.dirname(XEND_DEBUG_LOG)
if not os.path.exists(parent):
os.makedirs(parent, stat.S_IRWXU)
mkdir.parents(parent, stat.S_IRWXU)
fd = os.open(XEND_DEBUG_LOG, os.O_WRONLY|os.O_CREAT|os.O_APPEND)
except Exception, exn:
print >>sys.stderr, exn
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.