mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	bug 9189: fixed it in master, modifystoragepool doesn't try to create/import any more, will port it to 2.1.x
This commit is contained in:
		
							parent
							
								
									2e284e1f75
								
							
						
					
					
						commit
						436dccb6d7
					
				@ -77,6 +77,7 @@ import com.cloud.agent.api.CleanupNetworkRulesCmd;
 | 
			
		||||
import com.cloud.agent.api.Command;
 | 
			
		||||
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
 | 
			
		||||
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
 | 
			
		||||
import com.cloud.agent.api.CreateStoragePoolCommand;
 | 
			
		||||
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
 | 
			
		||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
 | 
			
		||||
import com.cloud.agent.api.DeleteSnapshotBackupAnswer;
 | 
			
		||||
@ -850,6 +851,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 | 
			
		||||
                return execute((CreatePrivateTemplateFromSnapshotCommand) cmd);
 | 
			
		||||
            } else if (cmd instanceof UpgradeSnapshotCommand) {
 | 
			
		||||
                return execute((UpgradeSnapshotCommand) cmd);
 | 
			
		||||
            } else if (cmd instanceof CreateStoragePoolCommand) {
 | 
			
		||||
                return execute((CreateStoragePoolCommand) cmd);
 | 
			
		||||
            } else if (cmd instanceof ModifyStoragePoolCommand) {
 | 
			
		||||
                return execute((ModifyStoragePoolCommand) cmd);
 | 
			
		||||
            } else if (cmd instanceof SecurityIngressRulesCmd) {
 | 
			
		||||
@ -1388,7 +1391,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
  
 | 
			
		||||
    protected Answer execute(CreateStoragePoolCommand cmd) {
 | 
			
		||||
        return new Answer(cmd, true, "success");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    protected Answer execute(ModifyStoragePoolCommand cmd) {
 | 
			
		||||
    	try {
 | 
			
		||||
    		Connect conn = LibvirtConnection.getConnection();
 | 
			
		||||
 | 
			
		||||
@ -67,6 +67,7 @@ import com.cloud.agent.api.CleanupNetworkRulesCmd;
 | 
			
		||||
import com.cloud.agent.api.Command;
 | 
			
		||||
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
 | 
			
		||||
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
 | 
			
		||||
import com.cloud.agent.api.CreateStoragePoolCommand;
 | 
			
		||||
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
 | 
			
		||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
 | 
			
		||||
import com.cloud.agent.api.DeleteSnapshotBackupAnswer;
 | 
			
		||||
@ -418,6 +419,8 @@ public abstract class CitrixResourceBase implements ServerResource {
 | 
			
		||||
            return execute((MigrateCommand) cmd);
 | 
			
		||||
        } else if (cmd instanceof DestroyCommand) {
 | 
			
		||||
            return execute((DestroyCommand) cmd);
 | 
			
		||||
        } else if (cmd instanceof CreateStoragePoolCommand) {
 | 
			
		||||
            return execute((CreateStoragePoolCommand) cmd);
 | 
			
		||||
        } else if (cmd instanceof ModifyStoragePoolCommand) {
 | 
			
		||||
            return execute((ModifyStoragePoolCommand) cmd);
 | 
			
		||||
        } else if (cmd instanceof DeleteStoragePoolCommand) {
 | 
			
		||||
@ -4044,6 +4047,27 @@ public abstract class CitrixResourceBase implements ServerResource {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected Answer execute(CreateStoragePoolCommand cmd) {
 | 
			
		||||
        Connection conn = getConnection();
 | 
			
		||||
        StorageFilerTO pool = cmd.getPool();
 | 
			
		||||
        try {
 | 
			
		||||
            if (pool.getType() == StoragePoolType.NetworkFilesystem) {
 | 
			
		||||
                getNfsSR(conn, pool);
 | 
			
		||||
            } else if (pool.getType() == StoragePoolType.IscsiLUN) {
 | 
			
		||||
                getIscsiSR(conn, pool);
 | 
			
		||||
            } else if (pool.getType() == StoragePoolType.PreSetup) {
 | 
			
		||||
            } else {
 | 
			
		||||
                return new Answer(cmd, false, "The pool type: " + pool.getType().name() + " is not supported.");
 | 
			
		||||
            }
 | 
			
		||||
            return new Answer(cmd, true, "success");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            String msg = "Catch Exception " + e.getClass().getName() + ", create StoragePool failed due to " + e.toString() + " on host:" + _host.uuid + " pool: " + pool.getHost() + pool.getPath();
 | 
			
		||||
            s_logger.warn(msg, e);
 | 
			
		||||
            return new Answer(cmd, false, msg);
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    protected Answer execute(ModifyStoragePoolCommand cmd) {
 | 
			
		||||
        Connection conn = getConnection();
 | 
			
		||||
        StorageFilerTO pool = cmd.getPool();
 | 
			
		||||
@ -4676,10 +4700,8 @@ public abstract class CitrixResourceBase implements ServerResource {
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (target.equals(dc.get("target")) && targetiqn.equals(dc.get("targetIQN")) && lunid.equals(dc.get("lunid"))) {
 | 
			
		||||
                        if (checkSR(conn, sr)) {
 | 
			
		||||
                            return sr;
 | 
			
		||||
                        }
 | 
			
		||||
                        throw new CloudRuntimeException("SR check failed for storage pool: " + pool.getUuid() + "on host:" + _host.uuid);
 | 
			
		||||
                        throw new CloudRuntimeException("There is a SR using the same configuration target:" + dc.get("target") +  ", targetIQN:" 
 | 
			
		||||
                                    + dc.get("targetIQN")  + ", lunid:" + dc.get("lunid") + " for pool " + pool.getUuid() + "on host:" + _host.uuid);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                deviceConfig.put("target", target);
 | 
			
		||||
@ -4791,14 +4813,11 @@ public abstract class CitrixResourceBase implements ServerResource {
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (server.equals(dc.get("server")) && serverpath.equals(dc.get("serverpath"))) {
 | 
			
		||||
                    if (checkSR(conn, sr)) {
 | 
			
		||||
                        return sr;
 | 
			
		||||
                    }
 | 
			
		||||
                    throw new CloudRuntimeException("SR check failed for storage pool: " + pool.getUuid() + "on host:" + _host.uuid);
 | 
			
		||||
                    throw new CloudRuntimeException("There is a SR using the same configuration server:" + dc.get("server") + ", serverpath:" 
 | 
			
		||||
                            + dc.get("serverpath") + " for pool " + pool.getUuid() + "on host:" + _host.uuid);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            deviceConfig.put("server", server);
 | 
			
		||||
            deviceConfig.put("serverpath", serverpath);
 | 
			
		||||
            Host host = Host.getByUuid(conn, _host.uuid);
 | 
			
		||||
@ -5658,20 +5677,10 @@ public abstract class CitrixResourceBase implements ServerResource {
 | 
			
		||||
            }
 | 
			
		||||
            throw new CloudRuntimeException("SR check failed for storage pool: " + pool.getUuid() + "on host:" + _host.uuid);
 | 
			
		||||
        } else {
 | 
			
		||||
            
 | 
			
		||||
	
 | 
			
		||||
	        if (pool.getType() == StoragePoolType.NetworkFilesystem) {
 | 
			
		||||
                return getNfsSR(conn, pool);
 | 
			
		||||
            } else if (pool.getType() == StoragePoolType.IscsiLUN) {
 | 
			
		||||
                return getIscsiSR(conn, pool);
 | 
			
		||||
            } else if (pool.getType() == StoragePoolType.PreSetup) {
 | 
			
		||||
                throw new CloudRuntimeException("The pool type: " + pool.getType().name() + " uuid " + pool.getUuid() + " doesn't exist");
 | 
			
		||||
            } else {
 | 
			
		||||
                throw new CloudRuntimeException("The pool type: " + pool.getType().name() + " is not supported.");
 | 
			
		||||
            }
 | 
			
		||||
            throw new CloudRuntimeException("Can not see storage pool: " + pool.getUuid() + " from on host:" + _host.uuid);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    protected Answer execute(final CheckConsoleProxyLoadCommand cmd) {
 | 
			
		||||
        return executeProxyLoadScan(cmd, cmd.getProxyVmId(), cmd.getProxyVmName(), cmd.getProxyManagementIp(), cmd.getProxyCmdPort());
 | 
			
		||||
 | 
			
		||||
@ -189,4 +189,6 @@ public interface StorageManager extends Manager {
 | 
			
		||||
	List<CapacityVO> getSecondaryStorageUsedStats(Long hostId, Long podId, Long zoneId);
 | 
			
		||||
 | 
			
		||||
	List<CapacityVO> getStoragePoolUsedStats(Long poolId, Long podId, Long zoneId);
 | 
			
		||||
 | 
			
		||||
    boolean createStoragePool(long hostId, StoragePoolVO pool);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -46,6 +46,7 @@ import com.cloud.agent.AgentManager;
 | 
			
		||||
import com.cloud.agent.api.Answer;
 | 
			
		||||
import com.cloud.agent.api.BackupSnapshotCommand;
 | 
			
		||||
import com.cloud.agent.api.Command;
 | 
			
		||||
import com.cloud.agent.api.CreateStoragePoolCommand;
 | 
			
		||||
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
 | 
			
		||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
 | 
			
		||||
import com.cloud.agent.api.DeleteStoragePoolCommand;
 | 
			
		||||
@ -961,6 +962,11 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
 | 
			
		||||
			throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: "+ zoneId );
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
        // Check if there is host up in this cluster
 | 
			
		||||
        List<HostVO> allHosts = _hostDao.listBy(Host.Type.Routing, clusterId, podId, zoneId);
 | 
			
		||||
        if (allHosts.isEmpty()) {
 | 
			
		||||
            throw new ResourceUnavailableException("No host up to associate a storage pool with in cluster " + clusterId, HostPodVO.class, podId);
 | 
			
		||||
        }
 | 
			
		||||
        URI uri = null;
 | 
			
		||||
        try {
 | 
			
		||||
            uri = new URI(cmd.getUrl());
 | 
			
		||||
@ -1073,14 +1079,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
 | 
			
		||||
                    uri.toASCIIString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // iterate through all the hosts and ask them to mount the filesystem.
 | 
			
		||||
        // FIXME Not a very scalable implementation. Need an async listener, or
 | 
			
		||||
        // perhaps do this on demand, or perhaps mount on a couple of hosts per
 | 
			
		||||
        // pod
 | 
			
		||||
        List<HostVO> allHosts = _hostDao.listBy(Host.Type.Routing, clusterId, podId, zoneId);
 | 
			
		||||
        if (allHosts.isEmpty()) {
 | 
			
		||||
            throw new ResourceUnavailableException("No host exists to associate a storage pool with in pod: ", HostPodVO.class, podId);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        long poolId = _storagePoolDao.getNextInSequence(Long.class, "id");
 | 
			
		||||
        String uuid = null;
 | 
			
		||||
        if (scheme.equalsIgnoreCase("sharedmountpoint")) {
 | 
			
		||||
@ -1115,10 +1114,21 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
 | 
			
		||||
        if (allHosts.isEmpty()) {
 | 
			
		||||
            return pool;
 | 
			
		||||
        }
 | 
			
		||||
        boolean success = false;
 | 
			
		||||
        for (HostVO h : allHosts) {
 | 
			
		||||
            success = createStoragePool(h.getId(), pool);
 | 
			
		||||
            if (success) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if ( !success ) {
 | 
			
		||||
            s_logger.warn("Can not create storage pool " + pool + " on cluster " + clusterId);
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        s_logger.debug("In createPool Adding the pool to each of the hosts");
 | 
			
		||||
        List<HostVO> poolHosts = new ArrayList<HostVO>();
 | 
			
		||||
        for (HostVO h : allHosts) {
 | 
			
		||||
            boolean success = addPoolToHost(h.getId(), pool);
 | 
			
		||||
            success = addPoolToHost(h.getId(), pool);
 | 
			
		||||
            if (success) {
 | 
			
		||||
                poolHosts.add(h);
 | 
			
		||||
            }
 | 
			
		||||
@ -1262,6 +1272,29 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
 | 
			
		||||
        return true;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean createStoragePool(long hostId, StoragePoolVO pool) {
 | 
			
		||||
        s_logger.debug("creating pool " + pool.getName() + " on  host " + hostId);
 | 
			
		||||
        if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem 
 | 
			
		||||
            && pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS
 | 
			
		||||
            && pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup) {
 | 
			
		||||
            s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
 | 
			
		||||
        final Answer answer = _agentMgr.easySend(hostId, cmd);
 | 
			
		||||
        if (answer != null && answer.getResult()) {
 | 
			
		||||
            return true;
 | 
			
		||||
        } else {
 | 
			
		||||
            if( answer != null) {
 | 
			
		||||
                s_logger.warn(" can not create strorage pool through host " + hostId + " due to " + answer.getDetails());
 | 
			
		||||
            } else {
 | 
			
		||||
                s_logger.warn(" can not create strorage pool through host " + hostId + " due to CreateStoragePoolCommand returns null");
 | 
			
		||||
            }
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean addPoolToHost(long hostId, StoragePoolVO pool) {
 | 
			
		||||
@ -1270,7 +1303,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
 | 
			
		||||
        	&& pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS
 | 
			
		||||
        	&& pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup) {
 | 
			
		||||
            s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
 | 
			
		||||
            return true;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user