Search in sources :

Example 1 with SetupPersistentNetworkAnswer

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

the class LibvirtSetupPersistentNetworkCommandWrapper method execute.

@Override
public Answer execute(SetupPersistentNetworkCommand command, LibvirtComputingResource serverResource) {
    NicTO nic = command.getNic();
    VifDriver driver = serverResource.getVifDriver(nic.getType());
    try {
        driver.plug(nic, null, "", null);
    } catch (InternalErrorException | LibvirtException e) {
        return new SetupPersistentNetworkAnswer(command, false, e.getLocalizedMessage());
    }
    return new SetupPersistentNetworkAnswer(command, true, "Successfully setup persistent network");
}
Also used : SetupPersistentNetworkAnswer(com.cloud.agent.api.SetupPersistentNetworkAnswer) LibvirtException(org.libvirt.LibvirtException) InternalErrorException(com.cloud.exception.InternalErrorException) VifDriver(com.cloud.hypervisor.kvm.resource.VifDriver) NicTO(com.cloud.agent.api.to.NicTO)

Example 2 with SetupPersistentNetworkAnswer

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

the class CitrixSetupPersistentNetworkCommandWrapper method execute.

@Override
public Answer execute(SetupPersistentNetworkCommand command, CitrixResourceBase citrixResourceBase) {
    final Connection conn = citrixResourceBase.getConnection();
    final XsHost host = citrixResourceBase.getHost();
    try {
        Network network = citrixResourceBase.getNetwork(conn, command.getNic());
        if (network == null) {
            return new SetupPersistentNetworkAnswer(command, false, "Failed to setup network on host: " + host.getIp());
        }
        return new SetupPersistentNetworkAnswer(command, true, "Successfully setup network on host: " + host.getIp());
    } catch (final Exception e) {
        final String msg = " Failed to setup network on host: " + host.getIp() + " due to: " + e.toString();
        s_logger.error(msg, e);
        return new SetupPersistentNetworkAnswer(command, false, msg);
    }
}
Also used : SetupPersistentNetworkAnswer(com.cloud.agent.api.SetupPersistentNetworkAnswer) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) Network(com.xensource.xenapi.Network) Connection(com.xensource.xenapi.Connection)

Example 3 with SetupPersistentNetworkAnswer

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

the class NetworkOrchestrator method setupPersistentNetwork.

private void setupPersistentNetwork(NetworkVO network, NetworkOfferingVO offering, Long dcId) throws AgentUnavailableException, OperationTimedoutException {
    List<ClusterVO> clusterVOs = clusterDao.listClustersByDcId(dcId);
    List<HostVO> hosts = resourceManager.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.Routing, dcId);
    Map<Long, List<Long>> clusterToHostsMap = new HashMap<>();
    for (HostVO host : hosts) {
        try {
            Pair<Boolean, NicTO> networkCfgStateAndDetails = isNtwConfiguredInCluster(host, clusterToHostsMap, network, offering);
            if (networkCfgStateAndDetails.first()) {
                continue;
            }
            NicTO to = networkCfgStateAndDetails.second();
            SetupPersistentNetworkCommand cmd = new SetupPersistentNetworkCommand(to);
            final SetupPersistentNetworkAnswer answer = (SetupPersistentNetworkAnswer) _agentMgr.send(host.getId(), cmd);
            if (answer == null) {
                s_logger.warn("Unable to get an answer to the SetupPersistentNetworkCommand from agent:" + host.getId());
                clusterToHostsMap.get(host.getClusterId()).remove(host.getId());
                continue;
            }
            if (!answer.getResult()) {
                s_logger.warn("Unable to setup agent " + host.getId() + " due to " + answer.getDetails());
                clusterToHostsMap.get(host.getClusterId()).remove(host.getId());
            }
        } catch (Exception e) {
            s_logger.warn("Failed to connect to host: " + host.getName());
        }
    }
    if (clusterToHostsMap.keySet().size() != clusterVOs.size()) {
        s_logger.warn("Hosts on all clusters may not have been configured with network devices.");
    }
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) HostVO(com.cloud.host.HostVO) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientVirtualNetworkCapacityException(com.cloud.exception.InsufficientVirtualNetworkCapacityException) ConfigurationException(javax.naming.ConfigurationException) SetupPersistentNetworkAnswer(com.cloud.agent.api.SetupPersistentNetworkAnswer) SetupPersistentNetworkCommand(com.cloud.agent.api.SetupPersistentNetworkCommand) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) List(java.util.List) NicTO(com.cloud.agent.api.to.NicTO)

Example 4 with SetupPersistentNetworkAnswer

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

the class VmwareResource method execute.

private Answer execute(SetupPersistentNetworkCommand cmd) {
    VmwareHypervisorHost host = getHyperHost(getServiceContext());
    String hostname = null;
    VmwareContext context = getServiceContext();
    HostMO hostMO = new HostMO(context, host.getMor());
    try {
        prepareNetworkFromNicInfo(hostMO, cmd.getNic(), false, null);
        hostname = host.getHyperHostName();
    } catch (Exception e) {
        return new SetupPersistentNetworkAnswer(cmd, false, "failed to setup port-group due to: " + e.getLocalizedMessage());
    }
    return new SetupPersistentNetworkAnswer(cmd, true, hostname);
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) SetupPersistentNetworkAnswer(com.cloud.agent.api.SetupPersistentNetworkAnswer) HostMO(com.cloud.hypervisor.vmware.mo.HostMO) VmwareHypervisorHost(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

SetupPersistentNetworkAnswer (com.cloud.agent.api.SetupPersistentNetworkAnswer)4 NicTO (com.cloud.agent.api.to.NicTO)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ConfigurationException (javax.naming.ConfigurationException)2 SetupPersistentNetworkCommand (com.cloud.agent.api.SetupPersistentNetworkCommand)1 ClusterVO (com.cloud.dc.ClusterVO)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 CloudException (com.cloud.exception.CloudException)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 ConnectionException (com.cloud.exception.ConnectionException)1 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InsufficientVirtualNetworkCapacityException (com.cloud.exception.InsufficientVirtualNetworkCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)1 HostVO (com.cloud.host.HostVO)1