From b188a513bad46b5a1e0c1f6e9d55f5a51b7fcede Mon Sep 17 00:00:00 2001 From: frank Date: Tue, 27 Sep 2011 16:43:26 -0700 Subject: [PATCH] Bug 11522 - New agent manager Secondary storage worked --- .../secondary/SecondaryStorageListener.java | 1 - .../SecondaryStorageManagerImpl.java | 67 +++++++++++-------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java b/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java index 4af2ef92b4d..fe7b2cccd2d 100755 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageListener.java @@ -83,7 +83,6 @@ public class SecondaryStorageListener implements Listener { if(s_logger.isInfoEnabled()) { s_logger.info("Received a host startup notification " + cmd); } - _agentMgr.agentStatusTransitTo(agent, Event.Ready, ManagementServerNode.getManagementServerId()); _ssVmMgr.onAgentConnect(agent.getDataCenterId(), cmd); _ssVmMgr.generateSetupCommand(agent.getId()); _ssVmMgr.generateFirewallConfiguration(agent.getId()); diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index ecce1acac33..605d8918cf6 100755 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -1195,51 +1195,60 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V @Override public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) { - // TODO Auto-generated method stub - return null; + /* Called when Secondary Storage VM connected */ + StartupCommand firstCmd = cmd[0]; + if (!(firstCmd instanceof StartupSecondaryStorageCommand)) { + return null; + } + + host.setType( com.cloud.host.Host.Type.SecondaryStorageVM); + return host; } @Override public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map details, List hostTags) { + /* Called when add secondary storage on UI */ StartupCommand firstCmd = startup[0]; - if (!(firstCmd instanceof StartupSecondaryStorageCommand) && !(firstCmd instanceof StartupSecondaryStorageCommand)) { + if (!(firstCmd instanceof StartupStorageCommand)) { return null; } com.cloud.host.Host.Type type = null; - if (firstCmd instanceof StartupSecondaryStorageCommand) { - type = com.cloud.host.Host.Type.SecondaryStorageVM; - } else if (firstCmd instanceof StartupSecondaryStorageCommand) { - StartupStorageCommand ssCmd = ((StartupStorageCommand) firstCmd); - if (ssCmd.getHostType() == Host.Type.SecondaryStorageCmdExecutor) { - type = ssCmd.getHostType(); + StartupStorageCommand ssCmd = ((StartupStorageCommand) firstCmd); + if (ssCmd.getHostType() == Host.Type.SecondaryStorageCmdExecutor) { + type = ssCmd.getHostType(); + } else { + if (ssCmd.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE) { + type = Host.Type.SecondaryStorage; + if (resource != null && resource instanceof DummySecondaryStorageResource) { + host.setResource(null); + } + } else if (ssCmd.getResourceType() == Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE) { + type = Host.Type.LocalSecondaryStorage; } else { - if (ssCmd.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE) { - type = Host.Type.SecondaryStorage; - if (resource != null && resource instanceof DummySecondaryStorageResource) { - host.setResource(null); - } - } else if (ssCmd.getResourceType() == Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE) { - type = Host.Type.LocalSecondaryStorage; + type = Host.Type.Storage; + } + + final Map hostDetails = ssCmd.getHostDetails(); + if (hostDetails != null) { + if (details != null) { + details.putAll(hostDetails); } else { - type = Host.Type.Storage; + details = hostDetails; } + } - final Map hostDetails = ssCmd.getHostDetails(); - if (hostDetails != null) { - if (details != null) { - details.putAll(hostDetails); - } else { - details = hostDetails; - } - } - - host.setDetails(details); + host.setDetails(details); + host.setParent(ssCmd.getParent()); + host.setTotalSize(ssCmd.getTotalSize()); + host.setHypervisorType(HypervisorType.None); + host.setType(type); + if (ssCmd.getNfsShare() != null) { + host.setStorageUrl(ssCmd.getNfsShare()); } } - - host.setType(type); + return host; }