use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.
the class StorageCapacityListener method processConnect.
@Override
public void processConnect(final Host server, final StartupCommand[] startupCommands, final boolean forRebalance) {
for (final StartupCommand startupCommand : startupCommands) {
if (!(startupCommand instanceof StartupStorageCommand)) {
return;
}
final StartupStorageCommand ssCmd = (StartupStorageCommand) startupCommand;
if (ssCmd.getResourceType() == StorageResourceType.STORAGE_HOST) {
final BigDecimal overProvFactor = BigDecimal.valueOf(CapacityManager.StorageOverprovisioningFactor.value());
final CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), server.getClusterId(), 0L, (overProvFactor.multiply(new BigDecimal(server.getTotalSize()))).longValue(), Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
_capacityDao.persist(capacity);
}
}
}
use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.
the class CitrixResourceBase method initialize.
@Override
public StartupCommand[] initialize() throws IllegalArgumentException {
final Connection conn = getConnection();
if (!getHostInfo(conn)) {
s_logger.warn("Unable to get host information for " + this._host.getIp());
return null;
}
final StartupRoutingCommand cmd = new StartupRoutingCommand();
fillHostInfo(conn, cmd);
cmd.setHypervisorType(HypervisorType.XenServer);
cmd.setCluster(this._cluster);
cmd.setPoolSync(false);
try {
final Pool pool = Pool.getByUuid(conn, this._host.getPool());
final Pool.Record poolr = pool.getRecord(conn);
poolr.master.getRecord(conn);
} catch (final XmlRpcException | XenAPIException e) {
s_logger.warn("Check for master failed, failing the FULL Cluster sync command");
}
final StartupStorageCommand sscmd = initializeLocalSR(conn);
if (sscmd != null) {
return new StartupCommand[] { cmd, sscmd };
}
return new StartupCommand[] { cmd };
}
use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.
the class AgentManagerImpl method connectAgent.
protected void connectAgent(final Link link, final Command[] cmds, final Request request) {
// send startupanswer to agent in the very beginning, so agent can move on without waiting for the answer for an undetermined time, if we put this logic into another
// thread pool.
final StartupAnswer[] answers = new StartupAnswer[cmds.length];
Command cmd;
for (int i = 0; i < cmds.length; i++) {
cmd = cmds[i];
if (cmd instanceof StartupRoutingCommand || cmd instanceof StartupProxyCommand || cmd instanceof StartupSecondaryStorageCommand || cmd instanceof StartupStorageCommand) {
answers[i] = new StartupAnswer((StartupCommand) cmds[i], 0, getPingInterval());
break;
}
}
Response response = null;
response = new Response(request, answers[0], this._nodeId, -1);
try {
link.send(response.toBytes());
} catch (final ClosedChannelException e) {
s_logger.debug("Failed to send startupanswer: " + e.toString());
}
this._connectExecutor.execute(new HandleAgentConnectTask(link, cmds, request));
}
use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.
the class UploadListener method processConnect.
@Override
public void processConnect(final Host agent, final StartupCommand[] startupCommands, final boolean forRebalance) {
for (final StartupCommand startupCommand : startupCommands) {
if (!(startupCommand instanceof StartupStorageCommand)) {
return;
}
final long agentId = agent.getId();
final StartupStorageCommand storage = (StartupStorageCommand) startupCommand;
if (storage.getResourceType() == StorageResourceType.STORAGE_HOST || storage.getResourceType() == StorageResourceType.SECONDARY_STORAGE) {
this.uploadMonitor.handleUploadSync(agentId);
}
}
}
use of com.cloud.legacymodel.communication.command.startup.StartupStorageCommand in project cosmic by MissionCriticalCloud.
the class CitrixResourceBase method initializeLocalSR.
protected StartupStorageCommand initializeLocalSR(final Connection conn) {
final SR lvmsr = getLocalLVMSR(conn);
if (lvmsr != null) {
try {
this._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 " + this._host.getUuid();
lvmsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, this._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(this._host.getUuid());
cmd.setDataCenter(Long.toString(this._dcId));
cmd.setResourceType(StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
final SR extsr = getLocalEXTSR(conn);
if (extsr != null) {
try {
final String extuuid = extsr.getUuid(conn);
this._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 " + this._host.getUuid();
extsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, this._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(this._host.getUuid());
cmd.setDataCenter(Long.toString(this._dcId));
cmd.setResourceType(StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
return null;
}
Aggregations