Skip to content
Browse files

Merge branch 'team/storage/EUCA-4136' of git.eucalyptus-systems.com:e…

…ucalyptus into testing
  • Loading branch information...
2 parents 80ca943 + bcf49b3 commit 9f04e8e3d175d02994575cd8485d24b3f909ad97 Neil Soman committed
View
12 clc/modules/core/src/main/java/edu/ucsb/eucalyptus/cloud/entities/DirectStorageInfo.java
@@ -105,9 +105,6 @@
@ConfigurableIdentifier
@Column( name = "storage_name", unique=true)
private String name;
- @ConfigurableField( description = "Storage network interface.", displayName = "Storage Interface" )
- @Column( name = "storage_interface" )
- private String storageInterface;
@ConfigurableField( description = "Storage volumes directory.", displayName = "Volumes path" )
@Column( name = "system_storage_volumes_dir" )
private String volumesDir;
@@ -133,7 +130,6 @@ public DirectStorageInfo(final String name,
final Boolean zeroFillVolumes,
final Long timeoutInMillis) {
this.name = name;
- this.storageInterface = storageInterface;
this.volumesDir = volumesDir;
this.zeroFillVolumes = zeroFillVolumes;
this.timeoutInMillis = timeoutInMillis;
@@ -147,14 +143,6 @@ public void setName(String name) {
this.name = name;
}
- public String getStorageInterface() {
- return storageInterface;
- }
-
- public void setStorageInterface(String storageInterface) {
- this.storageInterface = storageInterface;
- }
-
public String getVolumesDir() {
return volumesDir;
}
View
1 clc/modules/storage-controller/build.xml
@@ -76,7 +76,6 @@
<mkdir dir="include" />
<javah classpath="${build.dir}" destdir="include" force="yes">
<class name="com.eucalyptus.storage.OverlayManager" />
- <class name="com.eucalyptus.storage.AOEManager" />
<class name="com.eucalyptus.storage.DASManager" />
</javah>
<native-make dir="native" target="all" />
View
2 clc/modules/storage-controller/native/Makefile
@@ -76,7 +76,7 @@ all: $(LIBDIR)/$(LVM2_SO) $(LIBDIR)/$(DAS_SO)
$(LIBDIR)/$(LVM2_SO):
mkdir -p $(LIBDIR)
- gcc -shared $(CPPFLAGS) $(CFLAGS) -o $(LIBDIR)/$(LVM2_SO) com_eucalyptus_storage_OverlayManager.c com_eucalyptus_storage_AOEManager.c
+ gcc -shared $(CPPFLAGS) $(CFLAGS) -o $(LIBDIR)/$(LVM2_SO) com_eucalyptus_storage_OverlayManager.c
$(LIBDIR)/$(DAS_SO):
mkdir -p $(LIBDIR)
View
108 clc/modules/storage-controller/native/com_eucalyptus_storage_AOEManager.c
@@ -1,108 +0,0 @@
-/*************************************************************************
- * Copyright 2009-2012 Eucalyptus Systems, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3 of the License.
- *
- * 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, see http://www.gnu.org/licenses/.
- *
- * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
- * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
- * additional information or have any questions.
- *
- * This file may incorporate work covered under the following copyright
- * and permission notice:
- *
- * Software License Agreement (BSD License)
- *
- * Copyright (c) 2008, Regents of the University of California
- * All rights reserved.
- *
- * Redistribution and use of this software in source and binary forms,
- * with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 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.
- *
- * 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. USERS OF THIS SOFTWARE ACKNOWLEDGE
- * THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE LICENSED MATERIAL,
- * COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS SOFTWARE,
- * AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
- * IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA,
- * SANTA BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY,
- * WHICH IN THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION,
- * REPLACEMENT OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO
- * IDENTIFIED, OR WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT
- * NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
- ************************************************************************/
-
-#include <com_eucalyptus_storage_AOEManager.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define EUCALYPTUS_ENV_VAR_NAME "EUCALYPTUS"
-
-extern int run_command_and_get_pid(char *cmd, char **args);
-
-JNIEXPORT jint JNICALL Java_com_eucalyptus_storage_AOEManager_exportVolume(JNIEnv * env, jobject obj, jstring iface, jstring lvName, jint major,
- jint minor)
-{
- const jbyte *lv_name = (*env)->GetStringUTFChars(env, lvName, NULL);
- const jbyte *if_name = (*env)->GetStringUTFChars(env, iface, NULL);
- char major_str[4];
- char minor_str[4];
- char *args[7];
-
- char rootwrap[256];
- char *home = getenv(EUCALYPTUS_ENV_VAR_NAME);
- if (!home) {
- home = strdup(""); /* root by default */
- } else {
- home = strdup(home);
- }
-
- snprintf(rootwrap, 256, "%s/usr/lib/eucalyptus/euca_rootwrap", home);
-
- snprintf(major_str, 4, "%d", major);
- snprintf(minor_str, 4, "%d", minor);
-
- args[0] = rootwrap;
- args[1] = "vblade";
- args[2] = major_str;
- args[3] = minor_str;
- args[4] = (char *)if_name;
- args[5] = (char *)lv_name;
- args[6] = (char *)NULL;
-
- int pid = run_command_and_get_pid(rootwrap, args);
- (*env)->ReleaseStringUTFChars(env, lvName, lv_name);
- (*env)->ReleaseStringUTFChars(env, iface, if_name);
- if (home)
- free(home);
- return pid;
-}
View
196 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/AOEManager.java
@@ -1,196 +0,0 @@
-/*************************************************************************
- * Copyright 2009-2012 Eucalyptus Systems, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3 of the License.
- *
- * 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, see http://www.gnu.org/licenses/.
- *
- * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
- * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
- * additional information or have any questions.
- *
- * This file may incorporate work covered under the following copyright
- * and permission notice:
- *
- * Software License Agreement (BSD License)
- *
- * Copyright (c) 2008, Regents of the University of California
- * All rights reserved.
- *
- * Redistribution and use of this software in source and binary forms,
- * with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 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.
- *
- * 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. USERS OF THIS SOFTWARE ACKNOWLEDGE
- * THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE LICENSED MATERIAL,
- * COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS SOFTWARE,
- * AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
- * IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA,
- * SANTA BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY,
- * WHICH IN THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION,
- * REPLACEMENT OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO
- * IDENTIFIED, OR WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT
- * NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
- ************************************************************************/
-
-package com.eucalyptus.storage;
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.eucalyptus.entities.EntityWrapper;
-import com.eucalyptus.util.EucalyptusCloudException;
-import com.eucalyptus.util.StorageProperties;
-
-import edu.ucsb.eucalyptus.cloud.entities.AOEMetaInfo;
-import edu.ucsb.eucalyptus.cloud.entities.AOEVolumeInfo;
-import edu.ucsb.eucalyptus.cloud.entities.LVMVolumeInfo;
-import edu.ucsb.eucalyptus.util.StreamConsumer;
-import edu.ucsb.eucalyptus.util.SystemUtil;
-
-public class AOEManager implements StorageExportManager {
- private static Logger LOG = Logger.getLogger(AOEManager.class);
- public static final int MAX_MINOR_NUMBER = 16;
- public native int exportVolume(String iface, String lvName, int major, int minor);
-
- @Override
- public void checkPreconditions() throws EucalyptusCloudException {
- String returnValue;
- returnValue = SystemUtil.run(new String[]{StorageProperties.EUCA_ROOT_WRAPPER, "which", "vblade"});
- if(returnValue.length() == 0) {
- throw new EucalyptusCloudException("vblade not found: Is it installed?");
- } else {
- LOG.info(returnValue);
- }
- }
-
- public void unexportVolume(int vbladePid) {
- try
- {
- Runtime rt = Runtime.getRuntime();
- Process proc = rt.exec(new String[]{StorageProperties.EUCA_ROOT_WRAPPER, "kill", String.valueOf(vbladePid)});
- StreamConsumer error = new StreamConsumer(proc.getErrorStream());
- StreamConsumer output = new StreamConsumer(proc.getInputStream());
- error.start();
- output.start();
- proc.waitFor();
- output.join();
- } catch (Exception t) {
- LOG.error(t);
- }
- }
-
- public void loadModule() {
- try
- {
- Runtime rt = Runtime.getRuntime();
- Process proc = rt.exec(new String[]{StorageProperties.EUCA_ROOT_WRAPPER, "modprobe", "aoe"});
- StreamConsumer error = new StreamConsumer(proc.getErrorStream());
- StreamConsumer output = new StreamConsumer(proc.getInputStream());
- error.start();
- output.start();
- proc.waitFor();
- output.join();
- } catch (Exception t) {
- LOG.error(t);
- }
- }
-
-
- public AOEManager() {
- loadModule();
- }
-
- @Override
- public void configure() {
- EntityWrapper<AOEMetaInfo> db = StorageProperties.getEntityWrapper();
- AOEMetaInfo metaInfo = new AOEMetaInfo(StorageProperties.NAME);
- try {
- List<AOEMetaInfo> metaInfoList = db.query(metaInfo);
- if(metaInfoList.size() <= 0) {
- metaInfo.setMajorNumber(0);
- metaInfo.setMinorNumber(0);
- db.add(metaInfo);
- }
- } catch(Exception e) {
- db.rollback();
- LOG.error(e);
- }
- db.commit();
- }
-
- @Override
- public synchronized void allocateTarget(LVMVolumeInfo volumeInfo) {
- if(volumeInfo instanceof AOEVolumeInfo) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) volumeInfo;
- int majorNumber = -1;
- int minorNumber = -1;
- EntityWrapper<AOEMetaInfo> db = StorageProperties.getEntityWrapper();
- List<AOEMetaInfo> metaInfoList = db.query(new AOEMetaInfo(StorageProperties.NAME));
- if(metaInfoList.size() > 0) {
- AOEMetaInfo foundMetaInfo = metaInfoList.get(0);
- majorNumber = foundMetaInfo.getMajorNumber();
- minorNumber = foundMetaInfo.getMinorNumber();
- do {
- if(minorNumber >= MAX_MINOR_NUMBER - 1) {
- ++majorNumber;
- }
- minorNumber = (minorNumber + 1) % MAX_MINOR_NUMBER;
- LOG.info("Trying e" + majorNumber + "." + minorNumber);
- } while(new File(StorageProperties.ETHERD_PREFIX + majorNumber + "." + minorNumber).exists());
- foundMetaInfo.setMajorNumber(majorNumber);
- foundMetaInfo.setMinorNumber(minorNumber);
- }
- aoeVolumeInfo.setMajorNumber(majorNumber);
- aoeVolumeInfo.setMinorNumber(minorNumber);
- db.commit();
- }
- }
-
- @Override
- public void cleanup(LVMVolumeInfo volume) throws EucalyptusCloudException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void stop() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void check() throws EucalyptusCloudException {
- // TODO Auto-generated method stub
-
- }
-}
View
251 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/DASManager.java
@@ -99,7 +99,6 @@
import com.eucalyptus.util.StorageProperties;
import com.eucalyptus.util.WalrusProperties;
-import edu.ucsb.eucalyptus.cloud.entities.AOEVolumeInfo;
import edu.ucsb.eucalyptus.cloud.entities.DASInfo;
import edu.ucsb.eucalyptus.cloud.entities.DirectStorageInfo;
import edu.ucsb.eucalyptus.cloud.entities.ISCSIVolumeInfo;
@@ -138,11 +137,7 @@ public void checkPreconditions() throws EucalyptusCloudException {
} else {
LOG.info(returnValue);
}
- if(System.getProperty("euca.disable.iscsi") != null) {
- exportManager = new AOEManager();
- } else {
- exportManager = new ISCSIManager();
- }
+ exportManager = new ISCSIManager();
exportManager.checkPreconditions();
} catch(EucalyptusCloudException ex) {
String error = "Unable to run command: " + ex.getMessage();
@@ -402,11 +397,8 @@ public void createVolume(String volumeId, int size) throws EucalyptusCloudExcept
String lvName = "lv-" + Hashes.getRandom(4);
LVMVolumeInfo lvmVolumeInfo = null;
- if(exportManager instanceof AOEManager) {
- lvmVolumeInfo = new AOEVolumeInfo();
- } else {
- lvmVolumeInfo = new ISCSIVolumeInfo();
- }
+ lvmVolumeInfo = new ISCSIVolumeInfo();
+
volumeManager.finish();
//create file and attach to loopback device
try {
@@ -605,7 +597,7 @@ public void deleteVolume(String volumeId) throws EucalyptusCloudException {
if(snapshotPointId != null) {
throw new EucalyptusCloudException("Synchronous snapshot points not supported in DAS storage manager");
}
-
+
updateVolumeGroup();
VolumeEntityWrapperManager volumeManager = new VolumeEntityWrapperManager();
LVMVolumeInfo foundLVMVolumeInfo = volumeManager.getVolumeInfo(volumeId);
@@ -635,7 +627,7 @@ public void deleteVolume(String volumeId) throws EucalyptusCloudException {
} else {
absoluteSize = size * StorageProperties.KB;
}
-
+
//create physical volume, volume group and logical volume
// String returnValue = createSnapshotLogicalVolume(absoluteLVName, lvName, size);
String returnValue = createSnapshotLogicalVolume(absoluteLVName, lvName, absoluteSize);
@@ -658,7 +650,7 @@ public void deleteVolume(String volumeId) throws EucalyptusCloudException {
volumeManager.add(snapshotInfo);
returnValues.add(snapRawFileName);
returnValues.add(String.valueOf(size * WalrusProperties.G));
- // } catch(EucalyptusCloudException ex) {
+ // } catch(EucalyptusCloudException ex) {
} catch(Exception ex) {
if(volumeManager != null)
volumeManager.abort();
@@ -694,13 +686,13 @@ public void deleteSnapshot(String snapshotId) throws EucalyptusCloudException {
if(foundLVMVolumeInfo != null) {
volumeManager.remove(foundLVMVolumeInfo);
- File snapFile = new File (DirectStorageInfo.getStorageInfo().getVolumesDir() + File.separator + foundLVMVolumeInfo.getVolumeId());
- volumeManager.finish();
- if (snapFile.exists()) {
- if(!snapFile.delete()) {
- throw new EucalyptusCloudException("Unable to delete: " + snapFile.getAbsolutePath());
- }
- }
+ File snapFile = new File (DirectStorageInfo.getStorageInfo().getVolumesDir() + File.separator + foundLVMVolumeInfo.getVolumeId());
+ volumeManager.finish();
+ if (snapFile.exists()) {
+ if(!snapFile.delete()) {
+ throw new EucalyptusCloudException("Unable to delete: " + snapFile.getAbsolutePath());
+ }
+ }
} else {
volumeManager.abort();
throw new EucalyptusCloudException("Unable to find snapshot: " + snapshotId);
@@ -779,108 +771,42 @@ private VolumeEntityWrapperManager() {
public List<String> getSnapshotValues(String snapshotId) {
ArrayList<String> returnValues = new ArrayList<String>();
LVMVolumeInfo lvmVolumeInfo = getVolumeInfo(snapshotId);
- if(lvmVolumeInfo instanceof AOEVolumeInfo) {
- returnValues.add(volumeGroup);
- returnValues.add(lvmVolumeInfo.getLvName());
- }
return returnValues;
}
public void exportVolume(LVMVolumeInfo lvmVolumeInfo) throws EucalyptusCloudException {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) lvmVolumeInfo;
-
- int pid = aoeVolumeInfo.getVbladePid();
- if(pid > 0) {
- //enable logical volumes
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + volumeGroup + PATH_SEPARATOR + aoeVolumeInfo.getLvName();
- try {
- enableLogicalVolume(absoluteLVName);
- } catch(EucalyptusCloudException ex) {
- String error = "Unable to run command: " + ex.getMessage();
- LOG.error(error);
- throw new EucalyptusCloudException(ex);
- }
- String returnValue = aoeStatus(pid);
- if(returnValue.length() == 0) {
- int majorNumber = aoeVolumeInfo.getMajorNumber();
- int minorNumber = aoeVolumeInfo.getMinorNumber();
- pid = exportManager.exportVolume(DirectStorageInfo.getStorageInfo().getStorageInterface(), absoluteLVName, majorNumber, minorNumber);
- aoeVolumeInfo.setVbladePid(pid);
- File vbladePidFile = new File(EUCA_VAR_RUN_PATH + "/vblade-" + majorNumber + minorNumber + ".pid");
- FileOutputStream fileOutStream = null;
- try {
- fileOutStream = new FileOutputStream(vbladePidFile);
- String pidString = String.valueOf(pid);
- fileOutStream.write(pidString.getBytes());
- fileOutStream.close();
- } catch (Exception ex) {
- if(fileOutStream != null)
- try {
- fileOutStream.close();
- } catch (IOException e) {
- LOG.error(e);
- }
- LOG.error("Could not write pid file vblade-" + majorNumber + minorNumber + ".pid");
- }
- }
- }
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + volumeGroup + PATH_SEPARATOR + iscsiVolumeInfo.getLvName();
- try {
- enableLogicalVolume(absoluteLVName);
- } catch(EucalyptusCloudException ex) {
- String error = "Unable to run command: " + ex.getMessage();
- LOG.error(error);
- throw new EucalyptusCloudException(ex);
- }
- ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
- }
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
+ String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + volumeGroup + PATH_SEPARATOR + iscsiVolumeInfo.getLvName();
+ try {
+ enableLogicalVolume(absoluteLVName);
+ } catch(EucalyptusCloudException ex) {
+ String error = "Unable to run command: " + ex.getMessage();
+ LOG.error(error);
+ throw new EucalyptusCloudException(ex);
+ }
+ ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
}
public String getVolumeProperty(String volumeId) {
LVMVolumeInfo lvmVolumeInfo = getVolumeInfo(volumeId);
if(lvmVolumeInfo != null) {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) lvmVolumeInfo;
- return StorageProperties.ETHERD_PREFIX + aoeVolumeInfo.getMajorNumber() + "." + aoeVolumeInfo.getMinorNumber();
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
- String storeName = iscsiVolumeInfo.getStoreName();
- String encryptedPassword;
- try {
- encryptedPassword = ((ISCSIManager)exportManager).getEncryptedPassword();
- } catch (EucalyptusCloudException e) {
- LOG.error(e);
- return null;
- }
- return ",,," + encryptedPassword + ",," + StorageProperties.STORAGE_HOST + "," + storeName;
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
+ String storeName = iscsiVolumeInfo.getStoreName();
+ String encryptedPassword;
+ try {
+ encryptedPassword = ((ISCSIManager)exportManager).getEncryptedPassword();
+ } catch (EucalyptusCloudException e) {
+ LOG.error(e);
+ return null;
}
+ return ",,," + encryptedPassword + ",," + StorageProperties.STORAGE_HOST + "," + storeName;
}
return null;
}
public void unexportVolume(LVMVolumeInfo volumeInfo) {
- if(volumeInfo instanceof AOEVolumeInfo) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) volumeInfo;
- int pid = aoeVolumeInfo.getVbladePid();
- if(pid > 0) {
- String returnValue = aoeStatus(pid);
- if(returnValue.length() > 0) {
- exportManager.unexportVolume(pid);
- int majorNumber = aoeVolumeInfo.getMajorNumber();
- int minorNumber = aoeVolumeInfo.getMinorNumber();
- File vbladePidFile = new File(EUCA_VAR_RUN_PATH + "/vblade-" + majorNumber + minorNumber + ".pid");
- if(vbladePidFile.exists()) {
- vbladePidFile.delete();
- }
- }
- }
- } else if(volumeInfo instanceof ISCSIVolumeInfo) {
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) volumeInfo;
- ((ISCSIManager)exportManager).unexportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getLun());
- }
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) volumeInfo;
+ ((ISCSIManager)exportManager).unexportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getLun());
}
private void finish() {
@@ -893,44 +819,22 @@ private void abort() {
private LVMVolumeInfo getVolumeInfo(String volumeId) {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo AOEVolumeInfo = new AOEVolumeInfo(volumeId);
- List<AOEVolumeInfo> AOEVolumeInfos = entityWrapper.query(AOEVolumeInfo);
- if(AOEVolumeInfos.size() > 0) {
- return AOEVolumeInfos.get(0);
- }
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo(volumeId);
- List<ISCSIVolumeInfo> ISCSIVolumeInfos = entityWrapper.query(ISCSIVolumeInfo);
- if(ISCSIVolumeInfos.size() > 0) {
- return ISCSIVolumeInfos.get(0);
- }
+ ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo(volumeId);
+ List<ISCSIVolumeInfo> ISCSIVolumeInfos = entityWrapper.query(ISCSIVolumeInfo);
+ if(ISCSIVolumeInfos.size() > 0) {
+ return ISCSIVolumeInfos.get(0);
}
+
return null;
}
private LVMVolumeInfo getVolumeInfo() {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo aoeVolumeInfo = new AOEVolumeInfo();
- aoeVolumeInfo.setVbladePid(-1);
- aoeVolumeInfo.setMajorNumber(-1);
- aoeVolumeInfo.setMinorNumber(-1);
- return aoeVolumeInfo;
- } else if(exportManager instanceof ISCSIManager) {
- return new ISCSIVolumeInfo();
- }
- return null;
+ return new ISCSIVolumeInfo();
}
private List<LVMVolumeInfo> getAllVolumeInfos() {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo AOEVolumeInfo = new AOEVolumeInfo();
- return entityWrapper.query(AOEVolumeInfo);
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo();
- return entityWrapper.query(ISCSIVolumeInfo);
- }
- return new ArrayList<LVMVolumeInfo>();
+ ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo();
+ return entityWrapper.query(ISCSIVolumeInfo);
}
private void add(LVMVolumeInfo volumeInfo) {
@@ -956,63 +860,10 @@ private String encryptTargetPassword(String password) throws EucalyptusCloudExce
}
private int exportVolume(LVMVolumeInfo lvmVolumeInfo, String vgName, String lvName) throws EucalyptusCloudException {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) lvmVolumeInfo;
- exportManager.allocateTarget(aoeVolumeInfo);
- int majorNumber = aoeVolumeInfo.getMajorNumber();
- int minorNumber = aoeVolumeInfo.getMinorNumber();
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + vgName + PATH_SEPARATOR + lvName;
- int pid = exportManager.exportVolume(DirectStorageInfo.getStorageInfo().getStorageInterface(), absoluteLVName, majorNumber, minorNumber);
- boolean success = false;
- String returnValue = "";
- int timeout = 300;
- if(pid > 0) {
- for(int i=0; i < 5; ++i) {
- returnValue = aoeStatus(pid);
- if(returnValue.length() == 0) {
- success = false;
- try {
- Thread.sleep(timeout);
- } catch(InterruptedException ie) {
- LOG.error(ie);
- }
- timeout += 300;
- } else {
- success = true;
- break;
- }
- }
- }
- if(!success) {
- throw new EucalyptusCloudException("Could not export AoE device " + absoluteLVName + " iface: " + DirectStorageInfo.getStorageInfo().getStorageInterface() + " pid: " + pid + " returnValue: " + returnValue);
- }
-
- File vbladePidFile = new File(EUCA_VAR_RUN_PATH + "/vblade-" + majorNumber + minorNumber + ".pid");
- FileOutputStream fileOutStream = null;
- try {
- fileOutStream = new FileOutputStream(vbladePidFile);
- String pidString = String.valueOf(pid);
- fileOutStream.write(pidString.getBytes());
- } catch (Exception ex) {
- LOG.error("Could not write pid file vblade-" + majorNumber + minorNumber + ".pid");
- } finally {
- if(fileOutStream != null)
- try {
- fileOutStream.close();
- } catch (IOException e) {
- LOG.error(e);
- }
- }
- if(pid < 0)
- throw new EucalyptusCloudException("invalid vblade pid: " + pid);
- aoeVolumeInfo.setVbladePid(pid);
- return pid;
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
- exportManager.allocateTarget(iscsiVolumeInfo);
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + vgName + PATH_SEPARATOR + lvName;
- ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
- }
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
+ exportManager.allocateTarget(iscsiVolumeInfo);
+ String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + vgName + PATH_SEPARATOR + lvName;
+ ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
return 0;
}
}
@@ -1037,7 +888,7 @@ public String prepareSnapshot(String snapshotId, int sizeExpected, long actualSi
deviceName = snapshotInfo.getLoFileName();
volumeManager.add(snapshotInfo);
}
-
+
volumeManager.finish();
return deviceName;
// return DirectStorageInfo.getStorageInfo().getVolumesDir() + File.separator + snapshotId;
@@ -1216,14 +1067,14 @@ public void enable() throws EucalyptusCloudException {
@Override
public boolean getFromBackend(String snapshotId, int size)
- throws EucalyptusCloudException {
+ throws EucalyptusCloudException {
return false;
}
@Override
public void checkVolume(String volumeId) throws EucalyptusCloudException {
}
-
+
@Override
public List<CheckerTask> getCheckers() {
List<CheckerTask> checkers = new ArrayList<CheckerTask>();
@@ -1232,13 +1083,13 @@ public void checkVolume(String volumeId) throws EucalyptusCloudException {
@Override
public String createSnapshotPoint(String volumeId, String snapshotId)
- throws EucalyptusCloudException {
+ throws EucalyptusCloudException {
return null;
}
@Override
public void deleteSnapshotPoint(String volumeId, String snapshotId, String snapshotPointId)
- throws EucalyptusCloudException {
+ throws EucalyptusCloudException {
throw new EucalyptusCloudException("Synchronous snapshot points not supported in DAS storage manager");
}
}
View
6 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/ISCSIManager.java
@@ -318,12 +318,6 @@ public void unexportTarget(int tid, int lun) {
}
}
- public native int exportVolume(String iface, String lvName, int major, int minor);
-
- public native void unexportVolume(int vbladePid);
-
- public native void loadModule();
-
public ISCSIManager() {}
@Override
View
338 clc/modules/storage-controller/src/main/java/com/eucalyptus/storage/OverlayManager.java
@@ -95,7 +95,6 @@
import com.eucalyptus.util.WalrusProperties;
import com.google.common.base.Joiner;
-import edu.ucsb.eucalyptus.cloud.entities.AOEVolumeInfo;
import edu.ucsb.eucalyptus.cloud.entities.DirectStorageInfo;
import edu.ucsb.eucalyptus.cloud.entities.ISCSIVolumeInfo;
import edu.ucsb.eucalyptus.cloud.entities.LVMVolumeInfo;
@@ -117,7 +116,6 @@
private static final long LVM_HEADER_LENGTH = 4 * StorageProperties.MB;
public static StorageExportManager exportManager;
- public static String iface = "eth0";
public static boolean zeroFillVolumes = false;
private ConcurrentHashMap<String, VolumeOpMonitor> volumeOps;
@@ -139,11 +137,7 @@ public void checkPreconditions() throws EucalyptusCloudException {
} else {
LOG.info(returnValue);
}
- if(System.getProperty("euca.disable.iscsi") != null) {
- exportManager = new AOEManager();
- } else {
- exportManager = new ISCSIManager();
- }
+ exportManager = new ISCSIManager();
exportManager.checkPreconditions();
} catch(EucalyptusCloudException ex) {
String error = "Unable to run command: " + ex.getMessage();
@@ -229,7 +223,7 @@ private String removeLoopback(String loDevName) throws EucalyptusCloudException
}
retryCount++;
} while (retryCount < 20);
-
+
LOG.error("All attempts to remove loop device " + loDevName + " failed.");
return "";
}
@@ -530,11 +524,8 @@ public void createVolume(String volumeId, int size) throws EucalyptusCloudExcept
VolumeEntityWrapperManager volumeManager = new VolumeEntityWrapperManager();
LVMVolumeInfo lvmVolumeInfo = null;
- if(exportManager instanceof AOEManager) {
- lvmVolumeInfo = new AOEVolumeInfo();
- } else {
- lvmVolumeInfo = new ISCSIVolumeInfo();
- }
+ lvmVolumeInfo = new ISCSIVolumeInfo();
+
volumeManager.finish();
String rawFileName = DirectStorageInfo.getStorageInfo().getVolumesDir() + "/" + volumeId;
//create file and attach to loopback device
@@ -547,12 +538,12 @@ public void createVolume(String volumeId, int size) throws EucalyptusCloudExcept
String loDevName = createLoopback(rawFileName, absoluteSize);
lvmVolumeInfo.setVolumeId(volumeId);
lvmVolumeInfo.setLoDevName(loDevName);
-
+
//create physical volume, volume group and logical volume
createLogicalVolume(loDevName, vgName, lvName);
lvmVolumeInfo.setVgName(vgName);
lvmVolumeInfo.setLvName(lvName);
-
+
lvmVolumeInfo.setStatus(StorageProperties.Status.available.toString());
lvmVolumeInfo.setSize(size);
//tear down
@@ -601,21 +592,21 @@ public int createVolume(String volumeId, String snapshotId, int size) throws Euc
long absoluteSize;
if (size <= 0 || size == foundSnapshotInfo.getSize()) {
size = (int)(snapshotFile.length() / StorageProperties.GB);
- absoluteSize = snapshotFile.length() + LVM_HEADER_LENGTH;
+ absoluteSize = snapshotFile.length() + LVM_HEADER_LENGTH;
} else {
absoluteSize = size * StorageProperties.GB + LVM_HEADER_LENGTH;
}
-
+
String loDevName = createLoopback(rawFileName, absoluteSize);
lvmVolumeInfo.setVolumeId(volumeId);
lvmVolumeInfo.setLoDevName(loDevName);
-
+
//create physical volume, volume group and logical volume
createLogicalVolume(loDevName, vgName, lvName);
//duplicate snapshot volume
String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + vgName + PATH_SEPARATOR + lvName;
duplicateLogicalVolume(loFileName, absoluteLVName);
-
+
lvmVolumeInfo.setVgName(vgName);
lvmVolumeInfo.setLvName(lvName);
lvmVolumeInfo.setStatus(StorageProperties.Status.available.toString());
@@ -747,7 +738,7 @@ public void deleteVolume(String volumeId) throws EucalyptusCloudException {
volumeManager.finish();
}
}
-
+
if (foundLVMVolumeInfo != null) {
boolean isReadyForDelete = false;
int retryCount = 0;
@@ -859,7 +850,7 @@ private synchronized void deleteLogicalVolume(String loDevName, String vgName,
if(snapshotPointId != null) {
throw new EucalyptusCloudException("Synchronous snapshot points not supported in Overlay storage manager");
}
-
+
VolumeEntityWrapperManager volumeManager = new VolumeEntityWrapperManager();
LVMVolumeInfo foundLVMVolumeInfo = volumeManager.getVolumeInfo(volumeId);
ArrayList<String> returnValues = new ArrayList<String>();
@@ -1112,99 +1103,27 @@ private VolumeEntityWrapperManager() {
public List<String> getSnapshotValues(String snapshotId) {
ArrayList<String> returnValues = new ArrayList<String>();
LVMVolumeInfo lvmVolumeInfo = getVolumeInfo(snapshotId);
- if(lvmVolumeInfo instanceof AOEVolumeInfo) {
- returnValues.add(lvmVolumeInfo.getVgName());
- returnValues.add(lvmVolumeInfo.getLvName());
- }
return returnValues;
}
public void exportVolume(LVMVolumeInfo lvmVolumeInfo) throws EucalyptusCloudException {
- if(exportManager instanceof AOEManager) {
- if(lvmVolumeInfo instanceof AOEVolumeInfo) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) lvmVolumeInfo;
-
- int pid = aoeVolumeInfo.getVbladePid();
- if(pid > 0) {
- //enable logical volumes
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + aoeVolumeInfo.getVgName() + PATH_SEPARATOR + aoeVolumeInfo.getLvName();
- if(!logicalVolumeExists(absoluteLVName)) {
- LOG.error("Backing volume not found: " + absoluteLVName);
- throw new EucalyptusCloudException("Logical volume not found: " + absoluteLVName);
- }
- try {
- enableLogicalVolume(absoluteLVName);
- } catch(EucalyptusCloudException ex) {
- String error = "Unable to run command: " + ex.getMessage();
- LOG.error(error);
- throw new EucalyptusCloudException(ex);
- }
- String returnValue = aoeStatus(pid);
- if(returnValue.length() == 0) {
- int majorNumber = aoeVolumeInfo.getMajorNumber();
- int minorNumber = aoeVolumeInfo.getMinorNumber();
- pid = exportManager.exportVolume(DirectStorageInfo.getStorageInfo().getStorageInterface(), absoluteLVName, majorNumber, minorNumber);
- aoeVolumeInfo.setVbladePid(pid);
- File vbladePidFile = new File(EUCA_VAR_RUN_PATH + "/vblade-" + majorNumber + minorNumber + ".pid");
- FileOutputStream fileOutStream = null;
- try {
- fileOutStream = new FileOutputStream(vbladePidFile);
- String pidString = String.valueOf(pid);
- fileOutStream.write(pidString.getBytes());
- fileOutStream.close();
- } catch (Exception ex) {
- if(fileOutStream != null)
- try {
- fileOutStream.close();
- } catch (IOException e) {
- LOG.error(e);
- }
- LOG.error("Could not write pid file vblade-" + majorNumber + minorNumber + ".pid");
- }
- }
- }
- } else {
- //convert it
- AOEVolumeInfo volumeInfo = new AOEVolumeInfo();
- convertVolumeInfo(lvmVolumeInfo, volumeInfo);
- try {
- unexportVolume(lvmVolumeInfo);
- exportVolume(volumeInfo, volumeInfo.getVgName(), volumeInfo.getLvName());
- add(volumeInfo);
- remove(lvmVolumeInfo);
- } catch(EucalyptusCloudException ex) {
- LOG.error(ex);
- }
- }
- } else if(exportManager instanceof ISCSIManager) {
- if(lvmVolumeInfo instanceof ISCSIVolumeInfo) {
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + iscsiVolumeInfo.getVgName() + PATH_SEPARATOR + iscsiVolumeInfo.getLvName();
- if(!logicalVolumeExists(absoluteLVName)) {
- LOG.error("Backing volume not found: " + absoluteLVName);
- throw new EucalyptusCloudException("Logical volume not found: " + absoluteLVName);
- }
- try {
- enableLogicalVolume(absoluteLVName);
- } catch(EucalyptusCloudException ex) {
- String error = "Unable to run command: " + ex.getMessage();
- LOG.error(error);
- throw new EucalyptusCloudException(ex);
- }
- ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
+ if(lvmVolumeInfo instanceof ISCSIVolumeInfo) {
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
+ String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + iscsiVolumeInfo.getVgName() + PATH_SEPARATOR + iscsiVolumeInfo.getLvName();
+ if(!logicalVolumeExists(absoluteLVName)) {
+ LOG.error("Backing volume not found: " + absoluteLVName);
+ throw new EucalyptusCloudException("Logical volume not found: " + absoluteLVName);
}
- } else {
- ISCSIVolumeInfo volumeInfo = new ISCSIVolumeInfo();
- convertVolumeInfo(lvmVolumeInfo, volumeInfo);
try {
- unexportVolume(lvmVolumeInfo);
- exportVolume(volumeInfo, volumeInfo.getVgName(), volumeInfo.getLvName());
- add(volumeInfo);
- remove(lvmVolumeInfo);
+ enableLogicalVolume(absoluteLVName);
} catch(EucalyptusCloudException ex) {
- LOG.error(ex);
+ String error = "Unable to run command: " + ex.getMessage();
+ LOG.error(error);
+ throw new EucalyptusCloudException(ex);
}
- }
+ ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
+ }
+
}
private void convertVolumeInfo(LVMVolumeInfo lvmVolumeSource, LVMVolumeInfo lvmVolumeDestination) {
@@ -1223,61 +1142,28 @@ private void convertVolumeInfo(LVMVolumeInfo lvmVolumeSource, LVMVolumeInfo lvmV
public String getVolumeProperty(String volumeId) {
LVMVolumeInfo lvmVolumeInfo = getVolumeInfo(volumeId);
if(lvmVolumeInfo != null) {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) lvmVolumeInfo;
- return StorageProperties.ETHERD_PREFIX + aoeVolumeInfo.getMajorNumber() + "." + aoeVolumeInfo.getMinorNumber();
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
- String storeName = iscsiVolumeInfo.getStoreName();
- String encryptedPassword;
- try {
- encryptedPassword = ((ISCSIManager)exportManager).getEncryptedPassword();
- } catch (EucalyptusCloudException e) {
- LOG.error(e);
- return null;
- }
- return ",,," + encryptedPassword + ",," + StorageProperties.STORAGE_HOST + "," + storeName;
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
+ String storeName = iscsiVolumeInfo.getStoreName();
+ String encryptedPassword;
+ try {
+ encryptedPassword = ((ISCSIManager)exportManager).getEncryptedPassword();
+ } catch (EucalyptusCloudException e) {
+ LOG.error(e);
+ return null;
}
+ return ",,," + encryptedPassword + ",," + StorageProperties.STORAGE_HOST + "," + storeName;
}
return null;
}
public void unexportVolume(LVMVolumeInfo volumeInfo) {
StorageExportManager manager = exportManager;
- if(volumeInfo instanceof AOEVolumeInfo) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) volumeInfo;
- if(!(exportManager instanceof AOEManager)) {
- manager = new AOEManager();
- }
- int pid = aoeVolumeInfo.getVbladePid();
- if(pid > 0) {
- String returnValue = aoeStatus(pid);
- if(returnValue.length() > 0) {
- manager.unexportVolume(pid);
- int majorNumber = aoeVolumeInfo.getMajorNumber();
- int minorNumber = aoeVolumeInfo.getMinorNumber();
- File vbladePidFile = new File(EUCA_VAR_RUN_PATH + "/vblade-" + majorNumber + minorNumber + ".pid");
- if(vbladePidFile.exists()) {
- vbladePidFile.delete();
- }
- while(aoeStatus(pid).length() > 0) {
- LOG.info("Waiting for volume to be unexported...");
- try {
- Thread.sleep(300);
- } catch (InterruptedException e) {
- LOG.error(e);
- }
- }
- }
- }
- } else if(volumeInfo instanceof ISCSIVolumeInfo) {
- if(!(exportManager instanceof ISCSIManager)) {
- manager = new ISCSIManager();
- }
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) volumeInfo;
- ((ISCSIManager)manager).unexportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getLun());
- iscsiVolumeInfo.setTid(-1);
- }
+ if(!(exportManager instanceof ISCSIManager)) {
+ manager = new ISCSIManager();
+ }
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) volumeInfo;
+ ((ISCSIManager)manager).unexportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getLun());
+ iscsiVolumeInfo.setTid(-1);
}
private void finish() {
@@ -1295,59 +1181,31 @@ private void abort() {
private LVMVolumeInfo getVolumeInfo(String volumeId) {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo AOEVolumeInfo = new AOEVolumeInfo(volumeId);
- List<AOEVolumeInfo> AOEVolumeInfos = entityWrapper.query(AOEVolumeInfo);
- if(AOEVolumeInfos.size() > 0) {
- return AOEVolumeInfos.get(0);
- }
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo(volumeId);
- List<ISCSIVolumeInfo> ISCSIVolumeInfos = entityWrapper.query(ISCSIVolumeInfo);
- if(ISCSIVolumeInfos.size() > 0) {
- return ISCSIVolumeInfos.get(0);
- }
+ ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo(volumeId);
+ List<ISCSIVolumeInfo> ISCSIVolumeInfos = entityWrapper.query(ISCSIVolumeInfo);
+ if(ISCSIVolumeInfos.size() > 0) {
+ return ISCSIVolumeInfos.get(0);
}
return null;
}
private boolean areSnapshotsPending(String volumeId) {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo AOEVolumeInfo = new AOEVolumeInfo();
- AOEVolumeInfo.setSnapshotOf(volumeId);
- AOEVolumeInfo.setStatus(StorageProperties.Status.pending.toString());
- List<AOEVolumeInfo> AOEVolumeInfos = entityWrapper.query(AOEVolumeInfo);
- if(AOEVolumeInfos.size() > 0) {
- return true;
- }
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo();
- ISCSIVolumeInfo.setSnapshotOf(volumeId);
- ISCSIVolumeInfo.setStatus(StorageProperties.Status.pending.toString());
- List<ISCSIVolumeInfo> ISCSIVolumeInfos = entityWrapper.query(ISCSIVolumeInfo);
- if(ISCSIVolumeInfos.size() > 0) {
- return true;
- }
+ ISCSIVolumeInfo ISCSIVolumeInfo = new ISCSIVolumeInfo();
+ ISCSIVolumeInfo.setSnapshotOf(volumeId);
+ ISCSIVolumeInfo.setStatus(StorageProperties.Status.pending.toString());
+ List<ISCSIVolumeInfo> ISCSIVolumeInfos = entityWrapper.query(ISCSIVolumeInfo);
+ if(ISCSIVolumeInfos.size() > 0) {
+ return true;
}
return false;
}
private LVMVolumeInfo getVolumeInfo() {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo aoeVolumeInfo = new AOEVolumeInfo();
- aoeVolumeInfo.setVbladePid(-1);
- aoeVolumeInfo.setMajorNumber(-1);
- aoeVolumeInfo.setMinorNumber(-1);
- return aoeVolumeInfo;
- } else if(exportManager instanceof ISCSIManager) {
- return new ISCSIVolumeInfo();
- }
- return null;
+ return new ISCSIVolumeInfo();
}
private List<LVMVolumeInfo> getAllVolumeInfos() {
List<LVMVolumeInfo> volumeInfos = new ArrayList<LVMVolumeInfo>();
- volumeInfos.addAll(entityWrapper.query(new AOEVolumeInfo()));
volumeInfos.addAll(entityWrapper.query(new ISCSIVolumeInfo()));
return volumeInfos;
}
@@ -1375,79 +1233,29 @@ private String encryptTargetPassword(String password) throws EucalyptusCloudExce
}
private void exportVolume(LVMVolumeInfo lvmVolumeInfo, String vgName, String lvName) throws EucalyptusCloudException {
- if(exportManager instanceof AOEManager) {
- AOEVolumeInfo aoeVolumeInfo = (AOEVolumeInfo) lvmVolumeInfo;
- exportManager.allocateTarget(aoeVolumeInfo);
- int majorNumber = aoeVolumeInfo.getMajorNumber();
- int minorNumber = aoeVolumeInfo.getMinorNumber();
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + vgName + PATH_SEPARATOR + lvName;
- int pid = exportManager.exportVolume(DirectStorageInfo.getStorageInfo().getStorageInterface(), absoluteLVName, majorNumber, minorNumber);
- boolean success = false;
- String returnValue = "";
- int timeout = 300;
- if(pid > 0) {
- for(int i=0; i < 3; ++i) {
- returnValue = aoeStatus(pid);
- if(returnValue.length() == 0) {
- success = false;
- } else {
- success = true;
- }
- try {
- Thread.sleep(timeout);
- } catch(InterruptedException ie) {
- LOG.error(ie);
- }
- }
- }
- if(!success) {
- throw new EucalyptusCloudException("Could not export AoE device " + absoluteLVName + " StorageInfo.getStorageInfo().getStorageInterface(): " + DirectStorageInfo.getStorageInfo().getStorageInterface() + " pid: " + pid + " returnValue: " + returnValue);
- }
+ ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
- File vbladePidFile = new File(EUCA_VAR_RUN_PATH + "/vblade-" + majorNumber + minorNumber + ".pid");
- FileOutputStream fileOutStream = null;
+ String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + vgName + PATH_SEPARATOR + lvName;
+ int max_tries = 10;
+ int i = 0;
+ EucalyptusCloudException ex = null;
+ do {
+ exportManager.allocateTarget(iscsiVolumeInfo);
try {
- fileOutStream = new FileOutputStream(vbladePidFile);
- String pidString = String.valueOf(pid);
- fileOutStream.write(pidString.getBytes());
- } catch (Exception ex) {
- LOG.error("Could not write pid file vblade-" + majorNumber + minorNumber + ".pid");
- } finally {
- if(fileOutStream != null)
- try {
- fileOutStream.close();
- } catch (IOException e) {
- LOG.error(e);
- }
+ ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
+ ex = null;
+ //it worked. break out. may be break is a better way of breaking out?
+ //i = max_tries;
+ break;
+ } catch (EucalyptusCloudException e) {
+ ex = e;
+ LOG.error(e);
}
- if(pid < 0)
- throw new EucalyptusCloudException("invalid vblade pid: " + pid);
- aoeVolumeInfo.setVbladePid(pid);
- } else if(exportManager instanceof ISCSIManager) {
- ISCSIVolumeInfo iscsiVolumeInfo = (ISCSIVolumeInfo) lvmVolumeInfo;
+ } while (i++ < max_tries);
- String absoluteLVName = lvmRootDirectory + PATH_SEPARATOR + vgName + PATH_SEPARATOR + lvName;
- int max_tries = 10;
- int i = 0;
- EucalyptusCloudException ex = null;
- do {
- exportManager.allocateTarget(iscsiVolumeInfo);
- try {
- ((ISCSIManager)exportManager).exportTarget(iscsiVolumeInfo.getTid(), iscsiVolumeInfo.getStoreName(), iscsiVolumeInfo.getLun(), absoluteLVName, iscsiVolumeInfo.getStoreUser());
- ex = null;
- //it worked. break out. may be break is a better way of breaking out?
- //i = max_tries;
- break;
- } catch (EucalyptusCloudException e) {
- ex = e;
- LOG.error(e);
- }
- } while (i++ < max_tries);
-
- // EUCA-3597 After all retries, check if the process actually completed
- if (null != ex){
- throw ex;
- }
+ // EUCA-3597 After all retries, check if the process actually completed
+ if (null != ex){
+ throw ex;
}
}
}
@@ -1479,7 +1287,7 @@ public String prepareSnapshot(String snapshotId, int sizeExpected, long actualSi
}
volumeManager.finish();
return deviceName;
-
+
// return DirectStorageInfo.getStorageInfo().getVolumesDir() + File.separator + snapshotId;
}
@@ -1831,13 +1639,13 @@ public void removeMonitor(String key) {
@Override
public String createSnapshotPoint(String volumeId, String snapshotId)
- throws EucalyptusCloudException {
+ throws EucalyptusCloudException {
return null;
}
@Override
public void deleteSnapshotPoint(String volumeId, String snapshotId, String snapshotPointId)
- throws EucalyptusCloudException {
+ throws EucalyptusCloudException {
throw new EucalyptusCloudException("Synchronous snapshot points not supported in Overlay storage manager");
}
}
View
4 ...modules/storage-controller/src/main/java/com/eucalyptus/storage/StorageExportManager.java
@@ -69,10 +69,6 @@
public interface StorageExportManager {
public void checkPreconditions() throws EucalyptusCloudException;
- public int exportVolume(String iface, String lvName, int major, int minor);
-
- public void unexportVolume(int vbladePid);
-
public void configure();
public void allocateTarget(LVMVolumeInfo volumeInfo) throws EucalyptusCloudException;

0 comments on commit 9f04e8e

Please sign in to comment.
Something went wrong with that request. Please try again.