def rebootNode(self, nodes: List[Node], bSoftReset: Optional[bool] = False): \ # pylint: disable=unused-argument """Reboot the given node""" # By default raise unsupported operation raise UnsupportedOperation('Node does not support rebooting')
def addStorageVolume(self, nodeName, volume, isDirect="DEFAULT"): """ Raises: VolumeDoesNotExist UnsupportedOperation """ node = self.getNode(nodeName, {'hardwareprofile': True}) # Only allow persistent volumes to be attached... vol = self._san.getVolume(volume) if vol is None: raise VolumeDoesNotExist('Volume [%s] does not exist' % (volume)) if not vol.getPersistent(): raise UnsupportedOperation( 'Only persistent volumes can be attached') api = resourceAdapterFactory.getApi( node.getHardwareProfile().getResourceAdapter().getName()) if isDirect == "DEFAULT": return api.addVolumeToNode(node, volume) return api.addVolumeToNode(node, volume, isDirect)
def startupNode(self, nodes: List[Node], remainingNodeList: Optional[str] = None, tmpBootMethod: Optional[str] = 'n'): \ # pylint: disable=unused-argument """ Start nodes """ # By default raise unsupported operation raise UnsupportedOperation('Node does not support starting')
def __getPersistentVolume(self, volume): """ Raises: VolumeDoesNotExist UnsupportedOperation """ vol = self._san.getVolume(volume) if not vol.getPersistent(): raise UnsupportedOperation('Volume [%s] is not persistent' % (volume)) return vol
def revertDrivesToCheckpoint(self, dbNode, isDefaultCheckpointable): """ Raises: UnsupportedOperation """ if not self.supportsCheckpoint(dbNode, isDefaultCheckpointable): raise UnsupportedOperation( 'Node [%s] does not support checkpointing' % (dbNode.name)) self.getLogger().debug('[%s] Reverting node [%s] to checkpoint' % (self.__class__.__name__, dbNode.name)) # Find out what kind of disks we need for this node nodePartitions = dbNode.softwareprofile.partitions driveNumbers = [] drives = {} for partition in nodePartitions: # Look for drives driveNumber = partition.device.split('.')[0] if driveNumber in driveNumbers: continue # We haven't looked at this drive number yet driveNumbers.append(driveNumber) # Get the storage adapter for this drive driveinfo = self.__getDriveInfo(dbNode.name, driveNumber) # Only include non-persistent drives in revert checkpoint if not driveinfo.volume.getPersistent(): drives[driveNumber] = (driveinfo.volume.getStorageAdapter(), driveinfo.volume.getAdapterVolume()) for drive in drives: storageAdapter, adapterVolume = drives[drive] # Lookup storage adapter if storageAdapter != 'default': adapter = self.__getStorageAdapter(storageAdapter) # Checkpoint drive adapter.revertDriveToCheckpoint(adapterVolume)
def addVolumeToNode(self, node, volume, isDirect=True): '''Add a disk to a node''' if not isDirect: raise UnsupportedOperation( 'This node only supports direct volume attachment.') # Map the volume to a driveNumber openDriveNumber = self.sanApi.mapDrive(node, volume) try: # have the node connect the storage self.sanApi.connectStorageVolume(node, volume, node.getName()) except Exception: self.getLogger().exception('Error adding volume to node') # Need to clean up mapping self.sanApi.unmapDrive(node, driveNumber=openDriveNumber) raise
def removeStorageVolume(self, nodeName, volume): """ Raises: VolumeDoesNotExist UnsupportedOperation """ node = self.getNode(nodeName, {'hardwareprofile': True}) api = resourceAdapterFactory.getApi( node.getHardwareProfile().getResourceAdapter().getName()) vol = self._san.getVolume(volume) if vol is None: raise VolumeDoesNotExist('The volume [%s] does not exist' % (volume)) if not vol.getPersistent(): raise UnsupportedOperation( 'Only persistent volumes can be detached') return api.removeVolumeFromNode(node, volume)
def revertDriveToCheckpoint(self, volume): '''Revert the given node to its checkpoint''' # By default raise unsupported operation raise UnsupportedOperation('Volume %s does not support checkpointing' % (volume))
def shutdownNode(self, nodes, bSoftReset=False): \ # pylint: disable=unused-argument '''Shutdown the given node''' # By default raise unsupported operation raise UnsupportedOperation('Node does not support shutdown')
def connectStorage(self, dbNode, driveNumber, targetHost): """ Raise: UnsupportedOperation """ driveinfo = self.__getDriveInfo(dbNode.name, driveNumber) # Lookup storage adapter adapter = self.__getStorageAdapter( driveinfo.volume.getStorageAdapter()) # Get the list of all mounts for this volume _, mappedNodes = self.__getVolumeTargetHosts(driveinfo.volume) self.getLogger().debug( '[%s] Volume [%s] is mapped to nodes [%s]' % (self.__class__.__name__, driveinfo.volume, mappedNodes)) # Check if the device is already connected on the new hypervisor nodes, device = self.__checkVolumeTargetHost(driveinfo.volume, targetHost) self.getLogger().debug( '[%s] Volume [%s] is connected on target host [%s] at [%s]' ' for nodes [%s]' % (self.__class__.__name__, driveinfo.volume, targetHost, driveinfo.device, nodes)) # If this is a multi mount request and not shared we need to bail if mappedNodes: # This volume is attached somewhere if not driveinfo.volume.getShared(): # Check if this is a double connect if nodes and dbNode.name in nodes: # OK...this is is a non-shared device but this node was # already connected so we are ok newDevice = adapter.connectVolume( driveinfo.volume.getAdapterVolume(), targetHost, False) if newDevice != device: raise UnsupportedOperation( 'Inconsistent state for volume [%s] on node' ' [%s]. The node must be shutdown.' % (driveinfo.volume, dbNode.name)) self.__addTargetHostMapping(driveinfo.volume, targetHost, device, dbNode.name) self.__updateNodeVolume(dbNode.name, driveNumber, driveinfo.volume, device, targetHost) return device if dbNode.name in mappedNodes: # So the node is most likely being migrated as it is # mapped but not connected on the targetHost. We can # just continue pass else: raise UnsupportedOperation( 'Unable to multi-mount non-shared volume') if driveinfo.volume.getShared() or nodes: # Have the adapter connect the device to the node multiMount = False if targetHost != dbNode.name: if driveinfo.volume.getShared(): multiMount = dbNode.name device = adapter.connectVolume(driveinfo.volume.getAdapterVolume(), targetHost, multiMount) self.__addTargetHostMapping(driveinfo.volume, targetHost, device, dbNode.name) self.__updateNodeVolume(dbNode.name, driveNumber, driveinfo.volume, device, targetHost) return device
def addVolumeToNode(self, node, volume, isDirect): \ # pylint: disable=unused-argument '''Add a disk to a node''' # By default raise unsupported operation raise UnsupportedOperation( 'Node does not support dynamic disk addition')
def migrateNode(self, nodeId, remainingNodeList, liveMigrate): \ # pylint: disable=unused-argument '''Migrate the given node''' # By default raise unsupported operation raise UnsupportedOperation('Node does not support migrating')
def revertNodeToCheckpoint(self, nodeId): \ # pylint: disable=unused-argument '''Revert the given node to the checkpoint''' # By default raise unsupported operation raise UnsupportedOperation('Node does not support checkpointing')
def rebootNode(self, nodes, bSoftReset=False): \ # pylint: disable=unused-argument '''Reboot the given node''' # By default raise unsupported operation raise UnsupportedOperation('Node does not support rebooting')
def addVolumeToNode(self, node: Node, volume: str, isDirect: bool): \ # pylint: disable=unused-argument """Add a disk to a node""" # By default raise unsupported operation raise UnsupportedOperation( 'Node does not support dynamic disk addition')
def checkpointDrive(self, volume): '''Checkpoint the given node''' # By default raise unsupported operation raise UnsupportedOperation('Volume %s does not support checkpointing' % (volume))
def removeVolumeFromNode(self, node: Node, volume: str): \ # pylint: disable=unused-argument """Remove a disk from a node""" # By default raise unsupported operation raise UnsupportedOperation( 'Node does not support dynamic disk deletion' % (node))
def startupNode(self, nodeIds, remainingNodeList=None, tmpBootMethod='n'): \ # pylint: disable=unused-argument '''Start the given node''' # By default raise unsupported operation raise UnsupportedOperation('Node does not support starting')