Bug 11522 - New agent manager

Secondary storage worked
This commit is contained in:
frank 2011-09-27 16:43:26 -07:00
parent 5efaed1d82
commit b188a513ba
2 changed files with 38 additions and 30 deletions

View File

@ -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());

View File

@ -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<String, String> details,
List<String> 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<String, String> hostDetails = ssCmd.getHostDetails();
if (hostDetails != null) {
if (details != null) {
details.putAll(hostDetails);
} else {
type = Host.Type.Storage;
details = hostDetails;
}
}
final Map<String, String> 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;
}