public static InternalLoadBalancerElement getInstance() { if (internalLbElement == null) { internalLbElement = new InternalLoadBalancerElement(); } return internalLbElement; }
protected Map<Ip, List<LoadBalancingRule>> getLbRulesToApply(List<LoadBalancingRule> rules) { //Group rules by the source ip address as NetworkManager always passes the entire network lb config to the element Map<Ip, List<LoadBalancingRule>> rulesToApply = groupBySourceIp(rules); return rulesToApply; }
@Override public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { if (!canHandle(network, null)) { s_logger.trace("No need to implement " + getName()); return true; } return implementInternalLbVms(network, dest); }
public TenantPort createTenantPort(String tenantNetworkUuid) { TenantPort req = new TenantPort(); req.networkUuid = tenantNetworkUuid; req.attachmentType = "NoAttachment"; HttpPost method = new HttpPost(); method.setEntity(new StringEntity(new Gson().toJson(req), ContentType.APPLICATION_JSON)); return new Gson().fromJson( executeMethod(method, "/ssp.v1/tenant-ports"), TenantPort.class); }
public TenantNetwork createTenantNetwork(String tenantUuid, String networkName) { TenantNetwork req = new TenantNetwork(); req.name = networkName; req.tenantUuid = tenantUuid; HttpPost method = new HttpPost(); method.setEntity(new StringEntity(new Gson().toJson(req), ContentType.APPLICATION_JSON)); return new Gson().fromJson( executeMethod(method, "/ssp.v1/tenant-networks"), TenantNetwork.class); }
public boolean deleteTenantPort(String tenantPortUuid) { HttpDelete method = new HttpDelete(); if (executeMethod(method, "/ssp.v1/tenant-ports/" + tenantPortUuid) != null) { return true; } return false; }
@Override public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst) { try { release(network, nic, vm, dst); } catch (ConcurrentOperationException e) { s_logger.error("rollbackMigration failed.", e); } catch (ResourceUnavailableException e) { s_logger.error("rollbackMigration failed.", e); } }
@Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { s_logger.trace("prepare"); return createNicEnv(network, nic, dest, context); }
@Override public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException { s_logger.trace("shutdown"); return deleteNetwork(network); }
@Override public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { s_logger.trace("release"); return deleteNicEnv(network, nic, context); }
@Override public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { s_logger.info("implement"); return createNetwork(network, offering, dest, context); }
@Override public boolean prepareMigration(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) { try { prepare(network, nic, vm, dest, context); } catch (ConcurrentOperationException e) { s_logger.error("prepareForMigration failed.", e); return false; } catch (ResourceUnavailableException e) { s_logger.error("prepareForMigration failed.", e); return false; } catch (InsufficientCapacityException e) { s_logger.error("prepareForMigration failed.", e); return false; } return true; }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { super.reserve(nic, network, vm, dest, context); _sspMgr.createNicEnv(network, nic, dest, context); }
@Override public void shutdown(NetworkProfile profile, NetworkOffering offering) { s_logger.trace("shutdown " + profile.toString()); _sspMgr.deleteNetwork(profile); super.shutdown(profile, offering); }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { s_logger.trace("execute"); SuccessResponse resp = new SuccessResponse(); resp.setSuccess(_service.deleteSspHost(this)); this.setResponseObject(resp); }
@Override public VirtualRouterProvider getInternalLoadBalancerElement(long id) { VirtualRouterProvider provider = _vrProviderDao.findById(id); if (provider == null || provider.getType() != Type.InternalLbVm) { throw new InvalidParameterValueException("Unable to find " + getName() + " by id"); } return provider; }
@Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { if (!canHandle(network, null)) { s_logger.trace("No need to prepare " + getName()); return true; } if (vm.getType() == VirtualMachine.Type.User) { return implementInternalLbVms(network, dest); } return true; }
public TenantPort updateTenantVifBinding(String portUuid, String hypervisorIpAddress) { TenantPort req = new TenantPort(); if (hypervisorIpAddress != null) { req.attachmentType = "VifAttachment"; req.hypervisorIpAddress = hypervisorIpAddress; } else { req.attachmentType = "NoAttachment"; } HttpPut method = new HttpPut(); method.setEntity(new StringEntity(new Gson().toJson(req), ContentType.APPLICATION_JSON)); return new Gson().fromJson( executeMethod(method, "/ssp.v1/tenant-ports/" + portUuid), TenantPort.class); } }
public boolean deleteTenantNetwork(String tenantNetworkUuid) { HttpDelete method = new HttpDelete(); if (executeMethod(method, "/ssp.v1/tenant-networks/" + tenantNetworkUuid) != null) { return true; } return false; }
@Override public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst) { try { release(network, nic, vm, src); } catch (ConcurrentOperationException e) { s_logger.error("commitMigration failed.", e); } catch (ResourceUnavailableException e) { s_logger.error("commitMigration failed.", e); } }