use of com.cloud.agent.api.StartupStorageCommand in project cloudstack by apache.
the class CitrixResourceBase method initializeLocalSR.
protected StartupStorageCommand initializeLocalSR(final Connection conn) {
final SR lvmsr = getLocalLVMSR(conn);
if (lvmsr != null) {
try {
_host.setLocalSRuuid(lvmsr.getUuid(conn));
final String lvmuuid = lvmsr.getUuid(conn);
final long cap = lvmsr.getPhysicalSize(conn);
if (cap > 0) {
final long avail = cap - lvmsr.getPhysicalUtilisation(conn);
lvmsr.setNameLabel(conn, lvmuuid);
final String name = "Cloud Stack Local LVM Storage Pool for " + _host.getUuid();
lvmsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, _host.getUuid());
final String address = host.getAddress(conn);
final StoragePoolInfo pInfo = new StoragePoolInfo(lvmuuid, address, SRType.LVM.toString(), SRType.LVM.toString(), StoragePoolType.LVM, cap, avail);
final StartupStorageCommand cmd = new StartupStorageCommand();
cmd.setPoolInfo(pInfo);
cmd.setGuid(_host.getUuid());
cmd.setDataCenter(Long.toString(_dcId));
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local LVM info err in host:" + _host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local LVM info err in host:" + _host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
final SR extsr = getLocalEXTSR(conn);
if (extsr != null) {
try {
final String extuuid = extsr.getUuid(conn);
_host.setLocalSRuuid(extuuid);
final long cap = extsr.getPhysicalSize(conn);
if (cap > 0) {
final long avail = cap - extsr.getPhysicalUtilisation(conn);
extsr.setNameLabel(conn, extuuid);
final String name = "Cloud Stack Local EXT Storage Pool for " + _host.getUuid();
extsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, _host.getUuid());
final String address = host.getAddress(conn);
final StoragePoolInfo pInfo = new StoragePoolInfo(extuuid, address, SRType.EXT.toString(), SRType.EXT.toString(), StoragePoolType.EXT, cap, avail);
final StartupStorageCommand cmd = new StartupStorageCommand();
cmd.setPoolInfo(pInfo);
cmd.setGuid(_host.getUuid());
cmd.setDataCenter(Long.toString(_dcId));
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local EXT info err in host:" + _host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local EXT info err in host:" + _host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
return null;
}
use of com.cloud.agent.api.StartupStorageCommand in project cloudstack by apache.
the class AgentRoutingResource method initialize.
@Override
public StartupCommand[] initialize() {
Map<String, MockVMVO> vmsMaps = _simMgr.getVms(this.hostGuid);
totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed();
totalMem = agentHost.getMemorySize();
for (Map.Entry<String, MockVMVO> entry : vmsMaps.entrySet()) {
MockVMVO vm = entry.getValue();
usedCpu += vm.getCpu();
usedMem += vm.getMemory();
_runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory()));
}
List<Object> info = getHostInfo();
StartupRoutingCommand cmd = new StartupRoutingCommand((Integer) info.get(0), (Long) info.get(1), (Long) info.get(2), (Long) info.get(4), (String) info.get(3), HypervisorType.Simulator, RouterPrivateIpStrategy.HostLocal);
Map<String, String> hostDetails = new HashMap<String, String>();
hostDetails.put(RouterPrivateIpStrategy.class.getCanonicalName(), RouterPrivateIpStrategy.DcGlobal.toString());
cmd.setHostDetails(hostDetails);
cmd.setAgentTag("agent-simulator");
cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
cmd.setPrivateMacAddress(agentHost.getPrivateMacAddress());
cmd.setStorageIpAddress(agentHost.getStorageIpAddress());
cmd.setStorageNetmask(agentHost.getStorageNetMask());
cmd.setStorageMacAddress(agentHost.getStorageMacAddress());
cmd.setStorageIpAddressDeux(agentHost.getStorageIpAddress());
cmd.setStorageNetmaskDeux(agentHost.getStorageNetMask());
cmd.setStorageMacAddressDeux(agentHost.getStorageIpAddress());
cmd.setName(agentHost.getName());
cmd.setGuid(agentHost.getGuid());
cmd.setVersion(agentHost.getVersion());
cmd.setAgentTag("agent-simulator");
cmd.setDataCenter(String.valueOf(agentHost.getDataCenterId()));
cmd.setPod(String.valueOf(agentHost.getPodId()));
cmd.setCluster(String.valueOf(agentHost.getClusterId()));
StartupStorageCommand ssCmd = initializeLocalSR();
return new StartupCommand[] { cmd, ssCmd };
}
Aggregations