Change in vdsm[master]: Move fenceNode out of API.py
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: Move fenceNode out of API.py
......................................................................
Move fenceNode out of API.py
The actual details of how the response is mangles is part of the
bindings so API.py really doesn't serve a purpose.
This is the first step in a general trend of moving the logic out of
API.py to dedicated modules and move the response mangling to the
binding wrappers.
Change-Id: Idaba551333a0f289abaff11dc113e09c426d591a
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
2 files changed, 25 insertions(+), 38 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/7191/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 5826d81..4fdc7e7 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -37,7 +37,6 @@
from vdsm.define import doneCode, errCode, Kbytes, Mbytes
import caps
from vdsm.config import config
-import fenceAgent
import supervdsm
@@ -972,40 +971,6 @@
APIBase.__init__(self)
# General Host functions
- def fenceNode(self, addr, port, agent, username, password, action,
- secure=False, options=''):
- """Send a fencing command to a remote node.
-
- agent is one of (rsa, ilo, drac5, ipmilan, etc)
- action can be one of (status, on, off, reboot)."""
-
- self.log.debug('fenceNode(addr=%s,port=%s,agent=%s,user=%s,' +
- 'passwd=%s,action=%s,secure=%s,options=%s)', addr, port, agent,
- username, 'XXXX', action, secure, options)
-
- secure = utils.tobool(secure)
- port = int(port)
-
- if action == "status":
- try:
- power = fenceAgent.getFenceStatus(addr, port, agent, username,
- password, secure, options)
-
- return {'status': doneCode,
- 'power': power}
-
- except fenceAgent.FenceStatusCheckError as e:
- return {'status': {'code': 1, 'message': str(e)}}
-
- try:
- fenceAgent.fenceNode(addr, port, agent, username, password, secure,
- options, self._cif.shutdownEvent)
-
- return {'status': doneCode}
-
- except fenceAgent.UnsupportedFencingAgentError:
- return errCode['fenceAgent']
-
def ping(self):
"Ping the server. Useful for tests"
return {'status': doneCode}
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 48f4723..7eee29e 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -32,6 +32,8 @@
from vdsm.define import doneCode, errCode
import API
from vdsm.exception import VdsmException
+import fenceAgent
+
try:
from gluster.api import getGlusterMethods
_glusterEnabled = True
@@ -355,9 +357,29 @@
def fenceNode(self, addr, port, agent, username, password, action,
secure=False, options=''):
- api = API.Global()
- return api.fenceNode(addr, port, agent, username, password,
- action, secure, options)
+
+ secure = utils.tobool(secure)
+ port = int(port)
+
+ if action == "status":
+ try:
+ power = fenceAgent.getFenceStatus(addr, port, agent, username,
+ password, secure, options)
+
+ return {'status': doneCode,
+ 'power': power}
+
+ except fenceAgent.FenceStatusCheckError as e:
+ return {'status': {'code': 1, 'message': str(e)}}
+
+ try:
+ fenceAgent.fenceNode(addr, port, agent, username, password, secure,
+ options, self.cif.shutdownEvent)
+
+ return {'status': doneCode}
+
+ except fenceAgent.UnsupportedFencingAgentError:
+ return errCode['fenceAgent']
def setLogLevel(self, level):
api = API.Global()
--
To view, visit http://gerrit.ovirt.org/7191
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idaba551333a0f289abaff11dc113e09c426d591a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: vdsm: storage/task.py replace/remove too generic except hand...
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: vdsm: storage/task.py replace/remove too generic except handlers
......................................................................
vdsm: storage/task.py replace/remove too generic except handlers
Change-Id: Ia09dcada40bca3f16f94ad7a6c83e6d7a85ade77
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M vdsm/storage/task.py
1 file changed, 2 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/17751/1
diff --git a/vdsm/storage/task.py b/vdsm/storage/task.py
index 4eff5c1..5b8613f 100644
--- a/vdsm/storage/task.py
+++ b/vdsm/storage/task.py
@@ -173,7 +173,7 @@
self.state = self.unknown
else:
self.state = getattr(self, state)
- except:
+ except AttributeError:
self.state = self.unknown
def value(self):
@@ -751,7 +751,7 @@
self.log.error("Unexpected error", exc_info=True)
try:
getProcPool().fileUtils.cleanupdir(taskDir)
- except:
+ except Exception:
self.log.warning("can't remove temp taskdir %s" % taskDir)
raise se.TaskPersistError("%s persist failed: %s" % (self, e))
# Make sure backup dir doesn't exist
@@ -862,8 +862,6 @@
except Exception as e:
message = unicode(e)
self._setError(e)
- except:
- self._setError()
self.log.debug("Task._run: %s %s %s failed - stopping task",
self, args, kargs)
--
To view, visit http://gerrit.ovirt.org/17751
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia09dcada40bca3f16f94ad7a6c83e6d7a85ade77
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: gluster: Replace bricks verbs removed
by avishwan@redhat.com
Aravinda VK has uploaded a new change for review.
Change subject: gluster: Replace bricks verbs removed
......................................................................
gluster: Replace bricks verbs removed
glusterfs phased out replace-brick feature.
http://lists.nongnu.org/archive/html/gluster-devel/2013-09/msg00155.html
Existing replace-bricks verbs are not yet consumed by ovirt-engine, so removing
all the verbs.
Removed verbs:
glusterVolumeReplaceBrickStart
glusterVolumeReplaceBrickAbort
glusterVolumeReplaceBrickPause
glusterVolumeReplaceBrickStatus
glusterVolumeReplaceBrickCommit
glusterVolumeRemoveBrickStart
Change-Id: I23cd224ced9c6892ab182f663476df428f2f35da
Signed-off-by: Aravinda VK <avishwan(a)redhat.com>
---
M vdsm/gluster/api.py
M vdsm/gluster/cli.py
M vdsm/gluster/exception.py
M vdsm/gluster/tasks.py
4 files changed, 1 insertion(+), 163 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/60/20060/1
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index ebb0901..43e60cf 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -129,43 +129,6 @@
return self.svdsmProxy.glusterVolumeRebalanceStatus(volumeName)
@exportAsVerb
- def volumeReplaceBrickStart(self, volumeName, existingBrick, newBrick,
- options=None):
- return self.svdsmProxy.glusterVolumeReplaceBrickStart(volumeName,
- existingBrick,
- newBrick)
-
- @exportAsVerb
- def volumeReplaceBrickAbort(self, volumeName, existingBrick, newBrick,
- options=None):
- self.svdsmProxy.glusterVolumeReplaceBrickAbort(volumeName,
- existingBrick,
- newBrick)
-
- @exportAsVerb
- def volumeReplaceBrickPause(self, volumeName, existingBrick, newBrick,
- options=None):
- self.svdsmProxy.glusterVolumeReplaceBrickPause(volumeName,
- existingBrick,
- newBrick)
-
- @exportAsVerb
- def volumeReplaceBrickStatus(self, volumeName, oldBrick, newBrick,
- options=None):
- st, msg = self.svdsmProxy.glusterVolumeReplaceBrickStatus(volumeName,
- oldBrick,
- newBrick)
- return {'replaceBrick': st, 'message': msg}
-
- @exportAsVerb
- def volumeReplaceBrickCommit(self, volumeName, existingBrick, newBrick,
- force=False, options=None):
- self.svdsmProxy.glusterVolumeReplaceBrickCommit(volumeName,
- existingBrick,
- newBrick,
- force)
-
- @exportAsVerb
def volumeRemoveBrickStart(self, volumeName, brickList,
replicaCount=0, options=None):
return self.svdsmProxy.glusterVolumeRemoveBrickStart(volumeName,
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index a67658f..3ed3bd4 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -75,7 +75,6 @@
class TaskType:
REBALANCE = 'REBALANCE'
- REPLACE_BRICK = 'REPLACE_BRICK'
REMOVE_BRICK = 'REMOVE_BRICK'
@@ -651,83 +650,6 @@
@makePublic
-def volumeReplaceBrickStart(volumeName, existingBrick, newBrick):
- command = _getGlusterVolCmd() + ["replace-brick", volumeName,
- existingBrick, newBrick, "start"]
- try:
- xmltree = _execGlusterXml(command)
- except ge.GlusterCmdFailedException, e:
- raise ge.GlusterVolumeReplaceBrickStartFailedException(rc=e.rc,
- err=e.err)
- try:
- return {'taskId': xmltree.find('volReplaceBrick/task-id').text}
- except _etreeExceptions:
- raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
-
-
-@makePublic
-def volumeReplaceBrickAbort(volumeName, existingBrick, newBrick):
- command = _getGlusterVolCmd() + ["replace-brick", volumeName,
- existingBrick, newBrick, "abort"]
- try:
- _execGlusterXml(command)
- return True
- except ge.GlusterCmdFailedException, e:
- raise ge.GlusterVolumeReplaceBrickAbortFailedException(rc=e.rc,
- err=e.err)
-
-
-@makePublic
-def volumeReplaceBrickPause(volumeName, existingBrick, newBrick):
- command = _getGlusterVolCmd() + ["replace-brick", volumeName,
- existingBrick, newBrick, "pause"]
- try:
- _execGlusterXml(command)
- return True
- except ge.GlusterCmdFailedException, e:
- raise ge.GlusterVolumeReplaceBrickPauseFailedException(rc=e.rc,
- err=e.err)
-
-
-@makePublic
-def volumeReplaceBrickStatus(volumeName, existingBrick, newBrick):
- rc, out, err = _execGluster(_getGlusterVolCmd() + ["replace-brick",
- volumeName,
- existingBrick, newBrick,
- "status"])
- if rc:
- raise ge.GlusterVolumeReplaceBrickStatusFailedException(rc, out,
- err)
- message = "\n".join(out)
- statLine = out[0].strip().upper()
- if BrickStatus.PAUSED in statLine:
- return BrickStatus.PAUSED, message
- elif statLine.endswith('MIGRATION COMPLETE'):
- return BrickStatus.COMPLETED, message
- elif statLine.startswith('NUMBER OF FILES MIGRATED'):
- return BrickStatus.RUNNING, message
- elif statLine.endswith("UNKNOWN"):
- return BrickStatus.UNKNOWN, message
- else:
- return BrickStatus.NA, message
-
-
-@makePublic
-def volumeReplaceBrickCommit(volumeName, existingBrick, newBrick,
- force=False):
- command = _getGlusterVolCmd() + ["replace-brick", volumeName,
- existingBrick, newBrick, "commit"]
- if force:
- command.append('force')
- try:
- _execGlusterXml(command)
- return True
- except ge.GlusterCmdFailedException, e:
- raise ge.GlusterVolumeReplaceBrickCommitFailedException(rc=e.rc,
- err=e.err)
-
-
-@makePublic
def volumeRemoveBrickStart(volumeName, brickList, replicaCount=0):
command = _getGlusterVolCmd() + ["remove-brick", volumeName]
if replicaCount:
@@ -969,10 +891,7 @@
taskType = taskType.upper().replace('-', '_').replace(' ', '_')
taskId = c.find('id').text
bricks = []
- if taskType == TaskType.REPLACE_BRICK:
- bricks.append(c.find('params/srcBrick').text)
- bricks.append(c.find('params/dstBrick').text)
- elif taskType == TaskType.REMOVE_BRICK:
+ if taskType == TaskType.REMOVE_BRICK:
for b in c.findall('params/brick'):
bricks.append(b.text)
elif taskType == TaskType.REBALANCE:
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index 20c157e..4e9d08a 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -251,46 +251,6 @@
message = "Volume delete failed"
-class GlusterVolumeReplaceBrickAlreadyStartedException(GlusterVolumeException):
- code = 4141
- message = "Volume replace brick failed"
-
-
-class GlusterVolumeReplaceBrickStartFailedException(GlusterVolumeException):
- code = 4142
- message = "Volume replace brick start failed"
-
-
-class GlusterVolumeReplaceBrickNotStartedException(GlusterVolumeException):
- code = 4143
- message = "Volume replace brick not started"
-
-
-class GlusterVolumeReplaceBrickAbortFailedException(GlusterVolumeException):
- code = 4144
- message = "Volume replace brick abort failed"
-
-
-class GlusterVolumeReplaceBrickPauseFailedException(GlusterVolumeException):
- code = 4145
- message = "Volume replace brick pause failed"
-
-
-class GlusterVolumeReplaceBrickStatusFailedException(GlusterVolumeException):
- code = 4146
- message = "Volume replace brick status failed"
-
-
-class GlusterVolumeReplaceBrickInProgressException(GlusterVolumeException):
- code = 4147
- message = "Volume replace brick in progress"
-
-
-class GlusterVolumeReplaceBrickCommitFailedException(GlusterVolumeException):
- code = 4148
- message = "Volume replace brick commit failed"
-
-
class GlusterVolumesListFailedException(GlusterVolumeException):
code = 4149
message = "Volume list failed"
diff --git a/vdsm/gluster/tasks.py b/vdsm/gluster/tasks.py
index 8defd9b..f76d4a8 100644
--- a/vdsm/gluster/tasks.py
+++ b/vdsm/gluster/tasks.py
@@ -38,10 +38,6 @@
elif taskType == TaskType.REMOVE_BRICK:
data = cli.volumeRemoveBrickStatus(volumeName,
value['bricks'])
- elif taskType == TaskType.REPLACE_BRICK:
- data = cli.volumeReplaceBrickStatus(volumeName,
- value['bricks'][0],
- value['bricks'][1])
summary = data['summary'] if 'summary' in data else {}
return {"volume": volumeName,
--
To view, visit http://gerrit.ovirt.org/20060
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I23cd224ced9c6892ab182f663476df428f2f35da
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Aravinda VK <avishwan(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: More safe startSpm().
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: More safe startSpm().
......................................................................
More safe startSpm().
Change-Id: I1e6b32bdf1dd8dc36f6633306d4edef89d542e31
---
M vdsm/storage/sp.py
1 file changed, 16 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/451/1
--
To view, visit http://gerrit.ovirt.org/451
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e6b32bdf1dd8dc36f6633306d4edef89d542e31
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: [WIP] Add a releaseHostId option to stop the DomainMonitorTh...
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: [WIP] Add a releaseHostId option to stop the DomainMonitorThread
......................................................................
[WIP] Add a releaseHostId option to stop the DomainMonitorThread
Bug-Id: https://bugzilla.redhat.com/show_bug.cgi?id=851151
Change-Id: I83458fb4146de7e402606916615533da305bd867
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/domainMonitor.py
M vdsm/storage/sp.py
2 files changed, 19 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/7581/1
diff --git a/vdsm/storage/domainMonitor.py b/vdsm/storage/domainMonitor.py
index 95e2f7b..c1ec5a9 100644
--- a/vdsm/storage/domainMonitor.py
+++ b/vdsm/storage/domainMonitor.py
@@ -84,14 +84,14 @@
# The domain should be added only after it succesfully started
self._domains[sdUUID] = domainThread
- def stopMonitoring(self, sdUUID):
+ def stopMonitoring(self, sdUUID, releaseHostId=False):
# The domain monitor issues events that might become raceful if
# stopMonitoring doesn't stop until the thread exits.
# Eg: when a domain is detached the domain monitor is stopped and
# the host id is released. If the monitor didn't actually exit it
# might respawn a new acquire host id.
try:
- self._domains[sdUUID].stop()
+ self._domains[sdUUID].stop(releaseHostId=releaseHostId)
except KeyError:
return
@@ -100,13 +100,15 @@
def getStatus(self, sdUUID):
return self._domains[sdUUID].getStatus()
- def close(self):
+ def close(self, releaseHostId=False):
for sdUUID in self._domains.keys():
- self.stopMonitoring(sdUUID)
+ self.stopMonitoring(sdUUID, releaseHostId=releaseHostId)
class DomainMonitorThread(object):
log = logging.getLogger('Storage.DomainMonitorThread')
+
+ RELEASE_HOSTID_DEFAULT = False
def __init__(self, sdUUID, hostId, interval):
self.thread = Thread(target=self._monitorLoop)
@@ -121,16 +123,20 @@
self.nextStatus = DomainMonitorStatus()
self.isIsoDomain = None
self.lastRefresh = time()
+ self.releaseHostId = self.RELEASE_HOSTID_DEFAULT
self.refreshTime = \
config.getint("irs", "repo_stats_cache_refresh_timeout")
def start(self):
self.thread.start()
- def stop(self, wait=True):
+ def stop(self, wait=True, releaseHostId):
+ self.releaseHostId = releaseHostId
+
self.stopEvent.set()
if wait:
self.thread.join()
+
self.domain = None
def getStatus(self):
@@ -151,13 +157,17 @@
# If this is an ISO domain we didn't acquire the host id and releasing
# it is superfluous.
- if not self.isIsoDomain:
+ if not self.isIsoDomain and self.releaseHostId:
try:
self.domain.releaseHostId(self.hostId, unused=True)
except:
self.log.debug("Unable to release the host id %s for domain "
"%s", self.hostId, self.sdUUID, exc_info=True)
+ # Resetting the releaseHostId value to its default just to be sure in
+ # case in the future we want to recycle the DomainMonitor objects.
+ self.releaseHostId = self.RELEASE_HOSTID_DEFAULT
+
def _monitorDomain(self):
self.nextStatus.clear()
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 40de20a..e8c59f3 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -647,8 +647,8 @@
@unsecured
- def stopMonitoringDomains(self):
- self.domainMonitor.close()
+ def stopMonitoringDomains(self, releaseHostId=False):
+ self.domainMonitor.close(releaseHostId=releaseHostId)
return True
@@ -675,7 +675,7 @@
if os.path.exists(self.poolPath):
fileUtils.cleanupdir(self.poolPath)
- self.stopMonitoringDomains()
+ self.stopMonitoringDomains(releaseHostId=True)
return True
--
To view, visit http://gerrit.ovirt.org/7581
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I83458fb4146de7e402606916615533da305bd867
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: vmDevices: replace self.conf['devices'] by VmDeviceContainer
by mpoledni@redhat.com
Martin Polednik has uploaded a new change for review.
Change subject: vmDevices: replace self.conf['devices'] by VmDeviceContainer
......................................................................
vmDevices: replace self.conf['devices'] by VmDeviceContainer
This patch servers as an implementation of VmDeviceContainer, removing
access to self.conf['devices'] and keeping migration-friendly restore
file by pickling structure similar to self.conf['devices']
Change-Id: I3bdb5c331657c1c0d1ae902eabb5d3315d45bf8b
Signed-off-by: Martin Polednik <mpoledni(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 42 insertions(+), 127 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/21162/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index d4ce708..f2e22cf 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -2919,14 +2919,7 @@
if not 'recover' in self.conf:
self.preparePaths(devices[DISK_DEVICES])
self._prepareTransientDisks(devices[DISK_DEVICES])
- # Update self.conf with updated devices
- # For old type vmParams, new 'devices' key will be
- # created with all devices info
- newDevices = []
- for dev in devices.values():
- newDevices.extend(dev)
- self.conf['devices'] = newDevices
# We need to save conf here before we actually run VM.
# It's not enough to save conf only on status changes as we did
# before, because if vdsm will restarted between VM run and conf
@@ -2939,6 +2932,7 @@
for dev in devices[devType]:
self._devices[devType].append(devClass(self.conf, self.log,
**dev))
+ self.conf['devices'] = self._devices.legacy
# We should set this event as a last part of drives initialization
self._pathsPreparedEvent.set()
@@ -3072,9 +3066,8 @@
# we sent command to libvirt and before save conf. In this case
# we will gather almost all needed info about this NIC from
# the libvirt during recovery process.
- self._devices[NIC_DEVICES].append(nic)
with self._confLock:
- self.conf['devices'].append(nicParams)
+ self._devices[NIC_DEVICES].append(nic)
self.saveState()
self._getUnderlyingNetworkInterfaceInfo()
hooks.after_nic_hotplug(nicXml, self.conf,
@@ -3109,9 +3102,8 @@
'not found' % alias)
def _lookupConfByAlias(self, alias):
- for devConf in self.conf['devices'][:]:
- if devConf['type'] == NIC_DEVICES and \
- devConf['alias'] == alias:
+ for devConf in self._devices[NIC_DEVICES]:
+ if devConf['alias'] == alias:
return devConf
raise LookupError('Configuration of device identified by alias %s not'
'found' % alias)
@@ -3256,15 +3248,6 @@
# Remove found NIC from vm's NICs list
if nic:
self._devices[NIC_DEVICES].remove(nic)
- # Find and remove NIC device from vm's conf
- nicDev = None
- for dev in self.conf['devices'][:]:
- if (dev['type'] == NIC_DEVICES and
- dev['macAddr'].lower() == nicParams['macAddr'].lower()):
- with self._confLock:
- self.conf['devices'].remove(dev)
- nicDev = dev
- break
self.saveState()
@@ -3274,10 +3257,7 @@
self.log.error("Hotunplug failed", exc_info=True)
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return errCode['noVM']
- # Restore NIC device in vm's conf and _devices
- if nicDev:
- with self._confLock:
- self.conf['devices'].append(nicDev)
+ # Restore NIC device in vm's deviceContainer
if nic:
self._devices[NIC_DEVICES].append(nic)
self.saveState()
@@ -3365,11 +3345,10 @@
# we sent command to libvirt and before save conf. In this case
# we will gather almost all needed info about this drive from
# the libvirt during recovery process.
- self._devices[DISK_DEVICES].append(drive)
if vdsmImg:
self.sdIds.append(diskParams['domainID'])
with self._confLock:
- self.conf['devices'].append(diskParams)
+ self._devices[DISK_DEVICES].append(drive)
self.saveState()
self._getUnderlyingDriveInfo()
hooks.after_disk_hotplug(driveXml, self.conf,
@@ -3404,16 +3383,6 @@
if drive.isVdsmImage():
self.sdIds.remove(drive.domainID)
self._devices[DISK_DEVICES].remove(drive)
- # Find and remove disk device from vm's conf
- diskDev = None
- for dev in self.conf['devices'][:]:
- if (dev['type'] == DISK_DEVICES and
- dev['path'] == drive.path):
- with self._confLock:
- self.conf['devices'].remove(dev)
- diskDev = dev
- break
-
self.saveState()
hooks.before_disk_hotunplug(driveXml, self.conf,
@@ -3425,10 +3394,6 @@
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return errCode['noVM']
self._devices[DISK_DEVICES].append(drive)
- # Restore disk device in vm's conf and _devices
- if diskDev:
- with self._confLock:
- self.conf['devices'].append(diskDev)
self.saveState()
return {
'status': {'code': errCode['hotunplugDisk']['status']['code'],
@@ -4407,12 +4372,11 @@
return {'status': doneCode}
def _getBalloonInfo(self):
- for dev in self.conf['devices']:
- if dev['type'] == BALLOON_DEVICES and \
- dev['specParams']['model'] != 'none':
+ for dev in self._devices[BALLOON_DEVICES]:
+ if dev.specParams['model'] != 'none':
max_mem = int(self.conf.get('memSize')) * 1024
min_mem = int(self.conf.get('memGuaranteedSize', '0')) * 1024
- target_mem = dev.get('target', max_mem)
+ target_mem = getattr(dev, 'target', max_mem)
cur_mem = self._dom.info()[2]
return {'balloon_max': str(max_mem),
'balloon_cur': str(cur_mem),
@@ -4443,10 +4407,9 @@
return reportError(key='noVM')
return reportError(msg=e.message)
else:
- for dev in self.conf['devices']:
- if dev['type'] == BALLOON_DEVICES and \
- dev['specParams']['model'] != 'none':
- dev['target'] = target
+ for dev in self._devices[BALLOON_DEVICES]:
+ if dev.specParams['model'] != 'none':
+ dev.target = target
# persist the target value to make it consistent after recovery
self.saveState()
return {'status': doneCode}
@@ -4475,9 +4438,12 @@
passed during VM creation request.
"""
def isKnownDevice(alias):
- for dev in self.conf['devices']:
- if dev.get('alias') == alias:
- return True
+ for devClass in self._devices:
+ for dev in devClass:
+ if (hasattr(dev, 'alias') and
+ getattr(dev, 'alias') == alias):
+
+ return True
return False
devsxml = _domParseStr(self._lastXMLDesc).childNodes[0]. \
@@ -4499,7 +4465,16 @@
'alias': alias,
'device': device,
'address': address}
- self.conf['devices'].append(newDev)
+
+ # lets find out which device we are dealing with
+ for devType, devClass in self.DeviceMapping:
+ if device == devType:
+ self._devices[devType].append(
+ devClass(self.conf, self.log, **newDev))
+ break
+
+ # TODO: here comes the problem: the can device not have the
+ # type at this point?
def _getUnderlyingControllerDeviceInfo(self):
"""
@@ -4521,6 +4496,7 @@
# Get controller address
address = self._getUnderlyingDeviceAddress(x)
+ knownDev = False
# In case the controller has index and/or model, they
# are compared. Currently relevant for USB controllers.
for ctrl in self._devices[CONTROLLER_DEVICES]:
@@ -4529,24 +4505,14 @@
(not hasattr(ctrl, 'model') or ctrl.model == model)):
ctrl.alias = alias
ctrl.address = address
- # Update vm's conf with address for known controller devices
- # In case the controller has index and/or model, they
- # are compared. Currently relevant for USB controllers.
- knownDev = False
- for dev in self.conf['devices']:
- if ((dev['type'] == CONTROLLER_DEVICES) and
- (dev['device'] == device) and
- (not 'index' in dev or dev['index'] == index) and
- (not 'model' in dev or dev['model'] == model)):
- dev['address'] = address
- dev['alias'] = alias
knownDev = True
+
# Add unknown controller device to vm's conf
if not knownDev:
- self.conf['devices'].append({'type': CONTROLLER_DEVICES,
- 'device': device,
- 'address': address,
- 'alias': alias})
+ self._devices[CONTROLLER_DEVICES].append(
+ ControllerDevice(self.conf, self.log,
+ type=CONTROLLER_DEVICES, device=device,
+ address=address, alias=alias))
def _getUnderlyingBalloonDeviceInfo(self):
"""
@@ -4569,13 +4535,6 @@
if not hasattr(dev, 'alias'):
dev.alias = alias
- for dev in self.conf['devices']:
- if dev['type'] == BALLOON_DEVICES:
- if address and not dev.get('address'):
- dev['address'] = address
- if not dev.get('alias'):
- dev['alias'] = alias
-
def _getUnderlyingConsoleDeviceInfo(self):
"""
Obtain the alias for the console device from libvirt
@@ -4586,14 +4545,10 @@
for x in consolexml:
# All we care about is the alias
alias = x.getElementsByTagName('alias')[0].getAttribute('name')
+
for dev in self._devices[CONSOLE_DEVICES]:
if not hasattr(dev, 'alias'):
dev.alias = alias
-
- for dev in self.conf['devices']:
- if dev['device'] == CONSOLE_DEVICES and \
- not dev.get('alias'):
- dev['alias'] = alias
def _getUnderlyingSmartcardDeviceInfo(self):
"""
@@ -4614,12 +4569,6 @@
dev.address = address
dev.alias = alias
- for dev in self.conf['devices']:
- if dev['device'] == SMARTCARD_DEVICES and \
- not dev.get('address'):
- dev['address'] = address
- dev['alias'] = alias
-
def _getUnderlyingWatchdogDeviceInfo(self):
"""
Obtain watchdog device info from libvirt.
@@ -4638,12 +4587,6 @@
if not hasattr(wd, 'address') or not hasattr(wd, 'alias'):
wd.address = address
wd.alias = alias
-
- for dev in self.conf['devices']:
- if ((dev['type'] == WATCHDOG_DEVICES) and
- (not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
def _getUnderlyingVideoDeviceInfo(self):
"""
@@ -4665,13 +4608,6 @@
vc.alias = alias
vc.address = address
break
- # Update vm's conf with address
- for dev in self.conf['devices']:
- if ((dev['type'] == VIDEO_DEVICES) and
- (not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
- break
def _getUnderlyingSoundDeviceInfo(self):
"""
@@ -4692,13 +4628,6 @@
if not hasattr(sc, 'address') or not hasattr(sc, 'alias'):
sc.alias = alias
sc.address = address
- break
- # Update vm's conf with address
- for dev in self.conf['devices']:
- if ((dev['type'] == SOUND_DEVICES) and
- (not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
break
def _getUnderlyingDriveInfo(self):
@@ -4735,6 +4664,7 @@
# Get disk address
address = self._getUnderlyingDeviceAddress(x)
+ knownDev = False
for d in self._devices[DISK_DEVICES]:
if d.path == devPath:
d.name = name
@@ -4745,17 +4675,8 @@
d.readonly = readonly
if bootOrder:
d.bootOrder = bootOrder
- # Update vm's conf with address for known disk devices
- knownDev = False
- for dev in self.conf['devices']:
- if dev['type'] == DISK_DEVICES and dev['path'] == devPath:
- dev['name'] = name
- dev['address'] = address
- dev['alias'] = alias
- dev['readonly'] = str(readonly)
- if bootOrder:
- dev['bootOrder'] = bootOrder
knownDev = True
+
# Add unknown disk device to vm's conf
if not knownDev:
iface = 'ide' if address['type'] == 'drive' else 'pci'
@@ -4765,7 +4686,8 @@
'readonly': str(readonly)}
if bootOrder:
diskDev['bootOrder'] = bootOrder
- self.conf['devices'].append(diskDev)
+ self._devices[DISK_DEVICES].append(
+ Drive(self.conf, self.log, **diskDev))
def _getUnderlyingDisplayPort(self):
"""
@@ -4815,6 +4737,7 @@
network = source[0].getAttribute('network')
network = network[len(netinfo.LIBVIRT_NET_PREFIX):]
+ knownDev = False
# Get nic address
address = self._getUnderlyingDeviceAddress(x)
for nic in self._devices[NIC_DEVICES]:
@@ -4823,15 +4746,6 @@
nic.alias = alias
nic.address = address
nic.linkActive = linkActive
- # Update vm's conf with address for known nic devices
- knownDev = False
- for dev in self.conf['devices']:
- if (dev['type'] == NIC_DEVICES and
- dev['macAddr'].lower() == mac.lower()):
- dev['address'] = address
- dev['alias'] = alias
- dev['name'] = name
- dev['linkActive'] = linkActive
knownDev = True
# Add unknown nic device to vm's conf
if not knownDev:
@@ -4845,7 +4759,8 @@
'linkActive': linkActive}
if network:
nicDev['network'] = network
- self.conf['devices'].append(nicDev)
+ self._devices[DISK_DEVICES].append(
+ NetworkInterfaceDevice(self.conf, self.log, **nicDev))
def _setWriteWatermarks(self):
"""
--
To view, visit http://gerrit.ovirt.org/21162
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3bdb5c331657c1c0d1ae902eabb5d3315d45bf8b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: multipath: Remove unused 'deduceType'
by ykaplan@redhat.com
Yeela Kaplan has uploaded a new change for review.
Change subject: multipath: Remove unused 'deduceType'
......................................................................
multipath: Remove unused 'deduceType'
Change-Id: I37a94c3d67641f1c78d8fbecd63cbf1480c6e1b0
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M vdsm/storage/multipath.py
1 file changed, 0 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/13363/1
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 94801ca..5fdaa27 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -184,13 +184,6 @@
raise se.MultipathRestartError()
-def deduceType(a, b):
- if a == b:
- return a
- else:
- return DEV_MIXED
-
-
def getDeviceBlockSizes(dev):
devName = os.path.basename(dev)
logical = int(file(os.path.join("/sys/block/", devName,
--
To view, visit http://gerrit.ovirt.org/13363
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I37a94c3d67641f1c78d8fbecd63cbf1480c6e1b0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: Adding monitorDomains.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Adding monitorDomains.
......................................................................
Adding monitorDomains.
Making repoStats pool independent.
Change-Id: I9f148764ac030730c93bfd9c8da25a7ea434dc33
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 19 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/14674/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index d3e1beb..3fb0c30 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -40,6 +40,7 @@
from vdsm.config import config
import sp
+import domainMonitor
import sd
import blockSD
import nfsSD
@@ -93,6 +94,7 @@
QEMU_READABLE_TIMEOUT = 30
+HSM_DOM_MON_LOCK = "HsmDomainMonitorLock"
def public(f=None, **kwargs):
if f is None:
@@ -395,6 +397,9 @@
name="storageRefresh")
storageRefreshThread.daemon = True
storageRefreshThread.start()
+
+ monitorInterval = config.getint('irs', 'sd_health_check_delay')
+ self.domainMonitor = domainMonitor.DomainMonitor(monitorInterval)
def _hsmSchedule(self, name, func, *args):
self.taskMng.scheduleJob("hsm", self.tasksDir, vars.task,
@@ -934,7 +939,10 @@
"spUUID=%s, msdUUID=%s, masterVersion=%s, hostID=%s, "
"scsiKey=%s" % (spUUID, msdUUID, masterVersion,
hostID, scsiKey)))
- return self._connectStoragePool(spUUID, hostID, scsiKey, msdUUID,
+ with rmanager.acquireResource(STORAGE, HSM_DOM_MON_LOCK,
+ rm.LockType.exclusive):
+ self.domainMonitor.close()
+ return self._connectStoragePool(spUUID, hostID, scsiKey, msdUUID,
masterVersion, options)
def _connectStoragePool(self, spUUID, hostID, scsiKey, msdUUID,
@@ -3578,3 +3586,13 @@
result[d] = repo_stats[d]['result']
return result
+
+ @public
+ def monitorDomains(self, sdUUIDs, hostID, options=None):
+ with rmanager.acquireResource(STORAGE, HSM_DOM_MON_LOCK,
+ rm.LockType.exclusive):
+ if self.pools:
+ raise se.StoragePoolConnected()
+ self.domainMonitor.close()
+ for sdUUID in sdUUIDs:
+ self.domainMonitor.startMonitoring(sdUUID, hostId)
--
To view, visit http://gerrit.ovirt.org/14674
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f148764ac030730c93bfd9c8da25a7ea434dc33
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: mount: Reassign mount specification in case of backup option
by ykaplan@redhat.com
Yeela Kaplan has uploaded a new change for review.
Change subject: mount: Reassign mount specification in case of backup option
......................................................................
mount: Reassign mount specification in case of backup option
When using glusterfs volumes the backup option
'backupvolfile-server' allows mount to an alternative volume
when mount source not available.
Change-Id: I3166c6863dffa297bc0adcdeb4c22f810d18de8e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=922744
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M vdsm/storage/mount.py
M vdsm/storage/storageServer.py
2 files changed, 44 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/34/16534/1
diff --git a/vdsm/storage/mount.py b/vdsm/storage/mount.py
index 90cacc7..8cade18 100644
--- a/vdsm/storage/mount.py
+++ b/vdsm/storage/mount.py
@@ -187,6 +187,15 @@
raise OSError(errno.ENOENT, 'device %s not mounted' % device)
+def _getRecord(spec, file):
+ for record in _iterMountRecords():
+ if (record.fs_spec == spec and record.fs_file == file):
+ return record
+
+ raise OSError(errno.ENOENT,
+ "Mount of `%s` at `%s` does not exist" % (spec, file))
+
+
class Mount(object):
def __init__(self, fs_spec, fs_file):
self.fs_spec = normpath(fs_spec)
@@ -261,14 +270,7 @@
return True
def getRecord(self):
- for record in _iterMountRecords():
- if (record.fs_spec == self.fs_spec and
- record.fs_file == self.fs_file):
- return record
-
- raise OSError(errno.ENOENT,
- "Mount of `%s` at `%s` does not exist" %
- (self.fs_spec, self.fs_file))
+ return _getRecord(self.fs_spec, self.fs_file)
def __repr__(self):
return ("<Mount fs_spec='%s' fs_file='%s'>" %
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index 023f607..515ebd9 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -197,14 +197,14 @@
self._remotePath.replace("_",
"__").replace("/", "_"))
- def connect(self):
+ def createConnection(self):
if self._mount.isMounted():
return
fileUtils.createdir(self._getLocalPath())
try:
- self._mount.mount(self.options, self._vfsType)
+ self._mount.mount(self.options, self.vfsType)
except MountError as e:
self.log.error("Mount failed: %s", e, exc_info=True)
try:
@@ -214,17 +214,21 @@
self._getLocalPath(), exc_info=True)
raise e
- else:
+ def validateConnection(self):
+ try:
+ fileSD.validateDirAccess(
+ self.getMountObj().getRecord().fs_file)
+ except se.StorageServerAccessPermissionError as e:
try:
- fileSD.validateDirAccess(
- self.getMountObj().getRecord().fs_file)
- except se.StorageServerAccessPermissionError as e:
- try:
- self.disconnect()
- except OSError:
- self.log.warn("Error while disconnecting after access"
- "problem", exc_info=True)
- raise e
+ self.disconnect()
+ except OSError:
+ self.log.warn("Error while disconnecting after access"
+ "problem", exc_info=True)
+ raise e
+
+ def connect(self):
+ self.createConnection()
+ self.validateConnection()
def isConnected(self):
return self._mount.isMounted()
@@ -255,6 +259,24 @@
def getLocalPathBase(cls):
return os.path.join(MountConnection.getLocalPathBase(), "glusterSD")
+ def updateBackup(self):
+ if self.options and not self.isConnected():
+ for opt in self.options.split(','):
+ if opt.strip().startswith("backupvolfile-server"):
+ backupSpec = opt.split('=', 1)[1].strip()
+ try:
+ mount._getRecord(backupSpec, self._mount.fs_file)
+ except OSError as e:
+ self.log.warning("Mount of backup failed: %s", e)
+ else:
+ self._mount.fs_spec = backupSpec
+ return
+
+ def connect(self):
+ self.createConnection()
+ self.updateBackup()
+ self.validateConnection()
+
class NFSConnection(object):
DEFAULT_OPTIONS = ["soft", "nosharecache"]
--
To view, visit http://gerrit.ovirt.org/16534
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3166c6863dffa297bc0adcdeb4c22f810d18de8e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>
9 years, 11 months
Change in vdsm[master]: More precise exception when multipath failed.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: More precise exception when multipath failed.
......................................................................
More precise exception when multipath failed.
In spite that any OSError is translated to ENODEV in devicemapper,
the complete info is needed.
Related to BZ#965184.
Change-Id: I1b87e8e91b838db2c8a98c9afbbc998e8f4c792a
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/devicemapper.py
1 file changed, 4 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/45/17145/1
diff --git a/vdsm/storage/devicemapper.py b/vdsm/storage/devicemapper.py
index 451c736..ff1fb7a 100644
--- a/vdsm/storage/devicemapper.py
+++ b/vdsm/storage/devicemapper.py
@@ -34,11 +34,10 @@
devlinkPath = DMPATH_FORMAT % deviceMultipathName
try:
devStat = os.stat(devlinkPath)
- except OSError:
- raise OSError(errno.ENODEV, "Could not find dm device named `%s`" %
- deviceMultipathName)
-
- return "dm-%d" % os.minor(devStat.st_rdev)
+ except OSError as e:
+ raise OSError(errno.ENODEV, "%s: %s" % (deviceMultipathName, e))
+ else:
+ return "dm-%d" % os.minor(devStat.st_rdev)
def findDev(major, minor):
--
To view, visit http://gerrit.ovirt.org/17145
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b87e8e91b838db2c8a98c9afbbc998e8f4c792a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 11 months