Change in vdsm[master]: utils.py: Add hostUUID retrieval support for KVM on PPC64
by Pradipta Kumar Banerjee
Pradipta Banerjee has uploaded a new change for review.
Change subject: utils.py: Add hostUUID retrieval support for KVM on PPC64
......................................................................
utils.py: Add hostUUID retrieval support for KVM on PPC64
Change-Id: I7a557b096550631e340fcc61bcb3fa4c3ae73837
Signed-off-by: Pradipta Kr. Banerjee <bpradip(a)in.ibm.com>
---
M vdsm/utils.py
1 file changed, 16 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/8637/1
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 0dbb342..80582d4 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -37,6 +37,7 @@
import functools
import stat
import glob
+import platform
import ethtool
@@ -701,19 +702,23 @@
with open(constants.P_VDSM_NODE_ID) as f:
__hostUUID = f.readline().replace("\n", "")
else:
- p = subprocess.Popen([constants.EXT_SUDO,
+ arch = platform.machine()
+ if arch == 'x86_64':
+ p = subprocess.Popen([constants.EXT_SUDO,
constants.EXT_DMIDECODE, "-s", "system-uuid"],
- close_fds=True, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- out = '\n'.join( line for line in out.splitlines()
+ close_fds=True, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ out = '\n'.join( line for line in out.splitlines()
if not line.startswith('#') )
- if p.returncode == 0 and 'Not' not in out:
- #Avoid error string - 'Not Settable' or 'Not Present'
- __hostUUID = out.strip()
- else:
- logging.warning('Could not find host UUID.')
+ if p.returncode == 0 and 'Not' not in out:
+ #Avoid error string - 'Not Settable' or 'Not Present'
+ __hostUUID = out.strip()
+ elif arch == 'ppc64':
+ if os.path.exists('/proc/device-tree/system-id'):
+ #eg. output IBM,03061C14A
+ __hostUUID = file('/proc/device-tree/system-id').readline().replace(",", "")
try:
mac = sorted(_getAllMacs())[0]
@@ -724,6 +729,7 @@
if __hostUUID != "None":
__hostUUID += "_" + mac
else:
+ logging.warning('Could not find host UUID')
__hostUUID = "_" + mac
except:
logging.error("Error retrieving host UUID", exc_info=True)
--
To view, visit http://gerrit.ovirt.org/8637
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a557b096550631e340fcc61bcb3fa4c3ae73837
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Pradipta Banerjee <bpradip(a)in.ibm.com>
10 years, 3 months
Change in vdsm[master]: Adjust width for usage_command in vdsm-tool
by lilei@linux.vnet.ibm.com
Lei Li has uploaded a new change for review.
Change subject: Adjust width for usage_command in vdsm-tool
......................................................................
Adjust width for usage_command in vdsm-tool
The default value of width is 70 characters. It may not
be long enough for most of the usage_command comments.
So adjust it to add flexibility.
Change-Id: I800384e77452a76f651b73205b3335905274077c
Signed-off-by: Lei Li <lilei(a)linux.vnet.ibm.com>
---
M vdsm-tool/vdsm-tool
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/4648/1
--
To view, visit http://gerrit.ovirt.org/4648
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I800384e77452a76f651b73205b3335905274077c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lei Li <lilei(a)linux.vnet.ibm.com>
10 years, 3 months
Change in vdsm[master]: [WIP] Move vm logic to it's own module
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: [WIP] Move vm logic to it's own module
......................................................................
[WIP] Move vm logic to it's own module
Change-Id: Icc54c1d0ab7ad535d825dcd72fd2f4583b690f44
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/API.py
M vdsm/Makefile.am
M vdsm/clientIF.py
A vdsm/vmContainer.py
4 files changed, 134 insertions(+), 79 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/7423/1
diff --git a/vdsm/API.py b/vdsm/API.py
index e132fb9..818e00c 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -167,34 +167,36 @@
self.log.error("Error restoring VM parameters",
exc_info=True)
- requiredParams = ['vmId', 'memSize', 'display']
- for param in requiredParams:
+ for param in ['vmId', 'memSize', 'display']:
if param not in vmParams:
- self.log.error('Missing required parameter %s' % (param))
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'Missing required' + \
- 'parameter %s' % (param)}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing required parameter %s' % (param,)}
+ }
try:
storage.misc.validateUUID(vmParams['vmId'])
except:
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'vmId must be a valid UUID'}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'vmId must be a valid UUID'}
+ }
if vmParams['memSize'] == 0:
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'Must specify nonzero memSize'}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'Must specify nonzero memSize'}
+ }
if vmParams.get('boot') == 'c' and not 'hda' in vmParams \
and not vmParams.get('drives'):
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'missing boot disk'}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'missing boot disk'}
+ }
if 'vmType' not in vmParams:
vmParams['vmType'] = 'kvm'
- elif vmParams['vmType'] == 'kvm':
+
+ if vmParams['vmType'] == 'kvm':
if 'kvmEnable' not in vmParams:
vmParams['kvmEnable'] = 'true'
@@ -205,25 +207,27 @@
vmParams['volatileFloppy'] = True
if caps.osversion()['name'] == caps.OSName.UNKNOWN:
- return {'status': {'code': errCode['createErr']
- ['status']['code'],
- 'message': 'Unknown host operating system'}}
+ return {'status': {
+ 'code': errCode['createErr']['status']['code'],
+ 'message': 'Unknown host operating system'}
+ }
if 'sysprepInf' in vmParams:
if not self._createSysprepFloppyFromInf(vmParams['sysprepInf'],
vmParams['floppy']):
- return {'status': {'code': errCode['createErr']
- ['status']['code'],
- 'message': 'Failed to create '
- 'sysprep floppy image. '
- 'No space on /tmp?'}}
- return errCode['createErr']
+ return {'status': {
+ 'code': errCode['createErr']['status']['code'],
+ 'message': 'Failed to create sysprep floppy image. '
+ 'No space on /tmp?'}
+ }
if vmParams.get('display') not in ('vnc', 'qxl', 'qxlnc', 'local'):
- return {'status': {'code': errCode['createErr']
- ['status']['code'],
- 'message': 'Unknown display type %s'
- % vmParams.get('display')}}
+ return {'status': {
+ 'code': errCode['createErr']['status']['code'],
+ 'message': 'Unknown display type %s' %
+ vmParams.get('display')}
+ }
+
if 'nicModel' not in vmParams:
vmParams['nicModel'] = config.get('vars', 'nic_model')
vmParams['displayIp'] = self._getNetworkIp(vmParams.get(
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index d4c52ed..574d762 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -53,6 +53,7 @@
tc.py \
vdsmDebugPlugin.py \
vmChannels.py \
+ vmContainer.py \
vm.py \
$(NULL)
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index b9a4913..b2438fb 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -24,6 +24,7 @@
import pickle
from xml.dom import minidom
import uuid
+import errno
from storage.dispatcher import Dispatcher
from storage.hsm import HSM
@@ -40,9 +41,9 @@
import configNetwork
import caps
from vmChannels import Listener
-from libvirtvm import LibvirtVm
import blkid
import supervdsm
+import vmContainer
try:
import gluster.api as gapi
_glusterEnabled = True
@@ -66,7 +67,6 @@
:param log: a log object to be used for this object's logging.
:type log: :class:`logging.Logger`
"""
- self.vmContainerLock = threading.Lock()
self._networkSemaphore = threading.Semaphore()
self._shutdownSemaphore = threading.Semaphore()
self.log = log
@@ -82,7 +82,7 @@
else:
self.gluster = None
try:
- self.vmContainer = {}
+ self.vmContainer = vmContainer.VmContainer()
ifids = netinfo.nics() + netinfo.bondings()
ifrates = map(netinfo.speed, ifids)
self._hostStats = utils.HostStatsThread(
@@ -328,24 +328,19 @@
return res['status']['code']
def createVm(self, vmParams):
- self.vmContainerLock.acquire()
- self.log.info("vmContainerLock acquired by vm %s",
- vmParams['vmId'])
try:
- if 'recover' not in vmParams:
- if vmParams['vmId'] in self.vmContainer:
- self.log.warning('vm %s already exists' %
- vmParams['vmId'])
- return errCode['exist']
- vm = LibvirtVm(self, vmParams)
- self.vmContainer[vmParams['vmId']] = vm
- finally:
- container_len = len(self.vmContainer)
- self.vmContainerLock.release()
- vm.run()
- self.log.debug("Total desktops after creation of %s is %d" %
- (vmParams['vmId'], container_len))
- return {'status': doneCode, 'vmList': vm.status()}
+ vm = self.vmContainer.createVm(vmParams)
+ return {'status': doneCode, 'vmList': vm.status()}
+ except vmContainer.VmContainerError as e:
+ if e.errno == errno.EEXIST:
+ return errCode['exist']
+ return
+
+ def waitForShutdown(self, timeout=None):
+ self.shutdownEvent(timeout)
+ # Some versions of python have a bug where wait doesn't
+ # really return the correct value.
+ return self.shutdownEvent.isSet()
def _recoverExistingVms(self):
try:
@@ -364,10 +359,11 @@
'process with id: %s',
vmId, exc_info=True)
- while (self._enabled and
- 'WaitForLaunch' in [v.lastStatus for v in
- self.vmContainer.values()]):
- time.sleep(1)
+ vmList = self.vmContainer.getVMs()
+ while ('WaitForLaunch' in (v.lastStatus for v in vmList)):
+ if self.waitForShutdown(1):
+ break
+
self._cleanOldFiles()
self._recovery = False
@@ -375,20 +371,23 @@
# and then prepare all volumes.
# Actually, we need it just to get the resources for future
# volumes manipulations
- while self._enabled and self.vmContainer and \
- not self.irs.getConnectedStoragePoolsList()['poollist']:
- time.sleep(5)
+ if len(vmList) > 0:
+ while not self.irs.getConnectedStoragePoolsList()['poollist']:
+ if self.waitForShutdown(5):
+ break
- for vmId, vmObj in self.vmContainer.items():
- # Let's recover as much VMs as possible
+ # Let's recover as many VMs as possible
+ for vmObj in vmList:
+ # Do not prepare volumes when system goes down
+ if self.waitForShutdown(0):
+ break
+
try:
- # Do not prepare volumes when system goes down
- if self._enabled:
- vmObj.preparePaths(
- vmObj.getConfDevices()[vm.DISK_DEVICES])
+ devices = vmObj.getConfDevices()[vm.DISK_DEVICES]
+ vmObj.preparePaths(devices)
except:
- self.log.error("Vm %s recovery failed",
- vmId, exc_info=True)
+ self.log.error("Vm '%s' recovery failed", vmObj.id,
+ exc_info=True)
except:
self.log.error("Vm's recovery failed", exc_info=True)
@@ -452,27 +451,27 @@
return recoveryFile
except:
self.log.debug("Error recovering VM", exc_info=True)
- return None
def _cleanOldFiles(self):
for f in os.listdir(constants.P_VDSM_RUN):
try:
vmId, fileType = f.split(".", 1)
- if fileType in ["guest.socket", "monitor.socket", "pid",
+ if fileType not in ["guest.socket", "monitor.socket", "pid",
"stdio.dump", "recovery"]:
- if vmId in self.vmContainer:
- continue
- if f == 'vdsmd.pid':
- continue
- if f == 'respawn.pid':
- continue
- if f == 'svdsm.pid':
- continue
- if f == 'svdsm.sock':
- continue
- else:
continue
- self.log.debug("removing old file " + f)
+
+ if self.vmContainer.hasVM(vmId):
+ continue
+
+ #FIXME: Move VM crud to a subdir so we don't need a
+ # whitelist. I remember spending a considerable amount of
+ # time while writing Super VDSM trying to figure out why my
+ # pid file was disappearing!
+ if f in ('vdsmd.pid', 'respawn.pid',
+ 'svdsm.pid', 'svdsm.sock'):
+ continue
+
+ self.log.debug("Removing old file '%s'", f)
utils.rmFile(constants.P_VDSM_RUN + f)
except:
pass
diff --git a/vdsm/vmContainer.py b/vdsm/vmContainer.py
new file mode 100644
index 0000000..f15b8eb
--- /dev/null
+++ b/vdsm/vmContainer.py
@@ -0,0 +1,51 @@
+import logging
+import threading
+from libvirtvm import LibvirtVm
+import os
+import errno
+
+
+class VmContainerError(OSError):
+ def __init__(self, errno):
+ OSError.__init__(self, errno, os.strerror(errno))
+
+
+class VmContainer(object):
+ log = logging.getLogger("VmContainer")
+
+ def __init__(self):
+ self._syncroot = threading.Lock()
+ self._vms = {}
+
+ def createVm(self, vmParams):
+ self.log.info("vmContainerLock acquired by vm %s",
+ vmParams['vmId'])
+
+ with self._syncRoot:
+ if 'recover' not in vmParams:
+ if vmParams['vmId'] in self._vms:
+ self.log.warning('vm %s already exists' % vmParams['vmId'])
+
+ raise VmContainerError(errno.EEXIST)
+
+ vm = LibvirtVm(self, vmParams)
+ self._vms[vmParams['vmId']] = vm
+
+ container_len = len(self._vms)
+
+ vm.run()
+ self.log.debug("Total desktops after creation of %s is %d" %
+ (vmParams['vmId'], container_len))
+
+ return vm
+
+ def getVMs(self):
+ return self._vms.values()
+
+ def hasVM(self, vmId):
+ with self._syncRoot:
+ return vmId in self._vms
+
+ def get(self, vmId):
+ with self._syncRoot:
+ return self._vms.get(vmId)
--
To view, visit http://gerrit.ovirt.org/7423
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc54c1d0ab7ad535d825dcd72fd2f4583b690f44
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: add verb for vdsm to tuneCpu params
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: add verb for vdsm to tuneCpu params
......................................................................
add verb for vdsm to tuneCpu params
Engine and Mom need an interface to cap the max cpu and share.
So add this verb to vdsm.
tuneCpu:
Dynamically tune cpu absolute max proportion and relative share.
Input:
vmId: VM to be tuned
max_proportion=<value>: absolute max proportion for each vCPU can consume
-1:no limit,[0.001,1]:valid proportion
relative_share=<value>:relative share of CPU compared with other VMs
output:
success: return doneCode
failure: return errCode tunecpuErr.
Change-Id: I09e02e09ef06ad6de45be75c3f2f913a3025750f
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/define.py
M vdsm/libvirtvm.py
M vdsm/storage/misc.py
M vdsm_cli/vdsClient.py
6 files changed, 97 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/7492/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 827f73b..f0c47d1 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -26,6 +26,7 @@
import time
import threading
import logging
+import math
from vdsm import utils
from clientIF import clientIF
@@ -37,6 +38,7 @@
import storage.volume
import storage.sd
import storage.image
+import storage.storage_exception as se
from vdsm.define import doneCode, errCode, Kbytes, Mbytes
import caps
from vdsm.config import config
@@ -555,6 +557,33 @@
message = USER_SHUTDOWN_MESSAGE
return v.shutdown(delay, message)
+ def tuneCpu(self, tuneParams):
+ try:
+ v = self._cif.vmContainer[self._UUID]
+ if 'relative_share' in tuneParams:
+ tuneParams['cpu_shares'] = storage.misc.validateN(
+ tuneParams['relative_share'], 'relative_share')
+ del(tuneParams['relative_share'])
+ if 'max_proportion' in tuneParams:
+ max = storage.misc.validateFloat(
+ tuneParams['max_proportion'], 'max_proportion')
+ tuneParams['vcpu_period'] = 1000000
+ if max > 1:
+ raise se.InvalidParameterException('max_proportion', max)
+ elif max >= 0.001:
+ tuneParams['vcpu_quota'] = int(
+ round(tuneParams['vcpu_period'] * max))
+ else:
+ tuneParams['vcpu_quota'] = int(math.floor(max))
+ del(tuneParams['max_proportion'])
+ del(tuneParams['vmId'])
+ except KeyError:
+ return errCode['noVM']
+ except se.InvalidParameterException:
+ return errCode['tunecpuErr']
+
+ return v.tuneCpu(tuneParams)
+
def _createSysprepFloppyFromInf(self, infFileBinary, floppyImage):
try:
rc, out, err = utils.execCmd([constants.EXT_MK_SYSPREP_FLOPPY,
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 826c125..37b1f60 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -265,6 +265,10 @@
vm = API.VM(vmId)
return vm.snapshot(snapDrives)
+ def vmTuneCpu(self, params):
+ vm = API.VM(params['vmId'])
+ return vm.tuneCpu(params)
+
def vmMerge(self, vmId, mergeDrives):
vm = API.VM(vmId)
return vm.merge(mergeDrives)
@@ -765,7 +769,8 @@
(self.vmHotplugDisk, 'hotplugDisk'),
(self.vmHotunplugDisk, 'hotunplugDisk'),
(self.vmHotplugNic, 'hotplugNic'),
- (self.vmHotunplugNic, 'hotunplugNic'))
+ (self.vmHotunplugNic, 'hotunplugNic'),
+ (self.vmTuneCpu, 'tuneCpu'))
def getIrsMethods(self):
return ((self.domainActivate, 'activateStorageDomain'),
diff --git a/vdsm/define.py b/vdsm/define.py
index 049d36c..d41d467 100644
--- a/vdsm/define.py
+++ b/vdsm/define.py
@@ -117,6 +117,9 @@
'momErr': {'status':
{'code': 54,
'message': 'Failed to set mom policy'}},
+ 'tunecpuErr': {'status':
+ {'code': 55,
+ 'message': 'Failed to Tune CPU'}},
'recovery': {'status':
{'code': 99,
'message':
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index e95e94b..59c7ec6 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1371,13 +1371,17 @@
if self._initTimePauseCode == 'ENOSPC':
self.cont()
self.conf['pid'] = self._getPid()
-
- nice = int(self.conf.get('nice', '0'))
- nice = max(min(nice, 19), 0)
- try:
- self._dom.setSchedulerParameters({'cpu_shares': (20 - nice) * 51})
- except:
- self.log.warning('failed to set Vm niceness', exc_info=True)
+ #do not trying to change cpu_shares for recovery and restore flows
+ if not 'recover' in self.conf and not 'restoreState' in self.conf:
+ nice = int(self.conf.get('nice', '0'))
+ nice = max(min(nice, 19), 0)
+ cpuShare = (20 - nice) * 51
+ try:
+ self._dom.setSchedulerParameters({'cpu_shares': cpuShare})
+ except:
+ self.log.warning('failed to set Vm niceness', exc_info=True)
+ self.conf['cpu_shares'] = cpuShare
+ self.saveState()
def _run(self):
self.log.info("VM wrapper has started")
@@ -1931,6 +1935,23 @@
(snapFlags & libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
== libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE)}
+ def tuneCpu(self, tuneParams):
+ try:
+ self._dom.setSchedulerParameters(tuneParams)
+ self.conf['cpu_shares'] = tuneParams.get('cpu_shares')
+ self.conf['vcpu_quota'] = tuneParams.get('vcpu_quota')
+ self.conf['vcpu_period'] = tuneParams.get('vcpu_period')
+ self.saveState()
+ return {'status': doneCode}
+ except libvirt.libvirtError, e:
+ self.log.error("TuneCpu failed:%s",
+ e.message, exc_info=True)
+ return errCode['tunecpuErr']
+ except LookupError:
+ self.log.error('TuneCpu failed: unrecongnized params',
+ exc_info=True)
+ return errCode['tunecpuErr']
+
def _runMerge(self):
for mergeStatus in self.conf.get('liveMerge', []):
if mergeStatus['status'] != MERGESTATUS.NOT_STARTED:
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index 161726b..1f5ed1a 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -503,6 +503,13 @@
return n
+def validateFloat(floatNumber, name):
+ try:
+ return float(floatNumber)
+ except:
+ raise se.InvalidParameterException(floatNumber, name)
+
+
def rotateFiles(directory, prefixName, gen, cp=False, persist=False):
log.debug("dir: %s, prefixName: %s, versions: %s" %
(directory, prefixName, gen))
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index a164c20..ab0fa4c 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -204,6 +204,18 @@
return self.ExecAndExit(self.s.create(params))
+ def tuneCpu(self, args):
+ params = {}
+ confLines = []
+ params['vmId'] = args[0]
+ if len(args) > 1:
+ confLines.extend(args[1:])
+ for line in confLines:
+ if '=' in line:
+ param, value = line.split("=", 1)
+ params[param] = value
+ return self.ExecAndExit(self.s.tuneCpu(params))
+
def hotplugNic(self, args):
nic = self._parseDriveSpec(args[1])
nic['type'] = 'interface'
@@ -1802,6 +1814,18 @@
'Optional additional parameters in dictionary format,'
' name:value,name:value'
)),
+ 'tuneCpu': (serv.tuneCpu,
+ ('<vmId>'
+ '[max_proportion=value relative_share=value]',
+ 'Parameters list: r=required, o=optional',
+ 'r vmId: The vm to be tuned',
+ 'o max_proportion=<value>: '
+ 'max proportion for each vCPU can be consumed, '
+ '-1 is no limit,[0.001,1] is valid proportion',
+ 'o relative_share=<value>:relative share of CPU'
+ 'compared with other VMs',
+ 'Dynamically tune cpu absolute max proportion and relative share'
+ )),
'migrate': (serv.do_migrate,
('vmId=<id> method=<offline|online> src=<host:[port]> '
'dst=<host:[port]>',
--
To view, visit http://gerrit.ovirt.org/7492
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I09e02e09ef06ad6de45be75c3f2f913a3025750f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 4 months
Change in vdsm[master]: adjust betterPopenTest.py
by xiawenc@linux.vnet.ibm.com
Wenchao Xia has uploaded a new change for review.
Change subject: adjust betterPopenTest.py
......................................................................
adjust betterPopenTest.py
The main function in betterPopenTest is used to check result
after popen, it should not include the betterPopen and test class
code. If it include and the directory it lies on changes, the
import will fail, which means additional python settings should be
passed to betterPopen making things more complicate.
Change-Id: I3059df6abb5c261f45720fc1a3b5266314c62e79
Signed-off-by: wenchao xia <xiawenc(a)linux.vnet.ibm.com>
---
M tests/betterPopenTests.py
1 file changed, 50 insertions(+), 51 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/4585/1
--
To view, visit http://gerrit.ovirt.org/4585
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3059df6abb5c261f45720fc1a3b5266314c62e79
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Wenchao Xia <xiawenc(a)linux.vnet.ibm.com>
10 years, 4 months
Change in vdsm[master]: bz#831938 raise exception when error occurs in connectStorag...
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: bz#831938 raise exception when error occurs in connectStorageServer
......................................................................
bz#831938 raise exception when error occurs in connectStorageServer
connectStorageServer returned OK when error occurs:
iscsi login fails, local directory lack of permission,etc
change it to raise error to make early alarm
Change-Id: I4c363f41d08669eec022797eb1eb440fe193f9c2
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/storage/hsm.py
1 file changed, 2 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/6137/1
--
To view, visit http://gerrit.ovirt.org/6137
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c363f41d08669eec022797eb1eb440fe193f9c2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 4 months
Change in vdsm[master]: Add uploadIso API call for pushing ISOs into an active iso_d...
by Ryan Harper
Ryan Harper has uploaded a new change for review.
Change subject: Add uploadIso API call for pushing ISOs into an active iso_domain via pool
......................................................................
Add uploadIso API call for pushing ISOs into an active iso_domain via pool
The only way to get an ISO into the vdsm storage service is via ovirt-engine's
engine-iso-uploader. This requires a functioning ovirt-engine install. Instead
provide a simple API call to push the iso file out to the correct location.
Given an pool UUID, we can determine where the iso file should go via isoprefix
so use either wget or rsync to pull the iso file and place it in the pool's
iso_domain.
wget a remote iso
% vdsClient -s 0 uploadIso d3b3948a-ead6-11e1-a3a5-00fffe0000df \
http://server/path/Fedora-17-x86_64-netinst.iso
rsync in a local file
% vdsClient -s 0 uploadIso d3b3948a-ead6-11e1-a3a5-00fffe0000df \
/tmp/Fedora-17-x86_64-netinst.iso
Change-Id: Id78e46513c38789d08e63a38026b28bebb9a2b12
Signed-off-by: Ryan Harper <ryanh(a)us.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
M vdsm/storage/storage_exception.py
M vdsm_api/vdsmapi-schema.json
M vdsm_cli/vdsClient.py
7 files changed, 136 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/7849/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 827f73b..734f40d 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -956,6 +956,9 @@
return self._irs.upgradeStoragePool(self._UUID,
targetDomVersion)
+ def uploadIso(self, srcPath, method):
+ return self._irs.uploadIso(self._UUID, srcPath, method)
+
def validateStorageServerConnection(self, domainType,
connectionParams):
return self._irs.validateStorageServerConnection(domainType,
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 826c125..ca92779 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -563,6 +563,10 @@
pool = API.StoragePool(spUUID)
return pool.upgrade(targetDomVersion)
+ def poolUploadIso(self, spUUID, srcPath, method):
+ pool = API.StoragePool(spUUID)
+ return pool.uploadIso(srcPath, method)
+
def poolValidateStorageServerConnection(self, domType, spUUID, conList,
options=None):
pool = API.StoragePool(spUUID)
@@ -809,6 +813,7 @@
(self.poolSpmStart, 'spmStart'),
(self.poolSpmStop, 'spmStop'),
(self.poolUpgrade, 'upgradeStoragePool'),
+ (self.poolUploadIso, 'uploadIso'),
(self.poolValidateStorageServerConnection,
'validateStorageServerConnection'),
(self.poolUpdateVMs, 'updateVM'),
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 1e9311b..2fb9fae 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1189,6 +1189,19 @@
pool = self.getPool(spUUID)
pool.uploadVolume(sdUUID, imgUUID, volUUID, srcPath, size, method="rsync")
+ @public
+ def uploadIso(self, spUUID, srcPath, method):
+ """
+ Uploads an ISO to <pool UUID>'s iso domain
+
+ :param spUUID: The UUID of the storage pool that will contain the new iso.
+ :type spUUID: UUID
+ :param method: The desired method of upload. Currently only *'wget'* and *'rsync'* are supported.
+ :type method: str
+ """
+ vars.task.getSharedLock(STORAGE, spUUID)
+ pool = self.getPool(spUUID)
+ pool.uploadIso(srcPath, method)
@public
def createVolume(self, sdUUID, spUUID, imgUUID, size, volFormat, preallocate, diskType, volUUID, desc, srcImgUUID=volume.BLANK_UUID, srcVolUUID=volume.BLANK_UUID):
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index c10974c..1c9dec7 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -2004,6 +2004,69 @@
except:
self.log.warning("SP %s SD %s img %s Vol %s - teardown failed")
+
+ def uploadIso(self, srcPath, method):
+ self.log.info("uploadIso - srcPath=%s method=%s"%(srcPath, method))
+
+ # find the iso domain within the pool
+ info = self.getInfo()['info']
+ if 'isoprefix' in info.keys() and len(info['isoprefix']) > 0:
+ targetPath = info['isoprefix']
+ else:
+ self.log.error("uploadIso - target pool(%s) does not"
+ "have an ISO domain" %(self.spUUID))
+ raise se.StoragePoolNoIsoDomain()
+
+ self.log.info("uploadIso - targetPath=%s"%(targetPath))
+ rc = 0
+
+ # we can infer the method to use by inspection of srcPath
+ if len(method) == 0:
+ if srcPath.startswith("http://"):
+ method = "wget"
+ else:
+ method = "rsync"
+
+ try:
+ if method.lower() == "wget":
+ if not srcPath.startswith("http://"):
+ self.log.error("uploadIso - wget method requires HTTP URL")
+ raise se.InvalidParameterException('srcPath mismatch with'
+ ' method', method)
+
+ outFile = os.path.join(targetPath, os.path.basename(srcPath))
+ cmd = [constants.EXT_WGET, "-O", outFile, srcPath]
+ (rc, out, err) = misc.execCmd(cmd, sudo=False)
+
+ if rc:
+ self.log.error("uploadIso - error while trying to retrieve:"
+ "%s into: %s, stderr: %s" % (srcPath,
+ targetPath,
+ err))
+ raise se.VolumeCopyError(srcPath, err)
+ elif method.lower() == "rsync":
+ if srcPath.startswith("http://"):
+ self.log.error("uploadIso - rsync method cannot use"
+ "HTTP URL")
+ raise se.InvalidParameterException('srcPath mismatch with'
+ ' method', method)
+ cmd = [constants.EXT_RSYNC, "-aq", srcPath, targetPath]
+ (rc, out, err) = misc.execCmd(cmd, sudo=False)
+
+ if rc:
+ self.log.error("uploadIso - error while trying to copy:"
+ "%s into: %s, stderr: %s" % (srcPath,
+ targetPath,
+ err))
+ raise se.VolumeCopyError(srcPath, err)
+ else:
+ self.log.error("uploadIso - method '%s' not supported", method)
+ raise se.InvalidParameterException('method', method)
+
+ finally:
+ if rc == 0:
+ self.log.info("uploadIso - completed via %s", method)
+
def preDeleteRename(self, sdUUID, imgUUID):
repoPath = os.path.join(self.storage_repository, self.spUUID)
return image.Image(repoPath).preDeleteRename(sdUUID, imgUUID)
diff --git a/vdsm/storage/storage_exception.py b/vdsm/storage/storage_exception.py
index f1edad4..88ac2d5 100644
--- a/vdsm/storage/storage_exception.py
+++ b/vdsm/storage/storage_exception.py
@@ -508,6 +508,10 @@
code = 330
message = "Cannot get files list"
+class StoragePoolNoIsoDomain(StorageException):
+ code = 331
+ message = "No ISO Domain available in Storage Pool"
+
#################################################
# Domains Exceptions
#################################################
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index a773177..d898d0a 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -3309,6 +3309,38 @@
'size': 'int', 'method': 'UploadVolumeMethod'}}
##
+# @UploadIsoMethod:
+#
+# An enumeration of uploadIso methods.
+#
+# @wget: Fetch data using the wget command
+#
+# @rsync: Fetch data using the rsync command
+#
+# Since: 4.10.0
+##
+{'enum': 'UploadIsoMethod', 'data': ['wget', 'rsync']}
+
+##
+# @StoragePool.uploadIso:
+#
+# Upload an ISO file into a Storage Pool from a remote location.
+#
+# @spUUID: The UUID of the pool in which the ISO will be uploaded
+#
+# @srcPath: The remote location of the ISO data. Must be in a format that
+# can be understood by the command indicated in @method.
+#
+# @method: The method (command) to use to upload the data
+#
+# Since: 4.10.0
+##
+{'command': {'class': 'StoragePool', 'name': 'uploadIso'},
+ 'data': {'spUUID': 'UUID', 'srcPath': 'str',
+ 'method': 'UploadVolumeMethod'}}
+
+
+##
# @StorageDomain.validate:
#
# Check that the Storage Domain is accessible.
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index ff7ccc8..c1f5268 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -962,6 +962,17 @@
return status['status']['code'], status['status']['message']
return 0, ''
+ def uploadIso(self, args):
+ spUUID = args[0]
+ srcPath = args[1]
+ method = ''
+ if len(args) > 2:
+ method = args[2]
+ status = self.s.uploadIso(spUUID, srcPath, method)
+ if status['status']['code']:
+ return status['status']['code'], status['status']['message']
+ return 0, ''
+
def uploadVolume(self, args):
sdUUID = args[0]
spUUID = args[1]
@@ -2048,6 +2059,11 @@
'<new disk size>',
'Extend volume (SAN only)'
)),
+ 'uploadIso': (serv.uploadIso,
+ ('<spUUID> <srcPath> [<method>]',
+ 'Upload ISO file into the specified storage pool.'
+ ' <method> is one of [wget|rsync] and is optional'
+ )),
'uploadVolume': (serv.uploadVolume,
('<sdUUID> <spUUID> <imgUUID> <volUUID> <srcPath> '
'<size>',
--
To view, visit http://gerrit.ovirt.org/7849
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id78e46513c38789d08e63a38026b28bebb9a2b12
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ryan Harper <ryanh(a)us.ibm.com>
10 years, 4 months
Change in vdsm[master]: [WIP]add mem cgroup support to vdsm
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: [WIP]add mem cgroup support to vdsm
......................................................................
[WIP]add mem cgroup support to vdsm
add vdsm mem cgroup support,
New version libvirt memtune function has a bug,
tested uncompleted until I fix the bug.
Change-Id: If2ad220e21b114985ead4bd64e81133173566444
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/define.py
M vdsm/libvirtvm.py
M vdsm_api/vdsmapi-schema.json
M vdsm_cli/vdsClient.py
6 files changed, 90 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/8031/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 566d6e5..f5889f9 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -37,6 +37,7 @@
import storage.volume
import storage.sd
import storage.image
+import storage.storage_exception as se
from vdsm.define import doneCode, errCode, Kbytes, Mbytes
import caps
from vdsm.config import config
@@ -555,6 +556,19 @@
message = USER_SHUTDOWN_MESSAGE
return v.shutdown(delay, message)
+ def tuneMem(self, tuneParams):
+ try:
+ v = self._cif.vmContainer[self._UUID]
+ for key in tuneParams:
+ tuneParams[key] = storage.misc.validateN(
+ tuneParams[key], key)
+ except KeyError:
+ return errCode['noVM']
+ except se.InvalidParameterException:
+ return errCode['tuneMemErr']
+
+ return v.tuneMem(tuneParams)
+
def _createSysprepFloppyFromInf(self, infFileBinary, floppyImage):
try:
rc, out, err = utils.execCmd([constants.EXT_MK_SYSPREP_FLOPPY,
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 826c125..fe7b9d5 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -265,6 +265,10 @@
vm = API.VM(vmId)
return vm.snapshot(snapDrives)
+ def vmTuneMem(self, params):
+ vm = API.VM(params.pop('vmId'))
+ return vm.tuneMem(params)
+
def vmMerge(self, vmId, mergeDrives):
vm = API.VM(vmId)
return vm.merge(mergeDrives)
@@ -765,7 +769,8 @@
(self.vmHotplugDisk, 'hotplugDisk'),
(self.vmHotunplugDisk, 'hotunplugDisk'),
(self.vmHotplugNic, 'hotplugNic'),
- (self.vmHotunplugNic, 'hotunplugNic'))
+ (self.vmHotunplugNic, 'hotunplugNic'),
+ (self.vmTuneMem, 'tuneMem'))
def getIrsMethods(self):
return ((self.domainActivate, 'activateStorageDomain'),
diff --git a/vdsm/define.py b/vdsm/define.py
index 049d36c..ba71bf6 100644
--- a/vdsm/define.py
+++ b/vdsm/define.py
@@ -117,6 +117,9 @@
'momErr': {'status':
{'code': 54,
'message': 'Failed to set mom policy'}},
+ 'tuneMemErr': {'status':
+ {'code': 56,
+ 'message': 'Failed to tune Mem'}},
'recovery': {'status':
{'code': 99,
'message':
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 4dc47e3..048fa7d 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1887,6 +1887,22 @@
(snapFlags & libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
== libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE)}
+ def tuneMem(self, tuneParams):
+ try:
+ self._dom.setMemoryParameters(tuneParams)
+ for param in tuneParams:
+ self.conf[param] = tuneParams[param]
+ self.saveState()
+ return {'status': doneCode}
+ except libvirt.libvirtError, e:
+ self.log.error("TuneMem failed:%s",
+ e.message, exc_info=True)
+ return errCode['tuneMemErr']
+ except LookupError:
+ self.log.error('TuneMem failed: unrecongnized params',
+ exc_info=True)
+ return errCode['tuneMemErr']
+
def _runMerge(self):
for mergeStatus in self.conf.get('liveMerge', []):
if mergeStatus['status'] != MERGESTATUS.NOT_STARTED:
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index c0440d2..509a90c 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -5099,6 +5099,34 @@
{'command': {'class': 'VM', 'name': 'mergeStatus'},
'returns': ['MergeStatus']}
+##
+# @TuneMemParams:
+#
+# Parameters for @VM.tuneMem.
+#
+# @hard_limit: Maximum memory the VM can consume
+#
+# @soft_limit: Memory limit during contention
+#
+# @min_gurantee: Min memory guranteed to the VM
+#
+# Since: 4.10.0
+##
+{'type': 'TuneMemParams',
+ 'data': {'hard_limit': 'uint', 'soft_limit': 'uint',
+ 'min_gurantee': 'uint'}}
+##
+# @VM.tuneMem:
+#
+# Tune memory hard limits and min allocation guranteed.
+#
+# @TuneMemParams: Tunning parameters for memory
+#
+# Since: 4.10.0
+##
+{'command': {'class': 'VM', 'name': 'tuneMem'},
+ 'data': {'tuneParams': 'TuneMemParams'}}
+
## Category: @Volume ###########################################################
##
# @Volume:
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index fe2f083..8787c28 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -204,6 +204,16 @@
return self.ExecAndExit(self.s.create(params))
+ def tuneMem(self, args):
+ params = {}
+ params['vmId'] = args[0]
+ if len(args) > 1:
+ for param in args[1:]:
+ if '=' in param:
+ key, value = line.split("=", 1)
+ params[key] = value
+ return self.ExecAndExit(self.s.tuneMem(params))
+
def hotplugNic(self, args):
nic = self._parseDriveSpec(args[1])
nic['type'] = 'interface'
@@ -1801,6 +1811,19 @@
'Optional additional parameters in dictionary format,'
' name:value,name:value'
)),
+ 'tuneMem': (serv.tuneMem,
+ ('<vmId>'
+ '[hard_limit=value soft_limit=value min_gurantee]',
+ 'Parameters list: r=required, o=optional',
+ 'r vmId: The vm to be tuned',
+ 'o hard_limit=<value>: '
+ 'maximum memory the VM can use(in KiB)',
+ 'o soft_limit=<value>:'
+ 'memory limit to enforce during memory contention',
+ 'o min_gurantee=<value>:'
+ 'min memory guranteed to the VM',
+ 'Tune memory hard limits and min allocation gurantee'
+ )),
'migrate': (serv.do_migrate,
('vmId=<id> method=<offline|online> src=<host:[port]> '
'dst=<host:[port]>',
--
To view, visit http://gerrit.ovirt.org/8031
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If2ad220e21b114985ead4bd64e81133173566444
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 4 months
Change in vdsm[master]: No need to call receive if send is timeout
by shuming@linux.vnet.ibm.com
Shu Ming has uploaded a new change for review.
Change subject: No need to call receive if send is timeout
......................................................................
No need to call receive if send is timeout
In callCrabRPCFunction(), the request packet is sent to the crab server first
and then wait for the response packet from the crab server. When the
request packet is not sent correctly, there is no need to wait for the response
packet back. So raising exception after the send operation is timeout.
Change-Id: Ib233b24d108a986d2f9e07a66f2a8f7d8cfb221a
Signed-off-by: Shu Ming <shuming(a)linux.vnet.ibm.com>
---
M vdsm/storage/remoteFileHandler.py
1 file changed, 8 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/7759/1
diff --git a/vdsm/storage/remoteFileHandler.py b/vdsm/storage/remoteFileHandler.py
index 622ea5d..6995c39 100644
--- a/vdsm/storage/remoteFileHandler.py
+++ b/vdsm/storage/remoteFileHandler.py
@@ -173,8 +173,13 @@
def callCrabRPCFunction(self, timeout, name, *args, **kwargs):
request = pickle.dumps((name, args, kwargs))
- self._sendAll(pack(LENGTH_STRUCT_FMT, len(request)), timeout)
- self._sendAll(request, timeout)
+ try:
+ self._sendAll(pack(LENGTH_STRUCT_FMT, len(request)), timeout)
+ self._sendAll(request, timeout)
+ except:
+ self.log.warn("Problem with handler send, treating as timeout",
+ exc_info=True)
+ raise Timeout()
try:
rawLength = self._recvAll(LENGTH_STRUCT_LENGTH, timeout)
@@ -184,7 +189,7 @@
except:
# If for some reason the connection drops\gets out of sync we treat
# it as a timeout so we only have one error path
- self.log.warn("Problem with handler, treating as timeout",
+ self.log.warn("Problem with handler receive, treating as timeout",
exc_info=True)
raise Timeout()
--
To view, visit http://gerrit.ovirt.org/7759
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib233b24d108a986d2f9e07a66f2a8f7d8cfb221a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shu Ming <shuming(a)linux.vnet.ibm.com>
10 years, 4 months
Change in vdsm[master]: move get-conf-item to vdsm-tool
by shaohef@linux.vnet.ibm.com
ShaoHe Feng has uploaded a new change for review.
Change subject: move get-conf-item to vdsm-tool
......................................................................
move get-conf-item to vdsm-tool
many items in init scripts and spec file.
move the complexity from out of the init scripts and spec file and
into vdsm-tool
Change-Id: I5c64de097bbaea6a8cf862b43243377e10e00391
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
M vdsm-tool/Makefile.am
A vdsm-tool/vdsm_conf_item.py.in
M vdsm.spec.in
M vdsm/vdsmd.init.in
4 files changed, 86 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/7695/1
diff --git a/vdsm-tool/Makefile.am b/vdsm-tool/Makefile.am
index 6ec0198..dcbf7e1 100644
--- a/vdsm-tool/Makefile.am
+++ b/vdsm-tool/Makefile.am
@@ -23,9 +23,11 @@
vdsm-tool
EXTRA_DIST = \
- validate_ovirt_certs.py.in
+ validate_ovirt_certs.py.in \
+ vdsm_conf_item.py.in
dist_vdsmtool_DATA = \
__init__.py \
passwd.py \
- validate_ovirt_certs.py
\ No newline at end of file
+ validate_ovirt_certs.py \
+ vdsm_conf_item.py
diff --git a/vdsm-tool/vdsm_conf_item.py.in b/vdsm-tool/vdsm_conf_item.py.in
new file mode 100644
index 0000000..ed268ff
--- /dev/null
+++ b/vdsm-tool/vdsm_conf_item.py.in
@@ -0,0 +1,72 @@
+# Copyright 2012 IBM, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+# Access python's config files from bash.
+# Usage: get-conf-itemname
+
+from vdsm.tool import expose
+try:
+ from vdsm.config import config
+ vdsmconf = config
+except:
+ import ConfigParser
+ vdsmconf = ConfigParser.ConfigParser()
+from functools import partial
+
+
+CONF_FILE = "@CONFDIR(a)/vdsm.conf"
+
+
+def _get_conf_item(file, section, item, default):
+ vdsmconf.read(file)
+ try:
+ return vdsmconf.get(section, item)
+ except:
+ return default
+
+
+def print_conf_item(file, section, item, default):
+ val = _get_conf_item(file, section, item, default)
+ if (val.lower() == "false" or val.lower() == "true"):
+ print val.lower()
+ else:
+ print val
+
+
+# there are so many item in vdsm.conf so list all the item
+# then iterate the list and expose every item in list
+# item in tuple: (file, section, value, default)
+get_item_list = (
+ (CONF_FILE, 'addresses', 'management_port', ''),
+ (CONF_FILE, 'addresses', 'management_ip', '0.0.0.0'),
+ (CONF_FILE, 'irs', 'repository', '/rhev/'),
+ (CONF_FILE, 'irs', 'vdsm_nice', '-5'),
+ (CONF_FILE, 'vars', 'core_dump_enable', 'false'),
+ (CONF_FILE, 'vars', 'ssl', 'true'),
+ (CONF_FILE, 'vars', 'libvirt_log_filters', '1:libvirt 1:remote'),
+ (CONF_FILE, 'vars', 'libvirt_log_outputs',
+ '1:file:/var/log/vdsm/libvirt.log'),
+ (CONF_FILE, 'vars', 'trust_store_path', '/etc/pki/vdsm'))
+
+for item in get_item_list:
+ f, s, v, d = item
+ alias = "get-conf-" + v
+ globals()[alias] = partial(print_conf_item, f, s, v, d)
+ globals()[alias].__doc__ = " get %s from vdsm configure file" % v
+ expose(alias)(globals()[alias])
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 0d1b195..e161a93 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -720,6 +720,7 @@
%{python_sitearch}/%{vdsm_name}/tool/__init__.py*
%{python_sitearch}/%{vdsm_name}/tool/passwd.py*
%{python_sitearch}/%{vdsm_name}/tool/validate_ovirt_certs.py*
+%{python_sitearch}/%{vdsm_name}/tool/vdsm_conf_item.py*
%files tests
%doc %{_datadir}/%{vdsm_name}/tests/README
diff --git a/vdsm/vdsmd.init.in b/vdsm/vdsmd.init.in
index 860e301..b33e1be 100755
--- a/vdsm/vdsmd.init.in
+++ b/vdsm/vdsmd.init.in
@@ -40,7 +40,7 @@
LDCONF=/etc/sysconfig/libvirtd
QLCONF=/etc/libvirt/qemu-sanlock.conf
-is_coredump=`$GETCONFITEM $CONF_FILE vars core_dump_enable false | tr A-Z a-z`
+is_coredump=`/usr/bin/vdsm-tool get-conf-core_dump_enable`
[ $is_coredump != true ] && is_coredump=false
SYSTEMCTL_SKIP_REDIRECT=true
@@ -52,12 +52,12 @@
check_port_taken() {
local MANAGEMENT_PORT MANAGEMENT_IP
- MANAGEMENT_PORT=`$GETCONFITEM $CONF_FILE addresses management_port ""`
+ MANAGEMENT_PORT=`/usr/bin/vdsm-tool get-conf-management_port`
if [ -z "$MANAGEMENT_PORT" ]; then
log_failure_msg "$prog: management_port not found in $CONF_FILE"
return 1
fi
- MANAGEMENT_IP=`$GETCONFITEM $CONF_FILE addresses management_ip 0.0.0.0`
+ MANAGEMENT_IP=`/usr/bin/vdsm-tool get-conf-management_ip`
netstat -ntl | grep -q "$MANAGEMENT_IP:$MANAGEMENT_PORT"
RETVAL=$?
if [ "$RETVAL" -eq 0 ]; then
@@ -69,7 +69,7 @@
mk_data_center() {
local dc
- dc=`$GETCONFITEM $CONF_FILE irs repository /rhev/`
+ dc=`/usr/bin/vdsm-tool get-conf-repository`
/bin/mkdir -p "$dc"
/bin/chown vdsm.kvm "$dc"
}
@@ -110,7 +110,7 @@
test_conflicting_conf() {
local listen_tcp auth_tcp ssl
- ssl=`$GETCONFITEM $CONF_FILE vars ssl true | tr A-Z a-z`
+ ssl=`/usr/bin/vdsm-tool get-conf-ssl`
[ "$ssl" == true ] && return 0
listen_tcp="`get_libvirt_conf_item $LCONF listen_tcp`"
@@ -276,7 +276,7 @@
fi
local lconf qconf ldconf
- local ssl=`$GETCONFITEM $CONF_FILE vars ssl true | tr A-Z a-z`
+ local ssl=`/usr/bin/vdsm-tool get-conf-ssl`
lconf="$2"
qconf="$3"
@@ -511,10 +511,10 @@
fi
echo $"Starting up vdsm daemon: "
- local vdsm_nice=`$GETCONFITEM $CONF_FILE vars vdsm_nice -5`
+ local vdsm_nice=`/usr/bin/vdsm-tool get-conf-vdsm_nice`
- LIBVIRT_LOG_FILTERS=`$GETCONFITEM $CONF_FILE vars libvirt_log_filters "1:libvirt 1:remote"` \
- LIBVIRT_LOG_OUTPUTS=`$GETCONFITEM $CONF_FILE vars libvirt_log_outputs "1:file:/var/log/vdsm/libvirt.log"` \
+ LIBVIRT_LOG_FILTERS=`/usr/bin/vdsm-tool get-conf-libvirt_log_filters` \
+ LIBVIRT_LOG_OUTPUTS=`/usr/bin/vdsm-tool get-conf-libvirt_log_outputs` \
LC_ALL=C NICELEVEL=$vdsm_nice daemon --user=vdsm @VDSMDIR@/respawn --minlifetime 10 --daemon --masterpid $RESPAWNPIDFILE $VDSM_BIN
RETVAL=$?
[ "$RETVAL" -eq 0 ] && log_success_msg $"$prog start" || log_failure_msg $"$prog start"
--
To view, visit http://gerrit.ovirt.org/7695
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c64de097bbaea6a8cf862b43243377e10e00391
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
10 years, 4 months