use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method getProviderResponses.
private List<ProviderResponse> getProviderResponses(final Set<Provider> srvc_providers) {
final List<ProviderResponse> providers = new ArrayList<>();
for (final Provider provider : srvc_providers) {
if (provider != null) {
final ProviderResponse providerRsp = new ProviderResponse();
providerRsp.setName(provider.getName());
providers.add(providerRsp);
}
}
return providers;
}
use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createNetworkServiceProviderResponse.
@Override
public ProviderResponse createNetworkServiceProviderResponse(final PhysicalNetworkServiceProvider result) {
final ProviderResponse response = new ProviderResponse();
response.setId(result.getUuid());
response.setName(result.getProviderName());
final PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
if (pnw != null) {
response.setPhysicalNetworkId(pnw.getUuid());
}
final PhysicalNetwork dnw = ApiDBUtils.findPhysicalNetworkById(result.getDestinationPhysicalNetworkId());
if (dnw != null) {
response.setDestinationPhysicalNetworkId(dnw.getUuid());
}
response.setState(result.getState().toString());
// set enabled services
final List<String> services = new ArrayList<>();
for (final Service service : result.getEnabledServices()) {
services.add(service.getName());
}
response.setServices(services);
final Provider serviceProvider = Provider.getProvider(result.getProviderName());
final boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
response.setCanEnableIndividualServices(canEnableIndividualServices);
response.setObjectName("networkserviceprovider");
return response;
}
use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.
the class VirtualNetworkApplianceManagerImpl method finalizeCommandsOnStart.
@Override
public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachineProfile profile) {
final DomainRouterVO router = _routerDao.findById(profile.getId());
final NicProfile controlNic = getControlNic(profile);
if (controlNic == null) {
s_logger.error("Control network doesn't exist for the router " + router);
return false;
}
finalizeSshAndVersionAndNetworkUsageOnStart(cmds, profile, router, controlNic);
// restart network if restartNetwork = false is not specified in profile
// parameters
final boolean reprogramGuestNtwks = profile.getParameter(Param.ReProgramGuestNetworks) == null || (Boolean) profile.getParameter(Param.ReProgramGuestNetworks);
final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
if (vrProvider == null) {
throw new CloudRuntimeException("Cannot find related virtual router provider of router: " + router.getHostName());
}
final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
if (provider == null) {
throw new CloudRuntimeException("Cannot find related provider of virtual router provider: " + vrProvider.getType().toString());
}
final List<Long> routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId());
for (final Long guestNetworkId : routerGuestNtwkIds) {
final AggregationControlCommand startCmd = new AggregationControlCommand(Action.Start, router.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId()));
cmds.addCommand(startCmd);
if (reprogramGuestNtwks) {
finalizeNetworkRulesForNetwork(cmds, router, provider, guestNetworkId);
}
final AggregationControlCommand finishCmd = new AggregationControlCommand(Action.Finish, router.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId()));
cmds.addCommand(finishCmd);
}
return true;
}
use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.
the class VirtualNetworkApplianceManagerImpl method getPublicIpsToApply.
protected ArrayList<? extends PublicIpAddress> getPublicIpsToApply(final VirtualRouter router, final Provider provider, final Long guestNetworkId, final com.cloud.network.IpAddress.State... skipInStates) {
final long ownerId = router.getAccountId();
final List<? extends IpAddress> userIps;
final Network guestNetwork = _networkDao.findById(guestNetworkId);
if (guestNetwork.getGuestType() == GuestType.Shared) {
// ignore the account id for the shared network
userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(guestNetworkId, null);
} else {
userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
}
final List<PublicIp> allPublicIps = new ArrayList<>();
if (userIps != null && !userIps.isEmpty()) {
boolean addIp = true;
for (final IpAddress userIp : userIps) {
if (skipInStates != null) {
for (final IpAddress.State stateToSkip : skipInStates) {
if (userIp.getState() == stateToSkip) {
s_logger.debug("Skipping ip address " + userIp + " in state " + userIp.getState());
addIp = false;
break;
}
}
}
if (addIp) {
final IPAddressVO ipVO = _ipAddressDao.findById(userIp.getId());
final PublicIp publicIp = PublicIp.createFromAddrAndVlan(ipVO, _vlanDao.findById(userIp.getVlanId()));
allPublicIps.add(publicIp);
}
}
}
// Get public Ips that should be handled by router
final Network network = _networkDao.findById(guestNetworkId);
final Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(allPublicIps, false, true);
final Map<Provider, ArrayList<PublicIpAddress>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
return providerToIpList.get(provider);
}
use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.
the class VpcVirtualNetworkApplianceManagerImpl method sendNetworkRulesToRouter.
protected boolean sendNetworkRulesToRouter(final long routerId, final long networkId) throws ResourceUnavailableException {
final DomainRouterVO router = _routerDao.findById(routerId);
final Commands cmds = new Commands(OnError.Continue);
final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
if (vrProvider == null) {
throw new CloudRuntimeException("Cannot find related virtual router provider of router: " + router.getHostName());
}
final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
if (provider == null) {
throw new CloudRuntimeException("Cannot find related provider of virtual router provider: " + vrProvider.getType().toString());
}
finalizeNetworkRulesForNetwork(cmds, router, provider, networkId);
return _nwHelper.sendCommandsToRouter(router, cmds);
}
Aggregations