Search in sources :

Example 26 with NicProfile

use of com.cloud.vm.NicProfile in project cloudstack by apache.

the class InternalLoadBalancerVMManagerImpl method finalizeDeployment.

@Override
public boolean finalizeDeployment(final Commands cmds, final VirtualMachineProfile profile, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException {
    final DomainRouterVO internalLbVm = _internalLbVmDao.findById(profile.getId());
    final List<NicProfile> nics = profile.getNics();
    for (final NicProfile nic : nics) {
        if (nic.getTrafficType() == TrafficType.Control) {
            internalLbVm.setPrivateIpAddress(nic.getIPv4Address());
            internalLbVm.setPrivateMacAddress(nic.getMacAddress());
        }
    }
    _internalLbVmDao.update(internalLbVm.getId(), internalLbVm);
    finalizeCommandsOnStart(cmds, profile);
    return true;
}
Also used : NicProfile(com.cloud.vm.NicProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 27 with NicProfile

use of com.cloud.vm.NicProfile in project cloudstack by apache.

the class MidoNetPublicNetworkGuru method allocate.

@Override
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException {
    if (nic == null) {
        nic = new NicProfile(Nic.ReservationStrategy.Create, null, null, null, null);
    }
    s_logger.debug("allocate called with network: " + network + " nic: " + nic + " vm: " + vm);
    DataCenter dc = _dcDao.findById(network.getDataCenterId());
    if (nic.getRequestedIPv4() != null) {
        throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
    }
    getIp(nic, dc, vm, network);
    if (nic.getIPv4Address() == null) {
        nic.setReservationStrategy(Nic.ReservationStrategy.Start);
    } else if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
        nic.setReservationStrategy(Nic.ReservationStrategy.Managed);
    } else {
        nic.setReservationStrategy(Nic.ReservationStrategy.Create);
    }
    nic.setBroadcastUri(generateBroadcastUri(network));
    return nic;
}
Also used : DataCenter(com.cloud.dc.DataCenter) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NicProfile(com.cloud.vm.NicProfile)

Example 28 with NicProfile

use of com.cloud.vm.NicProfile in project cloudstack by apache.

the class ConsoleProxyManagerImpl method createProxyInstance.

protected Map<String, Object> createProxyInstance(long dataCenterId, VMTemplateVO template) throws ConcurrentOperationException {
    long id = _consoleProxyDao.getNextInSequence(Long.class, "id");
    String name = VirtualMachineName.getConsoleProxyName(id, _instance);
    DataCenterVO dc = _dcDao.findById(dataCenterId);
    Account systemAcct = _accountMgr.getSystemAccount();
    DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
    NetworkVO defaultNetwork = getDefaultNetworkForCreation(dc);
    List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork, NetworkOffering.SystemManagementNetwork);
    LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>(offerings.size() + 1);
    NicProfile defaultNic = new NicProfile();
    defaultNic.setDefaultNic(true);
    defaultNic.setDeviceId(2);
    networks.put(_networkMgr.setupNetwork(systemAcct, _networkOfferingDao.findById(defaultNetwork.getNetworkOfferingId()), plan, null, null, false).get(0), new ArrayList<NicProfile>(Arrays.asList(defaultNic)));
    for (NetworkOffering offering : offerings) {
        networks.put(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), new ArrayList<NicProfile>());
    }
    ServiceOfferingVO serviceOffering = _serviceOffering;
    if (serviceOffering == null) {
        serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.consoleProxyDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId));
    }
    ConsoleProxyVO proxy = new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), _accountMgr.getSystemUser().getId(), 0, serviceOffering.getOfferHA());
    proxy.setDynamicallyScalable(template.isDynamicallyScalable());
    proxy = _consoleProxyDao.persist(proxy);
    try {
        _itMgr.allocate(name, template, serviceOffering, networks, plan, null);
    } catch (InsufficientCapacityException e) {
        s_logger.warn("InsufficientCapacity", e);
        throw new CloudRuntimeException("Insufficient capacity exception", e);
    }
    Map<String, Object> context = new HashMap<String, Object>();
    context.put("dc", dc);
    HostPodVO pod = _podDao.findById(proxy.getPodIdToDeployIn());
    context.put("pod", pod);
    context.put("proxyVmId", proxy.getId());
    return context;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Account(com.cloud.user.Account) NetworkVO(com.cloud.network.dao.NetworkVO) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) NetworkOffering(com.cloud.offering.NetworkOffering) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) NicProfile(com.cloud.vm.NicProfile) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) HostPodVO(com.cloud.dc.HostPodVO) LinkedHashMap(java.util.LinkedHashMap) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Network(com.cloud.network.Network) ArrayList(java.util.ArrayList) List(java.util.List) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 29 with NicProfile

use of com.cloud.vm.NicProfile in project cloudstack by apache.

the class ConsoleProxyManagerImpl method finalizeCommandsOnStart.

@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile profile) {
    NicProfile managementNic = null;
    NicProfile controlNic = null;
    for (NicProfile nic : profile.getNics()) {
        if (nic.getTrafficType() == TrafficType.Management) {
            managementNic = nic;
        } else if (nic.getTrafficType() == TrafficType.Control && nic.getIPv4Address() != null) {
            controlNic = nic;
        }
    }
    if (controlNic == null) {
        if (managementNic == null) {
            s_logger.error("Management network doesn't exist for the console proxy vm " + profile.getVirtualMachine());
            return false;
        }
        controlNic = managementNic;
    }
    // verify ssh access on management nic for system vm running on HyperV
    if (profile.getHypervisorType() == HypervisorType.Hyperv) {
        controlNic = managementNic;
    }
    CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIPv4Address(), 3922);
    cmds.addCommand("checkSsh", check);
    return true;
}
Also used : CheckSshCommand(com.cloud.agent.api.check.CheckSshCommand) NicProfile(com.cloud.vm.NicProfile)

Example 30 with NicProfile

use of com.cloud.vm.NicProfile in project cloudstack by apache.

the class SecurityGroupManagerImpl method isVmSecurityGroupEnabled.

@Override
public boolean isVmSecurityGroupEnabled(Long vmId) {
    VirtualMachine vm = _vmDao.findByIdIncludingRemoved(vmId);
    List<NicProfile> nics = _networkMgr.getNicProfiles(vm);
    for (NicProfile nic : nics) {
        Network network = _networkModel.getNetwork(nic.getNetworkId());
        if (_networkModel.isSecurityGroupSupportedInNetwork(network) && vm.getHypervisorType() != HypervisorType.VMware) {
            return true;
        }
    }
    return false;
}
Also used : Network(com.cloud.network.Network) NicProfile(com.cloud.vm.NicProfile) VirtualMachine(com.cloud.vm.VirtualMachine)

Aggregations

NicProfile (com.cloud.vm.NicProfile)84 Network (com.cloud.network.Network)31 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)28 NetworkVO (com.cloud.network.dao.NetworkVO)27 ArrayList (java.util.ArrayList)23 DataCenterVO (com.cloud.dc.DataCenterVO)19 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)18 DomainRouterVO (com.cloud.vm.DomainRouterVO)16 NicVO (com.cloud.vm.NicVO)14 List (java.util.List)14 DataCenter (com.cloud.dc.DataCenter)13 NetworkOffering (com.cloud.offering.NetworkOffering)12 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)11 NetworkGuru (com.cloud.network.guru.NetworkGuru)11 LinkedHashMap (java.util.LinkedHashMap)11 Provider (com.cloud.network.Network.Provider)10 Nic (com.cloud.vm.Nic)10 ReservationContext (com.cloud.vm.ReservationContext)10 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)10 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)9