Search in sources :

Example 16 with StartupStorageCommand

use of com.cloud.agent.api.StartupStorageCommand in project CloudStack-archive by CloudStack-extras.

the class AgentRoutingResource method initializeLocalSR.

private StartupStorageCommand initializeLocalSR() {
    Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
    StoragePoolInfo poolInfo = _simMgr.getLocalStorage(hostGuid);
    StartupStorageCommand cmd = new StartupStorageCommand(poolInfo.getHostPath(), poolInfo.getPoolType(), poolInfo.getCapacityBytes(), tInfo);
    cmd.setPoolInfo(poolInfo);
    cmd.setGuid(agentHost.getGuid());
    cmd.setResourceType(StorageResourceType.STORAGE_POOL);
    return cmd;
}
Also used : TemplateInfo(com.cloud.storage.template.TemplateInfo) HashMap(java.util.HashMap) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StoragePoolInfo(com.cloud.agent.api.StoragePoolInfo)

Example 17 with StartupStorageCommand

use of com.cloud.agent.api.StartupStorageCommand in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method initialize.

@Override
public StartupCommand[] initialize() {
    Map<String, State> changes = null;
    synchronized (_vms) {
        _vms.clear();
        changes = sync();
    }
    final List<Object> info = getHostInfo();
    final 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.KVM, RouterPrivateIpStrategy.HostLocal);
    cmd.setStateChanges(changes);
    fillNetworkInformation(cmd);
    _privateIp = cmd.getPrivateIpAddress();
    cmd.getHostDetails().putAll(getVersionStrings());
    cmd.setPool(_pool);
    cmd.setCluster(_clusterId);
    cmd.setGatewayIpAddress(_localGateway);
    StartupStorageCommand sscmd = null;
    try {
        KVMStoragePool localStoragePool = _storagePoolMgr.createStoragePool(_localStorageUUID, "localhost", _localStoragePath, StoragePoolType.Filesystem);
        com.cloud.agent.api.StoragePoolInfo pi = new com.cloud.agent.api.StoragePoolInfo(localStoragePool.getUuid(), cmd.getPrivateIpAddress(), _localStoragePath, _localStoragePath, StoragePoolType.Filesystem, localStoragePool.getCapacity(), localStoragePool.getUsed());
        sscmd = new StartupStorageCommand();
        sscmd.setPoolInfo(pi);
        sscmd.setGuid(pi.getUuid());
        sscmd.setDataCenter(_dcId);
        sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
    } catch (CloudRuntimeException e) {
    }
    if (sscmd != null) {
        return new StartupCommand[] { cmd, sscmd };
    } else {
        return new StartupCommand[] { cmd };
    }
}
Also used : StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StartupCommand(com.cloud.agent.api.StartupCommand) KVMStoragePool(com.cloud.agent.storage.KVMStoragePool) State(com.cloud.vm.VirtualMachine.State) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Example 18 with StartupStorageCommand

use of com.cloud.agent.api.StartupStorageCommand in project cloudstack by apache.

the class LocalSecondaryStorageResource method initialize.

@Override
public StartupCommand[] initialize() {
    final StartupStorageCommand cmd = new StartupStorageCommand(_parent, StoragePoolType.Filesystem, 1024l * 1024l * 1024l * 1024l, _dlMgr.gatherTemplateInfo(_parent));
    cmd.setResourceType(Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE);
    cmd.setIqn("local://");
    fillNetworkInformation(cmd);
    cmd.setDataCenter(_dc);
    cmd.setPod(_pod);
    cmd.setGuid(_guid);
    cmd.setName(_guid);
    cmd.setVersion(LocalSecondaryStorageResource.class.getPackage().getImplementationVersion());
    return new StartupCommand[] { cmd };
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand)

Example 19 with StartupStorageCommand

use of com.cloud.agent.api.StartupStorageCommand in project cloudstack by apache.

the class HypervDirectConnectResource method initialize.

@Override
public final StartupCommand[] initialize() {
    // assert
    if (!_configureCalled) {
        final String errMsg = this.getClass().getName() + " requires configure() be called before" + " initialize()";
        s_logger.error(errMsg);
    }
    // Create default StartupRoutingCommand, then customise
    final StartupRoutingCommand defaultStartRoutCmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.Hyperv, RouterPrivateIpStrategy.HostLocal);
    // Identity within the data centre is decided by CloudStack kernel,
    // and passed via ServerResource.configure()
    defaultStartRoutCmd.setDataCenter(_zoneId);
    defaultStartRoutCmd.setPod(_podId);
    defaultStartRoutCmd.setCluster(_clusterId);
    defaultStartRoutCmd.setGuid(_guid);
    defaultStartRoutCmd.setName(_name);
    defaultStartRoutCmd.setPrivateIpAddress(_agentIp);
    defaultStartRoutCmd.setStorageIpAddress(_agentIp);
    defaultStartRoutCmd.setPool(_clusterGuid);
    s_logger.debug("Generated StartupRoutingCommand for _agentIp \"" + _agentIp + "\"");
    defaultStartRoutCmd.setVersion(this.getClass().getPackage().getImplementationVersion());
    // Specifics of the host's resource capacity and network configuration
    // comes from the host itself. CloudStack sanity checks network
    // configuration
    // and uses capacity info for resource allocation.
    final Command[] startCmds = requestStartupCommand(new Command[] { defaultStartRoutCmd });
    // TODO: may throw, is this okay?
    final StartupRoutingCommand startCmd = (StartupRoutingCommand) startCmds[0];
    // Assert that host identity is consistent with existing values.
    if (startCmd == null) {
        final String errMsg = String.format("Host %s (IP %s)" + "did not return a StartupRoutingCommand", _name, _agentIp);
        s_logger.error(errMsg);
        // TODO: valid to return null, or should we throw?
        return null;
    }
    if (!startCmd.getDataCenter().equals(defaultStartRoutCmd.getDataCenter())) {
        final String errMsg = String.format("Host %s (IP %s) changed zone/data center.  Was " + defaultStartRoutCmd.getDataCenter() + " NOW its " + startCmd.getDataCenter(), _name, _agentIp);
        s_logger.error(errMsg);
        // TODO: valid to return null, or should we throw?
        return null;
    }
    if (!startCmd.getPod().equals(defaultStartRoutCmd.getPod())) {
        final String errMsg = String.format("Host %s (IP %s) changed pod.  Was " + defaultStartRoutCmd.getPod() + " NOW its " + startCmd.getPod(), _name, _agentIp);
        s_logger.error(errMsg);
        // TODO: valid to return null, or should we throw?
        return null;
    }
    if (!startCmd.getCluster().equals(defaultStartRoutCmd.getCluster())) {
        final String errMsg = String.format("Host %s (IP %s) changed cluster.  Was " + defaultStartRoutCmd.getCluster() + " NOW its " + startCmd.getCluster(), _name, _agentIp);
        s_logger.error(errMsg);
        // TODO: valid to return null, or should we throw?
        return null;
    }
    if (!startCmd.getGuid().equals(defaultStartRoutCmd.getGuid())) {
        final String errMsg = String.format("Host %s (IP %s) changed guid.  Was " + defaultStartRoutCmd.getGuid() + " NOW its " + startCmd.getGuid(), _name, _agentIp);
        s_logger.error(errMsg);
        // TODO: valid to return null, or should we throw?
        return null;
    }
    if (!startCmd.getPrivateIpAddress().equals(defaultStartRoutCmd.getPrivateIpAddress())) {
        final String errMsg = String.format("Host %s (IP %s) IP address.  Was " + defaultStartRoutCmd.getPrivateIpAddress() + " NOW its " + startCmd.getPrivateIpAddress(), _name, _agentIp);
        s_logger.error(errMsg);
        // TODO: valid to return null, or should we throw?
        return null;
    }
    if (!startCmd.getName().equals(defaultStartRoutCmd.getName())) {
        final String errMsg = String.format("Host %s (IP %s) name.  Was " + startCmd.getName() + " NOW its " + defaultStartRoutCmd.getName(), _name, _agentIp);
        s_logger.error(errMsg);
        // TODO: valid to return null, or should we throw?
        return null;
    }
    // Host will also supply details of an existing StoragePool if it has
    // been configured with one.
    //
    // NB: if the host was configured
    // with a local storage pool, CloudStack may not be able to use it
    // unless
    // it is has service offerings configured to recognise this storage
    // type.
    StartupStorageCommand storePoolCmd = null;
    if (startCmds.length > 1) {
        storePoolCmd = (StartupStorageCommand) startCmds[1];
        // TODO: is this assertion required?
        if (storePoolCmd == null) {
            final String frmtStr = "Host %s (IP %s) sent incorrect Command, " + "second parameter should be a " + "StartupStorageCommand";
            final String errMsg = String.format(frmtStr, _name, _agentIp);
            s_logger.error(errMsg);
            // TODO: valid to return null, or should we throw?
            return null;
        }
        s_logger.info("Host " + _name + " (IP " + _agentIp + ") already configured with a storeage pool, details " + s_gson.toJson(startCmds[1]));
    } else {
        s_logger.info("Host " + _name + " (IP " + _agentIp + ") already configured with a storeage pool, details ");
    }
    return new StartupCommand[] { startCmd, storePoolCmd };
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) CheckRouterCommand(com.cloud.agent.api.CheckRouterCommand) PlugNicCommand(com.cloud.agent.api.PlugNicCommand) Site2SiteVpnCfgCommand(com.cloud.agent.api.routing.Site2SiteVpnCfgCommand) CheckSshCommand(com.cloud.agent.api.check.CheckSshCommand) SetupGuestNetworkCommand(com.cloud.agent.api.SetupGuestNetworkCommand) DnsMasqConfigCommand(com.cloud.agent.api.routing.DnsMasqConfigCommand) PingTestCommand(com.cloud.agent.api.PingTestCommand) CopyCommand(org.apache.cloudstack.storage.command.CopyCommand) ModifyVmNicConfigCommand(com.cloud.agent.api.ModifyVmNicConfigCommand) UnPlugNicCommand(com.cloud.agent.api.UnPlugNicCommand) SetStaticRouteCommand(com.cloud.agent.api.routing.SetStaticRouteCommand) NetworkElementCommand(com.cloud.agent.api.routing.NetworkElementCommand) SetStaticNatRulesCommand(com.cloud.agent.api.routing.SetStaticNatRulesCommand) VmDataCommand(com.cloud.agent.api.routing.VmDataCommand) SetSourceNatCommand(com.cloud.agent.api.routing.SetSourceNatCommand) CreateIpAliasCommand(com.cloud.agent.api.routing.CreateIpAliasCommand) SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand) CheckS2SVpnConnectionsCommand(com.cloud.agent.api.CheckS2SVpnConnectionsCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) RemoteAccessVpnCfgCommand(com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand) Command(com.cloud.agent.api.Command) NetworkUsageCommand(com.cloud.agent.api.NetworkUsageCommand) DeleteIpAliasCommand(com.cloud.agent.api.routing.DeleteIpAliasCommand) DhcpEntryCommand(com.cloud.agent.api.routing.DhcpEntryCommand) StartCommand(com.cloud.agent.api.StartCommand) GetVmConfigCommand(com.cloud.agent.api.GetVmConfigCommand) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) SetPortForwardingRulesCommand(com.cloud.agent.api.routing.SetPortForwardingRulesCommand) StartupCommand(com.cloud.agent.api.StartupCommand) IpAssocCommand(com.cloud.agent.api.routing.IpAssocCommand) SavePasswordCommand(com.cloud.agent.api.routing.SavePasswordCommand) PingCommand(com.cloud.agent.api.PingCommand) PingRoutingCommand(com.cloud.agent.api.PingRoutingCommand) LoadBalancerConfigCommand(com.cloud.agent.api.routing.LoadBalancerConfigCommand) SetFirewallRulesCommand(com.cloud.agent.api.routing.SetFirewallRulesCommand) IpAssocVpcCommand(com.cloud.agent.api.routing.IpAssocVpcCommand) SetNetworkACLCommand(com.cloud.agent.api.routing.SetNetworkACLCommand) VpnUsersCfgCommand(com.cloud.agent.api.routing.VpnUsersCfgCommand) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Example 20 with StartupStorageCommand

use of com.cloud.agent.api.StartupStorageCommand in project cloudstack by apache.

the class Ovm3HypervisorResource method initialize.

/*
     * configure is called before this, does setup of the connection and
     * gets the params.
     *
     * @see com.cloud.resource.ServerResource#initialize()
     */
@Override
public StartupCommand[] initialize() {
    LOGGER.debug("Ovm3 resource intializing");
    try {
        StartupRoutingCommand srCmd = new StartupRoutingCommand();
        StartupStorageCommand ssCmd = new StartupStorageCommand();
        /* here stuff gets completed, but where should state live ? */
        hypervisorsupport.fillHostInfo(srCmd);
        hypervisorsupport.vmStateMapClear();
        LOGGER.debug("Ovm3 pool " + ssCmd + " " + srCmd);
        return new StartupCommand[] { srCmd, ssCmd };
    } catch (Exception e) {
        LOGGER.debug("Ovm3 resource initializes failed", e);
        return new StartupCommand[] {};
    }
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)

Aggregations

StartupStorageCommand (com.cloud.agent.api.StartupStorageCommand)22 StartupCommand (com.cloud.agent.api.StartupCommand)14 StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)12 StoragePoolInfo (com.cloud.agent.api.StoragePoolInfo)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 HashMap (java.util.HashMap)3 Command (com.cloud.agent.api.Command)2 PingCommand (com.cloud.agent.api.PingCommand)2 PingRoutingCommand (com.cloud.agent.api.PingRoutingCommand)2 VmState (com.cloud.agent.api.StartupRoutingCommand.VmState)2 CloudException (com.cloud.exception.CloudException)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)2 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)2 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)2 RouterPrivateIpStrategy (com.cloud.network.Networks.RouterPrivateIpStrategy)2 MockVMVO (com.cloud.simulator.MockVMVO)2 TemplateProp (com.cloud.storage.template.TemplateProp)2 State (com.cloud.vm.VirtualMachine.State)2 IOException (java.io.IOException)2