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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations