diff options
49 files changed, 1160 insertions, 2607 deletions
diff --git a/build/package-gateway.sh b/build/package-gateway.sh index 640f69d5..6dc1e9db 100755 --- a/build/package-gateway.sh +++ b/build/package-gateway.sh @@ -48,7 +48,7 @@ get-dist() OS=${2} WS=${3} - OUT_DIR="${WORKSPACE}/../../${VERSION}-glustermc/workspace/arch/${ARCH}/os/${OS}/ws/${WS}/buckminster.output/com.gluster.storage.management.console.feature.webstart*.feature/glustermc" + OUT_DIR="${WORKSPACE}/../../${BRANCH}-glustermc/workspace/arch/${ARCH}/os/${OS}/ws/${WS}/buckminster.output/com.gluster.storage.management.console.feature.webstart*.feature/glustermc" NEW_DIR=${WAR_NAME}/${OS}.${WS}.${ARCH} cp -R ${OUT_DIR} ${NEW_DIR} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java index e6ca0457..3d27afb2 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java @@ -30,7 +30,6 @@ import javax.ws.rs.core.MultivaluedMap; import com.gluster.storage.management.core.constants.RESTConstants; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.TaskInfo; import com.gluster.storage.management.core.response.GlusterServerListResponse; import com.gluster.storage.management.core.utils.GlusterCoreUtil; import com.sun.jersey.api.representation.Form; diff --git a/src/com.gluster.storage.management.console.help/build.properties b/src/com.gluster.storage.management.console.help/build.properties index 9c6ba40f..9fb97e12 100644 --- a/src/com.gluster.storage.management.console.help/build.properties +++ b/src/com.gluster.storage.management.console.help/build.properties @@ -4,4 +4,5 @@ bin.includes = plugin.xml,\ toc.xml,\ tocconcepts.xml,\ tocgettingstarted.xml,\ - toctasks.xml + toctasks.xml,\ + tocreference.xml diff --git a/src/com.gluster.storage.management.console.help/html/gettingstarted/install_gmg_backend.html b/src/com.gluster.storage.management.console.help/html/gettingstarted/install_gmg_backend.html index af04461f..fad76f27 100644 --- a/src/com.gluster.storage.management.console.help/html/gettingstarted/install_gmg_backend.html +++ b/src/com.gluster.storage.management.console.help/html/gettingstarted/install_gmg_backend.html @@ -41,6 +41,7 @@ Gluster Management Gateway communicates with every node of your cluster using th <ul>
<li>You must enable port 24729 (UDP) for auto discovery of servers.
<li>In case CIFS only, the Samba services must be configured to run on port 445 which needs to be enabled and open on all the storage servers in your cluster.
+<li>Paravirtual VMs on Xen are not supported.
</ul>
</body>
</html>
\ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java index 0893952f..29481286 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java @@ -22,7 +22,6 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java index edf09f33..81abb01f 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java @@ -39,28 +39,23 @@ public class DownloadVolumeLogsAction extends AbstractActionDelegate { @Override protected void performAction(IAction action) { final VolumesClient client = new VolumesClient(); - final Volume volume = guiHelper.getSelectedEntity(getWindow(), Volume.class); + Volume volume = guiHelper.getSelectedEntity(getWindow(), Volume.class); FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); dialog.setFilterNames(new String[] { "GZipped Tar (*.tar.gz)" }); dialog.setFilterExtensions(new String[] { "*.tar.gz" }); - final String filePath = dialog.open(); + String filePath = dialog.open(); if (filePath == null) { return; } - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - String title = "Download Volume Logs [" + volume.getName() + "]"; - try { - client.downloadLogs(volume.getName(), filePath); - showInfoDialog(title, "Volume logs downloaded successfully to [" + filePath + "]"); - } catch (Exception e) { - showErrorDialog(title, e.getMessage()); - } - } - }); + String title = "Download Volume Logs [" + volume.getName() + "]"; + try { + client.downloadLogs(volume.getName(), filePath); + showInfoDialog(title, "Volume logs downloaded successfully to [" + filePath + "]"); + } catch (Exception e) { + showErrorDialog(title, e.getMessage()); + } } } diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java index ac61709d..51cf49c1 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java @@ -22,8 +22,6 @@ package com.gluster.storage.management.console.actions; import org.eclipse.jface.action.IAction; import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import com.gluster.storage.management.client.KeysClient; diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java index aeed223f..5ae93ede 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java @@ -21,7 +21,6 @@ package com.gluster.storage.management.console.actions; import java.net.URI; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import com.gluster.storage.management.client.TasksClient; diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java index 87f8ccd4..227c60b7 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java @@ -29,7 +29,6 @@ import com.gluster.storage.management.console.IImageKeys; import com.gluster.storage.management.console.utils.GUIHelper; import com.gluster.storage.management.console.utils.GlusterLogger; import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java index 2f271186..0dc06f6d 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java @@ -49,7 +49,6 @@ import com.gluster.storage.management.console.TableLabelProviderAdapter; import com.gluster.storage.management.console.utils.GUIHelper; import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Entity; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.utils.NumberUtil; diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java index 48cec9f8..6187d5ad 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java @@ -47,9 +47,9 @@ import com.gluster.storage.management.console.IImageKeys; import com.gluster.storage.management.console.actions.ActionConstants; import com.gluster.storage.management.console.preferences.PreferenceConstants; import com.gluster.storage.management.console.utils.ChartUtil; +import com.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener; import com.gluster.storage.management.console.utils.ChartViewerComposite; import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener; import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.model.Alert; diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java index 9fefc034..43853752 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java @@ -53,7 +53,6 @@ import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.model.Entity; import com.gluster.storage.management.core.model.Event; import com.gluster.storage.management.core.model.Event.EVENT_TYPE; -import com.gluster.storage.management.core.model.GlusterDataModel; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java index 11b0e6a6..b0121213 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java @@ -18,8 +18,6 @@ *******************************************************************************/ package com.gluster.storage.management.core.model; -import java.io.File; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlTransient; diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/Disk.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/Disk.py index ff994731..3b44e3a8 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/Disk.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/Disk.py @@ -44,7 +44,7 @@ class Disk: try: if dev.GetProperty('storage.removable'): disk_size = str(int(dev.GetProperty('storage.removable.media_size')) / 1024**2) - except: + except: # TODO: Add appropriated exception on property error. return self.disks.append({ diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py index deebb388..5d7b0b4a 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py @@ -90,23 +90,12 @@ def getDeviceByLabel(label): def getDiskPartitionLabel(device): - rv = Utils.runCommandFG(["sudo", "e2label", device], stdout=True) + rv = Utils.runCommand("e2label %s" % device, output=True, root=True) if rv["Status"] == 0: return rv["Stdout"].strip() return False -def readFile(fileName): - lines = None - try: - fp = open(fileName) - lines = fp.readlines() - fp.close() - except IOError, e: - Utils.log("failed to read file %s: %s" % (file, str(e))) - return lines - - def getRootPartition(fsTabFile=Globals.FSTAB_FILE): fsTabEntryList = FsTabUtils.readFsTab(fsTabFile) for fsTabEntry in fsTabEntryList: @@ -120,26 +109,6 @@ def getRootPartition(fsTabFile=Globals.FSTAB_FILE): return getDeviceName(fsTabEntry["Device"]) return None -def getMounts(): - mounts = {} - for line in readFile("/proc/mounts"): - str = line.strip() - if str.startswith("/dev/"): - tokens = str.split() - device = {} - mountPoint = tokens[1].strip() - device["MountPoint"] = mountPoint - device["FsType"] = tokens[2].strip() - device["Uuid"] = getDiskPartitionUuid(tokens[0].strip()) - device["Status"] = "INITIALIZED" - if mountPoint: - if mountPoint in ["/", "/boot"]: - device["Type"] = "BOOT" - else: - device["Type"] = "DATA" - mounts[tokens[0].strip()] = device - return mounts - def getRaidDisk(): array = [] arrayList = [] @@ -199,182 +168,76 @@ def getOsDisk(): Utils.log("WARNING: getOsDisk() is deprecated by getRootPartition()") return getRootPartition() +def getDiskInfo(diskNameList=None): + procPartitionsDict = getProcPartitions() + diskDict = {} + for name, values in procPartitionsDict.iteritems(): + values["Description"] = None + values["Uuid"] = None + values["FsType"] = None + values["MountPoint"] = None + values["SpaceInUse"] = None + values["Member"] = None + ## extras ?!?! + values["Init"] = False + values["Status"] = None + values["Interface"] = None + values["DriveType"] = None + values["Type"] = None + values["FsVersion"] = None + values["ReadOnlyAccess"] = None + + device = getDevice(name) + values["Uuid"] = getUuidByDiskPartition(device) + rv = Utils.runCommand("blkid -c /dev/null -o value %s" % device, output=True, root=True) + if rv["Status"] == 0: + lines = rv["Stdout"].strip().split("\n") + values["FsType"] = lines[-1].strip() + values["MountPoint"] = getDeviceMountPoint(device) + if values["FsType"]: + values["Init"] = True + if values["MountPoint"]: + rv = Utils.runCommand(["df", values["MountPoint"]], output=True) + if rv["Status"] == 0: + try: + values["SpaceInUse"] = long(rv["Stdout"].split("\n")[1].split()[2]) + except IndexError, e: + pass + except ValueError, e: + pass + if os.path.isdir("/sys/block/%s" % name): + model = Utils.readFile("/sys/block/%s/device/model" % name) + vendor = Utils.readFile("/sys/block/%s/device/vendor" % name) + values["Description"] = "%s %s" % (model.strip(), vendor.strip()) + values["Partitions"] = {} + diskDict[name] = values + + for diskName in diskDict.keys(): + del procPartitionsDict[diskName] + for partName, values in procPartitionsDict.iteritems(): + if os.path.isdir("/sys/block/%s/%s" % (diskName, partName)): + diskDict[diskName]["Partitions"][partName] = values + + procMdstatDict = getProcMdstat() + for name, values in procMdstatDict.iteritems(): + try: + diskDict[name]["Description"] = "Software Raid Array - %s - %s" % (values["Type"], values["Status"]) + diskDict[name]["Member"] = values["Member"] + except KeyError, e: + pass + + diskNameList = getDeviceName(diskNameList) + if Utils.isString(diskNameList): + diskNameList = [diskNameList] + + if not diskNameList: + return diskDict + + outputDict = {} + for diskName in list(set(diskDict.keys()).intersection(set(diskNameList))): + outputDict[diskName] = diskDict[diskName] + return outputDict -def getDiskInfo(diskDeviceList=None): - diskDeviceList = getDevice(diskDeviceList) - if Utils.isString(diskDeviceList): - diskDeviceList = [diskDeviceList] - - mounts = getMounts() - if Utils.runCommand("/usr/bin/lshal") != 0: - Utils.log("failed running /usr/bin/lshal") - - dbusSystemBus = dbus.SystemBus() - halObj = dbusSystemBus.get_object("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager") - halManager = dbus.Interface(halObj, "org.freedesktop.Hal.Manager") - storageUdiList = halManager.FindDeviceByCapability("storage") - - diskInfo = {} - diskList = [] - for udi in storageUdiList: - halDeviceObj = dbusSystemBus.get_object("org.freedesktop.Hal", udi) - halDevice = dbus.Interface(halDeviceObj, - "org.freedesktop.Hal.Device") - if halDevice.GetProperty("storage.drive_type") in ["cdrom", "floppy"] or \ - halDevice.GetProperty("block.is_volume"): - continue - disk = {} - disk["Device"] = str(halDevice.GetProperty('block.device')) - if diskDeviceList and disk["Device"] not in diskDeviceList: - continue - disk["Description"] = str(halDevice.GetProperty('storage.vendor')) + " " + str(halDevice.GetProperty('storage.model')) - if halDevice.GetProperty('storage.removable'): - disk["Size"] = long(halDevice.GetProperty('storage.removable.media_size')) - else: - disk["Size"] = long(halDevice.GetProperty('storage.size')) / 1024**2 - disk["Interface"] = str(halDevice.GetProperty('storage.bus')) - disk["DriveType"] = str(halDevice.GetProperty('storage.drive_type')) - disk["Status"] = None - disk["Uuid"] = None - disk["Init"] = False - disk["Type"] = None - disk["FsType"] = None - disk["FsVersion"] = None - disk["MountPoint"] = None - disk["ReadOnlyAccess"] = None - - partitionUdiList = halManager.FindDeviceStringMatch("info.parent", udi) - if isDiskInFormatting(disk["Device"]): - disk["Status"] = "INITIALIZING" - else: - if partitionUdiList: - disk["Status"] = "INITIALIZED" - else: - disk["Status"] = "UNINITIALIZED" - disk["Type"] = "UNKNOWN" - - if mounts and mounts.has_key(disk["Device"]): - disk["Uuid"] = mounts[disk["Device"]]["Uuid"] - disk["Type"] = mounts[disk["Device"]]["Type"] - disk["Status"] = mounts[disk["Device"]]["Status"] - disk["FsType"] = mounts[disk["Device"]]["FsType"] - disk["MountPoint"] = mounts[disk["Device"]]["MountPoint"] - - if disk["MountPoint"]: - disk["SpaceInUse"] = getDeviceUsedSpace(disk["Device"]) - else: - disk["SpaceInUse"] = None - - partitionList = [] - diskSpaceInUse = 0 - for partitionUdi in partitionUdiList: - used = 0 - partitionHalDeviceObj = dbusSystemBus.get_object("org.freedesktop.Hal", - partitionUdi) - partitionHalDevice = dbus.Interface(partitionHalDeviceObj, - "org.freedesktop.Hal.Device") - if not partitionHalDevice.GetProperty("block.is_volume"): - continue - partitionDevice = str(partitionHalDevice.GetProperty('block.device')) - if partitionHalDevice.GetProperty("volume.is_mounted"): - rv = Utils.runCommandFG(["df", str(partitionHalDevice.GetProperty('volume.mount_point'))], stdout=True) - if rv["Status"] == 0: - try: - used = long(rv["Stdout"].split("\n")[1].split()[2]) / 1024 - diskSpaceInUse += used - except IndexError: - pass - except ValueError: - pass - - if disk["Device"] == partitionDevice: - disk["Uuid"] = str(partitionHalDevice.GetProperty('volume.uuid')) - disk["Init"] = True # TODO: use isDataDiskPartitionFormatted function to cross verify this - disk["Status"] = "INITIALIZED" - mountPoint = str(partitionHalDevice.GetProperty('volume.mount_point')) - if mountPoint: - if mountPoint in ["/", "/boot"]: - disk["Type"] = "BOOT" - else: - disk["Type"] = "DATA" - disk["FsType"] = str(partitionHalDevice.GetProperty('volume.fstype')) - if disk["FsType"] and "UNINITIALIZED" == disk["Status"]: - disk["Status"] = "INITIALIZED" - disk["FsVersion"] = str(partitionHalDevice.GetProperty('volume.fsversion')) - disk["MountPoint"] = str(partitionHalDevice.GetProperty('volume.mount_point')) - disk["ReadOnlyAccess"] = str(partitionHalDevice.GetProperty('volume.is_mounted_read_only')) - if not disk["Size"]: - disk["Size"] = long(partitionHalDevice.GetProperty('volume.size')) / 1024**2 - #disk["SpaceInUse"] = used - continue - - partition = {} - partition["Init"] = False - partition["Type"] = "UNKNOWN" - partition["Device"] = partitionDevice - partition["Uuid"] = str(partitionHalDevice.GetProperty('volume.uuid')) - partition["Size"] = long(partitionHalDevice.GetProperty('volume.size')) / 1024**2 - partition["FsType"] = str(partitionHalDevice.GetProperty('volume.fstype')) - partition["FsVersion"] = str(partitionHalDevice.GetProperty('volume.fsversion')) - partition["Label"] = str(partitionHalDevice.GetProperty('volume.label')) - partition["MountPoint"] = str(partitionHalDevice.GetProperty('volume.mount_point')) - partition["Size"] = long(partitionHalDevice.GetProperty('volume.size')) / 1024**2 - - if isDiskInFormatting(partitionDevice): - partition["Status"] = "INITIALIZING" - else: - if partition["FsType"]: - partition["Status"] = "INITIALIZED" - else: - partition["Status"] = "UNINITIALIZED" - - partition["SpaceInUse"] = used - if partition["MountPoint"] or isDataDiskPartitionFormatted(partitionDevice): - partition["Init"] = True - partition["Status"] = "INITIALIZED" - if partition["MountPoint"]: - if partition["MountPoint"] in ["/", "/boot"]: - partition["Type"] = "BOOT" - else: - partition["Type"] = "DATA" - else: - if "SWAP" == partition["FsType"].strip().upper(): - partition["Type"] = "SWAP" - partition["ReadOnlyAccess"] = str(partitionHalDevice.GetProperty('volume.is_mounted_read_only')) - partitionList.append(partition) - disk["Partitions"] = partitionList - if not disk["SpaceInUse"]: - disk["SpaceInUse"] = diskSpaceInUse - diskList.append(disk) - diskInfo["disks"] = diskList - if diskList: - return diskInfo - for line in readFile("/proc/partitions")[2:]: - disk = {} - tokens = line.split() - if tokens[3].startswith("md"): - continue - disk["Device"] = tokens[3] - ## if diskDeviceList and disk["Device"] not in diskDeviceList: - ## continue - disk["Description"] = None - disk["Size"] = long(tokens[2]) / 1024 - disk["Status"] = None - disk["Interface"] = None - disk["DriveType"] = None - disk["Uuid"] = None - disk["Init"] = False - disk["Type"] = None - disk["FsType"] = None - disk["FsVersion"] = None - disk["MountPoint"] = None - disk["ReadOnlyAccess"] = None - disk["SpaceInUse"] = None - disk["Partitions"] = [] - diskList.append(disk) - diskInfo["disks"] = diskList - return diskInfo def getDiskList(diskDeviceList=None): return diskInfo["disks"] @@ -383,8 +246,9 @@ def getDiskList(diskDeviceList=None): def checkDiskMountPoint(diskMountPoint): try: fstabEntries = open(Globals.FSTAB_FILE).readlines() - except IOError: + except IOError, e: fstabEntries = [] + Utils.log("failed to read file %s: %s" % (Globals.FSTAB_FILE, str(e))) found = False for entry in fstabEntries: entry = entry.strip() @@ -400,8 +264,9 @@ def getMountPointByUuid(partitionUuid): # check uuid in etc/fstab try: fstabEntries = open(Globals.FSTAB_FILE).readlines() - except IOError: + except IOError, e: fstabEntries = [] + Utils.log("failed to read file %s: %s" % (Globals.FSTAB_FILE, str(e))) found = False for entry in fstabEntries: entry = entry.strip() @@ -416,9 +281,9 @@ def getDeviceUsedSpace(device): if rv["Status"] == 0: try: return long(rv["Stdout"].split("\n")[1].split()[2]) / 1024 - except IndexError: + except IndexError, e: pass - except ValueError: + except ValueError, e: pass def getDiskSizeInfo(partition): @@ -427,10 +292,10 @@ def getDiskSizeInfo(partition): used = None free = None command = "df -kl -t ext3 -t ext4 -t xfs" - rv = Utils.runCommandFG(command, stdout=True, root=True) + rv = Utils.runCommand(command, output=True, root=True) message = Utils.stripEmptyLines(rv["Stdout"]) - if rv["Stderr"]: - Utils.log("failed to get disk details. %s" % Utils.stripEmptyLines(rv["Stdout"])) + if rv["Status"] != 0: + Utils.log("failed to get disk partition details") return None, None, None for line in rv["Stdout"].split("\n"): tokens = line.split() @@ -457,10 +322,9 @@ def getDiskSizeInfo(partition): number = int(partitionNumber) command = "parted -ms %s unit kb print" % disk - rv = Utils.runCommandFG(command, stdout=True, root=True) - message = Utils.stripEmptyLines(rv["Stdout"]) - if rv["Stderr"]: - Utils.log("failed to get disk details. %s" % Utils.stripEmptyLines(rv["Stdout"])) + rv = Utils.runCommand(command, output=True, root=True) + if rv["Status"] != 0: + Utils.log("failed to get disk partition details") return None, None, None lines = rv["Stdout"].split(";\n") @@ -478,7 +342,6 @@ def getDiskSizeInfo(partition): def isDataDiskPartitionFormatted(device): - #Todo: Proper label needs to be added for data partition #if getDiskPartitionLabel(device) != Globals.DATA_PARTITION_LABEL: # return False device = getDeviceName(device) @@ -501,239 +364,6 @@ def isDataDiskPartitionFormatted(device): return False -def getDiskDom(diskDeviceList=None, bootPartition=None, skipDisk=None): - diskDeviceList = getDevice(diskDeviceList) - if Utils.isString(diskDeviceList): - diskDeviceList = [diskDeviceList] - - if skipDisk: - skipDisk = getDevice(skipDisk) - if Utils.isString(skipDisk): - skipDisk = [skipDisk] - - diskInfo = getDiskInfo(diskDeviceList) - diskList = diskInfo["disks"] - if not diskList: - return None - - raidPartitions = {} - raidDisk = getRaidDisk() - - for k, v in raidDisk.iteritems(): - for i in v['Disks']: - raidPartitions[i] = k - - #for partition in raidDisk.values(): - # raidDiskPartitions += partition['disks'] - - diskDom = Protocol.XDOM() - disksTag = diskDom.createTag("disks", None) - raidDisks = {} - if not bootPartition: - bootPartition = getRootPartition() - for disk in diskList: - if skipDisk and disk["Device"] in skipDisk: - continue - diskTag = diskDom.createTag("disk", None) - diskDevice = getDeviceName(disk["Device"]) - diskTag.appendChild(diskDom.createTag("name", diskDevice)) - diskTag.appendChild(diskDom.createTag("description", disk["Description"])) - diskTag.appendChild(diskDom.createTag("uuid", disk["Uuid"])) - diskTag.appendChild(diskDom.createTag("status", disk["Status"])) - diskTag.appendChild(diskDom.createTag("interface", disk["Interface"])) - - #if not disk["Partitions"]: - diskTag.appendChild(diskDom.createTag("type", disk["Type"])) - #diskTag.appendChild(diskDom.createTag("init", str(disk["Init"]).lower())) - diskTag.appendChild(diskDom.createTag("fsType", disk["FsType"])) - diskTag.appendChild(diskDom.createTag("fsVersion", disk["FsVersion"])) - diskTag.appendChild(diskDom.createTag("mountPoint", disk["MountPoint"])) - - diskTag.appendChild(diskDom.createTag("size", disk["Size"])) - diskTag.appendChild(diskDom.createTag("spaceInUse", disk["SpaceInUse"])) - partitionsTag = diskDom.createTag("partitions", None) - if raidPartitions.has_key(diskDevice): - rdList = {} - rdList[diskDevice] = [deepcopy(diskTag)] - if not raidDisks.has_key(raidPartitions[diskDevice]): - raidDisks[raidPartitions[diskDevice]] = [] - raidDisks[raidPartitions[diskDevice]] += [rdList] - continue - for partition in disk["Partitions"]: - partitionTag = diskDom.createTag("partition", None) - device = getDeviceName(partition["Device"]) - partitionTag.appendChild(diskDom.createTag("name", device)) - if partition["Uuid"]: #TODO: Move this verification and findings to getDiskInfo function - partitionTag.appendChild(diskDom.createTag("uuid", partition["Uuid"])) - else: - partitionTag.appendChild(diskDom.createTag("uuid", getUuidByDiskPartition("/dev/" + device))) - partitionTag.appendChild(diskDom.createTag("status", partition["Status"])) - #partitionTag.appendChild(diskDom.createTag("init", str(partition["Init"]).lower())) - partitionTag.appendChild(diskDom.createTag("type", str(partition["Type"]))) - partitionTag.appendChild(diskDom.createTag("fsType", partition["FsType"])) - partitionTag.appendChild(diskDom.createTag("mountPoint", partition['MountPoint'])) - partitionTag.appendChild(diskDom.createTag("size", partition["Size"])) - partitionTag.appendChild(diskDom.createTag("spaceInUse", partition["SpaceInUse"])) - if raidPartitions.has_key(device): - tempPartitionTag = diskDom.createTag("partitions", None) - if raidDisks.has_key(raidPartitions[device]): - rdList = raidDisks[raidPartitions[device]] - for rdItem in rdList: - if not rdItem.has_key(diskDevice): - rdItem[diskDevice] = [deepcopy(diskTag), tempPartitionTag] - rdItem[diskDevice][0].appendChild(tempPartitionTag) - rdItem[diskDevice][-1].appendChild(partitionTag) - continue - rdList = {} - rdList[diskDevice] = [deepcopy(diskTag), tempPartitionTag] - tempPartitionTag.appendChild(partitionTag) - rdList[diskDevice][0].appendChild(tempPartitionTag) - raidDisks[raidPartitions[device]] = [rdList] - continue - partitionsTag.appendChild(partitionTag) - diskTag.appendChild(partitionsTag) - disksTag.appendChild(diskTag) - - for rdisk in raidDisk.keys(): - raidDiskTag = diskDom.createTag("disk", None) - raidDiskTag.appendChild(diskDom.createTag("name", rdisk)) - raidDiskTag.appendChild(diskDom.createTag("description")) - raidDiskTag.appendChild(diskDom.createTag("uuid", raidDisk[rdisk]['Uuid'])) - raidDiskTag.appendChild(diskDom.createTag("type", raidDisk[rdisk]['Type'])) - raidDiskTag.appendChild(diskDom.createTag("mountPoint", raidDisk[rdisk]['MountPoint'])) - raidDiskTag.appendChild(diskDom.createTag("status", raidDisk[rdisk]['Status'])) - raidDiskTag.appendChild(diskDom.createTag("interface", raidDisk[rdisk]['Interface'])) - raidDiskTag.appendChild(diskDom.createTag("fsType", raidDisk[rdisk]['FsType'])) - raidDiskTag.appendChild(diskDom.createTag("fsVersion")) - raidDiskTag.appendChild(diskDom.createTag("size", raidDisk[rdisk]['Size'])) - raidDiskTag.appendChild(diskDom.createTag("spaceInUse", raidDisk[rdisk]['SpaceInUse'])) - raidDisksTag = diskDom.createTag("raidDisks", None) - if raidDisks.has_key(rdisk): - for item in raidDisks[rdisk]: - for diskTag in item.values(): - raidDisksTag.appendChild(diskTag[0]) - raidDiskTag.appendChild(raidDisksTag) - disksTag.appendChild(raidDiskTag) - diskDom.addTag(disksTag) - return diskDom - - -def initializeDisk(disk, boot=False, startSize=0, sudo=False): - if boot and startSize > 0: - return False - - disk = getDevice(disk) - diskObj = getDiskList(disk)[0] - - if boot or startSize == 0: - command = "dd if=/dev/zero of=%s bs=1024K count=1" % diskObj["Device"] - if runCommandFG(command, root=sudo) != 0: - if boot: - Utils.log("failed to clear boot sector of disk %s" % diskObj["Device"]) - return False - Utils.log("failed to clear boot sector of disk %s. ignoring" % diskObj["Device"]) - - command = "parted -s %s mklabel gpt" % diskObj["Device"] - if runCommandFG(command, root=sudo) != 0: - return False - - if boot: - command = "parted -s %s mkpart primary ext3 0MB %sMB" % (diskObj["Device"], Globals.OS_PARTITION_SIZE) - if runCommandFG(command, root=sudo) != 0: - return False - command = "parted -s %s set 1 boot on" % (diskObj["Device"]) - if runCommandFG(command, root=sudo) != 0: - return False - startSize = Globals.OS_PARTITION_SIZE - - size = (diskObj["Size"] / ONE_MB_SIZE) - startSize - while size > Globals.MAX_PARTITION_SIZE: - endSize = startSize + Globals.MAX_PARTITION_SIZE - command = "parted -s %s mkpart primary ext3 %sMB %sMB" % (diskObj["Device"], startSize, endSize) - if runCommandFG(command, root=sudo) != 0: - return False - size -= Globals.MAX_PARTITION_SIZE - startSize = endSize - - if size: - command = "parted -s %s mkpart primary ext3 %sMB 100%%" % (diskObj["Device"], startSize) - if runCommandFG(command, root=sudo) != 0: - return False - - if runCommandFG("udevadm settle", root=sudo) != 0: - if runCommandFG("udevadm settle", root=sudo) != 0: - Utils.log("udevadm settle for disk %s failed. ignoring" % diskObj["Device"]) - time.sleep(1) - - if runCommandFG("partprobe %s" % diskObj["Device"], root=sudo) != 0: - Utils.log("partprobe %s failed" % diskObj["Device"]) - return False - - if runCommandFG("gptsync %s" % diskObj["Device"], root=sudo) != 0: - Utils.log("gptsync %s failed. ignoring" % diskObj["Device"]) - - # wait forcefully to appear devices in /dev - time.sleep(2) - return True - - -def initializeOsDisk(diskObj): - Utils.log("WARNING: initializeOsDisk() is deprecated by initializeDisk(boot=True)") - return initializeDisk(diskObj, boot=True) - - -def initializeDataDisk(diskObj): - Utils.log("WARNING: initializeDataDisk() is deprecated by initializeDisk()") - return initializeDisk(diskObj) - -def getBootPartition(serverName): - diskDom = XDOM() - diskDom.parseFile("%s/%s/disk.xml" % (Globals.SERVER_VOLUME_CONF_DIR, serverName)) - if not diskDom: - return None - partitionDom = XDOM() - partitionUuid = None - partitionName = None - for partitionTag in diskDom.getElementsByTagRoute("disk.partition"): - partitionDom.setDomObj(partitionTag) - boot = partitionDom.getTextByTagRoute("boot") - if boot and boot.strip().upper() == 'YES': - partitionUuid = partitionDom.getTextByTagRoute("uuid") - partitionName = partitionDom.getTextByTagRoute("device") - break - if not (partitionUuid and partitionName): - return None - - # check device label name - deviceBaseName = os.path.basename(partitionName) - process = runCommandBG(['sudo', 'e2label', partitionName]) - if type(process) == type(True): - return None - if process.wait() != 0: - return None - output = process.communicate() - deviceLabel = output[0].split()[0] - if deviceLabel != Globals.BOOT_PARTITION_LABEL: - return None - - # check uuid in etc/fstab - try: - fstabEntries = open(Globals.FSTAB_FILE).readlines() - except IOError: - fstabEntries = [] - found = False - for entry in fstabEntries: - entry = entry.strip() - if not entry: - continue - if entry.split()[0] == "UUID=" + partitionUuid: - found = True - break - if not found: - return None - return partitionName - - def isDiskInFormatting(device): DEVICE_FORMAT_LOCK_FILE = "/var/lock/%s.lock" % device return os.path.exists(DEVICE_FORMAT_LOCK_FILE) @@ -745,12 +375,29 @@ def isDiskInFormat(device): def getDeviceMountPoint(device): - try: - fp = open("/proc/mounts") - for token in [line.strip().split() for line in fp.readlines()]: - if token and len(token) > 2 and token[0] == device: - return token[1] - fp.close() - except IOError, e: - return None + lines = Utils.readFile("/proc/mounts", lines=True) + uuid = getUuidByDiskPartition(device) + for line in lines: + tokens = line.split() + if tokens[0] == device or (uuid and tokens[0].endswith(uuid)): + return tokens[1] + return None +def getProcPartitions(): + procPartitionsDict = {} + s = Utils.readFile("/proc/partitions", lines=True) + for line in s[2:]: + tokens = line.strip().split() + procPartitionsDict[tokens[3]] = {"Size" : long(tokens[2])} + return procPartitionsDict + +def getProcMdstat(): + raidArrayDict = {} + lines = Utils.readFile("/proc/mdstat", lines=True) + for line in lines[1:]: + tokens = line.strip().split() + if not tokens: + continue + if tokens[0].startswith("md"): + raidArrayDict[tokens[0]] = {"Status" : tokens[2], "Type" : tokens[3], "Member" : [token.split('[')[0] for token in tokens[4:]]} + return raidArrayDict diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py index a9adf4de..368b7a15 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py @@ -39,7 +39,7 @@ def readFsTab(fsTabFile=Globals.FSTAB_FILE): fsTabEntry["Options"] = tokens[3] fsTabEntry["DumpOption"] = tokens[4] fsTabEntry["fsckOrder"] = tokens[5] - except IndexError: + except IndexError, e: pass if fsTabEntry["Device"] and fsTabEntry["MountPoint"] and fsTabEntry["FsType"] and fsTabEntry["Options"]: fsTabEntryList.append(fsTabEntry) @@ -81,7 +81,7 @@ def removeFsTabEntry(fsTabEntry, fsTabFile=Globals.FSTAB_FILE): try: fsTabEntryList.remove(fsTabEntry) - except ValueError: + except ValueError, e: return False return writeFsTab(fsTabEntryList, fsTabFile) diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/GlusterdUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/GlusterdUtils.py deleted file mode 100644 index 9295d83b..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/GlusterdUtils.py +++ /dev/null @@ -1,237 +0,0 @@ -# Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> -# This file is part of Gluster Storage Platform. -# - -import os -import Utils - -import ServerUtils - - -def getGlusterVolumeInfo(volumeName=None): - volumeNameList = None - if Utils.isString(volumeName): - volumeNameList = [volumeName] - if type(volumeName) == type([]): - volumeNameList = volumeName - - status = Utils.runCommand("gluster volume info", output=True, root=True) - if status["Status"] != 0: - Utils.log("Failed to execute 'gluster volume info' command") - return None - - volumeInfoDict = {} - volumeInfo = {} - volumeName = None - brickList = [] - for line in status['Stdout'].split("\n"): - if not line: - if volumeName and volumeInfo: - volumeInfo["Bricks"] = brickList - volumeInfoDict[volumeName] = volumeInfo - volumeInfo = {} - volumeName = None - brickList = [] - continue - - tokens = line.split(":") - if tokens[0].strip().upper() == "BRICKS": - continue - elif tokens[0].strip().upper() == "VOLUME NAME": - volumeName = tokens[1].strip() - volumeInfo["VolumeName"] = volumeName - elif tokens[0].strip().upper() == "TYPE": - volumeInfo["VolumeType"] = tokens[1].strip() - elif tokens[0].strip().upper() == "STATUS": - volumeInfo["VolumeStatus"] = tokens[1].strip() - elif tokens[0].strip().upper() == "TRANSPORT-TYPE": - volumeInfo["TransportType"] = tokens[1].strip() - elif tokens[0].strip().upper().startswith("BRICK"): - brickList.append(":".join(tokens[1:]).strip()) - - if volumeName and volumeInfo: - volumeInfoDict[volumeName] = volumeInfo - - if not volumeNameList: - return volumeInfoDict - - # remove unwanted volume info - for volumeName in list(set(volumeInfoDict.keys()) - set(volumeNameList)): - del volumeInfoDict[volumeName] - - return volumeInfoDict - - -def isVolumeRunning(volumeName): - if not volumeName: - return False - volumeInfo = getGlusterVolumeInfo(volumeName) - if not volumeInfo: - return False - status = volumeInfo[volumeName]["VolumeStatus"] - if not status: - return False - if status.upper() == "STARTED": - return True - return False - - -def isVolumeExist(volumeName): - if not volumeName: - return False - if getGlusterVolumeInfo(volumeName): - return True - return False - - -def peerProbe(serverName): - command = "gluster peer probe %s" % serverName - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def setAuthAllow(volumeName, authList, includeServers=True): - if not (volumeName and authList): - return False - vacl = [] - if includeServers: - for serverName in ServerUtils.getAllServerList(): - vacl += ServerUtils.getServerIpList(serverName) - vacl += authList - - command = "gluster volume set %s auth.allow %s" % (volumeName, ",".join(list(set(vacl)))) - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def volumeCreate(volumeName, volumeType, transportTypeList, brickList): - command = "gluster volume create %s" % volumeName - - if volumeType.upper() == "MIRROR": - command += " replica 2" - elif volumeType.upper() == "STRIPE": - command += " stripe 4" - - if "RDMA" in transportTypeList: - command += " transport rdma" - - command += " " + " ".join(brickList) - - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def volumeDelete(volumeName): - command = "gluster --mode=script volume delete %s" % volumeName - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def volumeLogFileName(volumeName, brick, logDir): - command = "gluster volume log filename %s %s %s" % (volumeName, brick, logDir) - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def startVolumeMigration(volumeName, sourcePath, destinationPath): - command = "gluster volume replace-brick %s %s %s start" % (volumeName, sourcePath, destinationPath) - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - lines = status["Stdout"].split("\n") - if lines[0].split()[-1] == "successfully": - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def stopVolumeMigration(volumeName, sourcePath, destinationPath): - command = "gluster volume replace-brick %s %s %s abort" % (volumeName, sourcePath, destinationPath) - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - lines = status["Stdout"].split("\n") - if lines[0].split()[-1] == "successful": - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def commitVolumeMigration(volumeName, sourcePath, destinationPath): - command = "gluster volume replace-brick %s %s %s commit" % (volumeName, sourcePath, destinationPath) - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - lines = status["Stdout"].split("\n") - if lines[0].split()[-1] == "successful": - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def getMigrationStatus(volumeName, sourcePath, destinationPath): - command = "gluster volume replace-brick %s %s %s status" % (volumeName, sourcePath, destinationPath) - status = Utils.runCommand(command, output=True, root=True) - if status['Status'] == 0 and status['Stdout']: - lines = status["Stdout"].split("\n") - if "Current file" in lines[0]: - return "started" - if "Migration complete" in lines[0]: - return "completed" - Utils.log("command [%s] returns unknown status:%s" % (command, lines[0])) - return "failed" - #if status['Status'] == 0 and status['Stdout']: - # for line in status['Stdout'].split('\n'): - # words = line.split() - # if words and words[0].upper() == "STATUS:": - # return " ".join(words[1:]).upper() - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return None - - -def volumeRebalanceStart(volumeName): - command = "gluster volume rebalance %s start" % volumeName - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - lines = status["Stdout"].split("\n") - if lines[0].split()[-1] == "successful": - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def volumeRebalanceStop(volumeName): - command = "gluster volume rebalance %s stop" % volumeName - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - lines = status["Stdout"].split("\n") - if lines[0].split()[0] == "stopped": - return True - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False - - -def volumeRebalanceStatus(volumeName): - command = "gluster volume rebalance %s status" % volumeName - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] == 0: - lines = status["Stdout"].split("\n") - if "rebalance not started" in lines[0]: - return "not started" - if "rebalance completed" in lines[0]: - return "completed" - return "running" - Utils.log("command [%s] failed with [%d:%s]" % (command, status["Status"], os.strerror(status["Status"]))) - return False diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py index 2c3f38e0..27a9c056 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py @@ -32,8 +32,8 @@ def readHostFile(fileName=None): continue hostEntryList.append({tokens[0] : tokens[1:]}) return hostEntryList - except IOError: - log("failed to read %s file" % fileName) + except IOError, e: + log("failed to read %s file: %s" % (fileName, str(e))) return None @@ -49,10 +49,10 @@ def writeHostFile(hostEntryList, fileName=None): fp.close() if hostFile == fileName: return True - except IOError: - log("failed to write %s file" % hostFile) + except IOError, e: + log("failed to write %s file: %s" % (hostFile, str(e))) return False - if runCommandFG("mv -f %s /etc/hosts" % hostFile, root=True) != 0: + if runCommand("mv -f %s /etc/hosts" % hostFile, root=True) != 0: log("failed to rename file %s to /etc/hosts" % hostFile) return False return True @@ -81,8 +81,8 @@ def readResolvConfFile(fileName=None, includeLocalHost=False): searchDomain = tokens[1:] continue return nameServerList, domain, searchDomain - except IOError: - log("failed to read %s file" % fileName) + except IOError, e: + log("failed to read %s file: %s" % (fileName, str(e))) return None, None, None @@ -104,10 +104,10 @@ def writeResolvConfFile(nameServerList, domain, searchDomain, fileName=None, app fp.close() if resolvConfFile == fileName: return True - except IOError: - log("failed to write %s file" % resolvConfFile) + except IOError, e: + log("failed to write %s file: %s" % (resolvConfFile, str(e))) return False - if runCommandFG("mv -f %s %s" % (resolvConfFile, Globals.RESOLV_CONF_FILE), root=True) != 0: + if runCommand("mv -f %s %s" % (resolvConfFile, Globals.RESOLV_CONF_FILE), root=True) != 0: log("failed to rename file %s to %s" % (resolvConfFile, Globals.RESOLV_CONF_FILE)) return False return True @@ -123,8 +123,8 @@ def readIfcfgConfFile(deviceName, root=""): continue conf[tokens[0].strip().lower()] = tokens[1].strip() return conf - except IOError: - log("failed to read %s file" % fileName) + except IOError, e: + log("failed to read %s file: %s" % (fileName, str(e))) return None @@ -162,10 +162,10 @@ def writeIfcfgConfFile(deviceName, conf, root="", deviceFile=None): fp.close() if ifcfgConfFile == deviceFile: return True - except IOError: - log("failed to write %s file" % ifcfgConfFile) + except IOError, e: + log("failed to write %s file" % (ifcfgConfFile, str(e))) return False - if runCommandFG("mv -f %s %s" % (ifcfgConfFile, deviceFile), root=True) != 0: + if runCommand("mv -f %s %s" % (ifcfgConfFile, deviceFile), root=True) != 0: log("failed to rename file %s to %s" % (ifcfgConfFile, deviceFile)) return False return True @@ -173,7 +173,7 @@ def writeIfcfgConfFile(deviceName, conf, root="", deviceFile=None): def getNetDeviceDetail(deviceName): deviceDetail = {} deviceDetail['Name'] = deviceName - rv = runCommandFG("ifconfig %s" % deviceName, stdout=True, root=True) + rv = runCommand("ifconfig %s" % deviceName, output=True, root=True) if rv["Status"] != 0: return False for line in rv["Stdout"].split(): @@ -189,7 +189,7 @@ def getNetDeviceDetail(deviceName): try: deviceDetail['Ip'] = tokens[1].strip().split()[0] deviceDetail['Mask'] = tokens[-1].strip() - except IndexError: + except IndexError, e: pass break return deviceDetail @@ -209,7 +209,7 @@ def getNetDeviceGateway(deviceName): return None def getNetSpeed(deviceName): - rv = runCommandFG("ethtool %s" % deviceName, stdout=True, root=True) + rv = runCommand("ethtool %s" % deviceName, output=True, root=True) if rv["Status"] != 0: return False for line in rv["Stdout"].split("\n"): @@ -221,7 +221,7 @@ def getNetSpeed(deviceName): def getLinkStatus(deviceName): return True ## ethtool takes very long time to respond. So its disabled now - rv = runCommandFG("ethtool %s" % deviceName, stdout=True, root=True) + rv = runCommand("ethtool %s" % deviceName, output=True, root=True) if rv["Status"] != 0: return False for line in rv["Stdout"].split("\n"): @@ -252,8 +252,8 @@ def getBondMode(deviceName, fileName=None): if tokens[5].startswith("mode="): return tokens[5].split("=")[1] return None - except IOError: - log("failed to read %s file" % fileName) + except IOError, e: + log("failed to read %s file: %s" % (fileName, str(e))) return None @@ -264,8 +264,8 @@ def setBondMode(deviceName, mode, fileName=None): try: fp = open(tempFileName, "w") lines = open(fileName).readlines() - except IOError: - log("unable to open file %s" % Globals.MODPROBE_CONF_FILE) + except IOError, e: + log("unable to open file %s: %s" % (Globals.MODPROBE_CONF_FILE, str(e))) return False for line in lines: tokens = line.split() @@ -278,7 +278,7 @@ def setBondMode(deviceName, mode, fileName=None): fp.write("alias %s bonding\n" % deviceName) fp.write("options %s max_bonds=2 mode=%s miimon=100\n" % (deviceName, mode)) fp.close() - if runCommandFG(["mv", "-f", tempFileName, fileName], root=True) != 0: + if runCommand(["mv", "-f", tempFileName, fileName], root=True) != 0: log("unable to move file from %s to %s" % (tempFileName, fileName)) return False return True @@ -329,7 +329,7 @@ def getNetDeviceList(root=""): netDevice["speed"] = getNetSpeed(deviceName) try: netDevice["hwaddr"] = open("/sys/class/net/%s/address" % deviceName).read().strip() - except IOError: + except IOError, e: pass netDeviceList.append(netDevice) @@ -339,17 +339,17 @@ def getNetDeviceList(root=""): continue try: netDevice["onboot"] = conf["onboot"] - except KeyError: + except KeyError, e: pass try: netDevice["bootproto"] = conf["bootproto"] - except KeyError: + except KeyError, e: pass if conf.has_key("ipaddr") and conf["ipaddr"]: netDevice["ipaddr"] = conf["ipaddr"] try: netDevice["netmask"] = conf["netmask"] - except KeyError: + except KeyError, e: pass if conf.has_key("gateway") and conf["gateway"]: netDevice["gateway"] = conf["gateway"] @@ -357,35 +357,35 @@ def getNetDeviceList(root=""): netDevice["gateway"] = getNetDeviceGateway(deviceName) try: netDevice["peerdns"] = conf["peerdns"] - except KeyError: + except KeyError, e: pass try: netDevice["autodns"] = conf["autodns"] - except KeyError: + except KeyError, e: pass try: netDevice["dns1"] = conf["dns1"] - except KeyError: + except KeyError, e: pass try: netDevice["dns2"] = conf["dns2"] - except KeyError: + except KeyError, e: pass try: netDevice["dns3"] = conf["dns3"] - except KeyError: + except KeyError, e: pass try: netDevice["master"] = conf["master"] - except KeyError: + except KeyError, e: pass try: netDevice["slave"] = conf["slave"] - except KeyError: + except KeyError, e: pass try: netDevice["nmcontrolled"] = conf["nmcontrolled"] - except KeyError: + except KeyError, e: pass return netDeviceList @@ -414,12 +414,12 @@ def configureDhcpServer(serverIpAddress, dhcpIpAddress): if token[0] == "dhcp": serverPortString = token[1] break - except IOError: - log(syslog.LOG_ERR, "Failed to read /proc/cmdline. Continuing with default port 68") + except IOError, e: + log(syslog.LOG_ERR, "Failed to read /proc/cmdline. Continuing with default port 68: %s" % str(e)) try: serverPort = int(serverPortString) - except ValueError: - log(syslog.LOG_ERR, "Invalid dhcp port '%s' in /proc/cmdline. Continuing with default port 68" % serverPortString) + except ValueError, e: + log(syslog.LOG_ERR, "Invalid dhcp port '%s' in /proc/cmdline. Continuing with default port 68: %s" % (serverPortString, str(e))) serverPort = 68 try: @@ -433,10 +433,10 @@ def configureDhcpServer(serverIpAddress, dhcpIpAddress): #fp.write("server=%s\n" % serverIpAddress) #fp.write("dhcp-script=/usr/sbin/server-info\n") fp.close() - except IOError: - log(syslog.LOG_ERR, "unable to write dnsmasq dhcp configuration %s" % tmpDhcpConfFile) + except IOError, e: + log(syslog.LOG_ERR, "unable to write dnsmasq dhcp configuration %s: %s" % (tmpDhcpConfFile, str(e))) return False - if runCommandFG("mv -f %s %s" % (tmpDhcpConfFile, Globals.DNSMASQ_DHCP_CONF_FILE), root=True) != 0: + if runCommand("mv -f %s %s" % (tmpDhcpConfFile, Globals.DNSMASQ_DHCP_CONF_FILE), root=True) != 0: log(syslog.LOG_ERR, "unable to copy dnsmasq dhcp configuration to %s" % Globals.DNSMASQ_DHCP_CONF_FILE) return False return True @@ -447,31 +447,31 @@ def isDhcpServer(): def getDhcpServerStatus(): - if runCommandFG("service dnsmasq status", root=True) == 0: + if runCommand("service dnsmasq status", root=True) == 0: return True return False def startDhcpServer(): - if runCommandFG("service dnsmasq start", root=True) == 0: + if runCommand("service dnsmasq start", root=True) == 0: return True return False def stopDhcpServer(): - if runCommandFG("service dnsmasq stop", root=True) == 0: - runCommandFG("rm -f %s" % Globals.DNSMASQ_LEASE_FILE, root=True) + if runCommand("service dnsmasq stop", root=True) == 0: + runCommand("rm -f %s" % Globals.DNSMASQ_LEASE_FILE, root=True) return True return False def restartDhcpServer(): stopDhcpServer() - runCommandFG("rm -f %s" % Globals.DNSMASQ_LEASE_FILE, root=True) + runCommand("rm -f %s" % Globals.DNSMASQ_LEASE_FILE, root=True) return startDhcpServer() def reloadDhcpServer(): - if runCommandFG("service dnsmasq reload", root=True) == 0: + if runCommand("service dnsmasq reload", root=True) == 0: return True return False diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/RRDUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/RRDUtils.py deleted file mode 100644 index d1a6c058..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/RRDUtils.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com> -# This file is part of Gluster Storage Platform. -# - -import rrdtool -import os -from socket import gethostname -from itertools import groupby - -class RRD: - def __init__ (self): - self.COLORS = [0xff7777, 0x7777ff, 0x55ff55, 0xffcc77, 0xff77ff, 0x77ffff,0xffff77, 0x55aaff] - self.HOST = gethostname() - self.DIR = "/var/lib/collectd" - - def fade_component(self, component): - return ((component + 255 * 5) / 6) - - def fade_color(self, color): - r = 0; - for i in [0,1,2]: - shft = (i * 8) - component = ((color >> shft) & 255) - r |= (self.fade_component(component) << shft) - return r - - def generate_pngs(self): - - rrdlist = os.popen ("find %s -type f -name '*.rrd'" % self.DIR) - - for rrd in rrdlist: - self.dss = [] - self.defs = "" - - rrdinfo = rrdtool.info(rrd.strip()) - - for key in rrdinfo.keys(): - if key.split('[')[0] == 'ds': - self.dss.append(key.split('[')[1].split(']')[0]) - self.dss.sort() - - self.dss = [a for a,b in groupby(self.dss)] - - for ds in self.dss: - self.defs = self.defs + " DEF:%s_avg=%s:%s:AVERAGE " % (ds, rrd.strip(), ds) - self.defs = self.defs + " DEF:%s_max=%s:%s:MAX " % (ds, rrd.strip(), ds) - - j = 0 - for ds in self.dss: - color = self.COLORS[j % len(self.COLORS)] - j = j + 1 - faded_color = self.fade_color(color) - self.defs = self.defs + " AREA:%s_max#%06x " % (ds, faded_color) - - j = 0 - for ds in self.dss: - color = self.COLORS[j % len(self.COLORS)] - j = j + 1 - self.defs = self.defs + " LINE2:%s_avg#%06x:%s " % (ds, color, ds) - self.defs = self.defs + " GPRINT:%s_avg:AVERAGE:%%5.1lf%%sAvg " % ds - self.defs = self.defs + " GPRINT:%s_max:MAX:%%5.1lf%%sMax " % ds - - for span in ['1hour', '1day', '1week', '1month']: - os.system ("mkdir -p %s/%s" % (self.DIR, self.HOST)) - image = os.path.dirname(rrd.strip()) + "-" + span + ".png" - cmd = "rrdtool graph " + image + " -t \"%s %s\"" % (os.path.dirname(rrd.strip()), span) + " --imgformat PNG --width 600 --height 100 --start now-" + span + " --end now --interlaced " + self.defs + " >/dev/null 2>&1" - os.system(cmd) - - -def main (): - - rrd = RRD () - rrd.generate_pngs () - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/ServerUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/ServerUtils.py deleted file mode 100644 index 16cdeed2..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/ServerUtils.py +++ /dev/null @@ -1,295 +0,0 @@ -# Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> -# This file is part of Gluster Storage Platform. -# - -import os -import re -import subprocess -import glob -import Globals -from Protocol import * -from Utils import * - -def isValidServer(serverName): - for profile in getProfileList(): - if profile.ProfileName == "default" and profile.Active: - if serverName == profile.DNS.Hostname: - return True - return False - -def getHostname(): - for profile in getProfileList(): - if profile.ProfileName == "default" and profile.Active: - return profile.DNS.Hostname - return None - -def getDomainName(): - try: - domainName = open(Globals.DOMAINNAME_FILE).read() - except IOError: - return None - return domainName.split()[0] - -def replaceServerIp(fileName, findWhat, replaceWith): - try: - data = open(fileName).read() - fp = open(fileName, "w") - fp.write(re.sub(findWhat, replaceWith, data)) - fp.close() - return True - except IOError: - return False - except ValueError: - return False - except OSError: - return False - -def serverName2IpAddress(serverName): - command = "dig %s | grep '^%s'" % (serverName, serverName) - ps = subprocess.Popen(command, - shell=True, - stdout=subprocess.PIPE, - stdin=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True) - ipAddress = serverName - if ps.wait() == 0: - output = ps.communicate() - ipAddress = output[0].split()[-1] - return ipAddress - -def getInstallerIp(): - if not os.path.exists(Globals.INSTALLER_INFO_FILE): - return None - try: - for line in open(Globals.INSTALLER_INFO_FILE): - tokens = line.split("=") - if tokens[0] == "IP-ADDRESS": - return tokens[1].split(",")[0].strip() - except IOError: - syslog.syslog(syslog.LOG_ERR, "unable to read %s file" % Globals.INSTALLER_INFO_FILE) - return False - -def setInstallerIp(installerIp): - try: - open(Globals.INSTALLER_INFO_FILE, "w").write("IP-ADDRESS=%s\n" % installerIp) - return True - except IOError: - log(syslog.LOG_ERR, "unable to create %s file" % Globals.INSTALLER_INFO_FILE) - return False - -def getCurrentServerName(): - try: - for line in open(Globals.SYSCONFIG_NETWORK_FILE): - tokens = line.split("=") - if tokens[0] == "HOSTNAME": - return tokens[1].strip() - except IOError: - syslog.syslog(syslog.LOG_ERR, "unable to read %s file" % Globals.SYSCONFIG_NETWORK_FILE) - return False - -def getLastAccessedNetwork(serverName): - lastAccessedNetworkFile = ("/%s/servers/%s/%s" % - (Globals.GLUSTER_CONF_DIR, serverName, Globals.LAST_ACCESSED_NETWORK_FILE)) - try: - return open(lastAccessedNetworkFile).read().strip() - except IOError: - log(syslog.LOG_ERR, "failed to read last accessed network file %s" % lastAccessedNetworkFile) - pass - return False - -def setLastAccessedNetwork(serverName, ipAddress): - lastAccessedNetworkFile = ("/%s/servers/%s/%s" % - (Globals.GLUSTER_CONF_DIR, serverName, Globals.LAST_ACCESSED_NETWORK_FILE)) - try: - open(lastAccessedNetworkFile, "w").write(ipAddress.strip() + "\n") - except IOError: - log(syslog.LOG_ERR, "failed to write last accessed network file %s" % lastAccessedNetworkFile) - return False - return True - -def getServerIpList(serverName, preferredNetworkOnly=False): - networkXmlFile = ("%s/servers/%s/network.xml" % (Globals.GLUSTER_CONF_DIR, serverName)) - configDom = XDOM() - if not configDom.parseFile(networkXmlFile): - log(syslog.LOG_ERR, "failed to read %s file" % networkXmlFile) - return None - preferredNetwork = configDom.getTextByTagRoute("preferred-network") - ipList = [] - interfaceDom = XDOM() - for tagE in configDom.getElementsByTagName("interface"): - interfaceDom.setDomObj(tagE) - deviceName = interfaceDom.getTextByTagRoute("device") - hostIp = interfaceDom.getTextByTagRoute("ipaddr") - if not hostIp: - continue - if preferredNetworkOnly: - if preferredNetwork.upper() == "ANY" or preferredNetwork.upper() == deviceName.upper(): - ipList.append(hostIp) - else: - ipList.append(hostIp) - if preferredNetworkOnly: - lastAccessedNetworkIp = getLastAccessedNetwork(serverName) - if lastAccessedNetworkIp in ipList: - ipList.remove(lastAccessedNetworkIp) - ipList = [lastAccessedNetworkIp] + ipList - return ipList - -def getServerPreferredIpList(serverName): - return getServerIpList(serverName, True) - -def getExecuteServerList(serverList): - executeServerList = {} - for serverName in serverList: - if serverName == Globals.INSTALLER_SERVER_NAME: - installerIp = getInstallerIp() - if installerIp: - executeServerList[serverName] = [installerIp] - continue - executeServerList[serverName] = getServerPreferredIpList(serverName) - return executeServerList - -def getAllServerList(): - serverList = [] - for filePath in glob.glob("%s/servers/*" % Globals.GLUSTER_CONF_DIR): - if os.path.isdir(filePath): - serverList.append(os.path.basename(filePath)) - try: - serverList.remove(Globals.INSTALLER_SERVER_NAME) - except ValueError: - pass - return serverList - -def getServerNetworkConfigFromLocalFile(serverName): - configDom = XDOM() - configDom.parseFile("%s/servers/%s/network.xml" % (Globals.GLUSTER_CONF_DIR, serverName)) - return configDom - -def updateServerNetworkConfigXmlFile(serverName, serverNetworkDom): - configDom = XDOM() - serverTag = serverNetworkDom.getElementsByTagRoute("server")[0] - configDom.setDomObj(serverTag) - if not configDom.writexml("%s/%s/network.xml" % (Globals.SERVER_VOLUME_CONF_DIR, serverName)): - log("Faild to write xml file %s/%s/network.xml" % (Globals.SERVER_VOLUME_CONF_DIR, serverName)) - -def compareServerNetworkDom(serverNetworkDomA, serverNetworkDomB, requestFlag=True): - command = "command.server." - if not requestFlag: - command = "" - sourceServer = {} - tagText = serverNetworkDomA.getTextByTagRoute("name") - if not tagText: - taxText = None - sourceServer["name"] = tagText - tagText = serverNetworkDomA.getTextByTagRoute("domain-name") - if not tagText: - tagText = None - sourceServer["domain-name"] = tagText - tagText = serverNetworkDomA.getTextByTagRoute("search-domain") - if not tagText: - tagText = None - sourceServer["search-domain"] = tagText - tagText = serverNetworkDomA.getTextByTagRoute("dns1") - if not tagText: - tagText = None - sourceServer["dns1"] = tagText - tagText = serverNetworkDomA.getTextByTagRoute("dns2") - if not tagText: - tagText = None - sourceServer["dns2"] = tagText - tagText = serverNetworkDomA.getTextByTagRoute("dns3") - if not tagText: - tagText = None - sourceServer["dns3"] = tagText - for tagE in serverNetworkDomA.getElementsByTagRoute("interface"): - interfaceDom = XDOM() - interfaceDom.setDomObj(tagE) - sourceServerList = {} - tagText = interfaceDom.getTextByTagRoute("description") - if not tagText: - tagText = None - sourceServerList["description"] = tagText - tagText = interfaceDom.getTextByTagRoute("hwaddr") - if not tagText: - tagText = None - sourceServerList["hwaddr"] = tagText - tagText = interfaceDom.getTextByTagRoute("onboot") - if not tagText: - tagText = None - sourceServerList["onboot"] = tagText - tagText = interfaceDom.getTextByTagRoute("bootproto") - if not tagText: - tagText = None - sourceServerList["bootproto"] = tagText - tagText = interfaceDom.getTextByTagRoute("ipaddr") - if not tagText: - tagText = None - sourceServerList["ipaddr"] = tagText - tagText = interfaceDom.getTextByTagRoute("netmask") - if not tagText: - tagText = None - sourceServerList["netmask"] = tagText - tagText = interfaceDom.getTextByTagRoute("gateway") - if not tagText: - tagText = None - sourceServerList["gateway"] = tagText - sourceServer[interfaceDom.getTextByTagRoute("device")] = sourceServerList - objServer = {} - tagText = serverNetworkDomB.getTextByTagRoute(command + "name") - if not tagText: - taxText = None - objServer["name"] = tagText - tagText = serverNetworkDomB.getTextByTagRoute(command + "domain-name") - if not tagText: - tagText = None - objServer["domain-name"] = tagText - tagText = serverNetworkDomB.getTextByTagRoute(command + "search-domain") - if not tagText: - tagText = None - objServer["search-domain"] = tagText - tagText = serverNetworkDomB.getTextByTagRoute(command + "dns1") - if not tagText: - tagText = None - objServer["dns1"] = tagText - tagText = serverNetworkDomB.getTextByTagRoute(command + "dns2") - if not tagText: - tagText = None - objServer["dns2"] = tagText - tagText = serverNetworkDomB.getTextByTagRoute(command + "dns3") - if not tagText: - tagText = None - objServer["dns3"] = tagText - for tagE in serverNetworkDomB.getElementsByTagRoute(command + "interface"): - interfaceDom = XDOM() - interfaceDom.setDomObj(tagE) - objServerList = {} - tagText = interfaceDom.getTextByTagRoute("description") - if not tagText: - tagText = None - objServerList["description"] = tagText - tagText = interfaceDom.getTextByTagRoute("hwaddr") - if not tagText: - tagText = None - objServerList["hwaddr"] = tagText - tagText = interfaceDom.getTextByTagRoute("onboot") - if not tagText: - tagText = None - objServerList["onboot"] = tagText - tagText = interfaceDom.getTextByTagRoute("bootproto") - if not tagText: - tagText = None - objServerList["bootproto"] = tagText - tagText = interfaceDom.getTextByTagRoute("ipaddr") - if not tagText: - tagText = None - objServerList["ipaddr"] = tagText - tagText = interfaceDom.getTextByTagRoute("netmask") - if not tagText: - tagText = None - objServerList["netmask"] = tagText - tagText = interfaceDom.getTextByTagRoute("gateway") - if not tagText: - tagText = None - objServerList["gateway"] = tagText - objServer[interfaceDom.getTextByTagRoute("device")] = objServerList - return sourceServer == objServer diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py index 020a1900..e5256178 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py @@ -3,30 +3,15 @@ # import os -import glob -import tempfile -from operator import itemgetter +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals -from Protocol import * -from Utils import * -from DiskUtils import * -from ServerUtils import * -import GlusterdUtils as Glusterd - - -def isVolumeExist(volumeName): - volumeDom = XDOM() - return volumeDom.parseFile("%s/%s.xml" % (Globals.VOLUME_CONF_DIR, volumeName)) and \ - Glusterd.isVolumeExist(volumeName) - - -def getVolumeUuid(volumeName): - fileName = "%s/%s.xml" % (Globals.VOLUME_CONF_DIR, volumeName) - volumeDom = XDOM() - if not volumeDom.parseFile(fileName): - log("Failed to parse volume configuration file %s of %s" % (fileName, volumeName)) - return None - return volumeDom.getTextByTagRoute("uuid") +import Utils def readVolumeSmbConfFile(fileName=Globals.VOLUME_SMBCONF_FILE): @@ -41,7 +26,7 @@ def readVolumeSmbConfFile(fileName=Globals.VOLUME_SMBCONF_FILE): entryList.append(tokens[1].strip()) fp.close() except IOError, e: - log("Failed to open file %s: %s" % (fileName, str(e))) + Utils.log("Failed to open file %s: %s" % (fileName, str(e))) return entryList @@ -53,7 +38,7 @@ def writeVolumeSmbConfFile(entryList, fileName=Globals.VOLUME_SMBCONF_FILE): fp.close() return True except IOError, e: - log("Failed to write file %s: %s" % (fileName, str(e))) + Utils.log("Failed to write file %s: %s" % (fileName, str(e))) return False @@ -76,7 +61,7 @@ def excludeVolume(volumeName, fileName=Globals.VOLUME_SMBCONF_FILE): if volumeFile not in entryList: return True entryList.remove(volumeFile) - log("entryList = %s" % entryList) + Utils.log("entryList = %s" % entryList) return writeVolumeSmbConfFile(entryList, fileName) @@ -99,7 +84,7 @@ def writeVolumeCifsConfiguration(volumeName, userList, adminUser=None): fp.close() return True except IOError, e: - log("Failed to write file %s: %s" % (volumeFile, str(e))) + Utils.log("Failed to write file %s: %s" % (volumeFile, str(e))) return False @@ -109,491 +94,6 @@ def removeVolumeCifsConfiguration(volumeName): os.remove(volumeFile) return True except OSError, e: - log("Failed to remove file %s: %s" % (volumeFile, str(e))) - return False - - -def getVolumeListByPartitionName(partitionName): - volumeConfigFileList = glob.glob(Globals.VOLUME_CONF_DIR + "/*.xml") - if not volumeConfigFileList: - return None - - volumeList = [] - for volumeXmlFile in volumeConfigFileList: - volumeDom = XDOM() - volumeDom.parseFile(volumeXmlFile) - serverTopology = volumeDom.getElementsByTagRoute("volume.topology.group") - serverPartitionFound = False - for topology in serverTopology: - partitionDom = XDOM() - for partition in topology.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - if partitionDom.getTextByTagRoute("name") == partitionName: - serverPartitionFound = True - break - if serverPartitionFound: - volumeList.append(volumeDom.getElementsByTagRoute("volume")[0]) - break - return volumeList - - -def addServerPartitionConfig(inputDom, groupOrder, partitionTag): - if not(inputDom and groupOrder and partitionTag): - return False - groupDom = XDOM() - for group in inputDom.getElementsByTagRoute("topology.group"): - groupDom.setDomObj(group) - order = groupDom.getTextByTagRoute("order") - if order and int(order) == groupOrder: - group.appendChild(partitionTag) - return inputDom - return False - - -def removeServerPartitionConfig(inputDom, partitionName): - if not(inputDom and partitionName): - return False - for group in inputDom.getElementsByTagRoute("topology.group"): - partitionDom = XDOM() - for partition in group.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - if partitionDom.getTextByTagRoute("name") == partitionName: - group.removeChild(partition) - return inputDom - return False - - -def updateServerPartitionConfig(inputDom, partitionName, partitionTag): - if not(inputDom and partitionName and partitionTag): - return False - for group in inputDom.getElementsByTagRoute("topology.group"): - partitionDom = XDOM() - for partition in group.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - if partitionDom.getTextByTagRoute("name") == partitionName: - try: - group.replaceChild(partitionTag, partition) - return inputDom - except AttributeError: - return False - return False - - -def getServerPartitionConfigUuid(serverGroupList, serverPartition): - for group in serverGroupList: - if not group: - continue - partitionDom = XDOM() - for partition in group.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - partitionName = partition.getTextByTagName("name") - if not partitionName: - continue - if partitionName == serverPartition: - return partitionDom.getTextByTagName("uuid") - return False - - -def setServerPartitionConfigProperty(inputDom, partitionName, propertyDict): - if not(inputDom and partitionName and propertyDict): - return False - for group in inputDom.getElementsByTagRoute("topology.group"): - partitionDom = XDOM() - for partition in group.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - if partitionDom.getTextByTagRoute("name") == partitionName: - for part in propertyDict.keys(): - x = partition.getElementsByTagName(part) - if x: - x[0].childNodes[0].nodeValue = propertyDict[part] - return inputDom - return False - - -def getSortedServerPartitionConfigProperty(inputDom): - groupDict = {} - if not inputDom: - return None - groupDom = XDOM() - for group in inputDom.getElementsByTagRoute("topology.group"): - groupDom.setDomObj(group) - groupOrder = groupDom.getTextByTagRoute("order") - if not groupOrder: - return None - groupOrder = int(groupOrder) - if groupOrder < 1: - return None - partitionDom = XDOM() - partitionDict = {} - for partition in group.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - partitionName = partitionDom.getTextByTagRoute("name") - if not partitionName: - return None - partitionOrder = partitionDom.getTextByTagRoute("order") - if not partitionOrder: - return None - partitionUuid = partitionDom.getTextByTagRoute("uuid") - partitionOrder = int(partitionOrder) - if partitionOrder < 1: - return None - partitionDetails = partitionName.split(":") - if not partitionDetails or len(partitionDetails) < 1: - return None - partitionDict[partitionOrder] = { "order":partitionOrder, - "servername":partitionDetails[0], - "name":partitionDetails[1], - "uuid":partitionUuid} - groupDict[groupOrder] = partitionDict - - serverList = [] - groupOrderList = groupDict.keys() - groupOrderList.sort() - for groupOrder in groupOrderList: - partitionOrderList = groupDict[groupOrder].keys() - partitionOrderList.sort() - for partitionOrder in partitionOrderList: - serverList.append(groupDict[groupOrder][partitionOrder]) - - return serverList - - -def getSortedServerPartitionList(serverGroupElements): - serverPartitionDict = {} - groupOrderList = [] - serverList = [] - partitionDom = XDOM() - for group in serverGroupElements: - if not group: - continue - groupOrderE = group.getElementsByTagName("order") - if not (groupOrderE and groupOrderE[0].childNodes): - return None - value = int(XDOM.getText(groupOrderE[0].childNodes)) - if value > 0: - groupOrderList.append(value) - partitionDict = {} - for partition in group.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - - partitionName = partitionDom.getTextByTagRoute("name") - if not partitionName: - return None - partitionOrder = partitionDom.getTextByTagRoute("order") - if not partitionOrder: - return None - partitionUuid = partitionDom.getTextByTagRoute("uuid") - partitionDict[int(partitionOrder)] = [partitionName, partitionUuid] - serverPartitionDict[value] = partitionDict - groupOrderList.sort() - - for groupOrder in groupOrderList: - items = serverPartitionDict[groupOrder].items() - items.sort(key = itemgetter(0)) - serverList = serverList + [ items[i][1] for i in range(0,len(items))] - return serverList - - -def clearExportDirectory(serverList, volumeName, volumeUuid): - thisServerName = getCurrentServerName() - for exportServer in serverList: - serverName, partition = exportServer[0].split(":") - if thisServerName != serverName: - continue - partitionUuid = getUuidByDiskPartition(getDevice(partition)) - if not partitionUuid: - log("unable to find uuid of partition %s" % partition) - return False - volumeDirName = "%s/%s/%s" % (Globals.GLUSTER_LUN_DIR, partitionUuid, volumeUuid) - if os.path.exists(volumeDirName): - ## Removing /data/PARTITION-UUID/VOLUME-UUID/ - ## TODO: Get an option to remove it at this time - if runCommandFG("mv -f %s %s.delete" % (volumeDirName, volumeDirName), root=True) != 0: - return False - if runCommandFG("rm -f %s/%s/volumes/%s" % (Globals.GLUSTER_LUN_DIR, partitionUuid, volumeName), root=True) != 0: - return False - return True - - -def createExportDirectory(serverList, volumeName, volumeUuid): - thisServerName = getCurrentServerName() - tempVolumeNameFile = getTempFileName() - - try: - fp = open(tempVolumeNameFile, "w") - fp.write("VOLUME_NAME=%s\n" % volumeName) - fp.write("VOLUME_UUID=%s\n" % volumeUuid) - fp.close() - except IOError, e: - log("failed to create temporary file for volume-name: %s" % (volumeName, str(e))) + Utils.log("Failed to remove file %s: %s" % (volumeFile, str(e))) return False - for exportServer in serverList: - serverName, partition = exportServer[0].split(":") - if thisServerName != serverName: - continue - partitionUuid = getUuidByDiskPartition(getDevice(partition)) - if not partitionUuid: - log("unable to find uuid of partition %s" % partition) - return False - - volumeDirName = "%s/%s/%s" % (Globals.GLUSTER_LUN_DIR, partitionUuid, volumeUuid) - ## Creating /data/PARTITION-UUID/VOLUME-UUID/ - if runCommandFG("mkdir %s" % volumeDirName, root=True) != 0: - return False - - ## Creating /data/PARTITION-UUID/VOLUME-UUID/exports/ - ## Creating /data/PARTITION-UUID/VOLUME-UUID/exports/brick1/ - if runCommandFG("mkdir -p %s/exports/brick1" % volumeDirName, root=True) != 0: - return False - - ## Creating /data/PARTITION-UUID/VOLUME-UUID/log/ - if runCommandFG("mkdir %s/log" % volumeDirName, root=True) != 0: - return False - - ## Creating /data/PARTITION-UUID/VOLUME-UUID/config/ - if runCommandFG("mkdir %s/config" % volumeDirName, root=True) != 0: - return False - - volumeLinkDirName = "%s/%s/volumes" % (Globals.GLUSTER_LUN_DIR, partitionUuid) - if not os.path.exists(volumeLinkDirName): - if runCommandFG("mkdir %s" % volumeLinkDirName, root=True) != 0: - return False - - ## Creating symlink - ## /data/PARTITION-UUID/volumes/VOLUME-NAME -> /data/PARTITION-UUID/VOLUME-UUID/ - command = "ln -fTs %s %s/%s" % (volumeDirName, - volumeLinkDirName, volumeName) - if runCommandFG(command, root=True) != 0: - return False - - if runCommandFG("cp -f %s %s/config/volume-name" % (tempVolumeNameFile, volumeDirName), root=True) != 0: - return False - - try: - os.remove(tempVolumeNameFile) - except OSError, e: - log("Failed to remove file %s: %s" % (tempVolumeNameFile, str(e))) - - return True - - -def getPartitionListByServerName(volumeDom, serverName, serverPartitionList=None): - partitionList = {} - if serverPartitionList: - for partitionName in serverPartitionList: - partitionUuid = getServerDiskPartitionUuid(serverName, partitionName) - if not partitionUuid: - log(syslog.LOG_ERR, "failed to get disk partition %s uuid of server %s" % (partitionName, serverName)) - return None - partitionList[partitionName] = partitionUuid - return partitionList - for group in volumeDom.getElementsByTagRoute("topology.group"): - for partitionTag in group.getElementsByTagName("partition"): - nameE = partitionTag.getElementsByTagName("name") - if not nameE: - continue - partition = XDOM.getText(nameE[0].childNodes) - if not partition: - continue - server, partitionName = partition.split(":") - if server != serverName: - continue - partitionUuid = getServerDiskPartitionUuid(serverName, partitionName) - if not partitionUuid: - log(syslog.LOG_ERR, "failed to get disk partition %s uuid of server %s" % (partitionName, serverName)) - return None - partitionList[partitionName] = partitionUuid - return partitionList - - -def isVolumeRunning(volumeName): - return Glusterd.isVolumeRunning(volumeName) - -def addVolumeMigrationDetails(sourcePartition, destinationPartition, volumeName): - migrationDom = XDOM() - if not os.path.exists(Globals.VOLUME_MIGRATION_LIST_FILE): - migrationDom.appendTagRoute("volume-migration") - else: - if not migrationDom.parseFile(Globals.VOLUME_MIGRATION_LIST_FILE): - log("Failed to load volume-migration.xml file") - return None - migrationList = migrationDom.getElementsByTagRoute("volume-migration.migration") - for tagE in migrationList: - dom = XDOM() - dom.setDomObj(tagE) - if dom.getTextByTagRoute("source-partition") == sourcePartition and \ - dom.getTextByTagRoute("destination-partition") == destinationPartition and \ - dom.getTextByTagRoute("volume-name") == volumeName: - return False - migrationTag = migrationDom.getElementsByTagRoute("volume-migration") - if not migrationTag: - return None - partitionTag = migrationDom.createTag("migration") - partitionTag.appendChild(migrationDom.createTag("source-partition", sourcePartition)) - partitionTag.appendChild(migrationDom.createTag("destination-partition", destinationPartition)) - partitionTag.appendChild(migrationDom.createTag("volume-name", volumeName)) - migrationTag[0].appendChild(partitionTag) - if not migrationDom.writexml(Globals.VOLUME_MIGRATION_LIST_FILE): - log("Unable to write disk migration details into %s/volume-migration.xml" % Globals.GLUSTER_BASE_DIR) - return False - return True - - -def removeVolumeMigrationDetails(sourcePartition, destinationPartition, volumeName): - migrationDom = XDOM() - if not os.path.exists(Globals.VOLUME_MIGRATION_LIST_FILE): - return None - if not migrationDom.parseFile(Globals.VOLUME_MIGRATION_LIST_FILE): - log("Failed to load volume-migration.xml file") - return None - migrationList = migrationDom.getElementsByTagRoute("volume-migration.migration") - for tagE in migrationList: - dom = XDOM() - dom.setDomObj(tagE) - if dom.getTextByTagRoute("source-partition") == sourcePartition and \ - dom.getTextByTagRoute("destination-partition") == destinationPartition and \ - dom.getTextByTagRoute("volume-name") == volumeName: - migrationDom.getElementsByTagRoute("volume-migration")[0].removeChild(tagE) - if not migrationDom.writexml(Globals.VOLUME_MIGRATION_LIST_FILE): - log("Unable to write disk migration details into %s/volume-migration.xml" % Globals.GLUSTER_BASE_DIR) - return False - return True - - -def addPartitionMigrationDetails(sourcePartition, destinationPartition, volumeList=None): - migrationDom = XDOM() - if not os.path.exists(Globals.MIGRATE_PARTITION_LIST_FILE): - migrationDom.appendTagRoute("partition-migration") - else: - if not migrationDom.parseFile(Globals.MIGRATE_PARTITION_LIST_FILE): - log("Failed to load migration.xml file") - return None - migrationList = migrationDom.getElementsByTagRoute("partition-migration.migration") - for tagE in migrationList: - dom = XDOM() - dom.setDomObj(tagE) - if dom.getTextByTagRoute("source-partition") == sourcePartition: - return False - if dom.getTextByTagRoute("destination-partition") == destinationPartition: - return False - migrationTag = migrationDom.getElementsByTagRoute("partition-migration") - if not migrationTag: - return None - partitionTag = migrationDom.createTag("migration") - partitionTag.appendChild(migrationDom.createTag("source-partition", sourcePartition)) - partitionTag.appendChild(migrationDom.createTag("destination-partition", destinationPartition)) - migrationTag[0].appendChild(partitionTag) - if not migrationDom.writexml(Globals.MIGRATE_PARTITION_LIST_FILE): - log("Unable to write disk migration details into %s/migration.xml" % Globals.GLUSTER_BASE_DIR) - return False - if volumeList: - for volumeName in volumeList: - addVolumeMigrationDetails(sourcePartition, destinationPartition, volumeName) - return True - - -def removePartitionMigrationDetails(sourcePartition, destinationPartition, volumeList=None): - migrationDom = XDOM() - if not os.path.exists(Globals.MIGRATE_PARTITION_LIST_FILE): - return None - if not migrationDom.parseFile(Globals.MIGRATE_PARTITION_LIST_FILE): - log("Failed to load migration.xml file") - return None - migrationList = migrationDom.getElementsByTagRoute("partition-migration.migration") - for tagE in migrationList: - dom = XDOM() - dom.setDomObj(tagE) - if dom.getTextByTagRoute("source-partition") == sourcePartition and \ - dom.getTextByTagRoute("destination-partition") == destinationPartition: - migrationDom.getElementsByTagRoute("partition-migration")[0].removeChild(tagE) - if not migrationDom.writexml(Globals.MIGRATE_PARTITION_LIST_FILE): - log("Unable to write disk migration details into %s/migration.xml" % Globals.GLUSTER_BASE_DIR) - return False - if volumeList: - for volumeName in volumeList: - removeVolumeMigrationDetails(sourcePartition, destinationPartition, volumeName) - return True - - -def isMigrationInProgress(partition): - migrationDom = XDOM() - if not os.path.exists(Globals.MIGRATE_PARTITION_LIST_FILE): - return None - if not migrationDom.parseFile(Globals.MIGRATE_PARTITION_LIST_FILE): - log("Failed to load migration.xml file") - return None - migrationList = migrationDom.getElementsByTagRoute("partition-migration.migration") - for tagE in migrationList: - dom = XDOM() - dom.setDomObj(tagE) - if migrationDom.getTextByTagRoute("source-partition") == partition or \ - migrationDom.getTextByTagRoute("destination-partition") == partition: - return True - return False - - -def getServerDiskPartitionUuid(serverName, partition): - diskConfigDom = XDOM() - if not diskConfigDom.parseFile("%s/%s/disk.xml" % (Globals.SERVER_CONF_DIR, serverName)): - return None - for disk in diskConfigDom.getElementsByTagRoute("disks.disk"): - diskDom = XDOM() - diskDom.setDomObj(disk) - partitionList = diskDom.getElementsByTagRoute("partition") - for tagE in partitionList: - partitionDom = XDOM() - partitionDom.setDomObj(tagE) - if partitionDom.getTextByTagRoute("device") == partition: - return partitionDom.getTextByTagRoute("uuid") - - -def getVolumeServerList(requestDom, requestFlag=True): - if requestFlag: - serverGroupElementList = requestDom.getElementsByTagRoute("command.volume.topology.group") - else: - serverGroupElementList = requestDom.getElementsByTagRoute("volume.topology.group") - if not serverGroupElementList: - return None - serverList = [] - partitionDom = XDOM() - for group in serverGroupElementList: - for partition in group.getElementsByTagName("partition"): - partitionDom.setDomObj(partition) - partitionName = partitionDom.getTextByTagRoute("name") - if not partitionName: - continue - serverPartition = partitionName.split(":") - if not(len(serverPartition) > 1 and serverPartition[1]): - return None - if serverPartition[0] not in serverList: - serverList.append(serverPartition[0]) - return serverList - - -def getVolumeServerListByName(volumeName): - serverList = [] - serverDom = XDOM() - volumeDom = XDOM() - if not os.path.exists("%s/%s.xml" % (Globals.VOLUME_CONF_DIR, volumeName)): - return False - if not volumeDom.parseFile("%s/%s.xml" % (Globals.VOLUME_CONF_DIR, volumeName)): - return False - return getVolumeServerList(volumeDom, False) - - -def getMigrateVolumeServerPartitionInfo(volumeName): - volumeMigrationDom = XDOM() - if not volumeMigrationDom.parseFile(Globals.VOLUME_MIGRATION_LIST_FILE): - Utils.log("Failed to parse file %s" % Globals.VOLUME_MIGRATION_LIST_FILE) - return None - volumeInfo = {} - dom = XDOM() - for tagE in volumeMigrationDom.getElementsByTagRoute("volume-migration.migration"): - dom.setDomObj(tagE) - if dom.getTextByTagRoute("volume-name") == volumeName: - volumeInfo['Name'] = volumeName - volumeInfo['SourcePartition'] = dom.getTextByTagRoute("source-partition") - volumeInfo['DestinationPartition'] = dom.getTextByTagRoute("destination-partition") - return volumeInfo - return None diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_file.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_file.py deleted file mode 100755 index 265823ab..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_file.py +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com> -# This file is part of Gluster Storage Platform. -# - -import Globals -import Utils -from VolumeUtils import * -from XmlHandler import ResponseXml - - -def enumLogType(logCode): - if "M" == logCode.upper(): - return "EMERGENCY" - elif "A" == logCode.upper(): - return "ALERT" - elif "C" == logCode.upper(): - return "CRITICAL" - elif "E" == logCode.upper(): - return "ERROR" - elif "W" == logCode.upper(): - return "WARNING" - elif "N" == logCode.upper(): - return "NOTICE" - elif "I" == logCode.upper(): - return "INFO" - elif "D" == logCode.upper(): - return "DEBUG" - elif "T" == logCode.upper(): - return "TRACE" - else: - return "UNKNOWN" -##--end of enumLogType() - - -def addLog(responseDom, logMessageTag, loginfo): - logTag = responseDom.createTag("log", None) - logTag.appendChild(responseDom.createTag("date", loginfo[0])) - logTag.appendChild(responseDom.createTag("time", loginfo[1])) - logTag.appendChild(responseDom.createTag("type", enumLogType(loginfo[2]))) - logTag.appendChild(responseDom.createTag("message", loginfo[3])) - logMessageTag.appendChild(logTag) - return True -##--end of addLog() - - -def logSplit(log): - loginfo = log.strip().split(None, 3) - loginfo[0] = loginfo[0][1:] #-- Remove '[' - loginfo[1] = loginfo[1][0:-1] #-- Remove ']' - return loginfo -##--end of logSplit() - - -def getVolumeLog(volumeName, tailCount): - rs = ResponseXml() - if not volumeName: - rs.appendTagRoute("status.code", "-1") - rs.appendTagRoute("status.message", "No volume name given") - return rs.toprettyxml() - - if not tailCount: - rs.appendTagRoute("status.code", "-1") - rs.appendTagRoute("status.message", "No tail count given") - return rs.toprettyxml() - - thisServerName = getCurrentServerName() - if not thisServerName: - rs.appendTagRoute("status.code", "-2") - rs.appendTagRoute("status.message", "Failed to get current server name") - return rs.toprettyxml() - - volumeDom = XDOM() - partitionList = getPartitionListByServerName(volumeDom, thisServerName) - if not partitionList: - rs.appendTagRoute("status.code", "-3") - rs.appendTagRoute("status.message", "Failed to get server partition details") - return rs.toprettyxml() - - pattern = '\[\d{4}-\d{2}-\d{2}\s{1}\d{2}:\d{2}:\d{2}.\d+\]\s{1}([MACEWNIDT]){1}\s+' - logMessagesTag = rs.createTag("response.logMessages") - for partitionName in partitionList: - logMessageTag = rs.createTag("logMessage") - logMessageTag.appendChild("disk", "%s:%s" % (thisServerName, partitionName)) - - logDirectory = "%s/%s/%s/log" % (Globals.GLUSTER_LUN_DIR, partitionList[partitionName], volumeUuid) - logFileName = "%s/%s-%s-%s-exports-brick1.log" % (logDirectory, - Globals.GLUSTER_LUN_DIR[1:], - partitionList[partitionName], - volumeUuid) - if not os.path.exists(logFileName): - Utils.log("volume log file not found %s" % logFileName) - continue - fp = open(logFileName) - lines = [line for line in fp if re.match(pattern, line)] - fp.close() - i = len(lines) - int(tailCount) - if i < 0: - i = 0 - for log in lines[i:]: - loginfo = logSplit(log) - addLog(rs, logMessageTag, loginfo) - logMessagesTag.appendChild(logMessageTag) - return rs.toprettyxml() -##--end of getVolumeLog() - -def main(): - if len(sys.argv) != 3: - print >> sys.stderr, "usage: %s <disk name> <volume name>" % sys.argv[0] - sys.exit(-1) - - volumeName = sys.argv[1] - tailCount = sys.argv[2] - print getVolumeLog(volumeName, tailCount) - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py index ccd5815b..5c5b4c4a 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py @@ -15,6 +15,7 @@ import dbus import socket import re import Utils +import Protocol import DiskUtils from NetworkUtils import * from Disk import * @@ -22,10 +23,153 @@ from XmlHandler import ResponseXml from optparse import OptionParser +def getDiskDom(): + diskInfo = DiskUtils.getDiskInfo() + if not diskInfo: + return None + procMdstat = DiskUtils.getProcMdstat() + diskDom = Protocol.XDOM() + disksTag = diskDom.createTag("disks", None) + diskTagDict = {} + raidDisksTag = diskDom.createTag("raidDisks", None) + for raidDiskName, raidDisk in procMdstat.iteritems(): + raidDiskTag = diskDom.createTag("disk", None) + raidDiskTag.appendChild(diskDom.createTag("name", raidDiskName)) + raidDiskTag.appendChild(diskDom.createTag("description", diskInfo[raidDiskName]['Description'])) + raidDiskTag.appendChild(diskDom.createTag("uuid", diskInfo[raidDiskName]['Uuid'])) + raidDiskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + raidDiskTag.appendChild(diskDom.createTag("mountPoint", diskInfo[raidDiskName]['MountPoint'])) + raidDiskTag.appendChild(diskDom.createTag("fsType", diskInfo[raidDiskName]['FsType'])) + if diskInfo[raidDiskName]['FsType']: + raidDiskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + else: + raidDiskTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + raidDiskTag.appendChild(diskDom.createTag("interface")) + raidDiskTag.appendChild(diskDom.createTag("fsVersion")) + raidDiskTag.appendChild(diskDom.createTag("size", diskInfo[raidDiskName]['Size'] / 1024.0)) + raidDiskTag.appendChild(diskDom.createTag("spaceInUse", diskInfo[raidDiskName]['SpaceInUse'])) + raidDisksTag.appendChild(raidDiskTag) + for raidMember in raidDisk['Member']: + # Case1: Raid array member is a disk. The following code will add the disk details under a disk tag + if diskInfo.has_key(raidMember): + diskTag = diskDom.createTag("disk", None) + diskTag.appendChild(diskDom.createTag("name", raidMember)) + diskTag.appendChild(diskDom.createTag("description", diskInfo[raidMember]["Description"])) + diskTag.appendChild(diskDom.createTag("uuid", diskInfo[raidMember]["Uuid"])) + if DiskUtils.isDiskInFormatting(raidMember): + diskTag.appendChild(diskDom.createTag("status", "INITIALIZING")) + else: + if diskInfo[raidMember]["FsType"]: + diskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + else: + diskTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + diskTag.appendChild(diskDom.createTag("interface", diskInfo[raidMember]["Interface"])) + diskTag.appendChild(diskDom.createTag("mountPoint", diskInfo[raidMember]["MountPoint"])) + if diskInfo[raidMember]["FsType"]: + diskTag.appendChild(diskDom.createTag("type", "DATA")) + else: + diskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + diskTag.appendChild(diskDom.createTag("fsType", diskInfo[raidMember]["FsType"])) + diskTag.appendChild(diskDom.createTag("fsVersion", diskInfo[raidMember]["FsVersion"])) + diskTag.appendChild(diskDom.createTag("size", diskInfo[raidMember]["Size"] / 1024.0)) + diskTag.appendChild(diskDom.createTag("spaceInUse", diskInfo[raidMember]["SpaceInUse"])) + raidDiskTag.appendChild(diskTag) + del diskInfo[raidMember] + continue + # Case2: Raid array member is a partition. The following code will add the partition and its corresponding disk its belong to. + for disk, item in diskInfo.iteritems(): + if not item['Partitions'].has_key(raidMember): + continue + if not diskTagDict.has_key(disk): + diskTag = diskDom.createTag("disk", None) + diskTag.appendChild(diskDom.createTag("name", disk)) + diskTag.appendChild(diskDom.createTag("description", item["Description"])) + diskTag.appendChild(diskDom.createTag("uuid", item["Uuid"])) + diskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + diskTag.appendChild(diskDom.createTag("interface", item["Interface"])) + diskTag.appendChild(diskDom.createTag("mountPoint")) + diskTag.appendChild(diskDom.createTag("type", "DATA")) + diskTag.appendChild(diskDom.createTag("fsType", item["FsType"])) + diskTag.appendChild(diskDom.createTag("fsVersion", item["FsVersion"])) + diskTag.appendChild(diskDom.createTag("size", item["Size"] / 1024.0)) + diskTag.appendChild(diskDom.createTag("spaceInUse", item["SpaceInUse"])) + partitionsTag = diskDom.createTag("partitions", None) + diskTag.appendChild(partitionsTag) + raidDiskTag.appendChild(diskTag) + # Constructed disk tag will be added to the dictonary. + # This will be used to keep add all the corresponding partitions tags of the disk to the disk tag. + diskTagDict[disk] = {'diskTag': diskTag, 'partitionsTag': partitionsTag} + # adding partition details under this disk tag + partitionTag = diskDom.createTag("partition", None) + partitionTag.appendChild(diskDom.createTag("name", raidMember)) + partitionTag.appendChild(diskDom.createTag("uuid", item['Partitions'][raidMember]["Uuid"])) + partitionTag.appendChild(diskDom.createTag("fsType", item['Partitions'][raidMember]["FsType"])) + if item['Partitions'][raidMember]["FsType"]: + partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "DATA")) + else: + partitionTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + partitionTag.appendChild(diskDom.createTag("mountPoint", item['Partitions'][raidMember]['MountPoint'])) + partitionTag.appendChild(diskDom.createTag("size", item['Partitions'][raidMember]["Size"] / 1024.0)) + partitionTag.appendChild(diskDom.createTag("spaceInUse", item['Partitions'][raidMember]["SpaceInUse"])) + diskTagDict[disk]['partitionsTag'].appendChild(partitionTag) + # deleting partition entry of a raid member from diskInfo (item['Partitions']) + del item['Partitions'][raidMember] + del diskInfo[raidDiskName] + disksTag.appendChild(raidDisksTag) + for diskName, value in diskInfo.iteritems(): + diskTag = diskDom.createTag("disk", None) + diskTag.appendChild(diskDom.createTag("name", diskName)) + diskTag.appendChild(diskDom.createTag("description", value["Description"])) + diskTag.appendChild(diskDom.createTag("uuid", value["Uuid"])) + if DiskUtils.isDiskInFormatting(diskName): + status = "INITIALIZING" + else: + if value["FsType"]: + status = "INITIALIZED" + else: + status = "UNINITIALIZED" + diskTag.appendChild(diskDom.createTag("status", status)) + diskTag.appendChild(diskDom.createTag("interface", value["Interface"])) + if value["MountPoint"] and value["MountPoint"] in ["/", "/boot"]: + diskTag.appendChild(diskDom.createTag("type", "BOOT")) + elif "UNINITIALIZED" == status: + diskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + else: + diskTag.appendChild(diskDom.createTag("type", "DATA")) + diskTag.appendChild(diskDom.createTag("fsType", value["FsType"])) + diskTag.appendChild(diskDom.createTag("fsVersion", value["FsVersion"])) + diskTag.appendChild(diskDom.createTag("mountPoint", value["MountPoint"])) + diskTag.appendChild(diskDom.createTag("size", value["Size"] / 1024.0)) + diskTag.appendChild(diskDom.createTag("spaceInUse", value["SpaceInUse"])) + partitionsTag = diskDom.createTag("partitions", None) + diskTag.appendChild(partitionsTag) + for partName, partValues in value['Partitions'].iteritems(): + partitionTag = diskDom.createTag("partition", None) + partitionTag.appendChild(diskDom.createTag("name", partName)) + partitionTag.appendChild(diskDom.createTag("uuid", partValues["Uuid"])) + partitionTag.appendChild(diskDom.createTag("fsType", partValues["FsType"])) + if partValues["FsType"]: + partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "DATA")) + else: + partitionTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + partitionTag.appendChild(diskDom.createTag("mountPoint", partValues['MountPoint'])) + partitionTag.appendChild(diskDom.createTag("size", partValues["Size"] / 1024.0)) + partitionTag.appendChild(diskDom.createTag("spaceInUse", partValues["SpaceInUse"])) + partitionsTag.appendChild(partitionTag) + continue + disksTag.appendChild(diskTag) + diskDom.addTag(disksTag) + return diskDom + + def getServerDetails(listall): serverName = socket.getfqdn() - meminfo = getMeminfo() - cpu = getCpuUsageAvg() + meminfo = Utils.getMeminfo() + cpu = Utils.getCpuUsageAvg() nameServerList, domain, searchDomain = readResolvConfFile() if not domain: domain = [None] @@ -57,7 +201,7 @@ def getServerDetails(listall): deviceList[device["device"]] = device try: macAddress = open("/sys/class/net/%s/address" % device["device"]).read().strip() - except IOError: + except IOError, e: continue interfaceTag = responseDom.createTag("networkInterface", None) interfaceTag.appendChild(responseDom.createTag("name", device["device"])) @@ -88,12 +232,7 @@ def getServerDetails(listall): responseDom.appendTag(serverTag) serverTag.appendChild(responseDom.createTag("numOfCPUs", int(os.sysconf('SC_NPROCESSORS_ONLN')))) - try: - diskDom = DiskUtils.getDiskDom() - except dbus.dbus_bindings.DBusException, e: - sys.stderr.write("%s. Please check if HAL services are running\n" % str(e)) - Utils.log("failed to get disk details :%s" % str(e)) - sys.exit(1) + diskDom = getDiskDom() if not diskDom: sys.stderr.write("No disk found!") Utils.log("Failed to get disk details") diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_log.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_log.py deleted file mode 100755 index c4c97a51..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_log.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com> -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -from VolumeUtils import * -from XmlHandler import ResponseXml - - -def enumLogType(logCode): - if "M" == logCode.upper(): - return "EMERGENCY" - elif "A" == logCode.upper(): - return "ALERT" - elif "C" == logCode.upper(): - return "CRITICAL" - elif "E" == logCode.upper(): - return "ERROR" - elif "W" == logCode.upper(): - return "WARNING" - elif "N" == logCode.upper(): - return "NOTICE" - elif "I" == logCode.upper(): - return "INFO" - elif "D" == logCode.upper(): - return "DEBUG" - elif "T" == logCode.upper(): - return "TRACE" - else: - return "UNKNOWN" -##--end of enumLogType() - - -def addLog(responseDom, logMessageTag, loginfo): - logTag = responseDom.createTag("log", None) - logTag.appendChild(responseDom.createTag("date", loginfo[0])) - logTag.appendChild(responseDom.createTag("time", loginfo[1])) - logTag.appendChild(responseDom.createTag("type", enumLogType(loginfo[2]))) - logTag.appendChild(responseDom.createTag("message", loginfo[3])) - logMessageTag.appendChild(logTag) - return True -##--end of addLog() - - -def logSplit(log): - loginfo = log.strip().split(None, 3) - loginfo[0] = loginfo[0][1:] #-- Remove '[' - loginfo[1] = loginfo[1][0:-1] #-- Remove ']' - return loginfo -##--end of logSplit() - - -def getVolumeLog(volumeName, tailCount): - rs = ResponseXml() - if not volumeName: - rs.appendTagRoute("status.code", "-1") - rs.appendTagRoute("status.message", "No volume name given") - return rs.toprettyxml() - - if not tailCount: - rs.appendTagRoute("status.code", "-1") - rs.appendTagRoute("status.message", "No tail count given") - return rs.toprettyxml() - - thisServerName = getCurrentServerName() - if not thisServerName: - rs.appendTagRoute("status.code", "-2") - rs.appendTagRoute("status.message", "Failed to get current server name") - return rs.toprettyxml() - - volumeDom = XDOM() - partitionList = getPartitionListByServerName(volumeDom, thisServerName) - if not partitionList: - rs.appendTagRoute("status.code", "-3") - rs.appendTagRoute("status.message", "Failed to get server partition details") - return rs.toprettyxml() - - pattern = '\[\d{4}-\d{2}-\d{2}\s{1}\d{2}:\d{2}:\d{2}.\d+\]\s{1}([MACEWNIDT]){1}\s+' - logMessagesTag = rs.createTag("response.logMessages") - for partitionName in partitionList: - logMessageTag = rs.createTag("logMessage") - logMessageTag.appendChild("disk", "%s:%s" % (thisServerName, partitionName)) - - logDirectory = "%s/%s/%s/log" % (Globals.GLUSTER_LUN_DIR, partitionList[partitionName], volumeUuid) - logFileName = "%s/%s-%s-%s-exports-brick1.log" % (logDirectory, - Globals.GLUSTER_LUN_DIR[1:], - partitionList[partitionName], - volumeUuid) - if not os.path.exists(logFileName): - Utils.log("volume log file not found %s" % logFileName) - continue - fp = open(logFileName) - lines = [line for line in fp if re.match(pattern, line)] - fp.close() - i = len(lines) - int(tailCount) - if i < 0: - i = 0 - for log in lines[i:]: - loginfo = logSplit(log) - addLog(rs, logMessageTag, loginfo) - logMessagesTag.appendChild(logMessageTag) - return rs.toprettyxml() -##--end of getVolumeLog() - -def main(): - if len(sys.argv) != 3: - print >> sys.stderr, "usage: %s <disk name> <volume name>" % sys.argv[0] - sys.exit(-1) - - volumeName = sys.argv[1] - tailCount = sys.argv[2] - print getVolumeLog(volumeName, tailCount) - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_cpu_details.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_cpu_details.py deleted file mode 100755 index 9f93b84b..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_cpu_details.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com> -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -from XmlHandler import ResponseXml -import Utils - -def createMemData(file, step): - rs = ResponseXml() - command = ["rrdtool", "create", file, "--step=%s" % step, - "DS:user:COUNTER:600:0:U", - "DS:system:COUNTER:600:0:U", - "DS:idle:COUNTER:600:0:U", - "RRA:AVERAGE:0.5:1:576", - "RRA:AVERAGE:0.5:6:672", - "RRA:AVERAGE:0.5:24:732", - "RRA:AVERAGE:0.5:144:1460"] - - rv = Utils.runCommand(command, output=True, root=True) - message = Utils.stripEmptyLines(rv["Stdout"]) - if rv["Stderr"]: - error = Utils.stripEmptyLines(rv["Stderr"]) - message += "Error: [%s]" % (error) - Utils.log("failed to create RRD file for cpu usages %s" % file) - rs.appendTagRoute("status.code", rv["Status"]) - rs.appendTagRoute("status.message", message) - return rs.toxml() - return None - -def updateMemData(file): - rs = ResponseXml() - user = None - system = None - idle = None - for line in open("/proc/stat").readlines(): - if line.startswith("cpu"): - cpudetails = line.split() - if "cpu" == cpudetails[0]: - user = cpudetails[1] - system = cpudetails[3] - idle = cpudetails[4] - break - - if None == user: - Utils.log("failed to fetch cpu details from /proc/stat") - rs.appendTagRoute("status.code", "-1") - rs.appendTagRoute("status.message", "failed to fetch cpu details") - return rs.toxml() - - command = ["rrdtool", "update", file, "-t", "user:system:idle", - "N:%s:%s:%s" % (user, system, idle)] - rv = Utils.runCommand(command, output=True, root=True) - if rv["Stderr"]: - error = Utils.stripEmptyLines(rv["Stderr"]) - message = "Error: [%s]" % (error) - Utils.log("failed to update cpu usage into rrd file %s" % file) - rs.appendTagRoute("status.code", rv["Status"]) - rs.appendTagRoute("status.message", message) - return rs.toxml() - return None - - -def main(): - cpuRrdFile = "/var/lib/rrd/cpu.rrd" - if not os.path.exists(cpuRrdFile): - status = createMemData(cpuRrdFile, 100) - if status: - print status - status = updateMemData(cpuRrdFile) - if status: - print status - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_memory_details.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_memory_details.py deleted file mode 100755 index 2639d490..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_update_memory_details.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com> -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -from XmlHandler import ResponseXml -import Utils - -def createMemData(file, step): - rs = ResponseXml() - command = ["rrdtool", "create", file, "--step=%s" % step, - "DS:memused:ABSOLUTE:600:0:U", - "DS:memfree:ABSOLUTE:600:0:U", - "DS:memcache:ABSOLUTE:600:0:U", - "DS:swapused:ABSOLUTE:600:0:U", - "DS:swapfree:ABSOLUTE:600:0:U", - "RRA:AVERAGE:0.5:1:576", - "RRA:AVERAGE:0.5:6:672", - "RRA:AVERAGE:0.5:24:732", - "RRA:AVERAGE:0.5:144:1460"] - - rv = Utils.runCommand(command, output=True, root=True) - message = Utils.stripEmptyLines(rv["Stdout"]) - if rv["Stderr"]: - error = Utils.stripEmptyLines(rv["Stderr"]) - message += "Error: [%s]" % (error) - Utils.log("failed to create RRD file for memory usages %s" % file) - rs.appendTagRoute("status.code", rv["Status"]) - rs.appendTagRoute("status.message", message) - return rs.toxml() - return None - -def updateMemData(file): - rs = ResponseXml() - command = ["free", "-b", "-o"] - rv = Utils.runCommand(command, output=True, root=True) - if rv["Stderr"]: - error = Utils.stripEmptyLines(rv["Stderr"]) - message += "Error: [%s]" % (error) - Utils.log("failed to retrieve memory details") - rs.appendTagRoute("status.code", rv["Status"]) - rs.appendTagRoute("status.message", message) - return rs.toxml() - - message = rv["Stdout"].split() - command = ["rrdtool", "update", file, "-t", "memused:memfree:memcache:swapused:swapfree", - "N:%s:%s:%s:%s:%s" % (message[8], message[9], message[12], message[14], message[15])] - rv = Utils.runCommand(command, output=True, root=True) - if rv["Stderr"]: - error = Utils.stripEmptyLines(rv["Stderr"]) - message += "Error: [%s]" % (error) - Utils.log(syslog.LOG_ERR, "failed to update memory usage into rrd file %s" % file) - rs.appendTagRoute("status.code", rv["Status"]) - rs.appendTagRoute("status.message", message) - return rs.toxml() - return None - - -def main(): - #if len(sys.argv) != 2: - # print >> sys.stderr, "usage: %s <step>" % sys.argv[0] - # sys.exit(-1) - #step = sys.argv[1] - - memRrdFile = "mem.rrd" - if not os.path.exists(memRrdFile): - status = createMemData(memRrdFile, 100) - if status: - print status - status = updateMemData(memRrdFile) - if status: - print status - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py b/src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py index ea37fa92..26a74bfd 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py @@ -11,71 +11,33 @@ SERVER_PORT = 24731 DEFAULT_BACKLOG = 5 DEFAULT_TIMEOUT = 3 DEFAULT_ID_LENGTH = 16 - GLUSTER_PLATFORM_VERSION = "3.2" ## System configuration constants SYSCONFIG_NETWORK_DIR = "/etc/sysconfig/network-scripts" -DNSMASQ_CONF_DIR = "/etc/dnsmasq.d" - FSTAB_FILE = "/etc/fstab" -NFS_EXPORTS_FILE = "/etc/exports" SAMBA_CONF_FILE = "/etc/samba/smb.conf" -TIMEZONE_FILE = "/etc/timezone" -ZONEINFO_DIR = "/usr/share/zoneinfo" -LOCALTIME_FILE = "/etc/localtime" -KERBEROS_CONF_FILE = "/etc/krb5.conf" -NSSWITCH_CONF_FILE = "/etc/nsswitch.conf" -NTP_CONF_FILE = "/etc/ntp.conf" +REAL_SAMBA_CONF_FILE = "/etc/samba/real.smb.conf" MODPROBE_CONF_FILE = "/etc/modprobe.d/bonding.conf" -SYSCONFIG_NETWORK_FILE = "/etc/sysconfig/network" RESOLV_CONF_FILE = "/etc/resolv.conf" DNSMASQ_LEASE_FILE = "/var/tmp/dnsmasq.leases" LIVE_MODE_FILE = "/etc/live" -ADD_SERVER_COMPLETED_FILE = "/var/tmp/installation-completed" - -DNSMASQ_DNS_CONF_FILE = DNSMASQ_CONF_DIR + "/dns.conf" +DNSMASQ_CONF_DIR = "/etc/dnsmasq.d" DNSMASQ_DHCP_CONF_FILE = DNSMASQ_CONF_DIR + "/dhcp.conf" -## - -## Base constants -MAX_PARTITION_SIZE = 16777216 # 16 TB -OS_PARTITION_SIZE = 4000 # 4 GB -SESSION_TIMEOUT = 1800 # 30 minutes -SERVER_AGENT_PORT = 50000 - -BOOT_PARTITION_LABEL = "GLUSTEROS" DATA_PARTITION_LABEL = "GLUSTERDATA" VOLUME_USER_DESCRIPTION = "Gluster Volume User" -SERVER_AGENT_RUN_USERNAME = "gluster" +GLUSTER_BASE_DIR = "/etc/glustermg" +REEXPORT_DIR = "/reexport" +CIFS_EXPORT_DIR = "/cifs" +GLUSTER_UPDATES_FILE = "updates.xml" INSTALLER_SERVER_NAME = "$installer$" -GLUSTER_BASE_DIR = "/etc/glustermg" -GLUSTER_LUN_DIR = "/data" -REEXPORT_DIR = "/reexport" -NFS_EXPORT_DIR = "/nfs" -CIFS_EXPORT_DIR = "/cifs" -WEBDAV_DOCUMENT_ROOT_DIR = "/var/www/html" -UPDATES_DIR = "/UPDATES" -TRANSPORT_HOME_DIR = "/transport" -GLUSTERFS_LOG_DIR = "/var/log/glusterfs" -LOG_DIR = "/var/log/glustermg" - -GLUSTER_UPDATES_FILE = "updates.xml" -INSTALLER_STATUS_FILE = "/var/log/install-server-status.log" -INSTALL_PLATFORM_LOCK_FILE = "/var/lock/install-gluster-platform.lock" -LAST_ACCESSED_NETWORK_FILE = "last-accessed-network" -PREPARE_DATA_DISK_LOCK_FILE = "/var/tmp/prepare-data-disk.lock" -## - ## Derived constants GLUSTER_CONF_DIR = GLUSTER_BASE_DIR + "/conf" GLUSTER_TMP_DIR = GLUSTER_BASE_DIR + "/tmp" VOLUME_CONF_DIR = GLUSTER_BASE_DIR + "/volumes" SERVER_CONF_DIR = GLUSTER_BASE_DIR + "/servers" DNS_RECORDS_DIR = GLUSTER_BASE_DIR + "/dns-records" -INSTALLER_CONF_DIR = SERVER_CONF_DIR + "/" + INSTALLER_SERVER_NAME - GSN_USER_INFO_FILE = GLUSTER_BASE_DIR + "/gsn-user.info" GLUSTER_VERSION_FILE = GLUSTER_BASE_DIR + "/version" GLUSTER_UPDATE_SITE_FILE = GLUSTER_BASE_DIR + "/update-site" @@ -86,37 +48,12 @@ SERVER_COUNT_FILE = GLUSTER_BASE_DIR + "/server-count" SIGNATURE_FILE = GLUSTER_BASE_DIR + "/.signature" GLUSTER_SERVER_POOL_FILE = GLUSTER_BASE_DIR + "/pool" GLUSTER_ADMIN_FILE = GLUSTER_BASE_DIR + "/.password" - +INSTALLER_CONF_DIR = SERVER_CONF_DIR + "/" + INSTALLER_SERVER_NAME VOLUME_SMBCONF_FILE = VOLUME_CONF_DIR + "/volumes.smbconf.list" - GLOBAL_NETWORK_FILE = INSTALLER_CONF_DIR + "/network.xml" -INSTALL_SERVER_CONF_FILE = INSTALLER_CONF_DIR + "/installer.xml" -INSTALLER_INFO_FILE = INSTALLER_CONF_DIR + "/installer.info" INSTALLED_SERVER_COUNT_FILE = INSTALLER_CONF_DIR + "/installed-server-count" -SESSION_FILE = GLUSTER_TMP_DIR + "/login.sessions" - -GENERAL_LOG_FILE = LOG_DIR + "/general.log" -INSTALLER_LOG_FILE = LOG_DIR + "/installer.log" -PEER_AGENT_LOG_FILE = LOG_DIR + "/peeragent.log" -SERVER_AGENT_LOG_FILE = LOG_DIR + "/serveragent.log" -TRANSPORT_AGENT_LOG_FILE = LOG_DIR + "/transport.log" -## - - -## Global variables -## TODO: These should be removed -DOWNLOAD_GLUSTER_UPDATE_PROCESS = None -DOWNLOAD_GLUSTER_UPDATE_LEVEL = None -DOWNLOAD_GLUSTER_CURRENT_UPDATE_LEVEL = None -DOWNLOAD_GLUSTER_UPDATE_MD5SUM = None -REQUEST_MAP = {} -VERSION_DICTONARY = {} -## - AWS_WEB_SERVICE_URL = "http://169.254.169.254/latest" -REAL_SAMBA_CONF_FILE = "/etc/samba/real.smb.conf" - DEFAULT_UID = 1024000 CIFS_USER_FILE = "/opt/glustermg/etc/users.cifs" CIFS_VOLUME_FILE = "/opt/glustermg/etc/volumes.cifs" diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/Protocol.py b/src/com.gluster.storage.management.gateway.scripts/src/common/Protocol.py index a11164f7..9649e534 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/common/Protocol.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/common/Protocol.py @@ -189,7 +189,7 @@ class XDOM: self._domObj.writexml(fp, indent, addindent, newl) fp.close() return True - except IOError: + except IOError, e: return False def toString(self, indent=" ", newl="\n", encoding = None): @@ -210,7 +210,7 @@ class XDOM: return None try: return self.getElementsByTagName("command")[0].getAttribute(attributeName) - except IndexError: + except IndexError, e: return False def setAttribute(self, attributeName, attributeValue): @@ -218,7 +218,7 @@ class XDOM: return None try: return self.getElementsByTagName("command")[0].setAttribute(attributeName, attributeValue) - except IndexError: + except IndexError, e: return False def getRequestCommand(self): @@ -269,9 +269,9 @@ class RequestXml(XDOM): self._domObj = MDOM.parse(requestString) elif XML_STRING == type: self._domObj = MDOM.parseString(requestString) - except IOError: + except IOError, e: XDOM.__init__(self) - except xml.parsers.expat.ExpatError: + except xml.parsers.expat.ExpatError, e: XDOM.__init__(self) ##--end of RequestXML diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py b/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py index 03e7eb58..874acaa8 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py @@ -21,12 +21,8 @@ import time import tempfile import grp import pwd -import inspect -from datetime import datetime -import urllib import Globals -import Protocol RUN_COMMAND_ERROR = -1024 LOG_SYSLOG = 1 @@ -35,116 +31,6 @@ LOG_FILE_NAME = None LOG_FILE_OBJ = None logOpened = False -def _getLogCode(priority): - if syslog.LOG_EMERG == priority: - return "M" - elif syslog.LOG_ALERT == priority: - return "A" - elif syslog.LOG_CRIT == priority: - return "C" - elif syslog.LOG_ERR == priority: - return "E" - elif syslog.LOG_WARNING == priority: - return "W" - elif syslog.LOG_NOTICE == priority: - return "N" - elif syslog.LOG_INFO == priority: - return "I" - elif syslog.LOG_DEBUG == priority: - return "D" - else: # UNKNOWN - return "X" - - -def setLogFile(fileName): - global LOG_FILE_NAME - - if fileName: - LOG_FILE_NAME = fileName - return True - return False - - -def closeLog(): - global LOG_FILE_OBJ - global SYSLOG_REQUIRED - - if SYSLOG_REQUIRED: - syslog.closelog() - SYSLOG_REQUIRED = False - return True - - if LOG_FILE_OBJ: - try: - LOG_FILE_OBJ.close() - LOG_FILE_OBJ = None - except IOError, e: - sys.stderr.write("Failed to close file: %s\n" % e) - return False - return True - - -def openLog(fileName=None): - global LOG_FILE_NAME - global LOG_FILE_OBJ - global SYSLOG_REQUIRED - - if fileName == LOG_SYSLOG: - syslog.openlog(os.path.basename(sys.argv[0])) - SYSLOG_REQUIRED = True - return True - - if fileName: - LOG_FILE_NAME = fileName - - if not LOG_FILE_NAME: - return False - - closeLog() - - try: - LOG_FILE_OBJ = open(LOG_FILE_NAME, "a") - except IOError, e: - sys.stderr.write("Failed to open file %s: %s\n" % (LOG_FILE_NAME, e)) - return False - return True - -def record(priority, message=None): - global LOG_FILE_OBJ - global SYSLOG_REQUIRED - - stack = inspect.stack()[1] - if stack[3] == "<module>": - prefix = "%s:%s:%s" % (stack[1], stack[2], stack[3]) - else: - prefix = "%s:%s:%s()" % (stack[1], stack[2], stack[3]) - - if type(priority) == type("") or type(priority) == type(u""): - logPriority = syslog.LOG_INFO - logMessage = priority - else: - logPriority = priority - logMessage = message - - if SYSLOG_REQUIRED: - syslog.syslog(logPriority, "[%s]: %s" % (prefix, logMessage)) - return - - fp = sys.stderr - if LOG_FILE_OBJ: - fp = LOG_FILE_OBJ - - fp.write("[%s] %s [%s]: %s" % (str(datetime.now()), _getLogCode(logPriority), prefix, logMessage)) - if logMessage[-1] != '\n': - fp.write("\n") - fp.flush() - return - - -def trace(message): - if message: - log(syslog.LOG_DEBUG, message) - def isString(value): return (type(value) == type("") or type(value) == type(u"")) @@ -260,22 +146,22 @@ def runCommandFG(command, stdout=False, stderr=False, def IP2Number(ipString): try: return socket.htonl(struct.unpack("I", socket.inet_aton(ipString))[0]) - except socket.error: + except socket.error, e: return None - except TypeError: + except TypeError, e: return None - except struct.error: + except struct.error, e: return None def Number2IP(number): try: return socket.inet_ntoa(struct.pack("I", socket.ntohl(number))) - except socket.error: + except socket.error, e: return None - except AttributeError: + except AttributeError, e: return None - except ValueError: + except ValueError, e: return None @@ -292,7 +178,7 @@ def computeHostName(hostName): hostPrefix = hostName[:pos+1] try: hostIndex = int(hostName[pos+1:]) - except ValueError: + except ValueError, e: hostIndex = 0 # TODO: Check the availablity of the (server) name return "%s%s" % (hostPrefix, hostIndex + 1) @@ -304,7 +190,7 @@ def daemonize(): if pid > 0: # exit first parent sys.exit(0) - except OSError, e: + except OSError, e: #sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror)) return False @@ -339,7 +225,7 @@ def getDownloadStatus(fileName): try: lines = [line for line in open(fileName) if "saved" in line or "%" in line] - except IOError: + except IOError, e: return 0 if not lines: return 0 @@ -406,8 +292,8 @@ def getCpuUsageAvg(): def getLoadavg(): try: loadavgstr = open('/proc/loadavg', 'r').readline().strip() - except IOError: - syslog.syslog(syslog.LOG_ERR, "failed to find cpu load") + except IOError, e: + syslog.syslog(syslog.LOG_ERR, "failed to find cpu load: %s" % str(e)) return None data = map(float, loadavgstr.split()[1:]) @@ -439,173 +325,33 @@ def getInfinibandPortStatus(): return portkeys -def getServerCount(): - try: - return int(open(Globals.SERVER_COUNT_FILE).read().strip()) - except IOError: - log("failed to read file %s" % Globals.SERVER_COUNT_FILE) - return 1 - except ValueError: - log("invalid number format in file %s" % Globals.SERVER_COUNT_FILE) - return 1 - - -def setServerCount(count): - try: - open(Globals.SERVER_COUNT_FILE, "w").write("%s\n" % count) - return True - except IOError: - log("failed to write file %s" % Globals.SERVER_COUNT_FILE) - return False - - -def getInstalledServerCount(): - try: - return int(open(Globals.INSTALLED_SERVER_COUNT_FILE).read().strip()) - except IOError: - log("failed to read file %s" % Globals.INSTALLED_SERVER_COUNT_FILE) - return 1 - except ValueError: - log("invalid number format in file %s" % Globals.INSTALLED_SERVER_COUNT_FILE) - return 1 - - -def setInstalledServerCount(count): - try: - open(Globals.INSTALLED_SERVER_COUNT_FILE, "w").write("%s\n" % count) - return True - except IOError: - log("failed to write file %s" % Globals.INSTALLED_SERVER_COUNT_FILE) - return False - - -def getLastInstalledServerIpList(): - ipList = {} - networkDom = Protocol.XDOM() - if not networkDom.parseFile(Globals.GLOBAL_NETWORK_FILE): - log("failed to parse file %s" % Globals.GLOBAL_NETWORK_FILE) - for tagE in networkDom.getElementsByTagRoute("server.interface"): - interfaceDom = Protocol.XDOM() - interfaceDom.setDomObj(tagE) - ipAddress = interfaceDom.getTextByTagRoute("ipaddr") - if ipAddress: - ipList[interfaceDom.getTextByTagRoute("device")] = ipAddress - return ipList - - -def getFreeIpAddress(device=None): - serverCount = getServerCount() - installedServerCount = getInstalledServerCount() - if serverCount == installedServerCount: - return None - - availableServerCount = serverCount - installedServerCount - ipList = getLastInstalledServerIpList() - - if not ipList: - return None - - if device: - if device not in ipList.keys(): - return None - deviceIpAddress = ipList[device] - else: - deviceIpAddress = ipList.values()[0] - ipNumber = IP2Number(deviceIpAddress) - - for i in range((ipNumber + availableServerCount), ipNumber, -1): - ipAddress = Number2IP(i) - if runCommandFG(["ping", "-qnc", "1", ipAddress]) != 0: - return ipAddress - return None - - def getPasswordHash(userName): try: #return spwd.getspnam(userName).sp_pwd return "Not implimented" - except KeyError: + except KeyError, e: return None -def getTransactionKey(): - try: - tokens = open(Globals.TRANSACTION_KEY_FILE).read().split(',') - except IOError: - return None, None - return tokens - - def generateSignature(): #return str(uuid.uuid4()) + ('--%f' % time.time()) return ('--%f' % time.time()) -def getSignature(): - try: - return open(Globals.SIGNATURE_FILE).read().strip() - except IOError: - log(syslog.LOG_ERR, "unable to read signaure from %s file" % Globals.SIGNATURE_FILE) - return False - - -def storeSignature(signature, fileName=Globals.SIGNATURE_FILE): - try: - open(fileName, "w").write(signature + "\n") - except IOError: - log(syslog.LOG_ERR, "unable to write signature %s to %s file" % (signature, fileName)) - return False - return True - - def isUserExist(userName): try: grp.getgrnam(userName).gr_gid return True - except KeyError: + except KeyError, e: pass try: pwd.getpwnam(userName).pw_uid return True - except KeyError: + except KeyError, e: pass return False -def getGsnUserInfo(fileName=Globals.GSN_USER_INFO_FILE): - userInfo = {} - userInfo["UserId"] = None - userInfo["Password"] = None - try: - for line in open(fileName): - line = line.strip() - k = line[:line.index("=")] - v = line[line.index("=") + 1:] - if v[0] == "'" or v[0] == '"': - v = v[1:] - if v[-1] == "'" or v[-1] == '"': - v = v[:-1] - if k.upper() == "GSN_ID": - userInfo["UserId"] = v - if k.upper() == "GSN_PASSWORD": - userInfo["Password"] = v - except IOError, e: - log("Failed to read file %s: %s" % (fileName, e)) - return userInfo - - -def setGsnUserInfo(userInfo, fileName=Globals.GSN_USER_INFO_FILE): - try: - fp = open(fileName, "w") - fp.write("GSN_ID=%s\n" % userInfo["UserId"]) - fp.write("GSN_PASSWORD=%s\n" % userInfo["Password"]) - fp.close() - return True - except IOError, e: - log("Failed to write file %s: %s" % (fileName, e)) - return False - - def getPlatformVersion(fileName=Globals.GLUSTER_VERSION_FILE): versionInfo = {} versionInfo["Version"] = None @@ -625,7 +371,7 @@ def getPlatformVersion(fileName=Globals.GLUSTER_VERSION_FILE): if k.upper() == "UPDATE": versionInfo["Update"] = v except IOError, e: - log("Failed to read file %s: %s" % (fileName, e)) + log("Failed to read file %s: %s" % (fileName, str(e))) return versionInfo @@ -649,42 +395,10 @@ def setPlatformVersion(versionInfo, fileName=Globals.GLUSTER_VERSION_FILE): fp.close() return True except IOError, e: - log("Failed to write file %s: %s" % (fileName, e)) + log("Failed to write file %s: %s" % (fileName, str(e))) return False -def getGlusterUpdateDom(serverVersion): - errorMessage = "" - updateInfoDom = None - try: - baseUrl = open(Globals.GLUSTER_UPDATE_SITE_FILE).read().strip() - except IOError, e: - log("Failed to read file %s: %s" % (Globals.GLUSTER_UPDATE_SITE_FILE, e)) - errorMessage = "Failed to read update site file" - return updateInfoDom, errorMessage - - try: - url = "%s/%s/%s" % (baseUrl, serverVersion, Globals.GLUSTER_UPDATES_FILE) - connection = urllib.urlopen(url) - if connection.getcode() != 200: - connection.close() - errorMessage = "Error received from server to open URL %s" % url - return updateInfoDom, errorMessage - updateInfoString = connection.read() - connection.close() - except IOError, e: - log("Failed to get update information from URL %s: %s" % (url, e)) - errorMessage = "Error getting update information" - return updateInfoDom, errorMessage - - updateInfoDom = Protocol.XDOM() - if not updateInfoDom.parseString(updateInfoString): - log("XML parse error on update information content [%s]" % updateInfoString) - errorMessage = "Parse error on update information" - updateInfoDom = None - return updateInfoDom, errorMessage - - def removeFile(fileName, root=False): if root: if runCommand("rm %s" % fileName, root=True) == 0: @@ -694,7 +408,7 @@ def removeFile(fileName, root=False): os.remove(fileName) return True except OSError, e: - log("Failed to remove file %s: %s" % (fileName, e)) + log("Failed to remove file %s: %s" % (fileName, str(e))) return False @@ -711,9 +425,9 @@ def getIPIndex(indexFile): line = fp.readline() fp.close() index = int(line) - except IOError: + except IOError, e: index = 0 - except ValueError: + except ValueError, e: index = False return index @@ -722,34 +436,34 @@ def setIPIndex(index, indexFile): fp = open(indexFile, "w") fp.write(str(index)) fp.close() - except IOError: + except IOError, e: return False return True def IP2Number(ipString): try: return socket.htonl(struct.unpack("I", socket.inet_aton(ipString))[0]) - except socket.error: + except socket.error, e: return None - except TypeError: + except TypeError, e: return None - except struct.error: + except struct.error, e: return None def Number2IP(number): try: return socket.inet_ntoa(struct.pack("I", socket.ntohl(number))) - except socket.error: + except socket.error, e: return None - except AttributeError: + except AttributeError, e: return None - except ValueError: + except ValueError, e: return None def hasEntryFoundInFile(searchString, dnsEntryFileName): try: addServerEntryList = open(dnsEntryFileName).read().split() - except IOError: + except IOError, e: return None if searchString in addServerEntryList: return True @@ -765,8 +479,8 @@ def computeIpAddress(ipAddress, startIp, endIp): while True: nextIpNumber = nextIpNumber + 1 ipAddress = Number2IP(nextIpNumber) - rv = runCommandFG(["ping", "-qnc", "1", ipAddress]) - if type(rv) == type(True): + rv = runCommand("ping -qnc 1 %s" % ipAddress, output=True) + if rv["Status"] != 0: return False if rv != 0: break @@ -778,8 +492,8 @@ def computeIpAddress(ipAddress, startIp, endIp): while True: ipAddress = Number2IP(nextIpNumber) nextIpNumber = nextIpNumber + 1 - rv = runCommandFG(["ping", "-qnc", "1", ipAddress]) - if type(rv) == type(True): + rv = runCommand("ping -qnc 1 %s" % ipAddress, output=True) + if rv["Status"] != 0: return False if rv != 0: break @@ -795,7 +509,7 @@ def setHostNameAndIp(hostName, ipAddress, lastAddServerDetailFile): fp.write("HOSTNAME=" + hostName + "\n") fp.write("IPADDRESS=" + ipAddress); fp.close() - except IOError: + except IOError, e: return False return True @@ -805,9 +519,9 @@ def getPort(): portString = fd.readline() fd.close() port = int(portString) - except IOError: + except IOError, e: port = Globals.DEFAULT_PORT - 2 - except ValueError: + except ValueError, e: port = Globals.DEFAULT_PORT - 2 return port @@ -816,84 +530,10 @@ def setPort(port): fd = open(Globals.PORT_FILE, "w") fd.write(str(port)) fd.close() - except IOError: + except IOError, e: return False return True -def getServerAgentCredentials(): - try: - lines = open(Globals.SERVERAGENT_AUTH_FILE).readlines() - except IOError: - return None,None - - userName = None - password = None - - for l in lines: - if l[-1] == '\n': - l = l[:-1] - k = l[:l.index('=')] - v = l[l.index('=') + 1:] - if v[0] == "'" or v[0] == '"': - v = v[1:] - if v[-1] == "'" or v[-1] == '"': - v = v[:-1] - if k.upper() == "AGENT_ID": - userName = v - if k.upper() == "AGENT_PASSWORD": - password = v - - return userName, password - -def getGatewayAgentCredentials(): - try: - lines = open(Globals.GATEWAYAGENT_AUTH_FILE).readlines() - except IOError: - return None - - #userName = None - password = None - - for l in lines: - if l[-1] == '\n': - l = l[:-1] - k = l[:l.index('=')] - v = l[l.index('=') + 1:] - if v[0] == "'" or v[0] == '"': - v = v[1:] - if v[-1] == "'" or v[-1] == '"': - v = v[:-1] - #if k.upper() == "AGENT_ID": - # userName = v - if k.upper() == "AGENT_PASSWORD": - password = v - - return password - -def getWebAgentCredentials(): - try: - lines = open(Globals.WEBAGENT_AUTH_FILE).readlines() - except IOError: - return None,None - - userName = None - password = None - - for l in lines: - if l[-1] == '\n': - l = l[:-1] - k = l[:l.index('=')] - v = l[l.index('=') + 1:] - if v[0] == "'" or v[0] == '"': - v = v[1:] - if v[-1] == "'" or v[-1] == '"': - v = v[:-1] - if k.upper() == "AGENT_ID": - userName = v - if k.upper() == "AGENT_PASSWORD": - password = v - - return userName, password def daemonize(): try: @@ -931,37 +571,19 @@ def daemonize(): os.dup2(se.fileno(), sys.stderr.fileno()) return True -def getFreeIpAddress(): - startRange, endRange = getStoragePoolInfo() - if not (startRange and endRange): - return None - - startIpNumber = IP2Number(startRange) - endIpNumber = IP2Number(endRange) - - for ipNumber in range(endIpNumber, startIpNumber, -1): - rv = runCommandFG(["ping", "-qnc", "1", Number2IP(ipNumber)]) - if type(rv) == type(True): - return None - if rv != 0: - return Number2IP(ipNumber) - return None def getDhcpServerStatus(): - status = runCommandFG(["sudo", "service", "dnsmasq", " status"]) - if type(status) == type(True) or 0 != status: + if runCommand("service dnsmasq status", root=True) != 0: return False return True def startDhcpServer(): - status = runCommandFG(["sudo", "service", "dnsmasq", " start"]) - if type(status) == type(True) or 0 != status: + if runCommand("service dnsmasq start", root=True) != 0: return False return True def stopDhcpServer(): - status = runCommandFG(["sudo", "service", "dnsmasq", " stop"]) - if type(status) == type(True) or 0 != status: + if runCommand("service dnsmasq stop", root=True) != 0: return False return True @@ -975,8 +597,8 @@ def getStoragePoolInfo(): startRange = tokens[1].strip() if tokens[0] == "ENDRANGE": endRange = tokens[1].strip() - except IOError: - log(syslog.LOG_ERR, "unable to read %s file" % Globals.GLUSTER_SERVER_POOL_FILE) + except IOError, e: + log(syslog.LOG_ERR, "unable to read %s file: %s" % (Globals.GLUSTER_SERVER_POOL_FILE, str(e))) return startRange, endRange def configureDnsmasq(serverIpAddress, dhcpIpAddress): @@ -988,12 +610,12 @@ def configureDnsmasq(serverIpAddress, dhcpIpAddress): if token[0] == "dhcp": serverPortString = token[1] break - except IOError: - log(syslog.LOG_ERR, "Failed to read /proc/cmdline. Continuing with default port 68") + except IOError, e: + log(syslog.LOG_ERR, "Failed to read /proc/cmdline. Continuing with default port 68: %s" % str(e)) try: serverPort = int(serverPortString) - except ValueError: - log(syslog.LOG_ERR, "Invalid dhcp port '%s' in /proc/cmdline. Continuing with default port 68" % serverPortString) + except ValueError, e: + log(syslog.LOG_ERR, "Invalid dhcp port '%s' in /proc/cmdline. Continuing with default port 68: %s" % (serverPortString, str(e))) serverPort = 68 try: @@ -1010,11 +632,10 @@ def configureDnsmasq(serverIpAddress, dhcpIpAddress): fp.write("server=%s\n" % serverIpAddress) fp.write("dhcp-script=/usr/sbin/server-info\n") fp.close() - except IOError: - log(syslog.LOG_ERR, "unable to write dnsmasq configuration %s" % dnsmasqConfFile) + except IOError, e: + log(syslog.LOG_ERR, "unable to write dnsmasq configuration %s: %s" % (dnsmasqConfFile, str(e))) return False - status = runCommandFG(["sudo", "cp", "-f", Globals.GLUSTER_CONF_CONF_DIR + "/dnsmasq.conf", Globals.DNSMASQ_CONF_FILE]) - if type(status) == type(True) or 0 != status: + if runCommand(["cp", "-f", Globals.GLUSTER_CONF_CONF_DIR + "/dnsmasq.conf", Globals.DNSMASQ_CONF_FILE], root=True) != 0: log(syslog.LOG_ERR, "unable to copy dnsmasq configuration to " + Globals.DNSMASQ_CONF_FILE) return False return True @@ -1084,3 +705,20 @@ def getCifsUserUid(userName): if tokens[1] == userName: return int(tokens[0]) return None + +def readFile(fileName, lines=False): + content = None + try: + fp = open(fileName) + if lines: + content = fp.readlines() + else: + content = fp.read() + fp.close() + return content + except IOError, e: + log("failed to read file %s: %s" % (fileName, str(e))) + if lines: + return [] + else: + return "" diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py b/src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py index beff388b..22c023cc 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py @@ -182,7 +182,7 @@ class XDOM: self._domObj.writexml(fp, indent, addindent, newl) fp.close() return True - except IOError: + except IOError, e: return False def toString(self, indent=" ", newl="\n", encoding = None): @@ -218,9 +218,9 @@ class RequestXml(XDOM): self._domObj = MDOM.parse(requestString) elif XML_STRING == type: self._domObj = MDOM.parseString(requestString) - except IOError: + except IOError, e: XDOM.__init__(self) - except xml.parsers.expat.ExpatError: + except xml.parsers.expat.ExpatError, e: XDOM.__init__(self) ##--end of RequestXML diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..d159aeca --- /dev/null +++ b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Tue Sep 20 14:10:09 IST 2011 +eclipse.preferences.version=1 +encoding//src/rebel.xml=UTF-8 diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt new file mode 100644 index 00000000..d24fbfdb --- /dev/null +++ b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt @@ -0,0 +1,135 @@ +The GNU General Public License (GPL) Version 2, June 1991 + + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + + Copyright (C) + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. + + +"CLASSPATH" EXCEPTION TO THE GPL VERSION 2 + +Certain source files distributed by Oracle are subject to the following clarification and special exception to the GPL Version 2, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the License file that accompanied this code." + +Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination. + +As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt new file mode 100644 index 00000000..b3acf520 --- /dev/null +++ b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt @@ -0,0 +1,188 @@ + +DO NOT TRANSLATE OR LOCALIZE. + +%% The following software may be included in this product: ASM + Use of any of this software is governed by the terms of the license below: + +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +%% The following software may be included in this product: Jettison + Use of any of this software is governed by the terms of the license below: + + +Copyright 2006 Envoi Solutions LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +-------------------------------------------------------------------------- + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. +Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + + +%% The following software may be included in this product: Jackson + Use of any of this software is governed by the terms of the license below: + + +Jackson is dual-licensed under two alternative popular Open Source licenses: Apache (AL 2.0) and Gnu Lesser GPL (LGPL 2.1). You choose one or the other, as necessary (if you want to redistribute the code ¿ for use, you do not need license), and abide by the license rules as defined by the respective license agreement (and only that one). + +-------------------------------------------------------------------------- + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. +Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/plugins/com.gluster.storage.management.client_1.0.0.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/plugins/com.gluster.storage.management.client_1.0.0.jar Binary files differdeleted file mode 100644 index 56222cbf..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/plugins/com.gluster.storage.management.client_1.0.0.jar +++ /dev/null diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/plugins/com.gluster.storage.management.core_1.0.0.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/plugins/com.gluster.storage.management.core_1.0.0.jar Binary files differdeleted file mode 100644 index d321e76c..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/plugins/com.gluster.storage.management.core_1.0.0.jar +++ /dev/null diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java index b495ec12..8d3784e9 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java @@ -55,11 +55,8 @@ import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; -import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.exceptions.GlusterValidationException; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.ServerStats; @@ -67,16 +64,12 @@ import com.gluster.storage.management.core.model.TaskStatus; import com.gluster.storage.management.core.response.GlusterServerListResponse; import com.gluster.storage.management.core.response.ServerNameListResponse; import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.data.ServerInfo; import com.gluster.storage.management.gateway.services.ClusterService; import com.gluster.storage.management.gateway.services.GlusterServerService; import com.gluster.storage.management.gateway.tasks.InitializeDiskTask; import com.gluster.storage.management.gateway.utils.CpuStatsFactory; -import com.gluster.storage.management.gateway.utils.GlusterUtil; import com.gluster.storage.management.gateway.utils.MemoryStatsFactory; import com.gluster.storage.management.gateway.utils.NetworkStatsFactory; -import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.gluster.storage.management.gateway.utils.SshUtil; import com.gluster.storage.management.gateway.utils.StatsFactory; import com.sun.jersey.api.core.InjectParam; import com.sun.jersey.spi.resource.Singleton; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java index c0872384..9b6af355 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java @@ -42,9 +42,8 @@ import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.exceptions.GlusterValidationException; import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.VolumeOptionInfo; import com.gluster.storage.management.core.model.Server.SERVER_STATUS; +import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java index be167133..591ddef0 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java @@ -25,16 +25,13 @@ import org.springframework.web.context.ContextLoader; import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo; import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.utils.ProcessResult; import com.gluster.storage.management.gateway.services.ClusterService; import com.gluster.storage.management.gateway.utils.GlusterUtil; import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.gluster.storage.management.gateway.utils.SshUtil; import com.sun.jersey.core.util.Base64; public class InitializeDiskTask extends Task { diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java index 4d63e872..35f9ba29 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java @@ -20,7 +20,6 @@ */ package com.gluster.storage.management.gateway.tasks; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.web.context.ContextLoader; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java index 89636fdf..19ae0383 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java @@ -28,11 +28,9 @@ import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.utils.ProcessResult; import com.gluster.storage.management.gateway.services.ClusterService; import com.gluster.storage.management.gateway.utils.GlusterUtil; import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.gluster.storage.management.gateway.utils.SshUtil; import com.sun.jersey.core.util.Base64; public class RebalanceVolumeTask extends Task { diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java index e224b4cb..ca4821d1 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java @@ -21,7 +21,6 @@ package com.gluster.storage.management.gateway.utils; import java.sql.DriverManager; import java.sql.SQLException; -import org.apache.derby.jdbc.EmbeddedDriver; import org.apache.log4j.Logger; import com.gluster.storage.management.core.constants.CoreConstants; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java index d2366899..f41dd989 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java @@ -46,7 +46,6 @@ import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; import com.gluster.storage.management.core.utils.ProcessResult; import com.gluster.storage.management.core.utils.StringUtil; -import com.gluster.storage.management.gateway.resources.v1_0.TasksResource; @Component public class GlusterUtil { diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java index a3593d0c..6af08049 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java @@ -18,9 +18,6 @@ *******************************************************************************/ package com.gluster.storage.management.gateway.utils; -import java.sql.DriverManager; -import java.sql.SQLException; - import org.apache.derby.jdbc.EmbeddedDriver; import org.springframework.jdbc.datasource.SimpleDriverDataSource; import org.springframework.security.authentication.dao.ReflectionSaltSource; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java index d31411ec..e491a1e7 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java @@ -40,8 +40,8 @@ import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.exceptions.ConnectionException; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.Server.SERVER_STATUS; +import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.utils.ProcessResult; import com.gluster.storage.management.core.utils.ProcessUtil; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java index 8222ea34..b871e376 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java @@ -23,7 +23,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.net.NoRouteToHostException; import java.util.Arrays; import org.apache.log4j.Logger; diff --git a/src/com.gluster.storage.management.gateway/src/rebel.xml b/src/com.gluster.storage.management.gateway/src/rebel.xml new file mode 100644 index 00000000..0f2140c9 --- /dev/null +++ b/src/com.gluster.storage.management.gateway/src/rebel.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd"> + + <classpath> + <dir name="${rebel.workspace.path}/console/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/classes"> + </dir> + </classpath> + + <web> + <link target="/"> + <dir name="${rebel.workspace.path}/console/src/com.gluster.storage.management.gateway/WebContent"> + </dir> + </link> + </web> + +</application> diff --git a/src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml b/src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml index 99574afb..e160d31a 100644 --- a/src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml +++ b/src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml @@ -12,7 +12,7 @@ <http auto-config="true" use-expressions="true"> <!-- SSL Protection --> - <intercept-url pattern="/1.0/**" access="hasRole('ROLE_ADMIN') and fullyAuthenticated" requires-channel="https" /> + <intercept-url pattern="/1.0.0/**" access="hasRole('ROLE_ADMIN') and fullyAuthenticated" requires-channel="https" /> <intercept-url pattern="*.jnlp" access="hasRole('ROLE_ADMIN') and fullyAuthenticated" requires-channel="any" /> <!-- intercept-url pattern="/*" access="permitAll" requires-channel="any" / --> <port-mappings> |