diff options
| author | Dhandapani <dhandapani@gluster.com> | 2011-07-07 21:27:15 +0530 |
|---|---|---|
| committer | Dhandapani <dhandapani@gluster.com> | 2011-07-07 21:27:15 +0530 |
| commit | 529525fe5dec5d9ead5aab6bd39029ea1a63762b (patch) | |
| tree | 0138f6dcdb86aa24be982bd645601a264f9ff52c /src | |
| parent | 7bc61b55432a68bc0845fcfab19f20f18822629a (diff) | |
VolumeOptions data model change
Diffstat (limited to 'src')
14 files changed, 105 insertions, 104 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java index 296de3d6..6db98ed4 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java @@ -604,10 +604,10 @@ public class GlusterDataModelManager { } } - public void setVolumeOption(Volume volume, Entry<String, String> entry) { - volume.setOption(entry.getKey(), (String) entry.getValue()); + public void setVolumeOption(Volume volume, String optionKey, String optionValue) { + volume.setOption(optionKey, optionValue); for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTION_SET, entry)); + listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTION_SET, optionKey)); } } @@ -672,8 +672,7 @@ public class GlusterDataModelManager { } public void setAccessControlList(Volume volume, String accessControlList) { - volume.setAccessControlList(accessControlList); - setVolumeOption(volume, getOptionEntry(volume, Volume.OPTION_AUTH_ALLOW)); + setVolumeOption(volume, Volume.OPTION_AUTH_ALLOW, accessControlList); } public Server getGlusterServer(String serverName) { @@ -685,17 +684,6 @@ public class GlusterDataModelManager { return null; } - @SuppressWarnings({ "rawtypes", "unchecked" }) - private Entry<String, String> getOptionEntry(Volume volume, String optionKey) { - for (Entry entry : volume.getOptions().entrySet()) { - if (entry.getKey().equals(optionKey)) { - return entry; - } - } - throw new GlusterRuntimeException("Couldn't find entry for option [" + optionKey + "] on volume [" - + volume.getName()); - } - private Boolean isDiskUsed(Volume volume, Disk disk) { for (Brick brick : volume.getBricks()) { if (disk.getName().equals(brick.getDiskName()) && disk.getServerName().equals(brick.getServerName())) { 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 90f319bb..063cdd18 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 @@ -19,6 +19,7 @@ package com.gluster.storage.management.core.model; import java.io.File; +import java.nio.channels.GatheringByteChannel; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlTransient; @@ -31,14 +32,15 @@ import com.gluster.storage.management.core.utils.StringUtil; */ public class Device extends Entity { public enum DEVICE_STATUS { - INITIALIZED, UNINITIALIZED, INITIALIZING, IO_ERROR + //TODO: Status "READY" to be removed after python script is changed accordingly + READY, INITIALIZED, UNINITIALIZED, INITIALIZING, IO_ERROR, UNKNOWN }; public enum DEVICE_TYPE { DATA, BOOT, SWAP, UNKNOWN }; - private static final String[] DEVICE_STATUS_STR = { "Initialized", "Uninitialized", "Initializing", "I/O Error" }; + private static final String[] DEVICE_STATUS_STR = { "Ready", "Initialized", "Uninitialized", "Initializing", "I/O Error", "Unknown" }; private static final String[] DEVICE_TYPE_STR = { "Data", "Boot", "Swap", "Unknown" }; // type = data, boot, other @@ -89,7 +91,8 @@ public class Device extends Entity { public boolean isReady() { // TODO: Check if status is INITIALIZED AND type = DATA - return getStatus() == DEVICE_STATUS.INITIALIZED; + // return (getStatus() == DEVICE_STATUS.INITIALIZED && getType() == DEVICE_TYPE.DATA); + return (getStatus() == DEVICE_STATUS.READY); } public DEVICE_STATUS getStatus() { @@ -97,6 +100,10 @@ public class Device extends Entity { } public String getStatusStr() { + if (getStatus() == null) { + return DEVICE_STATUS_STR[DEVICE_STATUS.UNKNOWN.ordinal()]; // Return as Unknown + } + if(isReady()) { return "Available"; } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java index e623f3d6..32341eca 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java @@ -26,7 +26,7 @@ import javax.xml.bind.annotation.XmlRootElement; import com.gluster.storage.management.core.utils.GlusterCoreUtil; import com.gluster.storage.management.core.utils.StringUtil; -@XmlRootElement(name="Disk") +@XmlRootElement(name="disk") public class Disk extends Device { private String description; @@ -96,19 +96,23 @@ public class Disk extends Device { return false; } - for(Disk raidDisk : raidDisks) { - // check if the disk contains same raid disks - if (!(raidDisk.equals(GlusterCoreUtil.getEntity(disk.getRaidDisks(), raidDisk.getName(), false)))) { - return false; + if (raidDisks != null) { + for (Disk raidDisk : raidDisks) { + // check if the disk contains same raid disks + if (!(raidDisk.equals(GlusterCoreUtil.getEntity(disk.getRaidDisks(), raidDisk.getName(), false)))) { + return false; + } } } - // check if the disk contains same partitions - for (Partition partition : partitions) { - if (!(partition.equals(GlusterCoreUtil.getEntity(disk.getPartitions(), partition.getName(), false)))) { - return false; - } - } +// // check if the disk contains same partitions +// if (partitions != null) { +// for (Partition partition : partitions) { +// if (!(partition.equals(GlusterCoreUtil.getEntity(disk.getPartitions(), partition.getName(), false)))) { +// return false; +// } +// } +// } return false; } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java index 006202fb..fe05c517 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map.Entry; import java.util.Set; import javax.xml.bind.annotation.XmlElement; @@ -196,7 +197,11 @@ public class Volume extends Entity { } public void setOptions(LinkedHashMap<String, String> options) { - this.options.setOptionsMap(options); + List<VolumeOption> volumeOptions = new ArrayList<VolumeOption>(); + for(Entry<String, String> entry : options.entrySet()) { + volumeOptions.add(new VolumeOption(entry.getKey(), entry.getValue())); + } + this.options.setOptions(volumeOptions); } public void addBrick(Brick brick) { diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java index f4ca3e81..4b54b010 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java @@ -23,7 +23,7 @@ import javax.xml.bind.annotation.XmlRootElement; /** * */ -@XmlRootElement +@XmlRootElement(name="option") public class VolumeOption { private String key; private String value; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java index f928c241..bda01075 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java @@ -27,64 +27,54 @@ import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; /** * */ -@XmlRootElement +@XmlRootElement(name="options") public class VolumeOptions { - private Map<String, String> optionsMap = new HashMap<String, String>(); + private List<VolumeOption> options = new ArrayList<VolumeOption>(); public VolumeOptions() { } public String get(String key) { - return optionsMap.get(key); + for(VolumeOption option : options) { + if(option.getKey().equals(key)) { + return option.getValue(); + } + } + return null; } - public String put(String key, String value) { - return optionsMap.put(key, value); + public void put(String key, String value) { + options.add(new VolumeOption(key, value)); } @XmlElement(name="option", type=VolumeOption.class) public List<VolumeOption> getOptions() { - List<VolumeOption> options = new ArrayList<VolumeOption>(); - for(Entry<String, String> entry : optionsMap.entrySet()) { - options.add(new VolumeOption(entry.getKey(), entry.getValue())); - } return options; } - public Set<Entry<String, String>> getOptionsMap() { - return optionsMap.entrySet(); - } - - public void setOptionsMap(Map<String, String> optionsMap) { - this.optionsMap = optionsMap; + public void setOptions(List<VolumeOption> options) { + this.options = options; } public void clear() { - optionsMap.clear(); + options.clear(); } - public Set<Entry<String, String>> entrySet() { - return optionsMap.entrySet(); - } - - public Set<String> keySet() { - return optionsMap.keySet(); - } - - public String remove(String key) { - return optionsMap.remove(key); + public boolean remove(String key) { + return options.remove(get(key)); } public int size() { - return optionsMap.size(); + return options.size(); } public boolean containsKey(String key) { - return optionsMap.containsKey(key); + return get(key) != null; } @Override @@ -108,8 +98,7 @@ public class VolumeOptions { } public void copyFrom(VolumeOptions options) { - for(Entry<String, String> entry : options.entrySet()) { - optionsMap.put(entry.getKey(), entry.getValue()); - } + this.options.clear(); + this.options.addAll(options.getOptions()); } }
\ No newline at end of file diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java index 5e49aae2..7d2b1b7b 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/BrickTableLabelProvider.java @@ -47,6 +47,7 @@ public class BrickTableLabelProvider extends TableLabelProviderAdapter { DEVICE_STATUS status = disk.getStatus(); switch (status) { case INITIALIZED: + case READY: return guiHelper.getImage(IImageKeys.STATUS_ONLINE); case IO_ERROR: return guiHelper.getImage(IImageKeys.STATUS_OFFLINE); @@ -63,7 +64,7 @@ public class BrickTableLabelProvider extends TableLabelProviderAdapter { } private String getDiskFreeSpace(Disk disk) { - if (disk.isReady() && disk.getFreeSpace() != null) { + if (disk != null && disk.isReady() && disk.getFreeSpace() != null) { return NumberUtil.formatNumber((disk.getFreeSpace() / 1024)); } else { return "NA"; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java index 9759e384..e0f11a85 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/DiskTableLabelProvider.java @@ -47,6 +47,7 @@ public class DiskTableLabelProvider extends TableLabelProviderAdapter { DEVICE_STATUS status = disk.getStatus(); switch (status) { case INITIALIZED: + case READY: return guiHelper.getImage(IImageKeys.STATUS_ONLINE); case IO_ERROR: return guiHelper.getImage(IImageKeys.STATUS_OFFLINE); diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java index 21ce00f9..d6564610 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ServerDiskTableLabelProvider.java @@ -42,6 +42,11 @@ public class ServerDiskTableLabelProvider extends TableLabelProviderAdapter { Disk disk = (Disk) element; if (columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { DEVICE_STATUS status = disk.getStatus(); + + if (status == null) { + return null; + } + switch (status) { case INITIALIZED: return guiHelper.getImage(IImageKeys.STATUS_ONLINE); diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeOptionsTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeOptionsTableLabelProvider.java index cd85d22b..53c8c472 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeOptionsTableLabelProvider.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/VolumeOptionsTableLabelProvider.java @@ -20,6 +20,7 @@ package com.gluster.storage.management.gui; import java.util.Map.Entry; +import com.gluster.storage.management.core.model.VolumeOption; import com.gluster.storage.management.gui.views.pages.VolumeOptionsPage.OPTIONS_TABLE_COLUMN_INDICES; public class VolumeOptionsTableLabelProvider extends TableLabelProviderAdapter { @@ -29,11 +30,9 @@ public class VolumeOptionsTableLabelProvider extends TableLabelProviderAdapter { return null; } - Entry<String, String> entry = (Entry<String, String>) element; - String key = entry.getKey(); - String value = entry.getValue(); - return (columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal() ? key - : columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE.ordinal() ? value + VolumeOption option = (VolumeOption)element; + return (columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal() ? option.getKey() + : columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE.ordinal() ? option.getValue() : "Invalid"); } } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionKeyEditingSupport.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionKeyEditingSupport.java index 1f64d82e..924c5cc8 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionKeyEditingSupport.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionKeyEditingSupport.java @@ -4,7 +4,6 @@ package com.gluster.storage.management.gui.views.pages; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map.Entry; @@ -17,6 +16,7 @@ import org.eclipse.swt.widgets.Composite; import com.gluster.storage.management.client.GlusterDataModelManager; import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.VolumeOption; import com.gluster.storage.management.core.model.VolumeOptionInfo; import com.gluster.storage.management.core.model.VolumeOptions; @@ -73,7 +73,7 @@ public class OptionKeyEditingSupport extends EditingSupport { @Override protected Object getValue(Object element) { - Entry<String, String> entryBeingAdded = getEntryBeingAdded(); + VolumeOption entryBeingAdded = getEntryBeingAdded(); if(entryBeingAdded == null) { return cellEditor.getValue(); } @@ -93,7 +93,7 @@ public class OptionKeyEditingSupport extends EditingSupport { return cellEditor; } - private int getIndexOfEntry(Entry<String, String> entryBeingAdded) { + private int getIndexOfEntry(VolumeOption entryBeingAdded) { for(int index = 0; index < allowedKeys.length; index++) { if(allowedKeys[index].equals(entryBeingAdded.getKey())) { return index; @@ -102,18 +102,16 @@ public class OptionKeyEditingSupport extends EditingSupport { return -1; } - protected Entry<String, String> getEntryBeingAdded() { - Entry<String, String> entryBeingAdded = null; - Iterator<Entry<String, String>> iter = volume.getOptions().entrySet().iterator(); - while(iter.hasNext()) { - Entry<String, String> nextEntry = iter.next(); - if(!iter.hasNext() && nextEntry.getValue().isEmpty()) { - // it's the LAST entry, and it's value is empty. - // means this is a new row being added in the table viewer. - entryBeingAdded = nextEntry; - } + protected VolumeOption getEntryBeingAdded() { + List<VolumeOption> options = volume.getOptions().getOptions(); + int size = options.size(); + String lastValue = options.get(size - 1).getValue(); + if(lastValue == null || lastValue.isEmpty()) { + // it's the LAST entry, and it's value is empty. + // means this is a new row being added in the table viewer. + return options.get(size - 1); } - return entryBeingAdded; + return null; } @SuppressWarnings("unchecked") diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionValueEditingSupport.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionValueEditingSupport.java index 2358aa73..b349ab78 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionValueEditingSupport.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/OptionValueEditingSupport.java @@ -18,6 +18,7 @@ import org.eclipse.swt.widgets.Display; import com.gluster.storage.management.client.GlusterDataModelManager; import com.gluster.storage.management.client.VolumesClient; import com.gluster.storage.management.core.model.Volume; +import com.gluster.storage.management.core.model.VolumeOption; import com.gluster.storage.management.core.model.VolumeOptionInfo; import com.gluster.storage.management.gui.utils.GUIHelper; @@ -39,7 +40,7 @@ public class OptionValueEditingSupport extends EditingSupport { @SuppressWarnings("unchecked") @Override protected void setValue(final Object element, final Object value) { - final Entry<String, String> entry = (Entry<String, String>) element; + final VolumeOption entry = (VolumeOption)element; final String optionKey = entry.getKey(); final String optionValue = (String)value; final String oldValue = entry.getValue(); @@ -67,9 +68,9 @@ public class OptionValueEditingSupport extends EditingSupport { public void run() { VolumesClient client = new VolumesClient(); try { - client.setVolumeOption(volume.getName(), entry.getKey(), (String) value); + client.setVolumeOption(volume.getName(), optionKey, optionValue); entry.setValue((String)value); - GlusterDataModelManager.getInstance().setVolumeOption(volume, entry); + GlusterDataModelManager.getInstance().setVolumeOption(volume, optionKey, optionValue); } catch(Exception e) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Set Volume Option", e.getMessage()); } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java index 956fc215..b131999b 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java @@ -58,6 +58,7 @@ import com.gluster.storage.management.core.model.DefaultClusterListener; 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.Volume; +import com.gluster.storage.management.core.model.VolumeOption; import com.gluster.storage.management.core.model.VolumeOptionInfo; import com.gluster.storage.management.gui.VolumeOptionsTableLabelProvider; import com.gluster.storage.management.gui.utils.GUIHelper; @@ -103,7 +104,7 @@ public class VolumeOptionsPage extends Composite { setAddButtonsEnabled(false); } - tableViewer.setInput(volume.getOptions().entrySet()); + tableViewer.setInput(volume.getOptions()); parent.layout(); // Important - this actually paints the table registerListeners(parent); @@ -151,7 +152,7 @@ public class VolumeOptionsPage extends Composite { if (!(addTopButton.isEnabled() || addBottomButton.isEnabled())) { // user has selected key, but not added value. Since this is not a valid entry, // remove the last option (without value) from the volume - Entry<String, String> entryBeingAdded = keyEditingSupport.getEntryBeingAdded(); + VolumeOption entryBeingAdded = keyEditingSupport.getEntryBeingAdded(); volume.getOptions().remove(entryBeingAdded.getKey()); } } @@ -200,7 +201,7 @@ public class VolumeOptionsPage extends Composite { } // if this is the last option in the volume options, it must be the new option - return optionKey.equals(volume.getOptions().keySet().toArray()[volume.getOptions().size() - 1]); + return optionKey.equals(volume.getOptions().getOptions().get(volume.getOptions().size() - 1)); } }; @@ -219,8 +220,8 @@ public class VolumeOptionsPage extends Composite { filterText.setEnabled(false); } - private Entry<String, String> getEntry(String key) { - for (Entry<String, String> entry : volume.getOptions().entrySet()) { + private VolumeOption getEntry(String key) { + for (VolumeOption entry : volume.getOptions().getOptions()) { if (entry.getKey().equals(key)) { return entry; } diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java index 2e78b57b..e8073765 100644 --- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java +++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java @@ -20,20 +20,17 @@ */ package com.gluster.storage.management.server.utils; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.net.InetAddress; -import java.net.Socket; +import java.io.ByteArrayOutputStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.servlet.ServletContext; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.springframework.beans.factory.annotation.Autowired; @@ -44,6 +41,8 @@ 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.VolumeOption; +import com.gluster.storage.management.core.model.VolumeOptions; import com.gluster.storage.management.core.response.GenericResponse; import com.gluster.storage.management.core.utils.ProcessResult; import com.gluster.storage.management.core.utils.ProcessUtil; @@ -86,7 +85,7 @@ public class ServerUtil { */ public void fetchServerDetails(Server server) { // fetch standard server details like cpu, disk, memory details - Object response = executeOnServer(true, server.getName(), "get_server_details.py --only-data-disks", Server.class); + Object response = executeOnServer(true, server.getName(), "get_server_details.py", Server.class); if (response instanceof Status) { throw new GlusterRuntimeException(((Status)response).getMessage()); } @@ -225,10 +224,13 @@ public class ServerUtil { } public static void main(String args[]) throws Exception { - ServerUtil su = new ServerUtil(); - su.setSshUtil(new SshUtil()); - // Object result = new ServerUtil().executeOnServer(true, "serverName", "ls -lrt", String.class); - // System.out.println(result); + //String diskStr = "<server><name>devserver1</name><domainname/><dns1>10.1.10.1</dns1><dns2>8.8.4.4</dns2><networkInterfaces><networkInterface><name>eth0</name><hwAddr>00:50:56:82:00:1d</hwAddr><speed>1000</speed><model>ETHERNET</model><onboot>yes</onboot><bootProto>none</bootProto><ipAddress>10.1.12.41</ipAddress><netMask>255.255.255.0</netMask><defaultGateway>10.1.12.1</defaultGateway></networkInterface></networkInterfaces><numOfCPUs>2</numOfCPUs><cpuUsage>0.0</cpuUsage><totalMemory>2010.5234375</totalMemory><memoryInUse>1267.6015625</memoryInUse><status>ONLINE</status><uuid/><disks><disk><name>sdd</name><description>VMware Virtual disk</description><uuid/><status>UNINITIALIZED</status><init>false</init><type>false</type><interface>pci</interface><fsType/><fsVersion/><mountPoint/><size>10240</size><spaceInUse/><partitions><partition><name>sdd1</name><uuid/><status>UNINITIALIZED</status><init>false</init><type>false</type><interface/><fsType/><mountPoint/><size>10236</size><spaceInUse/></partition></partitions></disk><disk><name>sda</name><description>VMware Virtual disk</description><uuid/><status>UNINITIALIZED</status><init>false</init><type>false</type><interface>pci</interface><fsType/><fsVersion/><mountPoint/><size>10240</size><spaceInUse>2019</spaceInUse><partitions><partition><name>sda1</name><uuid>345d880e-822a-4e46-a518-75cc48b1869f</uuid><status>INITIALIZED</status><init>true</init><type>false</type><interface/><fsType>ext3</fsType><mountPoint>/boot</mountPoint><size>125</size><spaceInUse>11</spaceInUse></partition><partition><name>sda2</name><uuid/><status>UNINITIALIZED</status><init>false</init><type>false</type><interface/><fsType>swap</fsType><mountPoint/><size>125</size><spaceInUse/></partition><partition><name>sda3</name><uuid>f94a0b2a-5ebc-4c13-a618-0328af97a31e</uuid><status>INITIALIZED</status><init>true</init><type>false</type><interface/><fsType>ext3</fsType><mountPoint>/</mountPoint><size>9985</size><spaceInUse>2008</spaceInUse></partition></partitions></disk><disk><name>sdb</name><description>VMware Virtual disk</description><uuid>97ee7ea3-d235-424c-bdda-f5b697f204a2</uuid><status>READY</status><init>true</init><type>true</type><interface>pci</interface><fsType>ext3</fsType><fsVersion>1.0</fsVersion><mountPoint>/export/sdb</mountPoint><size>1024</size><spaceInUse>427</spaceInUse><partitions/></disk><disk><name>sdc</name><description>VMware Virtual disk</description><uuid>87679044-6395-42fb-a80d-41c3b648f248</uuid><status>READY</status><init>true</init><type>true</type><interface>pci</interface><fsType>ext3</fsType><fsVersion>1.0</fsVersion><mountPoint>/export/sdc</mountPoint><size>8192</size><spaceInUse>602</spaceInUse><partitions/></disk></disks></server>"; + String diskStr = "<options><option><key>auth.allow</key><value>*</value></option><option><key>cluster.stripe-block-size</key><value>*:128KB</value></option></options>"; + //diskStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><options><option><key>auth.allow</key><value>*</value></option><option><key>cluster.stripe-block-size</key><value>*:128KB</value></option></options>"; + VolumeOptions disk = (VolumeOptions)new ServerUtil().unmarshal(VolumeOptions.class, diskStr, false); + System.out.println(disk.size()); + for(VolumeOption option : disk.getOptions()) { + System.out.println(option.toString()); + } } - } |
