mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' into add_remove_nics
pulling in network-refactor merge to master Conflicts: server/src/com/cloud/network/NetworkManagerImpl.java
This commit is contained in:
commit
42e4961da2
|
|
@ -0,0 +1,43 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.exception;
|
||||
|
||||
import com.cloud.utils.SerialVersionUID;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if number of requests is over api rate limit set.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public class RequestLimitException extends CloudRuntimeException {
|
||||
|
||||
private static final long serialVersionUID = SerialVersionUID.AccountLimitException;
|
||||
|
||||
protected RequestLimitException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RequestLimitException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public RequestLimitException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
|
||||
/**
|
||||
* The NetworkModel presents a read-only view into the Network data such as L2 networks,
|
||||
* Nics, PublicIps, NetworkOfferings, traffic labels, physical networks and the like
|
||||
* The idea is that only the orchestration core should be able to modify the data, while other
|
||||
* participants in the orchestration can use this interface to query the data.
|
||||
*/
|
||||
public interface NetworkModel {
|
||||
|
||||
/**
|
||||
* Lists IP addresses that belong to VirtualNetwork VLANs
|
||||
*
|
||||
* @param accountId
|
||||
* - account that the IP address should belong to
|
||||
* @param associatedNetworkId
|
||||
* TODO
|
||||
* @param sourceNat
|
||||
* - (optional) true if the IP address should be a source NAT address
|
||||
* @return - list of IP addresses
|
||||
*/
|
||||
List<? extends IpAddress> listPublicIpsAssignedToGuestNtwk(long accountId, long associatedNetworkId, Boolean sourceNat);
|
||||
|
||||
List<? extends NetworkOffering> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
List<? extends Nic> getNics(long vmId);
|
||||
|
||||
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
|
||||
|
||||
PublicIpAddress getPublicIpAddress(long ipAddressId);
|
||||
|
||||
List<? extends Vlan> listPodVlans(long podId);
|
||||
|
||||
List<? extends Network> listNetworksUsedByVm(long vmId, boolean isSystem);
|
||||
|
||||
Nic getNicInNetwork(long vmId, long networkId);
|
||||
|
||||
List<? extends Nic> getNicsForTraffic(long vmId, TrafficType type);
|
||||
|
||||
Network getDefaultNetworkForVm(long vmId);
|
||||
|
||||
Nic getDefaultNic(long vmId);
|
||||
|
||||
UserDataServiceProvider getUserDataUpdateProvider(Network network);
|
||||
|
||||
boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId);
|
||||
|
||||
Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service);
|
||||
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
|
||||
Network getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
|
||||
String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
|
||||
|
||||
List<? extends Network> listNetworksForAccount(long accountId, long zoneId, Network.GuestType type);
|
||||
|
||||
List<? extends Network> listAllNetworksInAllZonesByType(Network.GuestType type);
|
||||
|
||||
String getGlobalGuestDomainSuffix();
|
||||
|
||||
String getStartIpAddress(long networkId);
|
||||
|
||||
String getIpInNetwork(long vmId, long networkId);
|
||||
|
||||
String getIpInNetworkIncludingRemoved(long vmId, long networkId);
|
||||
|
||||
Long getPodIdForVlan(long vlanDbId);
|
||||
|
||||
List<Long> listNetworkOfferingsForUpgrade(long networkId);
|
||||
|
||||
boolean isSecurityGroupSupportedInNetwork(Network network);
|
||||
|
||||
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
|
||||
|
||||
boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName);
|
||||
|
||||
String getNetworkTag(HypervisorType hType, Network network);
|
||||
|
||||
List<Service> getElementServices(Provider provider);
|
||||
|
||||
boolean canElementEnableIndividualServices(Provider provider);
|
||||
|
||||
boolean areServicesSupportedInNetwork(long networkId, Service... services);
|
||||
|
||||
boolean isNetworkSystem(Network network);
|
||||
|
||||
Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service);
|
||||
|
||||
Long getPhysicalNetworkId(Network network);
|
||||
|
||||
boolean getAllowSubdomainAccessGlobal();
|
||||
|
||||
boolean isProviderForNetwork(Provider provider, long networkId);
|
||||
|
||||
boolean isProviderForNetworkOffering(Provider provider, long networkOfferingId);
|
||||
|
||||
void canProviderSupportServices(Map<Provider, Set<Service>> providersMap);
|
||||
|
||||
List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfo(long dcId, HypervisorType hypervisorType);
|
||||
|
||||
boolean canAddDefaultSecurityGroup();
|
||||
|
||||
List<Service> listNetworkOfferingServices(long networkOfferingId);
|
||||
|
||||
boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, List<Service> services);
|
||||
|
||||
Map<PublicIpAddress, Set<Service>> getIpToServices(List<? extends PublicIpAddress> publicIps, boolean rulesRevoked,
|
||||
boolean includingFirewall);
|
||||
|
||||
Map<Provider, ArrayList<PublicIpAddress>> getProviderToIpList(Network network, Map<PublicIpAddress, Set<Service>> ipToServices);
|
||||
|
||||
boolean checkIpForService(IpAddress ip, Service service, Long networkId);
|
||||
|
||||
void checkCapabilityForProvider(Set<Provider> providers, Service service, Capability cap, String capValue);
|
||||
|
||||
Provider getDefaultUniqueProviderForService(String serviceName);
|
||||
|
||||
void checkNetworkPermissions(Account owner, Network network);
|
||||
|
||||
String getDefaultManagementTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultStorageTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultPublicTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
String getDefaultGuestTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
/**
|
||||
* @param providerName
|
||||
* @return
|
||||
*/
|
||||
NetworkElement getElementImplementingProvider(String providerName);
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param zoneId
|
||||
* @return
|
||||
*/
|
||||
String getAccountNetworkDomain(long accountId, long zoneId);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getDefaultNetworkDomain();
|
||||
|
||||
/**
|
||||
* @param ntwkOffId
|
||||
* @return
|
||||
*/
|
||||
List<Provider> getNtwkOffDistinctProviders(long ntwkOffId);
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param dcId
|
||||
* @param sourceNat
|
||||
* @return
|
||||
*/
|
||||
List<? extends IpAddress> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat);
|
||||
|
||||
/**
|
||||
* @param zoneId
|
||||
* @param trafficType
|
||||
* @return
|
||||
*/
|
||||
List<? extends PhysicalNetwork> getPhysicalNtwksSupportingTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
/**
|
||||
* @param guestNic
|
||||
* @return
|
||||
*/
|
||||
boolean isPrivateGateway(Nic guestNic);
|
||||
|
||||
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
|
||||
|
||||
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
|
||||
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
|
||||
|
||||
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
|
||||
|
||||
List<? extends Network> listNetworksByVpc(long vpcId);
|
||||
|
||||
boolean canUseForDeploy(Network network);
|
||||
|
||||
Network getExclusiveGuestNetwork(long zoneId);
|
||||
|
||||
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
|
||||
|
||||
Integer getNetworkRate(long networkId, Long vmId);
|
||||
|
||||
boolean isVmPartOfNetwork(long vmId, long ntwkId);
|
||||
|
||||
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
Network getNetwork(long networkId);
|
||||
|
||||
IpAddress getIp(long sourceIpAddressId);
|
||||
|
||||
boolean isNetworkAvailableInDomain(long networkId, long domainId);
|
||||
|
||||
NicProfile getNicProfile(VirtualMachine vm, long networkId, String broadcastUri);
|
||||
|
||||
Set<Long> getAvailableIps(Network network, String requestedIp);
|
||||
|
||||
String getDomainNetworkDomain(long domainId, long zoneId);
|
||||
|
||||
PublicIpAddress getSourceNatIpAddressForGuestNetwork(Account owner, Network guestNetwork);
|
||||
|
||||
boolean isNetworkInlineMode(Network network);
|
||||
|
||||
}
|
||||
|
|
@ -17,8 +17,6 @@
|
|||
package com.cloud.network;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
|
|
@ -29,14 +27,17 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
|||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
/**
|
||||
* The NetworkService interface is the "public" api to entities that make requests to the orchestration engine
|
||||
* Such entities are usually the admin and end-user API.
|
||||
*
|
||||
*/
|
||||
public interface NetworkService {
|
||||
|
||||
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
|
@ -64,24 +65,12 @@ public interface NetworkService {
|
|||
|
||||
IpAddress getIp(long id);
|
||||
|
||||
NetworkProfile convertNetworkToNetworkProfile(long networkId);
|
||||
|
||||
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
|
||||
|
||||
boolean isNetworkAvailableInDomain(long networkId, long domainId);
|
||||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
|
||||
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
|
||||
String domainSuffix, Long networkOfferingId, Boolean changeCidr);
|
||||
|
||||
Integer getNetworkRate(long networkId, Long vmId);
|
||||
|
||||
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
|
||||
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
|
||||
List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
|
||||
|
||||
Pair<List<? extends PhysicalNetwork>, Integer> searchPhysicalNetworks(Long id, Long zoneId, String keyword,
|
||||
|
|
@ -94,8 +83,6 @@ public interface NetworkService {
|
|||
|
||||
List<? extends Service> listNetworkServices(String providerName);
|
||||
|
||||
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
|
||||
|
||||
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName,
|
||||
Long destinationPhysicalNetworkId, List<String> enabledServices);
|
||||
|
||||
|
|
@ -127,17 +114,14 @@ public interface NetworkService {
|
|||
|
||||
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId);
|
||||
|
||||
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
Network getExclusiveGuestNetwork(long zoneId);
|
||||
|
||||
List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd);
|
||||
|
||||
List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
List<? extends Network> listNetworksByVpc(long vpcId);
|
||||
|
||||
boolean isVmPartOfNetwork(long vmId, long ntwkId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param networkId
|
||||
|
|
@ -170,9 +154,5 @@ public interface NetworkService {
|
|||
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
|
||||
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId)
|
||||
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
|
||||
/**
|
||||
* @param network
|
||||
* @return
|
||||
*/
|
||||
boolean canUseForDeploy(Network network);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
public interface IpDeployer {
|
||||
public interface IpDeployer extends Adapter{
|
||||
/**
|
||||
* Apply ip addresses to this network
|
||||
* @param network
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
public interface RemoteAccessVPNServiceProvider extends NetworkElement, IpDeployingRequester {
|
||||
public interface RemoteAccessVPNServiceProvider extends Adapter {
|
||||
String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users) throws ResourceUnavailableException;
|
||||
|
||||
boolean startVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
package com.cloud.network.element;
|
||||
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
public interface Site2SiteVpnServiceProvider extends NetworkElement {
|
||||
public interface Site2SiteVpnServiceProvider extends Adapter {
|
||||
boolean startSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException;
|
||||
|
||||
boolean stopSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.Set;
|
|||
import com.cloud.alert.Alert;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
|
||||
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
|
||||
import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
|
||||
|
|
@ -140,6 +141,14 @@ public interface ManagementService {
|
|||
*/
|
||||
Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd);
|
||||
|
||||
/**
|
||||
* Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId",
|
||||
* "podId"
|
||||
*
|
||||
* @param cmd
|
||||
* @return List of Hosts
|
||||
*/
|
||||
Pair<List<? extends Host>, Integer> searchForServers(ListHostsCmd cmd);
|
||||
|
||||
/**
|
||||
* Creates a new template
|
||||
|
|
@ -384,7 +393,7 @@ public interface ManagementService {
|
|||
* @return Pair<List<? extends Host>, List<? extends Host>> List of all Hosts in VM's cluster and list of Hosts with
|
||||
* enough capacity
|
||||
*/
|
||||
Pair<List<? extends Host>, List<? extends Host>> listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize);
|
||||
Pair<Pair<List<? extends Host>, Integer>, List<? extends Host>> listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize);
|
||||
|
||||
String[] listEventTypes();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.cloudstack.acl;
|
||||
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.RequestLimitException;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
|
|
@ -26,5 +27,5 @@ public interface APIChecker extends Adapter {
|
|||
// If true, apiChecker has checked the operation
|
||||
// If false, apiChecker is unable to handle the operation or not implemented
|
||||
// On exception, checkAccess failed don't allow
|
||||
boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException;
|
||||
boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException, RequestLimitException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.acl;
|
||||
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
/**
|
||||
* APILimitChecker checks if we should block an API request based on pre-set account based api limit.
|
||||
*/
|
||||
public interface APILimitChecker extends Adapter {
|
||||
// Interface for checking if the account is over its api limit
|
||||
void checkLimit(Account account) throws ServerApiException;
|
||||
}
|
||||
|
|
@ -168,17 +168,16 @@ public class ListHostsCmd extends BaseListCmd {
|
|||
if (getVirtualMachineId() == null) {
|
||||
response = _queryService.searchForServers(this);
|
||||
} else {
|
||||
List<? extends Host> result = new ArrayList<Host>();
|
||||
Pair<List<? extends Host>,Integer> result;
|
||||
List<? extends Host> hostsWithCapacity = new ArrayList<Host>();
|
||||
|
||||
Pair<List<? extends Host>, List<? extends Host>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(),
|
||||
this.getStartIndex(), this.getPageSizeVal());
|
||||
Pair<Pair<List<? extends Host>,Integer>, List<? extends Host>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal());
|
||||
result = hostsForMigration.first();
|
||||
hostsWithCapacity = hostsForMigration.second();
|
||||
|
||||
response = new ListResponse<HostResponse>();
|
||||
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
|
||||
for (Host host : result) {
|
||||
for (Host host : result.first()) {
|
||||
HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails());
|
||||
Boolean suitableForMigration = false;
|
||||
if (hostsWithCapacity.contains(host)) {
|
||||
|
|
@ -189,7 +188,7 @@ public class ListHostsCmd extends BaseListCmd {
|
|||
hostResponses.add(hostResponse);
|
||||
}
|
||||
|
||||
response.setResponses(hostResponses);
|
||||
response.setResponses(hostResponses, result.second());
|
||||
}
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@
|
|||
<artifactId>cloud-plugin-acl-static-role-based</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-api-limit-account-based</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-api-discovery</artifactId>
|
||||
|
|
|
|||
|
|
@ -513,3 +513,8 @@ configureSimulator=1
|
|||
#### api discovery commands
|
||||
|
||||
listApis=15
|
||||
|
||||
#### API Rate Limit service command
|
||||
|
||||
getApiLimit=15
|
||||
resetApiLimit=1
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ under the License.
|
|||
<param name="premium">true</param>
|
||||
</dao>
|
||||
<adapters key="org.apache.cloudstack.acl.APIChecker">
|
||||
<adapter name="AccountBasedAPIRateLimit" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl" singleton="true">
|
||||
<param name="api.throttling.interval">1</param>
|
||||
<param name="api.throttling.max">25</param>
|
||||
<param name="api.throttling.cachesize">50000</param>
|
||||
</adapter>
|
||||
<adapter name="StaticRoleBasedAPIAccessChecker" class="org.apache.cloudstack.acl.StaticRoleBasedAPIAccessChecker"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.agent.manager.allocator.HostAllocator">
|
||||
|
|
@ -162,6 +167,59 @@ under the License.
|
|||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.FirewallServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.DhcpServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="ExternalDhcpElement" class="com.cloud.network.element.ExternalDhcpElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.UserDataServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.SourceNatServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.StaticNatServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.PortForwardingServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.LoadBalancingServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.RemoteAccessVPNServiceProvider">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.Site2SiteVpnServiceProvider">
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.IpDeployer">
|
||||
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.ConnectivityProvider">
|
||||
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.NetworkACLServiceProvider">
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.element.VpcProvider">
|
||||
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
|
||||
</adapters>
|
||||
|
||||
<adapters key="com.cloud.cluster.agentlb.AgentLoadBalancerPlanner">
|
||||
<adapter name="ClusterBasedAgentLbPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner"/>
|
||||
</adapters>
|
||||
|
|
@ -180,6 +238,7 @@ under the License.
|
|||
<pluggableservice name="ApiDiscoveryService" key="org.apache.cloudstack.discovery.ApiDiscoveryService" class="org.apache.cloudstack.discovery.ApiDiscoveryServiceImpl"/>
|
||||
<pluggableservice name="VirtualRouterElementService" key="com.cloud.network.element.VirtualRouterElementService" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<pluggableservice name="NiciraNvpElementService" key="com.cloud.network.element.NiciraNvpElementService" class="com.cloud.network.element.NiciraNvpElement"/>
|
||||
<pluggableservice name="ApiRateLimitService" key="org.apache.cloudstack.ratelimit.ApiRateLimitService" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl"/>
|
||||
<dao name="OvsTunnelInterfaceDao" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" singleton="false"/>
|
||||
<dao name="OvsTunnelAccountDao" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" singleton="false"/>
|
||||
<dao name="NiciraNvpDao" class="com.cloud.network.dao.NiciraNvpDaoImpl" singleton="false"/>
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class TrafficSentinelResource implements ServerResource {
|
|||
cmd.setPod("");
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
cmd.setVersion(TrafficSentinelResource.class.getPackage().getImplementationVersion());
|
||||
cmd.setGuid(_guid);
|
||||
return new StartupCommand[]{cmd};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
for i in $*
|
||||
do
|
||||
info=`/opt/cloud/bin/checks2svpn.sh $i`
|
||||
ret=$?
|
||||
echo -n "$i:$ret:$info&"
|
||||
done
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-plugin-api-limit-account-based</artifactId>
|
||||
<name>Apache CloudStack Plugin - API Rate Limit</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>-Xmx1024m</argLine>
|
||||
<excludes>
|
||||
<exclude>org/apache/cloudstack/ratelimit/integration/*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.ratelimit;
|
||||
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.PlugService;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
import org.apache.cloudstack.api.response.ApiLimitResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.ratelimit.ApiRateLimitService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "resetApiLimit", responseObject=ApiLimitResponse.class, description="Reset api count")
|
||||
public class ResetApiLimitCmd extends BaseCmd {
|
||||
private static final Logger s_logger = Logger.getLogger(ResetApiLimitCmd.class.getName());
|
||||
|
||||
private static final String s_name = "resetapilimitresponse";
|
||||
|
||||
@PlugService
|
||||
ApiRateLimitService _apiLimitService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ACL
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.UUID, entityType=AccountResponse.class,
|
||||
description="the ID of the acount whose limit to be reset")
|
||||
private Long accountId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
|
||||
public void setAccountId(Long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account account = UserContext.current().getCaller();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
boolean result = _apiLimitService.resetApiLimit(this.accountId);
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset api limit counter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.ratelimit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.PlugService;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.BaseCmd.CommandType;
|
||||
import org.apache.cloudstack.api.command.admin.ratelimit.ResetApiLimitCmd;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
import org.apache.cloudstack.api.response.ApiLimitResponse;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.ratelimit.ApiRateLimitService;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "getApiLimit", responseObject=ApiLimitResponse.class, description="Get API limit count for the caller")
|
||||
public class GetApiLimitCmd extends BaseCmd {
|
||||
private static final Logger s_logger = Logger.getLogger(GetApiLimitCmd.class.getName());
|
||||
|
||||
private static final String s_name = "getapilimitresponse";
|
||||
|
||||
@PlugService
|
||||
ApiRateLimitService _apiLimitService;
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account account = UserContext.current().getCaller();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Account caller = UserContext.current().getCaller();
|
||||
ApiLimitResponse response = _apiLimitService.searchApiLimit(caller);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("apilimit");
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
|
||||
public class ApiLimitResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ACCOUNT_ID) @Param(description="the account uuid of the api remaining count")
|
||||
private String accountId;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account name of the api remaining count")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName("apiIssued") @Param(description="number of api already issued")
|
||||
private int apiIssued;
|
||||
|
||||
@SerializedName("apiAllowed") @Param(description="currently allowed number of apis")
|
||||
private int apiAllowed;
|
||||
|
||||
@SerializedName("expireAfter") @Param(description="seconds left to reset counters")
|
||||
private long expireAfter;
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public void setApiIssued(int apiIssued) {
|
||||
this.apiIssued = apiIssued;
|
||||
}
|
||||
|
||||
public void setApiAllowed(int apiAllowed) {
|
||||
this.apiAllowed = apiAllowed;
|
||||
}
|
||||
|
||||
public void setExpireAfter(long duration) {
|
||||
this.expireAfter = duration;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public int getApiIssued() {
|
||||
return apiIssued;
|
||||
}
|
||||
|
||||
public int getApiAllowed() {
|
||||
return apiAllowed;
|
||||
}
|
||||
|
||||
public long getExpireAfter() {
|
||||
return expireAfter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit;
|
||||
|
||||
import org.apache.cloudstack.api.response.ApiLimitResponse;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
/**
|
||||
* Provide API rate limit service
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public interface ApiRateLimitService extends PluggableService{
|
||||
|
||||
public ApiLimitResponse searchApiLimit(Account caller);
|
||||
|
||||
public boolean resetApiLimit(Long accountId);
|
||||
|
||||
public void setTimeToLive(int timeToLive);
|
||||
|
||||
public void setMaxAllowed(int max);
|
||||
}
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.APIChecker;
|
||||
import org.apache.cloudstack.api.command.admin.ratelimit.ResetApiLimitCmd;
|
||||
import org.apache.cloudstack.api.command.user.ratelimit.GetApiLimitCmd;
|
||||
import org.apache.cloudstack.api.response.ApiLimitResponse;
|
||||
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.RequestLimitException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountService;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
||||
@Local(value = APIChecker.class)
|
||||
public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, ApiRateLimitService {
|
||||
private static final Logger s_logger = Logger.getLogger(ApiRateLimitServiceImpl.class);
|
||||
|
||||
/**
|
||||
* Fixed time duration where api rate limit is set, in seconds
|
||||
*/
|
||||
private int timeToLive = 1;
|
||||
|
||||
/**
|
||||
* Max number of api requests during timeToLive duration.
|
||||
*/
|
||||
private int maxAllowed = 30;
|
||||
|
||||
private LimitStore _store = null;
|
||||
|
||||
@Inject
|
||||
AccountService _accountService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
|
||||
if (_store == null) {
|
||||
// not configured yet, note that since this class is both adapter
|
||||
// and pluggableService, so this method
|
||||
// may be invoked twice in ComponentLocator.
|
||||
// get global configured duration and max values
|
||||
Object duration = params.get("api.throttling.interval");
|
||||
if (duration != null) {
|
||||
timeToLive = Integer.parseInt((String) duration);
|
||||
}
|
||||
Object maxReqs = params.get("api.throttling.max");
|
||||
if (maxReqs != null) {
|
||||
maxAllowed = Integer.parseInt((String) maxReqs);
|
||||
}
|
||||
// create limit store
|
||||
EhcacheLimitStore cacheStore = new EhcacheLimitStore();
|
||||
int maxElements = 10000;
|
||||
Object cachesize = params.get("api.throttling.cachesize");
|
||||
if ( cachesize != null ){
|
||||
maxElements = Integer.parseInt((String)cachesize);
|
||||
}
|
||||
CacheManager cm = CacheManager.create();
|
||||
Cache cache = new Cache("api-limit-cache", maxElements, false, false, timeToLive, timeToLive);
|
||||
cm.addCache(cache);
|
||||
s_logger.info("Limit Cache created with timeToLive=" + timeToLive + ", maxAllowed=" + maxAllowed + ", maxElements=" + maxElements );
|
||||
cacheStore.setCache(cache);
|
||||
_store = cacheStore;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ApiLimitResponse searchApiLimit(Account caller) {
|
||||
ApiLimitResponse response = new ApiLimitResponse();
|
||||
response.setAccountId(caller.getUuid());
|
||||
response.setAccountName(caller.getAccountName());
|
||||
StoreEntry entry = _store.get(caller.getId());
|
||||
if (entry == null) {
|
||||
|
||||
/* Populate the entry, thus unlocking any underlying mutex */
|
||||
entry = _store.create(caller.getId(), timeToLive);
|
||||
response.setApiIssued(0);
|
||||
response.setApiAllowed(maxAllowed);
|
||||
response.setExpireAfter(timeToLive);
|
||||
}
|
||||
else{
|
||||
response.setApiIssued(entry.getCounter());
|
||||
response.setApiAllowed(maxAllowed - entry.getCounter());
|
||||
response.setExpireAfter(entry.getExpireDuration());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean resetApiLimit(Long accountId) {
|
||||
if ( accountId != null ){
|
||||
_store.create(accountId, timeToLive);
|
||||
}
|
||||
else{
|
||||
_store.resetCounters();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException, RequestLimitException {
|
||||
Long accountId = user.getAccountId();
|
||||
Account account = _accountService.getAccount(accountId);
|
||||
if ( _accountService.isRootAdmin(account.getType())){
|
||||
// no API throttling on root admin
|
||||
return true;
|
||||
}
|
||||
StoreEntry entry = _store.get(accountId);
|
||||
|
||||
if (entry == null) {
|
||||
|
||||
/* Populate the entry, thus unlocking any underlying mutex */
|
||||
entry = _store.create(accountId, timeToLive);
|
||||
}
|
||||
|
||||
/* Increment the client count and see whether we have hit the maximum allowed clients yet. */
|
||||
int current = entry.incrementAndGet();
|
||||
|
||||
if (current <= maxAllowed) {
|
||||
s_logger.trace("account (" + account.getAccountId() + "," + account.getAccountName() + ") has current count = " + current);
|
||||
return true;
|
||||
} else {
|
||||
long expireAfter = entry.getExpireDuration();
|
||||
// for this exception, we can just show the same message to user and admin users.
|
||||
String msg = "The given user has reached his/her account api limit, please retry after " + expireAfter + " ms.";
|
||||
s_logger.warn(msg);
|
||||
throw new RequestLimitException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||
cmdList.add(ResetApiLimitCmd.class);
|
||||
cmdList.add(GetApiLimitCmd.class);
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTimeToLive(int timeToLive) {
|
||||
this.timeToLive = timeToLive;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setMaxAllowed(int max) {
|
||||
this.maxAllowed = max;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit;
|
||||
|
||||
import net.sf.ehcache.Ehcache;
|
||||
import net.sf.ehcache.Element;
|
||||
import net.sf.ehcache.constructs.blocking.BlockingCache;
|
||||
import net.sf.ehcache.constructs.blocking.LockTimeoutException;
|
||||
|
||||
/**
|
||||
* A Limit store implementation using Ehcache.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public class EhcacheLimitStore implements LimitStore {
|
||||
|
||||
|
||||
private BlockingCache cache;
|
||||
|
||||
|
||||
public void setCache(Ehcache cache) {
|
||||
BlockingCache ref;
|
||||
|
||||
if (!(cache instanceof BlockingCache)) {
|
||||
ref = new BlockingCache(cache);
|
||||
cache.getCacheManager().replaceCacheWithDecoratedCache(cache, new BlockingCache(cache));
|
||||
} else {
|
||||
ref = (BlockingCache) cache;
|
||||
}
|
||||
|
||||
this.cache = ref;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StoreEntry create(Long key, int timeToLive) {
|
||||
StoreEntryImpl result = new StoreEntryImpl(timeToLive);
|
||||
Element element = new Element(key, result);
|
||||
element.setTimeToLive(timeToLive);
|
||||
cache.put(element);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreEntry get(Long key) {
|
||||
|
||||
Element entry = null;
|
||||
|
||||
try {
|
||||
|
||||
/* This may block. */
|
||||
entry = cache.get(key);
|
||||
} catch (LockTimeoutException e) {
|
||||
throw new RuntimeException();
|
||||
} catch (RuntimeException e) {
|
||||
|
||||
/* Release the lock that may have been acquired. */
|
||||
cache.put(new Element(key, null));
|
||||
}
|
||||
|
||||
StoreEntry result = null;
|
||||
|
||||
if (entry != null) {
|
||||
|
||||
/*
|
||||
* We don't need to check isExpired() on the result, since ehcache takes care of expiring entries for us.
|
||||
* c.f. the get(Key) implementation in this class.
|
||||
*/
|
||||
result = (StoreEntry) entry.getObjectValue();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void resetCounters() {
|
||||
cache.removeAll();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
|
||||
/**
|
||||
* Interface to define how an api limit store should work.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public interface LimitStore {
|
||||
|
||||
/**
|
||||
* Returns a store entry for the given account. A value of null means that there is no
|
||||
* such entry and the calling client must call create to avoid
|
||||
* other clients potentially being blocked without any hope of progressing. A non-null
|
||||
* entry means that it has not expired and can be used to determine whether the current client should be allowed to
|
||||
* proceed with the rate-limited action or not.
|
||||
*
|
||||
*/
|
||||
StoreEntry get(Long account);
|
||||
|
||||
/**
|
||||
* Creates a new store entry
|
||||
*
|
||||
* @param account
|
||||
* the user account, key to the store
|
||||
* @param timeToLiveInSecs
|
||||
* the positive time-to-live in seconds
|
||||
* @return a non-null entry
|
||||
*/
|
||||
StoreEntry create(Long account, int timeToLiveInSecs);
|
||||
|
||||
void resetCounters();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit;
|
||||
|
||||
/**
|
||||
* Interface for each entry in LimitStore.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public interface StoreEntry {
|
||||
|
||||
int getCounter();
|
||||
|
||||
int incrementAndGet();
|
||||
|
||||
boolean isExpired();
|
||||
|
||||
long getExpireDuration(); /* seconds to reset counter */
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Implementation of limit store entry.
|
||||
* @author minc
|
||||
*
|
||||
*/
|
||||
public class StoreEntryImpl implements StoreEntry {
|
||||
|
||||
private final long expiry;
|
||||
|
||||
private final AtomicInteger counter;
|
||||
|
||||
StoreEntryImpl(int timeToLive) {
|
||||
this.expiry = System.currentTimeMillis() + timeToLive * 1000;
|
||||
this.counter = new AtomicInteger(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
return System.currentTimeMillis() > expiry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long getExpireDuration() {
|
||||
if ( isExpired() )
|
||||
return 0; // already expired
|
||||
else {
|
||||
return expiry - System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int incrementAndGet() {
|
||||
return this.counter.incrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCounter(){
|
||||
return this.counter.get();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.response.ApiLimitResponse;
|
||||
import org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.exception.RequestLimitException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountService;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserVO;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class ApiRateLimitTest {
|
||||
|
||||
static ApiRateLimitServiceImpl _limitService = new ApiRateLimitServiceImpl();
|
||||
static AccountService _accountService = mock(AccountService.class);
|
||||
private static long acctIdSeq = 5L;
|
||||
private static Account testAccount;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws ConfigurationException {
|
||||
|
||||
_limitService.configure("ApiRateLimitTest", Collections.<String, Object> emptyMap());
|
||||
|
||||
_limitService._accountService = _accountService;
|
||||
|
||||
// Standard responses
|
||||
AccountVO acct = new AccountVO(acctIdSeq);
|
||||
acct.setType(Account.ACCOUNT_TYPE_NORMAL);
|
||||
acct.setAccountName("demo");
|
||||
testAccount = acct;
|
||||
|
||||
when(_accountService.getAccount(5L)).thenReturn(testAccount);
|
||||
when(_accountService.isRootAdmin(Account.ACCOUNT_TYPE_NORMAL)).thenReturn(false);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void testSetUp() {
|
||||
// reset counter for each test
|
||||
_limitService.resetApiLimit(null);
|
||||
}
|
||||
|
||||
private User createFakeUser(){
|
||||
UserVO user = new UserVO();
|
||||
user.setAccountId(acctIdSeq);
|
||||
return user;
|
||||
}
|
||||
|
||||
private boolean isUnderLimit(User key){
|
||||
try{
|
||||
_limitService.checkAccess(key, null);
|
||||
return true;
|
||||
}
|
||||
catch (RequestLimitException ex){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sequentialApiAccess() {
|
||||
int allowedRequests = 1;
|
||||
_limitService.setMaxAllowed(allowedRequests);
|
||||
_limitService.setTimeToLive(1);
|
||||
|
||||
User key = createFakeUser();
|
||||
assertTrue("Allow for the first request", isUnderLimit(key));
|
||||
|
||||
assertFalse("Second request should be blocked, since we assume that the two api "
|
||||
+ " accesses take less than a second to perform", isUnderLimit(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
|
||||
int allowedRequests = 200;
|
||||
_limitService.setMaxAllowed(allowedRequests);
|
||||
_limitService.setTimeToLive(1);
|
||||
|
||||
User key = createFakeUser();
|
||||
|
||||
for (int i = 0; i < allowedRequests; i++) {
|
||||
assertTrue("We should allow " + allowedRequests + " requests per second, but failed at request " + i, isUnderLimit(key));
|
||||
}
|
||||
|
||||
|
||||
assertFalse("We should block >" + allowedRequests + " requests per second", isUnderLimit(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleClientsCanAccessWithoutBlocking() throws Exception {
|
||||
int allowedRequests = 200;
|
||||
_limitService.setMaxAllowed(allowedRequests);
|
||||
_limitService.setTimeToLive(1);
|
||||
|
||||
|
||||
final User key = createFakeUser();
|
||||
|
||||
int clientCount = allowedRequests;
|
||||
Runnable[] clients = new Runnable[clientCount];
|
||||
final boolean[] isUsable = new boolean[clientCount];
|
||||
|
||||
final CountDownLatch startGate = new CountDownLatch(1);
|
||||
|
||||
final CountDownLatch endGate = new CountDownLatch(clientCount);
|
||||
|
||||
|
||||
for (int i = 0; i < isUsable.length; ++i) {
|
||||
final int j = i;
|
||||
clients[j] = new Runnable() {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
startGate.await();
|
||||
|
||||
isUsable[j] = isUnderLimit(key);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
endGate.countDown();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(clientCount);
|
||||
|
||||
for (Runnable runnable : clients) {
|
||||
executor.execute(runnable);
|
||||
}
|
||||
|
||||
startGate.countDown();
|
||||
|
||||
endGate.await();
|
||||
|
||||
for (boolean b : isUsable) {
|
||||
assertTrue("Concurrent client request should be allowed within limit", b);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expiryOfCounterIsSupported() throws Exception {
|
||||
int allowedRequests = 1;
|
||||
_limitService.setMaxAllowed(allowedRequests);
|
||||
_limitService.setTimeToLive(1);
|
||||
|
||||
User key = this.createFakeUser();
|
||||
|
||||
assertTrue("The first request should be allowed", isUnderLimit(key));
|
||||
|
||||
// Allow the token to expire
|
||||
Thread.sleep(1001);
|
||||
|
||||
assertTrue("Another request after interval should be allowed as well", isUnderLimit(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyResetCounters() throws Exception {
|
||||
int allowedRequests = 1;
|
||||
_limitService.setMaxAllowed(allowedRequests);
|
||||
_limitService.setTimeToLive(1);
|
||||
|
||||
User key = this.createFakeUser();
|
||||
|
||||
assertTrue("The first request should be allowed", isUnderLimit(key));
|
||||
|
||||
assertFalse("Another request should be blocked", isUnderLimit(key));
|
||||
|
||||
_limitService.resetApiLimit(key.getAccountId());
|
||||
|
||||
assertTrue("Another request should be allowed after reset counter", isUnderLimit(key));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void verifySearchCounter() throws Exception {
|
||||
int allowedRequests = 10;
|
||||
_limitService.setMaxAllowed(allowedRequests);
|
||||
_limitService.setTimeToLive(1);
|
||||
|
||||
User key = this.createFakeUser();
|
||||
|
||||
for ( int i = 0; i < 5; i++ ){
|
||||
assertTrue("Issued 5 requests", isUnderLimit(key));
|
||||
}
|
||||
|
||||
ApiLimitResponse response = _limitService.searchApiLimit(testAccount);
|
||||
assertEquals("apiIssued is incorrect", 5, response.getApiIssued());
|
||||
assertEquals("apiAllowed is incorrect", 5, response.getApiAllowed());
|
||||
assertTrue("expiredAfter is incorrect", response.getExpireAfter() < 1000);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit.integration;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.EOFException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigInteger;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
|
||||
import com.cloud.api.ApiGsonHelper;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* Base class for API Test
|
||||
*
|
||||
* @author Min Chen
|
||||
*
|
||||
*/
|
||||
public abstract class APITest {
|
||||
|
||||
protected String rootUrl = "http://localhost:8080/client/api";
|
||||
protected String sessionKey = null;
|
||||
protected String cookieToSent = null;
|
||||
|
||||
|
||||
/**
|
||||
* Sending an api request through Http GET
|
||||
* @param command command name
|
||||
* @param params command query parameters in a HashMap
|
||||
* @return http request response string
|
||||
*/
|
||||
protected String sendRequest(String command, HashMap<String, String> params){
|
||||
try {
|
||||
// Construct query string
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
sBuilder.append("command=");
|
||||
sBuilder.append(command);
|
||||
if ( params != null && params.size() > 0){
|
||||
Iterator<String> keys = params.keySet().iterator();
|
||||
while (keys.hasNext()){
|
||||
String key = keys.next();
|
||||
sBuilder.append("&");
|
||||
sBuilder.append(key);
|
||||
sBuilder.append("=");
|
||||
sBuilder.append(URLEncoder.encode(params.get(key), "UTF-8"));
|
||||
}
|
||||
}
|
||||
|
||||
// Construct request url
|
||||
String reqUrl = rootUrl + "?" + sBuilder.toString();
|
||||
|
||||
// Send Http GET request
|
||||
URL url = new URL(reqUrl);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
|
||||
if ( !command.equals("login") && cookieToSent != null){
|
||||
// add the cookie to a request
|
||||
conn.setRequestProperty("Cookie", cookieToSent);
|
||||
}
|
||||
conn.connect();
|
||||
|
||||
|
||||
if ( command.equals("login")){
|
||||
// if it is login call, store cookie
|
||||
String headerName=null;
|
||||
for (int i=1; (headerName = conn.getHeaderFieldKey(i))!=null; i++) {
|
||||
if (headerName.equals("Set-Cookie")) {
|
||||
String cookie = conn.getHeaderField(i);
|
||||
cookie = cookie.substring(0, cookie.indexOf(";"));
|
||||
String cookieName = cookie.substring(0, cookie.indexOf("="));
|
||||
String cookieValue = cookie.substring(cookie.indexOf("=") + 1, cookie.length());
|
||||
cookieToSent = cookieName + "=" + cookieValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the response
|
||||
StringBuilder response = new StringBuilder();
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
try {
|
||||
while ((line = rd.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
} catch (EOFException ex) {
|
||||
// ignore this exception
|
||||
System.out.println("EOF exception due to java bug");
|
||||
}
|
||||
rd.close();
|
||||
|
||||
|
||||
|
||||
return response.toString();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new CloudRuntimeException("Problem with sending api request", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String createMD5String(String password) {
|
||||
MessageDigest md5;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new CloudRuntimeException("Error", e);
|
||||
}
|
||||
|
||||
md5.reset();
|
||||
BigInteger pwInt = new BigInteger(1, md5.digest(password.getBytes()));
|
||||
|
||||
// make sure our MD5 hash value is 32 digits long...
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String pwStr = pwInt.toString(16);
|
||||
int padding = 32 - pwStr.length();
|
||||
for (int i = 0; i < padding; i++) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(pwStr);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
protected Object fromSerializedString(String result, Class<?> repCls) {
|
||||
try {
|
||||
if (result != null && !result.isEmpty()) {
|
||||
// get real content
|
||||
int start;
|
||||
int end;
|
||||
if (repCls == LoginResponse.class || repCls == SuccessResponse.class) {
|
||||
|
||||
start = result.indexOf('{', result.indexOf('{') + 1); // find
|
||||
// the
|
||||
// second
|
||||
// {
|
||||
|
||||
end = result.lastIndexOf('}', result.lastIndexOf('}') - 1); // find
|
||||
// the
|
||||
// second
|
||||
// }
|
||||
// backwards
|
||||
|
||||
} else {
|
||||
// get real content
|
||||
start = result.indexOf('{', result.indexOf('{', result.indexOf('{') + 1) + 1); // find
|
||||
// the
|
||||
// third
|
||||
// {
|
||||
end = result.lastIndexOf('}', result.lastIndexOf('}', result.lastIndexOf('}') - 1) - 1); // find
|
||||
// the
|
||||
// third
|
||||
// }
|
||||
// backwards
|
||||
}
|
||||
if (start < 0 || end < 0) {
|
||||
throw new CloudRuntimeException("Response format is wrong: " + result);
|
||||
}
|
||||
String content = result.substring(start, end + 1);
|
||||
Gson gson = ApiGsonHelper.getBuilder().create();
|
||||
return gson.fromJson(content, repCls);
|
||||
}
|
||||
return null;
|
||||
} catch (RuntimeException e) {
|
||||
throw new CloudRuntimeException("Caught runtime exception when doing GSON deserialization on: " + result, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Login call
|
||||
* @param username user name
|
||||
* @param password password (plain password, we will do MD5 hash here for you)
|
||||
* @return login response string
|
||||
*/
|
||||
protected void login(String username, String password)
|
||||
{
|
||||
//String md5Psw = createMD5String(password);
|
||||
// send login request
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
params.put("response", "json");
|
||||
params.put("username", username);
|
||||
params.put("password", password);
|
||||
String result = this.sendRequest("login", params);
|
||||
LoginResponse loginResp = (LoginResponse)fromSerializedString(result, LoginResponse.class);
|
||||
sessionKey = loginResp.getSessionkey();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit.integration;
|
||||
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Login Response object
|
||||
*
|
||||
* @author Min Chen
|
||||
*
|
||||
*/
|
||||
public class LoginResponse extends BaseResponse {
|
||||
|
||||
@SerializedName("timeout")
|
||||
@Param(description = "session timeout period")
|
||||
private String timeout;
|
||||
|
||||
@SerializedName("sessionkey")
|
||||
@Param(description = "login session key")
|
||||
private String sessionkey;
|
||||
|
||||
@SerializedName("username")
|
||||
@Param(description = "login username")
|
||||
private String username;
|
||||
|
||||
@SerializedName("userid")
|
||||
@Param(description = "login user internal uuid")
|
||||
private String userid;
|
||||
|
||||
@SerializedName("firstname")
|
||||
@Param(description = "login user firstname")
|
||||
private String firstname;
|
||||
|
||||
@SerializedName("lastname")
|
||||
@Param(description = "login user lastname")
|
||||
private String lastname;
|
||||
|
||||
@SerializedName("account")
|
||||
@Param(description = "login user account type")
|
||||
private String account;
|
||||
|
||||
@SerializedName("domainid")
|
||||
@Param(description = "login user domain id")
|
||||
private String domainid;
|
||||
|
||||
@SerializedName("type")
|
||||
@Param(description = "login user type")
|
||||
private int type;
|
||||
|
||||
public String getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(String timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public String getSessionkey() {
|
||||
return sessionkey;
|
||||
}
|
||||
|
||||
public void setSessionkey(String sessionkey) {
|
||||
this.sessionkey = sessionkey;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getDomainid() {
|
||||
return domainid;
|
||||
}
|
||||
|
||||
public void setDomainid(String domainid) {
|
||||
this.domainid = domainid;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ratelimit.integration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.cloudstack.api.response.ApiLimitResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
|
||||
/**
|
||||
* Test fixture to do integration rate limit test.
|
||||
* Currently we commented out this test suite since it requires a real MS and Db running.
|
||||
*
|
||||
* @author Min Chen
|
||||
*
|
||||
*/
|
||||
public class RateLimitIntegrationTest extends APITest {
|
||||
|
||||
private static int apiMax = 25; // assuming ApiRateLimitService set api.throttling.max = 25
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
// always reset count for each testcase
|
||||
login("admin", "password");
|
||||
|
||||
// issue reset api limit calls
|
||||
final HashMap<String, String> params = new HashMap<String, String>();
|
||||
params.put("response", "json");
|
||||
params.put("sessionkey", sessionKey);
|
||||
String resetResult = sendRequest("resetApiLimit", params);
|
||||
assertNotNull("Reset count failed!", fromSerializedString(resetResult, SuccessResponse.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNoApiLimitOnRootAdmin() throws Exception {
|
||||
// issue list Accounts calls
|
||||
final HashMap<String, String> params = new HashMap<String, String>();
|
||||
params.put("response", "json");
|
||||
params.put("listAll", "true");
|
||||
params.put("sessionkey", sessionKey);
|
||||
// assuming ApiRateLimitService set api.throttling.max = 25
|
||||
int clientCount = 26;
|
||||
Runnable[] clients = new Runnable[clientCount];
|
||||
final boolean[] isUsable = new boolean[clientCount];
|
||||
|
||||
final CountDownLatch startGate = new CountDownLatch(1);
|
||||
|
||||
final CountDownLatch endGate = new CountDownLatch(clientCount);
|
||||
|
||||
|
||||
for (int i = 0; i < isUsable.length; ++i) {
|
||||
final int j = i;
|
||||
clients[j] = new Runnable() {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
startGate.await();
|
||||
|
||||
sendRequest("listAccounts", params);
|
||||
|
||||
isUsable[j] = true;
|
||||
|
||||
} catch (CloudRuntimeException e){
|
||||
isUsable[j] = false;
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
endGate.countDown();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(clientCount);
|
||||
|
||||
for (Runnable runnable : clients) {
|
||||
executor.execute(runnable);
|
||||
}
|
||||
|
||||
startGate.countDown();
|
||||
|
||||
endGate.await();
|
||||
|
||||
int rejectCount = 0;
|
||||
for ( int i = 0; i < isUsable.length; ++i){
|
||||
if ( !isUsable[i])
|
||||
rejectCount++;
|
||||
}
|
||||
|
||||
assertEquals("No request should be rejected!", 0, rejectCount);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testApiLimitOnUser() throws Exception {
|
||||
// log in using normal user
|
||||
login("demo", "password");
|
||||
// issue list Accounts calls
|
||||
final HashMap<String, String> params = new HashMap<String, String>();
|
||||
params.put("response", "json");
|
||||
params.put("listAll", "true");
|
||||
params.put("sessionkey", sessionKey);
|
||||
|
||||
int clientCount = apiMax + 1;
|
||||
Runnable[] clients = new Runnable[clientCount];
|
||||
final boolean[] isUsable = new boolean[clientCount];
|
||||
|
||||
final CountDownLatch startGate = new CountDownLatch(1);
|
||||
|
||||
final CountDownLatch endGate = new CountDownLatch(clientCount);
|
||||
|
||||
|
||||
for (int i = 0; i < isUsable.length; ++i) {
|
||||
final int j = i;
|
||||
clients[j] = new Runnable() {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
startGate.await();
|
||||
|
||||
sendRequest("listAccounts", params);
|
||||
|
||||
isUsable[j] = true;
|
||||
|
||||
} catch (CloudRuntimeException e){
|
||||
isUsable[j] = false;
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
endGate.countDown();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(clientCount);
|
||||
|
||||
for (Runnable runnable : clients) {
|
||||
executor.execute(runnable);
|
||||
}
|
||||
|
||||
startGate.countDown();
|
||||
|
||||
endGate.await();
|
||||
|
||||
int rejectCount = 0;
|
||||
for ( int i = 0; i < isUsable.length; ++i){
|
||||
if ( !isUsable[i])
|
||||
rejectCount++;
|
||||
}
|
||||
|
||||
assertEquals("Only one request should be rejected!", 1, rejectCount);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApiLimitOnUser() throws Exception {
|
||||
// log in using normal user
|
||||
login("demo", "password");
|
||||
|
||||
// issue an api call
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
params.put("response", "json");
|
||||
params.put("listAll", "true");
|
||||
params.put("sessionkey", sessionKey);
|
||||
sendRequest("listAccounts", params);
|
||||
|
||||
// issue get api limit calls
|
||||
final HashMap<String, String> params2 = new HashMap<String, String>();
|
||||
params2.put("response", "json");
|
||||
params2.put("sessionkey", sessionKey);
|
||||
String getResult = sendRequest("getApiLimit", params2);
|
||||
ApiLimitResponse getLimitResp = (ApiLimitResponse)fromSerializedString(getResult, ApiLimitResponse.class);
|
||||
assertEquals("Issued api count is incorrect!", 2, getLimitResp.getApiIssued() ); // should be 2 apis issues plus this getlimit api
|
||||
assertEquals("Allowed api count is incorrect!", apiMax -2, getLimitResp.getApiAllowed());
|
||||
}
|
||||
}
|
||||
|
|
@ -3225,8 +3225,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements
|
|||
}
|
||||
|
||||
try {
|
||||
//we use libvirt since we passed a libvirt connection to cleanupDisk
|
||||
KVMStoragePool pool = _storagePoolMgr.getStoragePool(null, poolUuid);
|
||||
// we use libvirt as storage adaptor since we passed a libvirt
|
||||
// connection to cleanupDisk. We pass a storage type that maps
|
||||
// to libvirt adaptor.
|
||||
KVMStoragePool pool = _storagePoolMgr.getStoragePool(
|
||||
StoragePoolType.Filesystem, poolUuid);
|
||||
if (pool != null) {
|
||||
pool.delete();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import com.cloud.hypervisor.HypervisorGuruBase;
|
|||
import com.cloud.hypervisor.vmware.VmwareCleanupMaid;
|
||||
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
|
|
@ -84,7 +84,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
@Inject VmwareManager _vmwareMgr;
|
||||
@Inject SecondaryStorageVmManager _secStorageMgr;
|
||||
@Inject CheckPointManager _checkPointMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
||||
protected VMwareGuru() {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ import com.cloud.hypervisor.vmware.mo.HostMO;
|
|||
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
|
||||
import com.cloud.hypervisor.vmware.resource.VmwareResource;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.DiscovererBase;
|
||||
|
|
@ -84,7 +84,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
||||
@Inject
|
||||
NetworkManager _netmgr;
|
||||
NetworkModel _netmgr;
|
||||
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
|||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||
import com.cloud.org.Cluster.ClusterType;
|
||||
import com.cloud.secstorage.CommandExecLogDao;
|
||||
|
|
@ -113,7 +113,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject
|
||||
protected NetworkManager _netMgr;
|
||||
protected NetworkModel _netMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject ClusterDao _clusterDao;
|
||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||
|
|
|
|||
|
|
@ -3984,7 +3984,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
cmd.setHypervisorType(HypervisorType.VMware);
|
||||
cmd.setStateChanges(changes);
|
||||
cmd.setCluster(_cluster);
|
||||
cmd.setVersion(hostApiVersion);
|
||||
cmd.setHypervisorVersion(hostApiVersion);
|
||||
|
||||
List<StartupStorageCommand> storageCmds = initializeLocalStorage();
|
||||
StartupCommand[] answerCmds = new StartupCommand[1 + storageCmds.size()];
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
|
|
@ -57,7 +57,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalancingServiceProvider, IpDeployer {
|
||||
private static final Logger s_logger = Logger.getLogger(ElasticLoadBalancerElement.class);
|
||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
@Inject NetworkManager _networkManager;
|
||||
@Inject NetworkModel _networkManager;
|
||||
@Inject ElasticLoadBalancerManager _lbMgr;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
|
|
@ -100,8 +101,8 @@ import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
|||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -147,6 +148,8 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
LoadBalancerDao _loadBalancerDao = null;
|
||||
|
|
@ -291,7 +294,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
String protocol = rule.getProtocol();
|
||||
String algorithm = rule.getAlgorithm();
|
||||
|
||||
String elbIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress()
|
||||
String elbIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress()
|
||||
.addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
String uuid = rule.getUuid();
|
||||
|
|
@ -472,7 +475,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
|
||||
try {
|
||||
|
||||
if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
if (_networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
owner = _accountService.getSystemAccount();
|
||||
}
|
||||
|
||||
|
|
@ -494,8 +497,8 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
s_logger.debug("Creating the ELB vm " + id);
|
||||
}
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
|
||||
NetworkOffering controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(2);
|
||||
|
|
@ -507,7 +510,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
VMTemplateVO template = _templateDao.findSystemVMTemplate(dcId);
|
||||
|
||||
String typeString = "ElasticLoadBalancerVm";
|
||||
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(guestNetwork);
|
||||
Long physicalNetworkId = _networkModel.getPhysicalNetworkId(guestNetwork);
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, typeString);
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " + typeString + " in physical network " + physicalNetworkId);
|
||||
|
|
@ -593,7 +596,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
|
||||
@DB
|
||||
public PublicIp allocDirectIp(Account account, long guestNetworkId) throws InsufficientAddressCapacityException {
|
||||
Network frontEndNetwork = _networkMgr.getNetwork(guestNetworkId);
|
||||
Network frontEndNetwork = _networkModel.getNetwork(guestNetworkId);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
|
|
@ -620,7 +623,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
@DB
|
||||
public LoadBalancer handleCreateLoadBalancerRule(CreateLoadBalancerRuleCmd lb, Account account, long networkId) throws InsufficientAddressCapacityException, NetworkRuleConflictException {
|
||||
//this part of code is executed when the LB provider is Elastic Load Balancer vm
|
||||
if (!_networkMgr.isProviderSupportServiceInNetwork(lb.getNetworkId(), Service.Lb, Provider.ElasticLoadBalancerVm)) {
|
||||
if (!_networkModel.isProviderSupportServiceInNetwork(lb.getNetworkId(), Service.Lb, Provider.ElasticLoadBalancerVm)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -659,7 +662,7 @@ ElasticLoadBalancerManager, Manager, VirtualMachineGuru<DomainRouterVO> {
|
|||
throw new NetworkRuleConflictException("ELB: Found existing load balancers matching requested new LB");
|
||||
}
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
IPAddressVO ipAddr = _ipAddressDao.findById(ipId);
|
||||
|
||||
LoadBalancer result = null;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ import com.cloud.network.Network.Capability;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
|
|
@ -93,13 +93,14 @@ import com.cloud.vm.VirtualMachine;
|
|||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
@Local(value = {NetworkElement.class, LoadBalancingServiceProvider.class,
|
||||
IpDeployer.class})
|
||||
public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, IpDeployer, F5ExternalLoadBalancerElementService, ExternalLoadBalancerDeviceManager {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(F5ExternalLoadBalancerElement.class);
|
||||
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ public class F5BigIpResource implements ServerResource {
|
|||
cmd.setPod("");
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
cmd.setVersion(F5BigIpResource.class.getPackage().getImplementationVersion());
|
||||
cmd.setGuid(_guid);
|
||||
return new StartupCommand[]{cmd};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ import com.cloud.network.Network.Capability;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkExternalFirewallVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
|
|
@ -93,7 +93,9 @@ import com.cloud.vm.ReservationContext;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
|
||||
PortForwardingServiceProvider.class, IpDeployer.class,
|
||||
SourceNatServiceProvider.class, RemoteAccessVPNServiceProvider.class})
|
||||
public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceManagerImpl implements SourceNatServiceProvider, FirewallServiceProvider,
|
||||
PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, JuniperSRXFirewallElementService, StaticNatServiceProvider {
|
||||
|
||||
|
|
@ -102,7 +104,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
|||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -447,7 +447,7 @@ public class JuniperSrxResource implements ServerResource {
|
|||
cmd.setPod("");
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
cmd.setVersion(JuniperSrxResource.class.getPackage().getImplementationVersion());
|
||||
cmd.setGuid(_guid);
|
||||
return new StartupCommand[]{cmd};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ import com.cloud.network.Network.Capability;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
|
|
@ -113,7 +113,7 @@ import com.cloud.vm.VirtualMachine;
|
|||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
@Local(value = {NetworkElement.class, StaticNatServiceProvider.class, LoadBalancingServiceProvider.class})
|
||||
public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, NetscalerLoadBalancerElementService, ExternalLoadBalancerDeviceManager, IpDeployer,
|
||||
StaticNatServiceProvider {
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ StaticNatServiceProvider {
|
|||
public static final AutoScaleCounterType AutoScaleCounterNetscaler = new AutoScaleCounterType("netscaler");
|
||||
|
||||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
NetworkModel _networkManager;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
|
|
@ -130,7 +130,7 @@ StaticNatServiceProvider {
|
|||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ public class NetscalerResource implements ServerResource {
|
|||
cmd.setPod("");
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
cmd.setVersion(NetscalerResource.class.getPackage().getImplementationVersion());
|
||||
cmd.setGuid(_guid);
|
||||
return new StartupCommand[]{cmd};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
|
|||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
|
|
@ -120,7 +121,9 @@ import com.cloud.vm.VirtualMachine;
|
|||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
@Local(value = {NetworkElement.class, ConnectivityProvider.class,
|
||||
SourceNatServiceProvider.class, StaticNatServiceProvider.class,
|
||||
PortForwardingServiceProvider.class, IpDeployer.class} )
|
||||
public class NiciraNvpElement extends AdapterBase implements
|
||||
ConnectivityProvider, SourceNatServiceProvider,
|
||||
PortForwardingServiceProvider, StaticNatServiceProvider,
|
||||
|
|
@ -155,6 +158,8 @@ public class NiciraNvpElement extends AdapterBase implements
|
|||
@Inject
|
||||
NetworkManager _networkManager;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
|
|
@ -178,7 +183,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!_networkManager.isProviderForNetwork(getProvider(),
|
||||
if (!_networkModel.isProviderForNetwork(getProvider(),
|
||||
network.getId())) {
|
||||
s_logger.debug("NiciraNvpElement is not a provider for network "
|
||||
+ network.getDisplayText());
|
||||
|
|
@ -242,58 +247,50 @@ public class NiciraNvpElement extends AdapterBase implements
|
|||
* Lock the network as we might need to do multiple operations that
|
||||
* should be done only once.
|
||||
*/
|
||||
Network lock = _networkDao.acquireInLockTable(network.getId(),
|
||||
_networkManager.getNetworkLockTimeout());
|
||||
if (lock == null) {
|
||||
throw new ConcurrentOperationException("Unable to lock network "
|
||||
+ network.getId());
|
||||
// Network lock = _networkDao.acquireInLockTable(network.getId(),
|
||||
// _networkModel.getNetworkLockTimeout());
|
||||
// if (lock == null) {
|
||||
// throw new ConcurrentOperationException("Unable to lock network "
|
||||
// + network.getId());
|
||||
// }
|
||||
|
||||
// Implement SourceNat immediately as we have al the info already
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(
|
||||
network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
|
||||
s_logger.debug("Apparently we are supposed to provide SourceNat on this network");
|
||||
|
||||
PublicIp sourceNatIp = _networkManager
|
||||
.assignSourceNatIpAddressToGuestNetwork(owner, network);
|
||||
String publicCidr = sourceNatIp.getAddress().addr() + "/"
|
||||
+ NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
|
||||
String internalCidr = network.getGateway() + "/"
|
||||
+ network.getCidr().split("/")[1];
|
||||
long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
|
||||
: Long.parseLong(sourceNatIp.getVlanTag());
|
||||
|
||||
CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
|
||||
niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
|
||||
network.getBroadcastUri().getSchemeSpecificPart(),
|
||||
"router-" + network.getDisplayText(), publicCidr,
|
||||
sourceNatIp.getGateway(), internalCidr, context
|
||||
.getDomain().getName()
|
||||
+ "-"
|
||||
+ context.getAccount().getAccountName());
|
||||
CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
|
||||
.easySend(niciraNvpHost.getId(), cmd);
|
||||
if (answer.getResult() == false) {
|
||||
s_logger.error("Failed to create Logical Router for network "
|
||||
+ network.getDisplayText());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the uuid so we can easily find it during cleanup
|
||||
NiciraNvpRouterMappingVO routermapping =
|
||||
new NiciraNvpRouterMappingVO(answer.getLogicalRouterUuid(), network.getId());
|
||||
_niciraNvpRouterMappingDao.persist(routermapping);
|
||||
}
|
||||
try {
|
||||
// Implement SourceNat immediately as we have al the info already
|
||||
if (_networkManager.isProviderSupportServiceInNetwork(
|
||||
network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
|
||||
s_logger.debug("Apparently we are supposed to provide SourceNat on this network");
|
||||
|
||||
PublicIp sourceNatIp = _networkManager
|
||||
.assignSourceNatIpAddressToGuestNetwork(owner, network);
|
||||
String publicCidr = sourceNatIp.getAddress().addr() + "/"
|
||||
+ NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
|
||||
String internalCidr = network.getGateway() + "/"
|
||||
+ network.getCidr().split("/")[1];
|
||||
long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
|
||||
: Long.parseLong(sourceNatIp.getVlanTag());
|
||||
|
||||
CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
|
||||
niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
|
||||
network.getBroadcastUri().getSchemeSpecificPart(),
|
||||
"router-" + network.getDisplayText(), publicCidr,
|
||||
sourceNatIp.getGateway(), internalCidr, context
|
||||
.getDomain().getName()
|
||||
+ "-"
|
||||
+ context.getAccount().getAccountName());
|
||||
CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
|
||||
.easySend(niciraNvpHost.getId(), cmd);
|
||||
if (answer.getResult() == false) {
|
||||
s_logger.error("Failed to create Logical Router for network "
|
||||
+ network.getDisplayText());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the uuid so we can easily find it during cleanup
|
||||
NiciraNvpRouterMappingVO routermapping =
|
||||
new NiciraNvpRouterMappingVO(answer.getLogicalRouterUuid(), network.getId());
|
||||
_niciraNvpRouterMappingDao.persist(routermapping);
|
||||
}
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
_networkDao.releaseFromLockTable(lock.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Lock is released for network id "
|
||||
+ lock.getId() + " as a part of router startup in "
|
||||
+ dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -442,7 +439,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
|||
NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
|
||||
HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
|
||||
|
||||
if (_networkManager.isProviderSupportServiceInNetwork(network.getId(),
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(),
|
||||
Service.SourceNat, Provider.NiciraNvp)) {
|
||||
s_logger.debug("Apparently we were providing SourceNat on this network");
|
||||
|
||||
|
|
@ -892,7 +889,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
|||
|
||||
List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();
|
||||
for (StaticNat rule : rules) {
|
||||
IpAddress sourceIp = _networkManager.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
// Force the nat rule into the StaticNatRuleTO, no use making a new TO object
|
||||
// we only need the source and destination ip. Unfortunately no mention if a rule
|
||||
// is new.
|
||||
|
|
@ -940,7 +937,7 @@ public class NiciraNvpElement extends AdapterBase implements
|
|||
|
||||
List<PortForwardingRuleTO> portForwardingRules = new ArrayList<PortForwardingRuleTO>();
|
||||
for (PortForwardingRule rule : rules) {
|
||||
IpAddress sourceIp = _networkManager.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());
|
||||
PortForwardingRuleTO ruleTO = new PortForwardingRuleTO((PortForwardingRule) rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
|
||||
portForwardingRules.add(ruleTO);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import com.cloud.host.dao.HostDao;
|
|||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
|
|
@ -70,10 +70,9 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(NiciraNvpGuestNetworkGuru.class);
|
||||
|
||||
@Inject
|
||||
NetworkManager _externalNetworkManager;
|
||||
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
|
|
@ -153,7 +152,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
|||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
network.getDataCenterId(), physicalNetworkId);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public class NiciraNvpResource implements ServerResource {
|
|||
sc.setPod("");
|
||||
sc.setPrivateIpAddress("");
|
||||
sc.setStorageIpAddress("");
|
||||
sc.setVersion("");
|
||||
sc.setVersion(NiciraNvpResource.class.getPackage().getImplementationVersion());
|
||||
return new StartupCommand[] { sc };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.cloud.network.Network.GuestType;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
|
|
@ -48,6 +49,7 @@ public class NiciraNvpElementTest {
|
|||
|
||||
NiciraNvpElement _element = new NiciraNvpElement();
|
||||
NetworkManager _networkManager = mock(NetworkManager.class);
|
||||
NetworkModel _networkModel = mock(NetworkModel.class);
|
||||
NetworkServiceMapDao _ntwkSrvcDao = mock (NetworkServiceMapDao.class);
|
||||
|
||||
@Before
|
||||
|
|
@ -55,9 +57,10 @@ public class NiciraNvpElementTest {
|
|||
_element._resourceMgr = mock(ResourceManager.class);
|
||||
_element._networkManager = _networkManager;
|
||||
_element._ntwkSrvcDao = _ntwkSrvcDao;
|
||||
_element._networkModel = _networkModel;
|
||||
|
||||
// Standard responses
|
||||
when(_networkManager.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
|
||||
_element.configure("NiciraNvpTestElement", Collections.<String, Object> emptyMap());
|
||||
}
|
||||
|
|
@ -81,12 +84,12 @@ public class NiciraNvpElementTest {
|
|||
// No nvp provider in the network
|
||||
assertFalse(_element.canHandle(net, Service.Connectivity));
|
||||
|
||||
when(_networkManager.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(false);
|
||||
when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(false);
|
||||
when(_ntwkSrvcDao.canProviderSupportServiceInNetwork(42L, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
|
||||
// NVP provider does not provide Connectivity for this network
|
||||
assertFalse(_element.canHandle(net, Service.Connectivity));
|
||||
|
||||
when(_networkManager.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
when(_networkModel.isProviderForNetwork(Provider.NiciraNvp, 42L)).thenReturn(true);
|
||||
// Only service Connectivity is supported
|
||||
assertFalse(_element.canHandle(net, Service.Dhcp));
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import com.cloud.network.Network.GuestType;
|
|||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
|
|
@ -67,6 +68,8 @@ public class NiciraNvpGuestNetworkGuruTest {
|
|||
NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
|
||||
AgentManager agentmgr = mock (AgentManager.class);
|
||||
NetworkManager netmgr = mock (NetworkManager.class);
|
||||
NetworkModel netmodel = mock (NetworkModel.class);
|
||||
|
||||
HostDao hostdao = mock (HostDao.class);
|
||||
NetworkDao netdao = mock(NetworkDao.class);
|
||||
NiciraNvpGuestNetworkGuru guru;
|
||||
|
|
@ -80,7 +83,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
|||
guru._niciraNvpDao = nvpdao;
|
||||
guru._dcDao = dcdao;
|
||||
guru._ntwkOfferingSrvcDao = nosd;
|
||||
guru._networkMgr = netmgr;
|
||||
guru._networkModel = netmodel;
|
||||
guru._hostDao = hostdao;
|
||||
guru._agentMgr = agentmgr;
|
||||
guru._networkDao = netdao;
|
||||
|
|
@ -261,7 +264,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
|||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
|
|
@ -318,7 +321,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
|||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
|
|
@ -374,7 +377,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
|||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
|
|
@ -432,7 +435,7 @@ public class NiciraNvpGuestNetworkGuruTest {
|
|||
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
|
||||
when(niciraHost.getId()).thenReturn(42L);
|
||||
|
||||
when(netmgr.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
|
||||
Domain dom = mock(Domain.class);
|
||||
when(dom.getName()).thenReturn("domain");
|
||||
Account acc = mock(Account.class);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import com.cloud.vm.ReservationContext;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
@Local(value = {NetworkElement.class})
|
||||
public class OvsElement extends AdapterBase implements NetworkElement {
|
||||
@Inject
|
||||
OvsTunnelManager _ovsTunnelMgr;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -29,32 +27,25 @@ import com.cloud.deploy.DeploymentPlan;
|
|||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.ovs.OvsTunnelManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
|
||||
@Local(value=NetworkGuru.class)
|
||||
public class OvsGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(OvsGuestNetworkGuru.class);
|
||||
|
||||
@Inject NetworkManager _externalNetworkManager;
|
||||
@Inject OvsTunnelManager _ovsTunnelMgr;
|
||||
|
||||
OvsGuestNetworkGuru() {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
<testSourceDirectory>test</testSourceDirectory>
|
||||
</build>
|
||||
<modules>
|
||||
<module>api/rate-limit</module>
|
||||
<module>api/discovery</module>
|
||||
<module>acl/static-role-based</module>
|
||||
<module>deployment-planners/user-concentrated-pod</module>
|
||||
|
|
|
|||
37
pom.xml
37
pom.xml
|
|
@ -160,7 +160,6 @@
|
|||
<module>utils</module>
|
||||
<module>deps/XenServerJava</module>
|
||||
<module>plugins</module>
|
||||
<module>awsapi</module>
|
||||
<module>patches</module>
|
||||
<module>client</module>
|
||||
<module>test</module>
|
||||
|
|
@ -359,11 +358,47 @@
|
|||
</formats>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings
|
||||
only. It has no influence on the Maven build itself. -->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>
|
||||
org.apache.maven.plugins
|
||||
</groupId>
|
||||
<artifactId>
|
||||
maven-antrun-plugin
|
||||
</artifactId>
|
||||
<versionRange>[1.7,)</versionRange>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>awsapi</id>
|
||||
<modules>
|
||||
<module>awsapi</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>developer</id>
|
||||
<modules>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import com.cloud.domain.Domain;
|
|||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.projects.ProjectManager;
|
||||
|
|
@ -42,20 +42,14 @@ import com.cloud.utils.component.Inject;
|
|||
|
||||
@Local(value = SecurityChecker.class)
|
||||
public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||
|
||||
@Inject
|
||||
DomainDao _domainDao;
|
||||
@Inject
|
||||
AccountDao _accountDao;
|
||||
@Inject
|
||||
LaunchPermissionDao _launchPermissionDao;
|
||||
@Inject
|
||||
ProjectManager _projectMgr;
|
||||
@Inject
|
||||
ProjectAccountDao _projecAccountDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
|
||||
|
||||
@Inject DomainDao _domainDao;
|
||||
@Inject AccountDao _accountDao;
|
||||
@Inject LaunchPermissionDao _launchPermissionDao;
|
||||
@Inject ProjectManager _projectMgr;
|
||||
@Inject ProjectAccountDao _projecAccountDao;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
||||
protected DomainChecker() {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import java.util.Random;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
|
@ -94,6 +96,7 @@ import com.cloud.resource.Discoverer;
|
|||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StorageService;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
|
|
@ -220,7 +223,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
|
||||
protected ExecutorService _executor;
|
||||
protected ThreadPoolExecutor _connectExecutor;
|
||||
|
||||
protected ScheduledExecutorService _directAgentExecutor;
|
||||
|
||||
protected StateMachine2<Status, Status.Event, Host> _statusStateMachine = Status.getStateMachine();
|
||||
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
|
@ -280,10 +284,15 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("AgentConnectTaskPool"));
|
||||
//allow core threads to time out even when there are no items in the queue
|
||||
_connectExecutor.allowCoreThreadTimeOut(true);
|
||||
|
||||
_connection = new NioServer("AgentManager", _port, workers + 10, this);
|
||||
|
||||
_connection = new NioServer("AgentManager", _port, workers + 10, this);
|
||||
s_logger.info("Listening on " + _port + " with " + workers + " workers");
|
||||
|
||||
value = configs.get(Config.DirectAgentPoolSize.key());
|
||||
int size = NumbersUtil.parseInt(value, 500);
|
||||
_directAgentExecutor = new ScheduledThreadPoolExecutor(size, new NamedThreadFactory("DirectAgent"));
|
||||
s_logger.debug("Created DirectAgentAttache pool with size: " + size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -909,10 +918,16 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
s_logger.info("Investigating why host " + hostId + " has disconnected with event " + event);
|
||||
|
||||
final Status determinedState = investigate(attache);
|
||||
// if state cannot be determined do nothing and bail out
|
||||
if (determinedState == null) {
|
||||
s_logger.warn("Agent state cannot be determined, do nothing");
|
||||
return false;
|
||||
}
|
||||
|
||||
final Status currentStatus = host.getStatus();
|
||||
s_logger.info("The state determined is " + determinedState);
|
||||
|
||||
if (determinedState == null || determinedState == Status.Down) {
|
||||
if (determinedState == Status.Down) {
|
||||
s_logger.error("Host is down: " + host.getId() + "-" + host.getName() + ". Starting HA on the VMs");
|
||||
event = Status.Event.HostDown;
|
||||
} else if (determinedState == Status.Up) {
|
||||
|
|
@ -1521,7 +1536,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, Manager {
|
|||
attache.setMaintenanceMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ScheduledExecutorService getDirectAgentPool() {
|
||||
return _directAgentExecutor;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,11 @@ package com.cloud.agent.manager;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.CronCommand;
|
||||
|
|
@ -37,13 +34,11 @@ import com.cloud.exception.AgentUnavailableException;
|
|||
import com.cloud.host.Status;
|
||||
import com.cloud.host.Status.Event;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
|
||||
public class DirectAgentAttache extends AgentAttache {
|
||||
private final static Logger s_logger = Logger.getLogger(DirectAgentAttache.class);
|
||||
|
||||
ServerResource _resource;
|
||||
static ScheduledExecutorService s_executor = new ScheduledThreadPoolExecutor(500, new NamedThreadFactory("DirectAgent"));
|
||||
List<ScheduledFuture<?>> _futures = new ArrayList<ScheduledFuture<?>>();
|
||||
AgentManagerImpl _mgr;
|
||||
long _seq = 0;
|
||||
|
|
@ -94,15 +89,15 @@ public class DirectAgentAttache extends AgentAttache {
|
|||
if (answers != null && answers[0] instanceof StartupAnswer) {
|
||||
StartupAnswer startup = (StartupAnswer)answers[0];
|
||||
int interval = startup.getPingInterval();
|
||||
_futures.add(s_executor.scheduleAtFixedRate(new PingTask(), interval, interval, TimeUnit.SECONDS));
|
||||
_futures.add(_agentMgr.getDirectAgentPool().scheduleAtFixedRate(new PingTask(), interval, interval, TimeUnit.SECONDS));
|
||||
}
|
||||
} else {
|
||||
Command[] cmds = req.getCommands();
|
||||
if (cmds.length > 0 && !(cmds[0] instanceof CronCommand)) {
|
||||
s_executor.execute(new Task(req));
|
||||
_agentMgr.getDirectAgentPool().execute(new Task(req));
|
||||
} else {
|
||||
CronCommand cmd = (CronCommand)cmds[0];
|
||||
_futures.add(s_executor.scheduleAtFixedRate(new Task(req), cmd.getInterval(), cmd.getInterval(), TimeUnit.SECONDS));
|
||||
_futures.add(_agentMgr.getDirectAgentPool().scheduleAtFixedRate(new Task(req), cmd.getInterval(), cmd.getInterval(), TimeUnit.SECONDS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +108,7 @@ public class DirectAgentAttache extends AgentAttache {
|
|||
StartupAnswer startup = (StartupAnswer)answers[0];
|
||||
int interval = startup.getPingInterval();
|
||||
s_logger.info("StartupAnswer received " + startup.getHostId() + " Interval = " + interval );
|
||||
_futures.add(s_executor.scheduleAtFixedRate(new PingTask(), interval, interval, TimeUnit.SECONDS));
|
||||
_futures.add(_agentMgr.getDirectAgentPool().scheduleAtFixedRate(new PingTask(), interval, interval, TimeUnit.SECONDS));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ import com.cloud.network.Network.Provider;
|
|||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkDomainVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkRuleConfigVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
|
|
@ -255,6 +256,7 @@ public class ApiDBUtils {
|
|||
private static StorageManager _storageMgr;
|
||||
private static UserVmManager _userVmMgr;
|
||||
private static NetworkManager _networkMgr;
|
||||
private static NetworkModel _networkModel;
|
||||
private static StatsCollector _statsCollector;
|
||||
|
||||
private static AccountDao _accountDao;
|
||||
|
|
@ -350,6 +352,7 @@ public class ApiDBUtils {
|
|||
_storageMgr = locator.getManager(StorageManager.class);
|
||||
_userVmMgr = locator.getManager(UserVmManager.class);
|
||||
_networkMgr = locator.getManager(NetworkManager.class);
|
||||
_networkModel = locator.getManager(NetworkModel.class);
|
||||
_configMgr = locator.getManager(ConfigurationService.class);
|
||||
|
||||
_accountDao = locator.getDao(AccountDao.class);
|
||||
|
|
@ -477,7 +480,7 @@ public class ApiDBUtils {
|
|||
}
|
||||
|
||||
public static Long getPodIdForVlan(long vlanDbId) {
|
||||
return _networkMgr.getPodIdForVlan(vlanDbId);
|
||||
return _networkModel.getPodIdForVlan(vlanDbId);
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
|
|
@ -844,11 +847,11 @@ public class ApiDBUtils {
|
|||
}
|
||||
|
||||
public static Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId, long zoneId) {
|
||||
return _networkMgr.getNetworkCapabilities(networkId);
|
||||
return _networkModel.getNetworkCapabilities(networkId);
|
||||
}
|
||||
|
||||
public static long getPublicNetworkIdByZone(long zoneId) {
|
||||
return _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
return _networkModel.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
}
|
||||
|
||||
public static Long getVlanNetworkId(long vlanId) {
|
||||
|
|
@ -878,7 +881,7 @@ public class ApiDBUtils {
|
|||
}
|
||||
|
||||
public static Long getDedicatedNetworkDomain(long networkId) {
|
||||
return _networkMgr.getDedicatedNetworkDomain(networkId);
|
||||
return _networkModel.getDedicatedNetworkDomain(networkId);
|
||||
}
|
||||
|
||||
public static float getCpuOverprovisioningFactor() {
|
||||
|
|
@ -931,25 +934,25 @@ public class ApiDBUtils {
|
|||
}
|
||||
|
||||
public static Map<Service, Set<Provider>> listNetworkOfferingServices(long networkOfferingId) {
|
||||
return _networkMgr.getNetworkOfferingServiceProvidersMap(networkOfferingId);
|
||||
return _networkModel.getNetworkOfferingServiceProvidersMap(networkOfferingId);
|
||||
}
|
||||
|
||||
public static List<Service> getElementServices(Provider provider) {
|
||||
return _networkMgr.getElementServices(provider);
|
||||
return _networkModel.getElementServices(provider);
|
||||
}
|
||||
|
||||
public static List<? extends Provider> getProvidersForService(Service service) {
|
||||
return _networkMgr.listSupportedNetworkServiceProviders(service.getName());
|
||||
return _networkModel.listSupportedNetworkServiceProviders(service.getName());
|
||||
}
|
||||
|
||||
public static boolean canElementEnableIndividualServices(Provider serviceProvider) {
|
||||
return _networkMgr.canElementEnableIndividualServices(serviceProvider);
|
||||
return _networkModel.canElementEnableIndividualServices(serviceProvider);
|
||||
}
|
||||
|
||||
public static Pair<Long, Boolean> getDomainNetworkDetails(long networkId) {
|
||||
NetworkDomainVO map = _networkDomainDao.getDomainNetworkMapByNetworkId(networkId);
|
||||
|
||||
boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : _networkMgr.getAllowSubdomainAccessGlobal();
|
||||
boolean subdomainAccess = (map.isSubdomainAccess() != null) ? map.isSubdomainAccess() : _networkModel.getAllowSubdomainAccessGlobal();
|
||||
|
||||
return new Pair<Long, Boolean>(map.getDomainId(), subdomainAccess);
|
||||
}
|
||||
|
|
@ -976,11 +979,11 @@ public class ApiDBUtils {
|
|||
}
|
||||
|
||||
public static List<? extends Network> listVpcNetworks(long vpcId) {
|
||||
return _networkMgr.listNetworksByVpc(vpcId);
|
||||
return _networkModel.listNetworksByVpc(vpcId);
|
||||
}
|
||||
|
||||
public static boolean canUseForDeploy(Network network) {
|
||||
return _networkMgr.canUseForDeploy(network);
|
||||
return _networkModel.canUseForDeploy(network);
|
||||
}
|
||||
|
||||
public static String getUuid(String resourceId, TaggedResourceType resourceType) {
|
||||
|
|
|
|||
|
|
@ -349,7 +349,6 @@ public class ApiDispatcher {
|
|||
try {
|
||||
internalId = Long.parseLong(uuid);
|
||||
} catch(NumberFormatException e) {
|
||||
// In case regex failed, and it's still uuid string
|
||||
internalId = null;
|
||||
}
|
||||
if (internalId != null)
|
||||
|
|
@ -381,10 +380,8 @@ public class ApiDispatcher {
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Object entity with uuid=" + uuid + " does not exist in the database.");
|
||||
}
|
||||
if (annotation.required()) {
|
||||
throw new InvalidParameterValueException("Invalid parameter with uuid=" + uuid
|
||||
+ ". Entity not found, or an annotation bug.");
|
||||
}
|
||||
throw new InvalidParameterValueException("Invalid parameter value=" + uuid
|
||||
+ " due to incorrect long value, entity not found, or an annotation bug.");
|
||||
}
|
||||
return internalId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.cloud.utils.ReflectUtil;
|
||||
import org.apache.cloudstack.acl.APILimitChecker;
|
||||
import org.apache.cloudstack.acl.APIChecker;
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.*;
|
||||
|
|
@ -118,6 +119,7 @@ import com.cloud.exception.CloudAuthenticationException;
|
|||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.RequestLimitException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.server.ManagementServer;
|
||||
|
|
@ -150,6 +152,8 @@ public class ApiServer implements HttpRequestHandler {
|
|||
@Inject private DomainManager _domainMgr = null;
|
||||
@Inject private AsyncJobManager _asyncMgr = null;
|
||||
|
||||
@Inject(adapter = APILimitChecker.class)
|
||||
protected Adapters<APILimitChecker> _apiLimitCheckers;
|
||||
@Inject(adapter = APIChecker.class)
|
||||
protected Adapters<APIChecker> _apiAccessCheckers;
|
||||
|
||||
|
|
@ -256,7 +260,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
// (Immutable)Multimap<String, String> paramMultiMap = HashMultimap.create();
|
||||
// Map<String, Collection<String>> parameterMap = paramMultiMap.asMap();
|
||||
Map parameterMap = new HashMap<String, String[]>();
|
||||
String responseType = BaseCmd.RESPONSE_TYPE_JSON;
|
||||
String responseType = BaseCmd.RESPONSE_TYPE_XML;
|
||||
for (NameValuePair param : paramList) {
|
||||
if (param.getName().equalsIgnoreCase("response")) {
|
||||
responseType = param.getValue();
|
||||
|
|
@ -267,7 +271,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
|
||||
// Check responseType, if not among valid types, fallback to JSON
|
||||
if (!(responseType.equals(BaseCmd.RESPONSE_TYPE_JSON) || responseType.equals(BaseCmd.RESPONSE_TYPE_XML)))
|
||||
responseType = BaseCmd.RESPONSE_TYPE_JSON;
|
||||
responseType = BaseCmd.RESPONSE_TYPE_XML;
|
||||
|
||||
try {
|
||||
// always trust commands from API port, user context will always be UID_SYSTEM/ACCOUNT_ID_SYSTEM
|
||||
|
|
@ -382,6 +386,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
if (UserContext.current().getCaller().getType() != Account.ACCOUNT_TYPE_ADMIN){
|
||||
// hide internal details to non-admin user for security reason
|
||||
errorMsg = BaseCmd.USER_ERROR_MESSAGE;
|
||||
|
||||
}
|
||||
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, errorMsg, ex);
|
||||
}
|
||||
|
|
@ -585,6 +590,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
// if userId not null, that mean that user is logged in
|
||||
if (userId != null) {
|
||||
User user = ApiDBUtils.findUserById(userId);
|
||||
|
||||
try{
|
||||
checkCommandAvailable(user, commandName);
|
||||
}
|
||||
|
|
@ -592,6 +598,10 @@ public class ApiServer implements HttpRequestHandler {
|
|||
s_logger.debug("The given command:" + commandName + " does not exist or it is not available for user with id:" + userId);
|
||||
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "The given command does not exist or it is not available for user");
|
||||
}
|
||||
catch (RequestLimitException ex){
|
||||
s_logger.debug(ex.getMessage());
|
||||
throw new ServerApiException(ApiErrorCode.API_LIMIT_EXCEED, ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// check against every available command to see if the command exists or not
|
||||
|
|
@ -821,6 +831,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void checkCommandAvailable(User user, String commandName) throws PermissionDeniedException {
|
||||
if (user == null) {
|
||||
throw new PermissionDeniedException("User is null for role based API access check for command" + commandName);
|
||||
|
|
|
|||
|
|
@ -304,13 +304,11 @@ public class ApiServlet extends HttpServlet {
|
|||
* key mechanism updateUserContext(params, session != null ? session.getId() : null);
|
||||
*/
|
||||
|
||||
auditTrailSb.insert(0,
|
||||
"(userId=" + UserContext.current().getCallerUserId() + " accountId=" + UserContext.current().getCaller().getId() + " sessionId=" + (session != null ? session.getId() : null)
|
||||
+ ")");
|
||||
auditTrailSb.insert(0, "(userId=" + UserContext.current().getCallerUserId() + " accountId="
|
||||
+ UserContext.current().getCaller().getId() + " sessionId=" + (session != null ? session.getId() : null) + ")");
|
||||
|
||||
String response = _apiServer.handleRequest(params, false, responseType, auditTrailSb);
|
||||
writeResponse(resp, response != null ? response : "", HttpServletResponse.SC_OK, responseType);
|
||||
|
||||
} else {
|
||||
if (session != null) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package com.cloud.async;
|
|||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.async.dao.AsyncJobDao;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.StorageManager;
|
||||
|
|
@ -37,7 +37,7 @@ import com.cloud.vm.dao.UserVmDao;
|
|||
public interface AsyncJobExecutorContext extends Manager {
|
||||
public ManagementServer getManagementServer();
|
||||
public AgentManager getAgentMgr();
|
||||
public NetworkManager getNetworkMgr();
|
||||
public NetworkModel getNetworkMgr();
|
||||
public UserVmManager getVmMgr();
|
||||
public SnapshotManager getSnapshotMgr();
|
||||
public AccountManager getAccountMgr();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.cloud.agent.AgentManager;
|
|||
import com.cloud.async.dao.AsyncJobDao;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.storage.StorageManager;
|
||||
|
|
@ -44,7 +45,7 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
|||
private String _name;
|
||||
|
||||
private AgentManager _agentMgr;
|
||||
private NetworkManager _networkMgr;
|
||||
private NetworkModel _networkMgr;
|
||||
private UserVmManager _vmMgr;
|
||||
private SnapshotManager _snapMgr;
|
||||
private AccountManager _accountMgr;
|
||||
|
|
@ -72,7 +73,7 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NetworkManager getNetworkMgr() {
|
||||
public NetworkModel getNetworkMgr() {
|
||||
return _networkMgr;
|
||||
}
|
||||
|
||||
|
|
@ -159,9 +160,9 @@ public class AsyncJobExecutorContextImpl implements AsyncJobExecutorContext {
|
|||
throw new ConfigurationException("unable to get " + AgentManager.class.getName());
|
||||
}
|
||||
|
||||
_networkMgr = locator.getManager(NetworkManager.class);
|
||||
_networkMgr = locator.getManager(NetworkModel.class);
|
||||
if (_networkMgr == null) {
|
||||
throw new ConfigurationException("unable to get " + NetworkManager.class.getName());
|
||||
throw new ConfigurationException("unable to get " + NetworkModel.class.getName());
|
||||
}
|
||||
|
||||
_vmMgr = locator.getManager(UserVmManager.class);
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
|||
s_logger.warn("Bare Metal only supports basical network mode now, switch to baisc network automatically");
|
||||
}
|
||||
|
||||
Network defaultNetwork = _networkMgr.getExclusiveGuestNetwork(dc.getId());
|
||||
Network defaultNetwork = _networkModel.getExclusiveGuestNetwork(dc.getId());
|
||||
if (defaultNetwork == null) {
|
||||
throw new InvalidParameterValueException("Unable to find a default network to start a vm");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class ExternalDhcpResourceBase implements ServerResource {
|
|||
cmd.setPod(_podId);
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
cmd.setVersion(ExternalDhcpResourceBase.class.getPackage().getImplementationVersion());
|
||||
cmd.setGuid(_guid);
|
||||
return new StartupCommand[]{cmd};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class PxeServerResourceBase implements ServerResource {
|
|||
cmd.setPod(_podId);
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
cmd.setVersion(PxeServerResourceBase.class.getPackage().getImplementationVersion());
|
||||
cmd.setGuid(_guid);
|
||||
return new StartupCommand[]{cmd};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,8 +296,8 @@ public enum Config {
|
|||
VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600", "Time (in seconds) to wait before cleanuping up any vm work items", "Seconds"),
|
||||
VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"),
|
||||
|
||||
|
||||
DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null),
|
||||
DirectAgentPoolSize("Advanced", ManagementServer.class, Integer.class, "direct.agent.pool.size", "500", "Default size for DirectAgentPool", null),
|
||||
|
||||
TaskCleanupRetryInterval("Advanced", ManagementServer.class, Integer.class, "task.cleanup.retry.interval", "600", "Time (in seconds) to wait before retrying cleanup of tasks if the cleanup failed previously. 0 means to never retry.", "Seconds"),
|
||||
|
||||
|
|
@ -360,7 +360,6 @@ public enum Config {
|
|||
ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, Long.class, "concurrent.snapshots.threshold.perhost",
|
||||
null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null);
|
||||
|
||||
|
||||
private final String _category;
|
||||
private final Class<?> _componentClass;
|
||||
private final Class<?> _type;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ import com.cloud.network.Network.GuestType;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
|
@ -208,6 +210,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkService _networkSvc;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
ClusterDao _clusterDao;
|
||||
@Inject
|
||||
AlertManager _alertMgr;
|
||||
|
|
@ -753,7 +759,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
// Delete vlans associated with the pod
|
||||
List<? extends Vlan> vlans = _networkMgr.listPodVlans(podId);
|
||||
List<? extends Vlan> vlans = _networkModel.listPodVlans(podId);
|
||||
if (vlans != null && !vlans.isEmpty()) {
|
||||
for (Vlan vlan : vlans) {
|
||||
_vlanDao.remove(vlan.getId());
|
||||
|
|
@ -1522,18 +1528,18 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
PhysicalNetwork mgmtPhyNetwork;
|
||||
if (NetworkType.Advanced == zone.getNetworkType()) {
|
||||
// zone should have a physical network with public and management traffiType
|
||||
_networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
|
||||
mgmtPhyNetwork = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
_networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
|
||||
mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
} else {
|
||||
// zone should have a physical network with management traffiType
|
||||
mgmtPhyNetwork = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
|
||||
}
|
||||
|
||||
try {
|
||||
_networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
|
||||
_networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
|
||||
} catch (InvalidParameterValueException noStorage) {
|
||||
PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Management);
|
||||
_networkMgr.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(),
|
||||
_networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(),
|
||||
mgmtTraffic.getVmwareNetworkLabel(), mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan());
|
||||
s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network " + mgmtPhyNetwork.getId() + " with same configure of management traffic type");
|
||||
}
|
||||
|
|
@ -2134,14 +2140,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
} else {
|
||||
if (forVirtualNetwork) {
|
||||
// default physical network with public traffic in the zone
|
||||
physicalNetworkId = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
} else {
|
||||
if (zone.getNetworkType() == DataCenter.NetworkType.Basic) {
|
||||
// default physical network with guest traffic in the zone
|
||||
physicalNetworkId = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
} else if (zone.getNetworkType() == DataCenter.NetworkType.Advanced) {
|
||||
if (zone.isSecurityGroupEnabled()) {
|
||||
physicalNetworkId = _networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Guest).getId();
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Physical Network Id is null, please provide the Network id for Direct vlan creation ");
|
||||
}
|
||||
|
|
@ -2165,18 +2171,18 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if (forVirtualNetwork) {
|
||||
if (network == null) {
|
||||
// find default public network in the zone
|
||||
networkId = _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
network = _networkMgr.getNetwork(networkId);
|
||||
networkId = _networkModel.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId();
|
||||
network = _networkModel.getNetwork(networkId);
|
||||
} else if (network.getGuestType() != null || network.getTrafficType() != TrafficType.Public) {
|
||||
throw new InvalidParameterValueException("Can't find Public network by id=" + networkId);
|
||||
}
|
||||
} else {
|
||||
if (network == null) {
|
||||
if (zone.getNetworkType() == DataCenter.NetworkType.Basic) {
|
||||
networkId = _networkMgr.getExclusiveGuestNetwork(zoneId).getId();
|
||||
network = _networkMgr.getNetwork(networkId);
|
||||
networkId = _networkModel.getExclusiveGuestNetwork(zoneId).getId();
|
||||
network = _networkModel.getNetwork(networkId);
|
||||
} else {
|
||||
network = _networkMgr.getNetworkWithSecurityGroupEnabled(zoneId);
|
||||
network = _networkModel.getNetworkWithSecurityGroupEnabled(zoneId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Nework id is required for Direct vlan creation ");
|
||||
}
|
||||
|
|
@ -2276,7 +2282,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String vlanId, Account vlanOwner) {
|
||||
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
|
||||
//Validate the zone
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
|
|
@ -2517,7 +2523,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
" as ip " + ip + " belonging to the range is used for static nat purposes. Cleanup the rules first");
|
||||
}
|
||||
|
||||
if (ip.isSourceNat() && _networkMgr.getNetwork(ip.getAssociatedWithNetworkId()) != null) {
|
||||
if (ip.isSourceNat() && _networkModel.getNetwork(ip.getAssociatedWithNetworkId()) != null) {
|
||||
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
|
||||
" as ip " + ip + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId() +
|
||||
". IP range with the source nat ip address can be removed either as a part of Network, or account removal");
|
||||
|
|
@ -3061,7 +3067,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
// validate providers combination here
|
||||
_networkMgr.canProviderSupportServices(providerCombinationToVerify);
|
||||
_networkModel.canProviderSupportServices(providerCombinationToVerify);
|
||||
|
||||
// validate the LB service capabilities specified in the network offering
|
||||
Map<Capability, String> lbServiceCapabilityMap = cmd.getServiceCapabilities(Service.Lb);
|
||||
|
|
@ -3237,7 +3243,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if ((lbServiceCapabilityMap != null) && (!lbServiceCapabilityMap.isEmpty())) {
|
||||
String isolationCapability = lbServiceCapabilityMap.get(Capability.SupportedLBIsolation);
|
||||
if (isolationCapability != null) {
|
||||
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.SupportedLBIsolation, isolationCapability);
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.SupportedLBIsolation, isolationCapability);
|
||||
dedicatedLb = isolationCapability.contains("dedicated");
|
||||
} else {
|
||||
dedicatedLb = true;
|
||||
|
|
@ -3250,7 +3256,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
String inlineMode = lbServiceCapabilityMap.get(Capability.InlineMode);
|
||||
if (inlineMode != null) {
|
||||
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.InlineMode, inlineMode);
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.InlineMode, inlineMode);
|
||||
inline = inlineMode.contains("true");
|
||||
} else {
|
||||
inline = false;
|
||||
|
|
@ -3261,14 +3267,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if ((sourceNatServiceCapabilityMap != null) && (!sourceNatServiceCapabilityMap.isEmpty())) {
|
||||
String sourceNatType = sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes);
|
||||
if (sourceNatType != null) {
|
||||
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
Capability.SupportedSourceNatTypes, sourceNatType);
|
||||
sharedSourceNat = sourceNatType.contains("perzone");
|
||||
}
|
||||
|
||||
String param = sourceNatServiceCapabilityMap.get(Capability.RedundantRouter);
|
||||
if (param != null) {
|
||||
_networkMgr.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
Capability.RedundantRouter, param);
|
||||
redundantRouter = param.contains("true");
|
||||
}
|
||||
|
|
@ -3424,7 +3430,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
Network network = null;
|
||||
if (networkId != null) {
|
||||
// check if network exists and the caller can operate with it
|
||||
network = _networkMgr.getNetwork(networkId);
|
||||
network = _networkModel.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Unable to find the network by id=" + networkId);
|
||||
}
|
||||
|
|
@ -3436,7 +3442,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
_accountMgr.checkAccess(caller, null, true, network);
|
||||
|
||||
List<Long> offeringIds = _networkMgr.listNetworkOfferingsForUpgrade(networkId);
|
||||
List<Long> offeringIds = _networkModel.listNetworkOfferingsForUpgrade(networkId);
|
||||
|
||||
if (!offeringIds.isEmpty()) {
|
||||
sc.addAnd("id", SearchCriteria.Op.IN, offeringIds.toArray());
|
||||
|
|
@ -3515,21 +3521,21 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
if (listBySupportedServices) {
|
||||
addOffering = addOffering && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), supportedServices);
|
||||
addOffering = addOffering && _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), supportedServices);
|
||||
}
|
||||
|
||||
if (checkIfProvidersAreEnabled) {
|
||||
if (supportedServices != null && supportedServices.length > 0) {
|
||||
checkForProviders = Arrays.asList(supportedServices);
|
||||
} else {
|
||||
checkForProviders = _networkMgr.listNetworkOfferingServices(offering.getId());
|
||||
checkForProviders = _networkModel.listNetworkOfferingServices(offering.getId());
|
||||
}
|
||||
|
||||
addOffering = addOffering && _networkMgr.areServicesEnabledInZone(zoneId, offering, checkForProviders);
|
||||
addOffering = addOffering && _networkModel.areServicesEnabledInZone(zoneId, offering, checkForProviders);
|
||||
}
|
||||
|
||||
if (sourceNatSupported != null) {
|
||||
addOffering = addOffering && (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
|
||||
addOffering = addOffering && (_networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
|
||||
}
|
||||
|
||||
if (forVpc != null) {
|
||||
|
|
@ -3654,7 +3660,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
} else {
|
||||
if (availability == NetworkOffering.Availability.Required) {
|
||||
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated
|
||||
&& _networkMgr.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
&& _networkModel.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
if (!canOffBeRequired) {
|
||||
throw new InvalidParameterValueException("Availability can be " +
|
||||
NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
|
|
@ -3780,7 +3786,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
Long networkId = vlan.getNetworkId();
|
||||
if (networkId != null) {
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
if (network != null) {
|
||||
accountId = network.getAccountId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ import com.cloud.maint.UpgradeManagerImpl;
|
|||
import com.cloud.maint.dao.AgentUpgradeDaoImpl;
|
||||
import com.cloud.network.ExternalLoadBalancerUsageManagerImpl;
|
||||
import com.cloud.network.NetworkManagerImpl;
|
||||
import com.cloud.network.NetworkModelImpl;
|
||||
import com.cloud.network.NetworkServiceImpl;
|
||||
import com.cloud.network.StorageNetworkManagerImpl;
|
||||
import com.cloud.network.as.AutoScaleManagerImpl;
|
||||
import com.cloud.network.as.dao.AutoScalePolicyConditionMapDaoImpl;
|
||||
|
|
@ -413,7 +415,9 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
addManager("account manager", AccountManagerImpl.class);
|
||||
addManager("domain manager", DomainManagerImpl.class);
|
||||
addManager("resource limit manager", ResourceLimitManagerImpl.class);
|
||||
addManager("network service", NetworkServiceImpl.class);
|
||||
addManager("network manager", NetworkManagerImpl.class);
|
||||
addManager("network model", NetworkModelImpl.class);
|
||||
addManager("download manager", DownloadMonitorImpl.class);
|
||||
addManager("upload manager", UploadMonitorImpl.class);
|
||||
addManager("keystore manager", KeystoreManagerImpl.class);
|
||||
|
|
|
|||
|
|
@ -94,13 +94,14 @@ import com.cloud.keystore.KeystoreVO;
|
|||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ResourceStateAdapter;
|
||||
|
|
@ -212,6 +213,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
ServiceOfferingDao _offeringDao;
|
||||
|
|
@ -236,9 +239,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
private ServiceOfferingVO _serviceOffering;
|
||||
|
||||
NetworkOfferingVO _publicNetworkOffering;
|
||||
NetworkOfferingVO _managementNetworkOffering;
|
||||
NetworkOfferingVO _linkLocalNetworkOffering;
|
||||
NetworkOffering _publicNetworkOffering;
|
||||
NetworkOffering _managementNetworkOffering;
|
||||
NetworkOffering _linkLocalNetworkOffering;
|
||||
|
||||
@Inject
|
||||
private VirtualMachineManager _itMgr;
|
||||
|
|
@ -766,7 +769,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
NetworkVO defaultNetwork = defaultNetworks.get(0);
|
||||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork, NetworkOfferingVO.SystemManagementNetwork);
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork, NetworkOffering.SystemManagementNetwork);
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
|
||||
NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
|
|
@ -774,7 +777,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, _networkOfferingDao.findById(defaultNetwork.getNetworkOfferingId()), plan, null, null, false).get(0), defaultNic));
|
||||
|
||||
for (NetworkOfferingVO offering : offerings) {
|
||||
for (NetworkOffering offering : offerings) {
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.Nic;
|
||||
|
|
@ -40,7 +40,7 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl {
|
|||
|
||||
private String _name = null;
|
||||
@Inject private HostDao _hostDao = null;
|
||||
@Inject private NetworkManager _networkMgr = null;
|
||||
@Inject private NetworkModel _networkMgr = null;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import com.cloud.agent.api.PingTestCommand;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||
|
|
@ -49,7 +49,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
|||
private String _name = null;
|
||||
@Inject private final UserVmDao _userVmDao = null;
|
||||
@Inject private final AgentManager _agentMgr = null;
|
||||
@Inject private final NetworkManager _networkMgr = null;
|
||||
@Inject private final NetworkModel _networkMgr = null;
|
||||
@Inject private final VpcVirtualNetworkApplianceManager _vnaMgr = null;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import com.cloud.host.dao.HostDao;
|
|||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.PhysicalNetworkSetupInfo;
|
||||
import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.DiscovererBase;
|
||||
|
|
@ -79,7 +79,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
|||
@Inject ClusterDao _clusterDao;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
|
||||
@Override
|
||||
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||
@Inject HostDao _hostDao;
|
||||
@Inject NetworkServiceMapDao _ntwkSrvcProviderDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
@Inject InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject AgentManager _agentMgr;
|
||||
|
|
@ -420,8 +420,8 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||
|
||||
IPAddressVO sourceNatIp = null;
|
||||
if (!sharedSourceNat) {
|
||||
// Get the source NAT IP address for this account
|
||||
List<IPAddressVO> sourceNatIps = _networkMgr.listPublicIpsAssignedToAccount(network.getAccountId(),
|
||||
// Get the source NAT IP address for this account
|
||||
List<? extends IpAddress> sourceNatIps = _networkMgr.listPublicIpsAssignedToAccount(network.getAccountId(),
|
||||
zoneId, true);
|
||||
|
||||
if (sourceNatIps.size() != 1) {
|
||||
|
|
@ -430,7 +430,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||
s_logger.error(errorMsg);
|
||||
return true;
|
||||
} else {
|
||||
sourceNatIp = sourceNatIps.get(0);
|
||||
sourceNatIp = _ipAddressDao.findById(sourceNatIps.get(0).getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
|
|
@ -743,7 +745,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
};
|
||||
|
||||
private MappingNic getLoadBalancingIpNic(DataCenterVO zone, Network network, long sourceIpId, boolean revoked, String existedGuestIp) throws ResourceUnavailableException {
|
||||
String srcIp = _networkMgr.getIp(sourceIpId).getAddress().addr();
|
||||
String srcIp = _networkModel.getIp(sourceIpId).getAddress().addr();
|
||||
InlineLoadBalancerNicMapVO mapping = _inlineLoadBalancerNicMapDao.findByPublicIpAddress(srcIp);
|
||||
NicVO loadBalancingIpNic = null;
|
||||
MappingNic nic = new MappingNic();
|
||||
|
|
@ -861,7 +863,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
String protocol = rule.getProtocol();
|
||||
String algorithm = rule.getAlgorithm();
|
||||
String uuid = rule.getUuid();
|
||||
String srcIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
String srcIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
List<LbDestination> destinations = rule.getDestinations();
|
||||
|
||||
|
|
@ -970,7 +972,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
long guestVlanTag = Long.parseLong(guestConfig.getBroadcastUri().getHost());
|
||||
String selfIp = null;
|
||||
String guestVlanNetmask = NetUtils.cidr2Netmask(guestConfig.getCidr());
|
||||
Integer networkRate = _networkMgr.getNetworkRate(guestConfig.getId(), null);
|
||||
Integer networkRate = _networkModel.getNetworkRate(guestConfig.getId(), null);
|
||||
|
||||
if (add) {
|
||||
// on restart network, network could have already been implemented. If already implemented then return
|
||||
|
|
@ -1094,7 +1096,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||
return null;
|
||||
}
|
||||
|
||||
NetworkElement element = _networkMgr.getElementImplementingProvider(providers.get(0).getName());
|
||||
NetworkElement element = _networkModel.getElementImplementingProvider(providers.get(0).getName());
|
||||
if (!(element instanceof IpDeployer)) {
|
||||
s_logger.error("The firewall provider for network " + network.getName() + " don't have ability to deploy IP address!");
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class ExternalLoadBalancerUsageManagerImpl implements ExternalLoadBalance
|
|||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
|
|||
@Inject ExternalDhcpManager _dhcpMgr;
|
||||
@Inject PxeServerManager _pxeMgr;
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject AccountDao _accountDao;
|
||||
|
|
|
|||
|
|
@ -16,14 +16,11 @@
|
|||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
|
|
@ -34,16 +31,10 @@ import com.cloud.exception.InsufficientCapacityException;
|
|||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.element.LoadBalancingServiceProvider;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.RemoteAccessVPNServiceProvider;
|
||||
import com.cloud.network.element.Site2SiteVpnServiceProvider;
|
||||
import com.cloud.network.element.StaticNatServiceProvider;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
|
|
@ -52,6 +43,7 @@ import com.cloud.network.rules.StaticNat;
|
|||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
|
@ -65,7 +57,7 @@ import com.cloud.vm.VirtualMachineProfileImpl;
|
|||
* NetworkManager manages the network for the different end users.
|
||||
*
|
||||
*/
|
||||
public interface NetworkManager extends NetworkService {
|
||||
public interface NetworkManager {
|
||||
/**
|
||||
* Assigns a new public ip address.
|
||||
*
|
||||
|
|
@ -98,27 +90,12 @@ public interface NetworkManager extends NetworkService {
|
|||
*/
|
||||
public boolean disassociatePublicIpAddress(long id, long userId, Account caller);
|
||||
|
||||
/**
|
||||
* Lists IP addresses that belong to VirtualNetwork VLANs
|
||||
*
|
||||
* @param accountId
|
||||
* - account that the IP address should belong to
|
||||
* @param associatedNetworkId
|
||||
* TODO
|
||||
* @param sourceNat
|
||||
* - (optional) true if the IP address should be a source NAT address
|
||||
* @return - list of IP addresses
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpsAssignedToGuestNtwk(long accountId, long associatedNetworkId, Boolean sourceNat);
|
||||
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
|
||||
throws ConcurrentOperationException;
|
||||
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
List<NetworkVO> setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
|
||||
ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException;
|
||||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
|
|
@ -131,29 +108,13 @@ public interface NetworkManager extends NetworkService {
|
|||
|
||||
void expungeNics(VirtualMachineProfile<? extends VMInstanceVO> vm);
|
||||
|
||||
List<? extends Nic> getNics(long vmId);
|
||||
|
||||
List<NicProfile> getNicProfiles(VirtualMachine vm);
|
||||
|
||||
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
|
||||
|
||||
boolean applyRules(List<? extends FirewallRule> rules, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
public boolean validateRule(FirewallRule rule);
|
||||
|
||||
List<? extends RemoteAccessVPNServiceProvider> getRemoteAccessVpnElements();
|
||||
|
||||
List<? extends Site2SiteVpnServiceProvider> getSite2SiteVpnElements();
|
||||
|
||||
PublicIpAddress getPublicIpAddress(long ipAddressId);
|
||||
|
||||
List<? extends Vlan> listPodVlans(long podId);
|
||||
boolean applyRules(List<? extends FirewallRule> rules, FirewallRule.Purpose purpose, NetworkRuleApplier applier, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException;
|
||||
|
||||
List<NetworkVO> listNetworksUsedByVm(long vmId, boolean isSystem);
|
||||
|
||||
<T extends VMInstanceVO> void prepareNicForMigration(VirtualMachineProfile<T> vm, DeployDestination dest);
|
||||
|
||||
boolean shutdownNetwork(long networkId, ReservationContext context, boolean cleanupElements);
|
||||
|
|
@ -181,133 +142,35 @@ public interface NetworkManager extends NetworkService {
|
|||
boolean associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId, Network guestNetwork) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceUnavailableException, ResourceAllocationException;
|
||||
|
||||
Nic getNicInNetwork(long vmId, long networkId);
|
||||
|
||||
List<? extends Nic> getNicsForTraffic(long vmId, TrafficType type);
|
||||
|
||||
Network getDefaultNetworkForVm(long vmId);
|
||||
|
||||
Nic getDefaultNic(long vmId);
|
||||
|
||||
UserDataServiceProvider getPasswordResetProvider(Network network);
|
||||
|
||||
UserDataServiceProvider getUserDataUpdateProvider(Network network);
|
||||
|
||||
boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId);
|
||||
|
||||
Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service);
|
||||
|
||||
boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
|
||||
|
||||
NetworkVO getNetworkWithSecurityGroupEnabled(Long zoneId);
|
||||
|
||||
boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List<? extends PublicIpAddress> publicIps) throws ResourceUnavailableException;
|
||||
|
||||
boolean startNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
|
||||
|
||||
List<NetworkVO> listNetworksForAccount(long accountId, long zoneId, Network.GuestType type);
|
||||
|
||||
List<NetworkVO> listAllNetworksInAllZonesByType(Network.GuestType type);
|
||||
|
||||
IPAddressVO markIpAsUnavailable(long addrId);
|
||||
|
||||
public String acquireGuestIpAddress(Network network, String requestedIp);
|
||||
|
||||
String getGlobalGuestDomainSuffix();
|
||||
|
||||
String getStartIpAddress(long networkId);
|
||||
|
||||
boolean applyStaticNats(List<? extends StaticNat> staticNats, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
String getIpInNetwork(long vmId, long networkId);
|
||||
|
||||
String getIpInNetworkIncludingRemoved(long vmId, long networkId);
|
||||
|
||||
Long getPodIdForVlan(long vlanDbId);
|
||||
|
||||
List<Long> listNetworkOfferingsForUpgrade(long networkId);
|
||||
|
||||
boolean isSecurityGroupSupportedInNetwork(Network network);
|
||||
|
||||
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
|
||||
|
||||
boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName);
|
||||
|
||||
String getNetworkTag(HypervisorType hType, Network network);
|
||||
|
||||
List<Service> getElementServices(Provider provider);
|
||||
|
||||
boolean canElementEnableIndividualServices(Provider provider);
|
||||
|
||||
boolean areServicesSupportedInNetwork(long networkId, Service... services);
|
||||
|
||||
boolean isNetworkSystem(Network network);
|
||||
|
||||
boolean reallocate(VirtualMachineProfile<? extends VMInstanceVO> vm,
|
||||
DataCenterDeployment dest) throws InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service);
|
||||
|
||||
Long getPhysicalNetworkId(Network network);
|
||||
|
||||
boolean getAllowSubdomainAccessGlobal();
|
||||
|
||||
boolean isProviderForNetwork(Provider provider, long networkId);
|
||||
|
||||
boolean isProviderForNetworkOffering(Provider provider, long networkOfferingId);
|
||||
|
||||
void canProviderSupportServices(Map<Provider, Set<Service>> providersMap);
|
||||
|
||||
List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfo(long dcId,
|
||||
HypervisorType hypervisorType);
|
||||
|
||||
boolean canAddDefaultSecurityGroup();
|
||||
|
||||
List<Service> listNetworkOfferingServices(long networkOfferingId);
|
||||
|
||||
boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, List<Service> services);
|
||||
|
||||
public Map<PublicIp, Set<Service>> getIpToServices(List<PublicIp> publicIps, boolean rulesRevoked, boolean includingFirewall);
|
||||
|
||||
public Map<Provider, ArrayList<PublicIp>> getProviderToIpList(Network network, Map<PublicIp, Set<Service>> ipToServices);
|
||||
|
||||
public boolean checkIpForService(IPAddressVO ip, Service service, Long networkId);
|
||||
|
||||
void checkCapabilityForProvider(Set<Provider> providers, Service service,
|
||||
Capability cap, String capValue);
|
||||
|
||||
Provider getDefaultUniqueProviderForService(String serviceName);
|
||||
|
||||
IpAddress assignSystemIp(long networkId, Account owner,
|
||||
boolean forElasticLb, boolean forElasticIp)
|
||||
throws InsufficientAddressCapacityException;
|
||||
|
||||
boolean handleSystemIpRelease(IpAddress ip);
|
||||
|
||||
void checkNetworkPermissions(Account owner, Network network);
|
||||
|
||||
void allocateDirectIp(NicProfile nic, DataCenter dc,
|
||||
VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||
Network network, String requestedIp)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException;
|
||||
|
||||
String getDefaultManagementTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultStorageTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultPublicTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
String getDefaultGuestTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
/**
|
||||
* @param providerName
|
||||
* @return
|
||||
*/
|
||||
NetworkElement getElementImplementingProvider(String providerName);
|
||||
|
||||
/**
|
||||
* @param owner
|
||||
* @param guestNetwork
|
||||
|
|
@ -318,27 +181,6 @@ public interface NetworkManager extends NetworkService {
|
|||
PublicIp assignSourceNatIpAddressToGuestNetwork(Account owner, Network guestNetwork) throws InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param zoneId
|
||||
* @return
|
||||
*/
|
||||
String getAccountNetworkDomain(long accountId, long zoneId);
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getDefaultNetworkDomain();
|
||||
|
||||
|
||||
/**
|
||||
* @param ntwkOffId
|
||||
* @return
|
||||
*/
|
||||
List<Provider> getNtwkOffDistinctProviders(long ntwkOffId);
|
||||
|
||||
|
||||
/**
|
||||
* @param requested
|
||||
* @param network
|
||||
|
|
@ -380,15 +222,6 @@ public interface NetworkManager extends NetworkService {
|
|||
void removeNic(VirtualMachineProfile<? extends VMInstanceVO> vm, Nic nic);
|
||||
|
||||
|
||||
/**
|
||||
* @param accountId
|
||||
* @param dcId
|
||||
* @param sourceNat
|
||||
* @return
|
||||
*/
|
||||
List<IPAddressVO> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat);
|
||||
|
||||
|
||||
/**
|
||||
* @param ipAddrId
|
||||
* @param networkId
|
||||
|
|
@ -398,15 +231,6 @@ public interface NetworkManager extends NetworkService {
|
|||
InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* @param vm
|
||||
* @param networkId
|
||||
* @param broadcastUri TODO
|
||||
* @return
|
||||
*/
|
||||
NicProfile getNicProfile(VirtualMachine vm, long networkId, String broadcastUri);
|
||||
|
||||
|
||||
/**
|
||||
* @param network
|
||||
* @param provider
|
||||
|
|
@ -425,21 +249,6 @@ public interface NetworkManager extends NetworkService {
|
|||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* @param zoneId
|
||||
* @param trafficType
|
||||
* @return
|
||||
*/
|
||||
List<? extends PhysicalNetwork> getPhysicalNtwksSupportingTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
|
||||
/**
|
||||
* @param guestNic
|
||||
* @return
|
||||
*/
|
||||
boolean isPrivateGateway(Nic guestNic);
|
||||
|
||||
|
||||
/**
|
||||
* @param network
|
||||
* @param requested
|
||||
|
|
@ -478,12 +287,38 @@ public interface NetworkManager extends NetworkService {
|
|||
*/
|
||||
PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat) throws ConcurrentOperationException, InsufficientAddressCapacityException;
|
||||
|
||||
NetworkProfile convertNetworkToNetworkProfile(long networkId);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
int getNetworkLockTimeout();
|
||||
|
||||
|
||||
boolean cleanupIpResources(long addrId, long userId, Account caller);
|
||||
|
||||
|
||||
boolean restartNetwork(Long networkId, Account callerAccount,
|
||||
User callerUser, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
|
||||
boolean shutdownNetworkElementsAndResources(ReservationContext context,
|
||||
boolean b, NetworkVO network);
|
||||
|
||||
|
||||
void implementNetworkElementsAndResources(DeployDestination dest,
|
||||
ReservationContext context, NetworkVO network,
|
||||
NetworkOfferingVO findById) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
|
||||
IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId,
|
||||
DataCenter zone) throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException;
|
||||
|
||||
|
||||
Map<String, String> finalizeServicesAndProvidersForNetwork(NetworkOffering offering,
|
||||
Long physicalNetworkId);
|
||||
|
||||
|
||||
List<Provider> getProvidersForServiceInNetwork(Network network, Service service);
|
||||
|
||||
StaticNatServiceProvider getStaticNatProviderForNetwork(Network network);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,28 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
|
||||
public interface NetworkRuleApplier {
|
||||
public boolean applyRules(Network network, FirewallRule.Purpose purpose, List<? extends FirewallRule> rules) throws ResourceUnavailableException;
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -44,7 +44,7 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
|
|
@ -72,7 +72,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
|
|||
@Inject
|
||||
NetworkDao _networkConfigDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
UserVmManager _userVmMgr;
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
|
|
@ -82,7 +82,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
|
@ -90,7 +89,10 @@ import com.cloud.vm.dao.DomainRouterDao;
|
|||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@Local(value = NetworkElement.class)
|
||||
@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
|
||||
DhcpServiceProvider.class, UserDataServiceProvider.class,
|
||||
StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
|
||||
PortForwardingServiceProvider.class, IpDeployer.class, RemoteAccessVPNServiceProvider.class} )
|
||||
public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider,
|
||||
UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
|
||||
LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer {
|
||||
|
|
@ -101,7 +103,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
@Inject
|
||||
NetworkDao _networksDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
LoadBalancingRulesManager _lbMgr;
|
||||
@Inject
|
||||
|
|
@ -112,8 +114,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
RulesManager _rulesMgr;
|
||||
@Inject
|
||||
UserVmManager _userVmMgr;
|
||||
|
||||
@Inject
|
||||
UserVmDao _userVmDao;
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
|
|
@ -61,11 +60,13 @@ import com.cloud.vm.ReservationContext;
|
|||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
@Local(value = NetworkElement.class)
|
||||
@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
|
||||
DhcpServiceProvider.class, UserDataServiceProvider.class,
|
||||
StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
|
||||
PortForwardingServiceProvider.class, IpDeployer.class, VpcProvider.class,
|
||||
Site2SiteVpnServiceProvider.class, NetworkACLServiceProvider.class})
|
||||
public class VpcVirtualRouterElement extends VirtualRouterElement implements VpcProvider, Site2SiteVpnServiceProvider, NetworkACLServiceProvider{
|
||||
private static final Logger s_logger = Logger.getLogger(VpcVirtualRouterElement.class);
|
||||
@Inject
|
||||
NetworkService _ntwkService;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject
|
||||
|
|
@ -234,7 +235,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
|||
List<? extends VirtualRouter> routers = _routerDao.listByVpcId(vpcId);
|
||||
for (VirtualRouter router : routers) {
|
||||
//1) Check if router is already a part of the network
|
||||
if (!_ntwkService.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part the network " + network);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -262,7 +263,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
|||
List<? extends VirtualRouter> routers = _routerDao.listByVpcId(vpcId);
|
||||
for (VirtualRouter router : routers) {
|
||||
//1) Check if router is already a part of the network
|
||||
if (!_ntwkService.isVmPartOfNetwork(router.getId(), config.getId())) {
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), config.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part the network " + config);
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,16 +46,25 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkRuleApplier;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.element.FirewallServiceProvider;
|
||||
import com.cloud.network.element.NetworkACLServiceProvider;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.PortForwardingServiceProvider;
|
||||
import com.cloud.network.element.StaticNatServiceProvider;
|
||||
import com.cloud.network.rules.FirewallManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.FirewallRuleType;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.FirewallRule.State;
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
|
|
@ -68,6 +77,7 @@ import com.cloud.user.DomainManager;
|
|||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.db.DB;
|
||||
|
|
@ -83,7 +93,7 @@ import com.cloud.vm.UserVmVO;
|
|||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@Local(value = { FirewallService.class, FirewallManager.class})
|
||||
public class FirewallManagerImpl implements FirewallService, FirewallManager, Manager {
|
||||
public class FirewallManagerImpl implements FirewallService, FirewallManager, NetworkRuleApplier, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(FirewallManagerImpl.class);
|
||||
String _name;
|
||||
|
||||
|
|
@ -102,6 +112,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
UsageEventDao _usageEventDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
|
@ -115,6 +127,17 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
ResourceTagDao _resourceTagDao;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject(adapter = FirewallServiceProvider.class)
|
||||
Adapters<FirewallServiceProvider> _firewallElements;
|
||||
|
||||
@Inject(adapter = PortForwardingServiceProvider.class)
|
||||
Adapters<PortForwardingServiceProvider> _pfElements;
|
||||
|
||||
@Inject(adapter = StaticNatServiceProvider.class)
|
||||
Adapters<StaticNatServiceProvider> _staticNatElements;
|
||||
|
||||
@Inject(adapter = NetworkACLServiceProvider.class)
|
||||
Adapters<NetworkACLServiceProvider> _networkAclElements;
|
||||
|
||||
private boolean _elbEnabled = false;
|
||||
|
||||
|
|
@ -138,6 +161,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
_name = name;
|
||||
String elbEnabledString = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key());
|
||||
_elbEnabled = Boolean.parseBoolean(elbEnabledString);
|
||||
s_logger.info("Firewall provider list is " + _firewallElements.iterator().next());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +188,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
" doesn't exist in the system");
|
||||
}
|
||||
|
||||
_networkMgr.checkIpForService(ipAddress, Service.Firewall, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.Firewall, null);
|
||||
|
||||
validateFirewallRule(caller, ipAddress, portStart, portEnd, protocol, Purpose.Firewall, type);
|
||||
|
||||
|
|
@ -399,7 +423,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
networkId = ipAddress.getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
assert network != null : "Can't create port forwarding rule as network associated with public ip address is null?";
|
||||
|
||||
// Verify that the network guru supports the protocol specified
|
||||
|
|
@ -407,10 +431,10 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
|
||||
if (purpose == Purpose.LoadBalancing) {
|
||||
if (!_elbEnabled) {
|
||||
caps = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.Lb);
|
||||
caps = _networkModel.getNetworkServiceCapabilities(network.getId(), Service.Lb);
|
||||
}
|
||||
} else if (purpose == Purpose.PortForwarding) {
|
||||
caps = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.PortForwarding);
|
||||
caps = _networkModel.getNetworkServiceCapabilities(network.getId(), Service.PortForwarding);
|
||||
}
|
||||
|
||||
if (caps != null) {
|
||||
|
|
@ -427,7 +451,12 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
public boolean applyRules(List<? extends FirewallRule> rules, boolean continueOnError, boolean updateRulesInDB)
|
||||
throws ResourceUnavailableException {
|
||||
boolean success = true;
|
||||
if (!_networkMgr.applyRules(rules, continueOnError)) {
|
||||
if (rules == null || rules.size() == 0) {
|
||||
s_logger.debug("There are no rules to forward to the network elements");
|
||||
return true;
|
||||
}
|
||||
Purpose purpose = rules.get(0).getPurpose();
|
||||
if (!_networkMgr.applyRules(rules, purpose, this, continueOnError)) {
|
||||
s_logger.warn("Rules are not completely applied");
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -459,6 +488,46 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyRules(Network network, Purpose purpose, List<? extends FirewallRule> rules)
|
||||
throws ResourceUnavailableException {
|
||||
boolean handled = false;
|
||||
switch (purpose){
|
||||
case Firewall:
|
||||
for (FirewallServiceProvider fwElement: _firewallElements) {
|
||||
handled = fwElement.applyFWRules(network, rules);
|
||||
if (handled)
|
||||
break;
|
||||
}
|
||||
case PortForwarding:
|
||||
for (PortForwardingServiceProvider element: _pfElements) {
|
||||
handled = element.applyPFRules(network, (List<PortForwardingRule>) rules);
|
||||
if (handled)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case StaticNat:
|
||||
for (StaticNatServiceProvider element: _staticNatElements) {
|
||||
handled = element.applyStaticNats(network, (List<? extends StaticNat>) rules);
|
||||
if (handled)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NetworkACL:
|
||||
for (NetworkACLServiceProvider element: _networkAclElements) {
|
||||
handled = element.applyNetworkACLs(network, (List<? extends FirewallRule>) rules);
|
||||
if (handled)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false): "Unexpected fall through in applying rules to the network elements";
|
||||
s_logger.error("FirewallManager cannot process rules of type " + purpose);
|
||||
throw new CloudRuntimeException("FirewallManager cannot process rules of type " + purpose);
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRule(FirewallRule rule) {
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
|||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
|
|
@ -58,7 +58,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(ControlNetworkGuru.class);
|
||||
@Inject DataCenterDao _dcDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
String _cidr;
|
||||
String _gateway;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import com.cloud.network.Network.GuestType;
|
|||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
|
|
@ -64,6 +65,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
@Inject
|
||||
VlanDao _vlanDao;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
IPAddressDao _ipAddressDao;
|
||||
|
|
@ -132,7 +135,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
}
|
||||
}
|
||||
|
||||
boolean isSecurityGroupEnabled = _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
||||
boolean isSecurityGroupEnabled = _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
||||
if (isSecurityGroupEnabled) {
|
||||
config.setName("SecurityGroupEnabledNetwork");
|
||||
config.setDisplayText("SecurityGroupEnabledNetwork");
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
|||
}
|
||||
|
||||
if (rsStrategy == ReservationStrategy.Create) {
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(network.getId());
|
||||
String mac = _networkModel.getNextAvailableMacAddressInNetwork(network.getId());
|
||||
nic.setMacAddress(mac);
|
||||
}
|
||||
return nic;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
NetworkVO config = (NetworkVO) super.design(offering, plan, userSpecified, owner);
|
||||
if (config == null) {
|
||||
return null;
|
||||
} else if (_networkMgr.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
|
||||
} else if (_networkModel.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
|
||||
/* In order to revert userSpecified network setup */
|
||||
config.setState(State.Allocated);
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (!_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
return super.implement(config, offering, dest, context);
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
|
||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
profile.setStrategy(ReservationStrategy.Start);
|
||||
/* We won't clear IP address, because router may set gateway as it IP, and it would be updated properly later */
|
||||
//profile.setIp4Address(null);
|
||||
|
|
@ -225,7 +225,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return;
|
||||
}
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
nic.setIp4Address(null);
|
||||
nic.setGateway(null);
|
||||
nic.setNetmask(null);
|
||||
|
|
@ -245,7 +245,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
DataCenter dc = _dcDao.findById(config.getDataCenterId());
|
||||
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
|
||||
nic.setBroadcastUri(config.getBroadcastUri());
|
||||
nic.setIsolationUri(config.getBroadcastUri());
|
||||
nic.setDns1(dc.getDns1());
|
||||
|
|
@ -280,7 +280,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||
|
||||
if (network != null && _networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
if (network != null && _networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
return true;
|
||||
} else {
|
||||
return super.release(nic, vm, reservationId);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import com.cloud.network.IPAddressVO;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
|
|
@ -82,6 +83,8 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
@Inject
|
||||
protected NetworkManager _networkMgr;
|
||||
@Inject
|
||||
protected NetworkModel _networkModel;
|
||||
@Inject
|
||||
protected DataCenterDao _dcDao;
|
||||
@Inject
|
||||
protected VlanDao _vlanDao;
|
||||
|
|
@ -310,7 +313,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
long physicalNetworkId = _networkMgr.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(),
|
||||
network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
|
|
@ -355,11 +358,11 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
boolean isGateway = false;
|
||||
if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
|
||||
if (network.getVpcId() != null) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VPCVirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VPCVirtualRouter)) {
|
||||
isGateway = true;
|
||||
}
|
||||
} else {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
isGateway = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -387,7 +390,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
|||
nic.setStrategy(ReservationStrategy.Start);
|
||||
|
||||
if (nic.getMacAddress() == null) {
|
||||
nic.setMacAddress(_networkMgr.getNextAvailableMacAddressInNetwork(network.getId()));
|
||||
nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId()));
|
||||
if (nic.getMacAddress() == null) {
|
||||
throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", Network.class, network.getId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
|
|
@ -62,7 +62,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
@Inject
|
||||
protected PrivateIpDao _privateIpDao;
|
||||
@Inject
|
||||
protected NetworkManager _networkMgr;
|
||||
protected NetworkModel _networkMgr;
|
||||
|
||||
private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ import com.cloud.network.Network.Capability;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkRuleApplier;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.as.AutoScalePolicy;
|
||||
import com.cloud.network.as.AutoScalePolicyConditionMapVO;
|
||||
|
|
@ -90,6 +92,8 @@ import com.cloud.network.dao.LoadBalancerDao;
|
|||
import com.cloud.network.dao.LoadBalancerVMMapDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.element.LoadBalancingServiceProvider;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbAutoScalePolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmGroup;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbAutoScaleVmProfile;
|
||||
|
|
@ -114,7 +118,6 @@ import com.cloud.service.dao.ServiceOfferingDao;
|
|||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.tags.ResourceTagVO;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.DomainService;
|
||||
|
|
@ -125,6 +128,7 @@ import com.cloud.user.dao.UserDao;
|
|||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.db.DB;
|
||||
|
|
@ -144,7 +148,7 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@Local(value = { LoadBalancingRulesManager.class, LoadBalancingRulesService.class })
|
||||
public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesManager, LoadBalancingRulesService, Manager {
|
||||
public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesManager, LoadBalancingRulesService, NetworkRuleApplier, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(LoadBalancingRulesManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
|
|
@ -152,6 +156,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
RulesManager _rulesMgr;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
|
|
@ -189,8 +195,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
DomainService _domainMgr;
|
||||
@Inject
|
||||
ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
TemplateManager _templateMgr;
|
||||
|
||||
@Inject
|
||||
ExternalLoadBalancerUsageManager _externalLBUsageMgr;
|
||||
@Inject
|
||||
|
|
@ -223,12 +228,13 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
DataCenterDao _dcDao = null;
|
||||
@Inject
|
||||
UserDao _userDao;
|
||||
|
||||
@Inject(adapter = LoadBalancingServiceProvider.class)
|
||||
Adapters<LoadBalancingServiceProvider> _lbProviders;
|
||||
|
||||
// Will return a string. For LB Stickiness this will be a json, for autoscale this will be "," separated values
|
||||
@Override
|
||||
public String getLBCapability(long networkid, String capabilityName) {
|
||||
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkMgr.getNetworkCapabilities(networkid);
|
||||
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkModel.getNetworkCapabilities(networkid);
|
||||
if (serviceCapabilitiesMap != null) {
|
||||
for (Service service : serviceCapabilitiesMap.keySet()) {
|
||||
ServiceResponse serviceResponse = new ServiceResponse();
|
||||
|
|
@ -321,7 +327,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
List<LoadBalancingRule> rules = Arrays.asList(rule);
|
||||
|
||||
if (!_networkMgr.applyRules(rules, false)) {
|
||||
if (!_networkMgr.applyRules(rules, FirewallRule.Purpose.LoadBalancing, this, false)) {
|
||||
s_logger.debug("LB rules' autoscale config are not completely applied");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -480,7 +486,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
List<LbStickinessPolicy> policyList = new ArrayList<LbStickinessPolicy>();
|
||||
policyList.add(new LbStickinessPolicy(cmd.getStickinessMethodName(), lbpolicy.getParams()));
|
||||
LoadBalancingRule lbRule = new LoadBalancingRule(loadBalancer, getExistingDestinations(lbpolicy.getId()), policyList);
|
||||
if (!_networkMgr.validateRule(lbRule)) {
|
||||
if (!validateRule(lbRule)) {
|
||||
throw new InvalidParameterValueException("Failed to create Stickiness policy: Validation Failed " + cmd.getLbRuleId());
|
||||
}
|
||||
|
||||
|
|
@ -491,6 +497,22 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
return policy;
|
||||
}
|
||||
|
||||
|
||||
private boolean validateRule(LoadBalancingRule lbRule) {
|
||||
Network network = _networkDao.findById(lbRule.getNetworkId());
|
||||
Purpose purpose = lbRule.getPurpose();
|
||||
if (purpose != Purpose.LoadBalancing) {
|
||||
s_logger.debug("Unable to validate network rules for purpose: " + purpose.toString());
|
||||
return false;
|
||||
}
|
||||
for (LoadBalancingServiceProvider ne : _lbProviders) {
|
||||
boolean validated = ne.validateLBRule(network, lbRule);
|
||||
if (!validated)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_LB_STICKINESSPOLICY_CREATE, eventDescription = "Apply Stickinesspolicy to load balancer ", async = true)
|
||||
|
|
@ -624,7 +646,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
}
|
||||
|
||||
// Let's check to make sure the vm has a nic in the same network as the load balancing rule.
|
||||
List<? extends Nic> nics = _networkMgr.getNics(vm.getId());
|
||||
List<? extends Nic> nics = _networkModel.getNics(vm.getId());
|
||||
Nic nicInSameNetwork = null;
|
||||
for (Nic nic : nics) {
|
||||
if (nic.getNetworkId() == loadBalancer.getNetworkId()) {
|
||||
|
|
@ -858,7 +880,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
// gather external network usage stats for this lb rule
|
||||
NetworkVO network = _networkDao.findById(lb.getNetworkId());
|
||||
if (network != null) {
|
||||
if (_networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
if (_networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
|
||||
_externalLBUsageMgr.updateExternalLoadBalancerNetworkUsageStats(loadBalancerId);
|
||||
}
|
||||
}
|
||||
|
|
@ -939,7 +961,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
ipVO = _ipAddressDao.findById(ipAddrId);
|
||||
}
|
||||
|
||||
Network network = _networkMgr.getNetwork(lb.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(lb.getNetworkId());
|
||||
|
||||
// FIXME: breaking the dependency on ELB manager. This breaks functionality of ELB using virtual router
|
||||
// Bug CS-15411 opened to document this
|
||||
|
|
@ -968,14 +990,14 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
//set networkId just for verification purposes
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
_networkModel.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
|
||||
ipVO = _networkMgr.associateIPToGuestNetwork(ipAddrId, lb.getNetworkId(), false);
|
||||
performedIpAssoc = true;
|
||||
}
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, null);
|
||||
_networkModel.checkIpForService(ipVO, Service.Lb, null);
|
||||
}
|
||||
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
|
|
@ -1047,7 +1069,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
_accountMgr.checkAccess(caller.getCaller(), null, true, ipAddr);
|
||||
|
||||
// verify that lb service is supported by the network
|
||||
if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("LB service is not supported in specified network id");
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
|
|
@ -1061,7 +1083,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
// verify rule is supported by Lb provider of the network
|
||||
LoadBalancingRule loadBalancing = new LoadBalancingRule(newRule, new ArrayList<LbDestination>(), new ArrayList<LbStickinessPolicy>());
|
||||
if (!_networkMgr.validateRule(loadBalancing)) {
|
||||
if (!validateRule(loadBalancing)) {
|
||||
throw new InvalidParameterValueException("LB service provider cannot support this rule");
|
||||
}
|
||||
|
||||
|
|
@ -1128,6 +1150,19 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyRules(Network network, Purpose purpose, List<? extends FirewallRule> rules)
|
||||
throws ResourceUnavailableException {
|
||||
assert(purpose == Purpose.LoadBalancing): "LB Manager asked to handle non-LB rules";
|
||||
boolean handled = false;
|
||||
for (LoadBalancingServiceProvider lbElement: _lbProviders) {
|
||||
handled = lbElement.applyLBRules(network, (List<LoadBalancingRule>) rules);
|
||||
if (handled)
|
||||
break;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected boolean applyLoadBalancerRules(List<LoadBalancerVO> lbs, boolean updateRulesInDB) throws ResourceUnavailableException {
|
||||
|
|
@ -1141,7 +1176,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
rules.add(loadBalancing);
|
||||
}
|
||||
|
||||
if (!_networkMgr.applyRules(rules, false)) {
|
||||
if (!_networkMgr.applyRules(rules, FirewallRule.Purpose.LoadBalancing, this, false)) {
|
||||
s_logger.debug("LB rules are not completely applied");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1578,4 +1613,6 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
//remove the rule
|
||||
_lbDao.remove(rule.getId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ import com.cloud.network.Network.GuestType;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
|
|
@ -176,8 +177,8 @@ import com.cloud.network.rules.StaticNatImpl;
|
|||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpn.Site2SiteVpnManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
|
|
@ -292,6 +293,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
VirtualMachineManager _itMgr;
|
||||
@Inject
|
||||
VpnUserDao _vpnUsersDao;
|
||||
|
|
@ -826,7 +829,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
boolean forVpc = router.getVpcId() != null;
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
//Send network usage command for public nic in VPC VR
|
||||
//Send network usage command for isolated guest nic of non VPC VR
|
||||
if ((forVpc && network.getTrafficType() == TrafficType.Public) || (!forVpc && network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Isolated)) {
|
||||
|
|
@ -1381,7 +1384,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
assert guestNetwork.getTrafficType() == TrafficType.Guest;
|
||||
|
||||
// 1) Get deployment plan and find out the list of routers
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic);
|
||||
boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic ||
|
||||
_networkModel.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SecurityGroup))
|
||||
&& guestNetwork.getTrafficType() == TrafficType.Guest;
|
||||
|
||||
// dest has pod=null, for Basic Zone findOrDeployVRs for all Pods
|
||||
List<DeployDestination> destinations = new ArrayList<DeployDestination>();
|
||||
|
|
@ -1440,7 +1445,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
// Check if providers are supported in the physical networks
|
||||
VirtualRouterProviderType type = VirtualRouterProviderType.VirtualRouter;
|
||||
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(guestNetwork);
|
||||
Long physicalNetworkId = _networkModel.getPhysicalNetworkId(guestNetwork);
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " + type.toString() + " in physical network " + physicalNetworkId);
|
||||
|
|
@ -1450,13 +1455,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
throw new CloudRuntimeException("Cannot find virtual router provider " + type.toString() + " as service provider " + provider.getId());
|
||||
}
|
||||
|
||||
if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
if (_networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
|
||||
owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
|
||||
}
|
||||
|
||||
// Check if public network has to be set on VR
|
||||
boolean publicNetwork = false;
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter)) {
|
||||
publicNetwork = true;
|
||||
}
|
||||
if (isRedundant && !publicNetwork) {
|
||||
|
|
@ -1642,7 +1647,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
s_logger.debug("Adding nic for Virtual Router in Guest network " + guestNetwork);
|
||||
String defaultNetworkStartIp = null;
|
||||
if (guestNetwork.getCidr() != null && !setupPublicNetwork) {
|
||||
String startIp = _networkMgr.getStartIpAddress(guestNetwork.getId());
|
||||
String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
|
||||
if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(), startIp).getAllocatedTime() == null) {
|
||||
defaultNetworkStartIp = startIp;
|
||||
} else if (s_logger.isDebugEnabled()){
|
||||
|
|
@ -1674,8 +1679,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
//2) Control network
|
||||
s_logger.debug("Adding nic for Virtual Router in Control network ");
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
|
||||
NetworkOffering controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
|
||||
|
||||
|
|
@ -1697,7 +1702,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (hasGuestNetwork) {
|
||||
defaultNic.setDeviceId(2);
|
||||
}
|
||||
NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
|
||||
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||
String publicIp = defaultNic.getIp4Address();
|
||||
// We want to use the identical MAC address for RvR on public interface if possible
|
||||
|
|
@ -1922,8 +1927,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
}
|
||||
} else if (nic.getTrafficType() == TrafficType.Guest) {
|
||||
dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dns, Provider.VirtualRouter);
|
||||
dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter);
|
||||
dnsProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dns, Provider.VirtualRouter);
|
||||
dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter);
|
||||
//build bootloader parameter for the guest
|
||||
buf.append(createGuestBootLoadArgs(nic, defaultDns1, defaultDns2, router));
|
||||
} else if (nic.getTrafficType() == TrafficType.Public) {
|
||||
|
|
@ -2024,7 +2029,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
s_logger.error("Failed to get update priority!", e);
|
||||
throw new CloudRuntimeException("Failed to get update priority!");
|
||||
}
|
||||
Network net = _networkMgr.getNetwork(guestNic.getNetworkId());
|
||||
Network net = _networkModel.getNetwork(guestNic.getNetworkId());
|
||||
buf.append(" guestgw=").append(net.getGateway());
|
||||
String brd = NetUtils.long2Ip(NetUtils.ip2Long(guestNic.getIp4Address()) | ~NetUtils.ip2Long(guestNic.getNetmask()));
|
||||
buf.append(" guestbrd=").append(brd);
|
||||
|
|
@ -2180,13 +2185,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
protected void finalizeUserDataAndDhcpOnStart(Commands cmds, DomainRouterVO router, Provider provider, Long guestNetworkId) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)) {
|
||||
// Resend dhcp
|
||||
s_logger.debug("Reapplying dhcp entries as a part of domR " + router + " start...");
|
||||
createDhcpEntryCommandsForVMs(router, cmds, guestNetworkId);
|
||||
}
|
||||
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.UserData, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.UserData, provider)) {
|
||||
// Resend user data
|
||||
s_logger.debug("Reapplying vm data (userData and metaData) entries as a part of domR " + router + " start...");
|
||||
createVmDataCommandForVMs(router, cmds, guestNetworkId);
|
||||
|
|
@ -2207,26 +2212,26 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
//Get information about all the rules (StaticNats and StaticNatRules; PFVPN to reapply on domR start)
|
||||
for (PublicIpAddress ip : publicIps) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.PortForwarding, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.PortForwarding, provider)) {
|
||||
pfRules.addAll(_pfRulesDao.listForApplication(ip.getId()));
|
||||
}
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
staticNatFirewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.StaticNat));
|
||||
}
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
firewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.Firewall));
|
||||
}
|
||||
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Vpn, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Vpn, provider)) {
|
||||
RemoteAccessVpn vpn = _vpnDao.findById(ip.getId());
|
||||
if (vpn != null) {
|
||||
vpns.add(vpn);
|
||||
}
|
||||
}
|
||||
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
|
||||
if (ip.isOneToOneNat()) {
|
||||
String dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), guestNetworkId);
|
||||
String dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), guestNetworkId);
|
||||
StaticNatImpl staticNat = new StaticNatImpl(ip.getAccountId(), ip.getDomainId(), guestNetworkId, ip.getId(), dstIp, false);
|
||||
staticNats.add(staticNat);
|
||||
}
|
||||
|
|
@ -2271,7 +2276,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkId(guestNetworkId);
|
||||
List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb, provider)) {
|
||||
// Re-apply load balancing rules
|
||||
for (LoadBalancerVO lb : lbs) {
|
||||
List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
|
||||
|
|
@ -2296,7 +2301,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (publicIps != null && !publicIps.isEmpty()) {
|
||||
s_logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR " + router + " start.");
|
||||
// Re-apply public ip addresses - should come before PF/LB/VPN
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
|
||||
createAssociateIPCommands(router, publicIps, cmds, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -2305,11 +2310,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
protected ArrayList<? extends PublicIpAddress> getPublicIpsToApply(VirtualRouter router, Provider provider,
|
||||
Long guestNetworkId, com.cloud.network.IpAddress.State... skipInStates) {
|
||||
long ownerId = router.getAccountId();
|
||||
final List<IPAddressVO> userIps = _networkMgr.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
|
||||
final List<? extends IpAddress> userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
|
||||
List<PublicIp> allPublicIps = new ArrayList<PublicIp>();
|
||||
if (userIps != null && !userIps.isEmpty()) {
|
||||
boolean addIp = true;
|
||||
for (IPAddressVO userIp : userIps) {
|
||||
for (IpAddress userIp : userIps) {
|
||||
if (skipInStates != null) {
|
||||
for (IpAddress.State stateToSkip : skipInStates) {
|
||||
if (userIp.getState() == stateToSkip) {
|
||||
|
|
@ -2321,8 +2326,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
if (addIp) {
|
||||
PublicIp publicIp = new PublicIp(userIp, _vlanDao.findById(userIp.getVlanId()),
|
||||
NetUtils.createSequenceBasedMacAddress(userIp.getMacAddress()));
|
||||
IPAddressVO ipVO = _ipAddressDao.findById(userIp.getId());
|
||||
PublicIp publicIp = new PublicIp(ipVO, _vlanDao.findById(userIp.getVlanId()),
|
||||
NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress()));
|
||||
allPublicIps.add(publicIp);
|
||||
}
|
||||
}
|
||||
|
|
@ -2330,11 +2336,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
//Get public Ips that should be handled by router
|
||||
Network network = _networkDao.findById(guestNetworkId);
|
||||
Map<PublicIp, Set<Service>> ipToServices = _networkMgr.getIpToServices(allPublicIps, false, true);
|
||||
Map<Provider, ArrayList<PublicIp>> providerToIpList = _networkMgr.getProviderToIpList(network, ipToServices);
|
||||
Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(allPublicIps, false, true);
|
||||
Map<Provider, ArrayList<PublicIpAddress>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
|
||||
// Only cover virtual router for now, if ELB use it this need to be modified
|
||||
|
||||
ArrayList<PublicIp> publicIps = providerToIpList.get(provider);
|
||||
ArrayList<PublicIpAddress> publicIps = providerToIpList.get(provider);
|
||||
return publicIps;
|
||||
}
|
||||
|
||||
|
|
@ -2364,7 +2370,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Guest) {
|
||||
guestNetworks.add(network);
|
||||
}
|
||||
|
|
@ -2464,7 +2470,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
for (VirtualRouter router : routers) {
|
||||
if (router.getState() == State.Running) {
|
||||
Commands cmds = new Commands(OnError.Continue);
|
||||
IpAddress ip = _networkMgr.getIp(vpn.getServerAddressId());
|
||||
IpAddress ip = _networkModel.getIp(vpn.getServerAddressId());
|
||||
|
||||
RemoteAccessVpnCfgCommand removeVpnCmd = new RemoteAccessVpnCfgCommand(false, ip.getAddress().addr(),
|
||||
vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
|
||||
|
|
@ -2564,16 +2570,16 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
|
||||
|
||||
//check if DNS provider is the domR
|
||||
if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
|
||||
if (!_networkModel.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = _networkOfferingDao.findById(_networkDao.findById(defaultNic.getNetworkId()).getNetworkOfferingId());
|
||||
NetworkOffering offering = _networkOfferingDao.findById(_networkDao.findById(defaultNic.getNetworkId()).getNetworkOfferingId());
|
||||
if (offering.getRedundantRouter()) {
|
||||
return findGatewayIp(userVmId);
|
||||
}
|
||||
|
||||
DataCenter dc = _dcDao.findById(_networkMgr.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
|
||||
DataCenter dc = _dcDao.findById(_networkModel.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
|
||||
boolean isZoneBasic = (dc.getNetworkType() == NetworkType.Basic);
|
||||
|
||||
//find domR's nic in the network
|
||||
|
|
@ -2792,8 +2798,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
});
|
||||
|
||||
// Get network rate - required for IpAssoc
|
||||
Integer networkRate = _networkMgr.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkMgr.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
|
||||
IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
|
||||
int i = 0;
|
||||
|
|
@ -2816,7 +2822,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, networkRate, ipAddr.isOneToOneNat());
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
||||
ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
||||
ipsToSend[i++] = ip;
|
||||
/* send the firstIP = true for the first Add, this is to create primary on interface*/
|
||||
if (!firstIP || add) {
|
||||
|
|
@ -2839,7 +2845,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (rules != null) {
|
||||
rulesTO = new ArrayList<PortForwardingRuleTO>();
|
||||
for (PortForwardingRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, null, sourceIp.getAddress().addr());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
|
|
@ -2867,7 +2873,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (rules != null) {
|
||||
rulesTO = new ArrayList<StaticNatRuleTO>();
|
||||
for (StaticNatRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(rule, null, sourceIp.getAddress().addr(), rule.getDestIpAddress());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
|
|
@ -2894,7 +2900,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
String algorithm = rule.getAlgorithm();
|
||||
String uuid = rule.getUuid();
|
||||
|
||||
String srcIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
String srcIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
List<LbDestination> destinations = rule.getDestinations();
|
||||
List<LbStickinessPolicy> stickinessPolicies = rule.getStickinessPolicies();
|
||||
|
|
@ -2908,12 +2914,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
routerPublicIp = domr.getPublicIpAddress();
|
||||
}
|
||||
|
||||
Network guestNetwork = _networkMgr.getNetwork(guestNetworkId);
|
||||
Network guestNetwork = _networkModel.getNetwork(guestNetworkId);
|
||||
Nic nic = _nicDao.findByInstanceIdAndNetworkId(guestNetwork.getId(), router.getId());
|
||||
NicProfile nicProfile = new NicProfile(nic, guestNetwork, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||
_networkMgr.getNetworkRate(guestNetwork.getId(), router.getId()),
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(guestNetwork),
|
||||
_networkMgr.getNetworkTag(router.getHypervisorType(), guestNetwork));
|
||||
_networkModel.getNetworkRate(guestNetwork.getId(), router.getId()),
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(guestNetwork),
|
||||
_networkModel.getNetworkTag(router.getHypervisorType(), guestNetwork));
|
||||
|
||||
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,routerPublicIp,
|
||||
getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress(),
|
||||
|
|
@ -2951,7 +2957,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(vpn.getNetworkId(), router.getId()));
|
||||
addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
|
||||
IpAddress ip = _networkMgr.getIp(vpn.getServerAddressId());
|
||||
IpAddress ip = _networkModel.getIp(vpn.getServerAddressId());
|
||||
|
||||
RemoteAccessVpnCfgCommand startVpnCmd = new RemoteAccessVpnCfgCommand(true, ip.getAddress().addr(),
|
||||
vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
|
||||
|
|
@ -3226,7 +3232,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (rules != null) {
|
||||
rulesTO = new ArrayList<FirewallRuleTO>();
|
||||
for (FirewallRule rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
FirewallRuleTO ruleTO = new FirewallRuleTO(rule, null, sourceIp.getAddress().addr());
|
||||
rulesTO.add(ruleTO);
|
||||
}
|
||||
|
|
@ -3370,7 +3376,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (rules != null) {
|
||||
rulesTO = new ArrayList<StaticNatRuleTO>();
|
||||
for (StaticNat rule : rules) {
|
||||
IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
|
||||
IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
|
||||
StaticNatRuleTO ruleTO = new StaticNatRuleTO(0, sourceIp.getAddress().addr(), null,
|
||||
null, rule.getDestIpAddress(), null, null, null, rule.isForRevoke(), false);
|
||||
rulesTO.add(ruleTO);
|
||||
|
|
@ -3503,7 +3509,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (privateIP != null) {
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Public) {
|
||||
boolean forVpc = router.getVpcId() != null;
|
||||
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.agent.AgentManager.OnError;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetDomRVersionCmd;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.PlugNicAnswer;
|
||||
import com.cloud.agent.api.PlugNicCommand;
|
||||
|
|
@ -105,7 +104,7 @@ import com.cloud.network.vpc.dao.StaticRouteDao;
|
|||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.network.vpn.Site2SiteVpnManager;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserStatisticsVO;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -287,12 +286,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
}
|
||||
|
||||
//Check if router is a part of the Guest network
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
if (!_networkModel.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean result = setupVpcGuestNetwork(network, router, false, _networkMgr.getNicProfile(router, network.getId(), null));
|
||||
boolean result = setupVpcGuestNetwork(network, router, false, _networkModel.getNicProfile(router, network.getId(), null));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
|
||||
return false;
|
||||
|
|
@ -421,13 +420,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
}
|
||||
|
||||
protected SetupGuestNetworkCommand createSetupGuestNetworkCommand(VirtualRouter router, boolean add, NicProfile guestNic) {
|
||||
Network network = _networkMgr.getNetwork(guestNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(guestNic.getNetworkId());
|
||||
|
||||
String defaultDns1 = null;
|
||||
String defaultDns2 = null;
|
||||
|
||||
boolean dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
|
||||
boolean dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||
boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
|
||||
boolean dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||
Provider.VPCVirtualRouter);
|
||||
|
||||
boolean setupDns = dnsProvided || dhcpProvided;
|
||||
|
|
@ -441,7 +440,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
String networkDomain = network.getNetworkDomain();
|
||||
String dhcpRange = getGuestDhcpRange(guestNic, network, _configMgr.getZone(network.getDataCenterId()));
|
||||
|
||||
NicProfile nicProfile = _networkMgr.getNicProfile(router, nic.getNetworkId(), null);
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null);
|
||||
|
||||
SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, false, null,
|
||||
defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
|
||||
|
|
@ -482,8 +481,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
List<PublicIpAddress> ipAddrList = vlanAndIp.getValue();
|
||||
|
||||
// Get network rate - required for IpAssoc
|
||||
Integer networkRate = _networkMgr.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkMgr.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
|
||||
Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
|
||||
|
||||
IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
|
||||
int i = 0;
|
||||
|
|
@ -498,7 +497,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
networkRate, ipAddr.isOneToOneNat());
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
||||
ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
||||
ipsToSend[i++] = ip;
|
||||
if (ipAddr.isSourceNat()) {
|
||||
sourceNatIpAdd = new Pair<IpAddressTO, Long>(ip, ipAddr.getNetworkId());
|
||||
|
|
@ -528,7 +527,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
}
|
||||
|
||||
protected NicTO getNicTO(final VirtualRouter router, Long networkId, String broadcastUri) {
|
||||
NicProfile nicProfile = _networkMgr.getNicProfile(router, networkId, broadcastUri);
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(router, networkId, broadcastUri);
|
||||
|
||||
return _itMgr.toNicTO(nicProfile, router.getHypervisorType());
|
||||
}
|
||||
|
|
@ -557,7 +556,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
for (String vlanTag : nicsToUnplug.keySet()) {
|
||||
Network publicNtwk = null;
|
||||
try {
|
||||
publicNtwk = _networkMgr.getNetwork(nicsToUnplug.get(vlanTag).getNetworkId());
|
||||
publicNtwk = _networkModel.getNetwork(nicsToUnplug.get(vlanTag).getNetworkId());
|
||||
URI broadcastUri = BroadcastDomainType.Vlan.toUri(vlanTag);
|
||||
_itMgr.removeVmFromNetwork(router, publicNtwk, broadcastUri);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
|
|
@ -589,7 +588,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
NicProfile publicNic = null;
|
||||
Network publicNtwk = null;
|
||||
try {
|
||||
publicNtwk = _networkMgr.getNetwork(ip.getNetworkId());
|
||||
publicNtwk = _networkModel.getNetwork(ip.getNetworkId());
|
||||
publicNic = _itMgr.addVmToNetwork(router, publicNtwk, defaultNic);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag +
|
||||
|
|
@ -772,7 +771,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
|
||||
List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
|
||||
for (Nic routerNic : routerNics) {
|
||||
Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Guest) {
|
||||
Pair<Nic, Network> guestNic = new Pair<Nic, Network>(routerNic, network);
|
||||
guestNics.add(guestNic);
|
||||
|
|
@ -835,10 +834,10 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName());
|
||||
cmds.addCommand(plugNicCmd);
|
||||
|
||||
if (!_networkMgr.isPrivateGateway(guestNic)) {
|
||||
if (!_networkModel.isPrivateGateway(guestNic)) {
|
||||
//set guest network
|
||||
VirtualMachine vm = _vmDao.findById(router.getId());
|
||||
NicProfile nicProfile = _networkMgr.getNicProfile(vm, guestNic.getNetworkId(), null);
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(), null);
|
||||
SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, true, nicProfile);
|
||||
cmds.addCommand(setupCmd);
|
||||
} else {
|
||||
|
|
@ -918,7 +917,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
super.finalizeNetworkRulesForNetwork(cmds, router, provider, guestNetworkId);
|
||||
|
||||
if (router.getVpcId() != null) {
|
||||
if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) {
|
||||
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) {
|
||||
List<? extends FirewallRule> networkACLs = _networkACLMgr.listNetworkACLs(guestNetworkId);
|
||||
s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + router
|
||||
+ " start for guest network id=" + guestNetworkId);
|
||||
|
|
@ -933,7 +932,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
public boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
boolean result = true;
|
||||
try {
|
||||
Network network = _networkMgr.getNetwork(gateway.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(gateway.getNetworkId());
|
||||
NicProfile requested = createPrivateNicProfileForGateway(gateway);
|
||||
|
||||
NicProfile guestNic = _itMgr.addVmToNetwork(router, network, requested);
|
||||
|
|
@ -1006,15 +1005,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
|
||||
if (!_networkModel.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
|
||||
s_logger.debug("Router doesn't have nic for gateway " + gateway + " so no need to removed it");
|
||||
return true;
|
||||
}
|
||||
|
||||
Network privateNetwork = _networkMgr.getNetwork(gateway.getNetworkId());
|
||||
Network privateNetwork = _networkModel.getNetwork(gateway.getNetworkId());
|
||||
|
||||
s_logger.debug("Releasing private ip for gateway " + gateway + " from " + router);
|
||||
boolean result = setupVpcPrivateNetwork(router, false, _networkMgr.getNicProfile(router, privateNetwork.getId(), null));
|
||||
boolean result = setupVpcPrivateNetwork(router, false, _networkModel.getNicProfile(router, privateNetwork.getId(), null));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to release private ip for gateway " + gateway + " on router " + router);
|
||||
return false;
|
||||
|
|
@ -1167,13 +1166,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
int i = 0;
|
||||
|
||||
for (final PrivateIpAddress ipAddr : ipAddrList) {
|
||||
Network network = _networkMgr.getNetwork(ipAddr.getNetworkId());
|
||||
Network network = _networkModel.getNetwork(ipAddr.getNetworkId());
|
||||
IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false,
|
||||
false, ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(),
|
||||
null, false);
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
||||
ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
||||
ipsToSend[i++] = ip;
|
||||
|
||||
}
|
||||
|
|
@ -1205,7 +1204,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
VpcGateway privateGateway = _vpcMgr.getPrivateGatewayForVpc(vpcId);
|
||||
if (privateGateway != null) {
|
||||
NicProfile privateNic = createPrivateNicProfileForGateway(privateGateway);
|
||||
Network privateNetwork = _networkMgr.getNetwork(privateGateway.getNetworkId());
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO) privateNetwork, privateNic));
|
||||
}
|
||||
|
||||
|
|
@ -1235,7 +1234,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
publicNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
publicNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag()));
|
||||
publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
|
||||
NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
|
||||
NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
|
||||
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), publicNic));
|
||||
publicVlans.add(publicIp.getVlanTag());
|
||||
|
|
@ -1247,7 +1246,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
|
||||
@DB
|
||||
protected NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
|
||||
Network privateNetwork = _networkMgr.getNetwork(privateGateway.getNetworkId());
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getIp4Address());
|
||||
Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
|
||||
|
||||
|
|
@ -1256,9 +1255,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
if (privateNic != null) {
|
||||
VirtualMachine vm = _vmDao.findById(privateNic.getId());
|
||||
privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(),
|
||||
_networkMgr.getNetworkRate(privateNetwork.getId(), vm.getId()),
|
||||
_networkMgr.isSecurityGroupSupportedInNetwork(privateNetwork),
|
||||
_networkMgr.getNetworkTag(vm.getHypervisorType(), privateNetwork));
|
||||
_networkModel.getNetworkRate(privateNetwork.getId(), vm.getId()),
|
||||
_networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
|
||||
_networkModel.getNetworkTag(vm.getHypervisorType(), privateNetwork));
|
||||
} else {
|
||||
String vlanTag = privateNetwork.getBroadcastUri().getHost();
|
||||
String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import com.cloud.network.IpAddress;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
|
|
@ -90,6 +91,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
EventDao _eventDao;
|
||||
@Inject
|
||||
UsageEventDao _usageEventDao;
|
||||
|
|
@ -173,14 +176,14 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
}
|
||||
|
||||
Long networkId = rule.getNetworkId();
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
//associate ip address to network (if needed)
|
||||
boolean performedIpAssoc = false;
|
||||
if (ipAddress.getAssociatedWithNetworkId() == null) {
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipAddress.getVpcId() != null && ipAddress.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.PortForwarding, networkId);
|
||||
_networkModel.checkIpForService(ipAddress, Service.PortForwarding, networkId);
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ networkId + ", so assigning");
|
||||
try {
|
||||
|
|
@ -192,7 +195,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.PortForwarding, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.PortForwarding, null);
|
||||
}
|
||||
|
||||
if (ipAddress.getAssociatedWithNetworkId() == null) {
|
||||
|
|
@ -228,7 +231,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
// Verify that vm has nic in the network
|
||||
Ip dstIp = rule.getDestinationIpAddress();
|
||||
Nic guestNic = _networkMgr.getNicInNetwork(vmId, networkId);
|
||||
Nic guestNic = _networkModel.getNicInNetwork(vmId, networkId);
|
||||
if (guestNic == null || guestNic.getIp4Address() == null) {
|
||||
throw new InvalidParameterValueException("Vm doesn't belong to network associated with ipAddress");
|
||||
} else {
|
||||
|
|
@ -326,15 +329,15 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
Long accountId = ipAddress.getAllocatedToAccountId();
|
||||
Long domainId = ipAddress.getAllocatedInDomainId();
|
||||
|
||||
_networkMgr.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
if (off.getElasticIp()) {
|
||||
throw new InvalidParameterValueException("Can't create ip forwarding rules for the network where elasticIP service is enabled");
|
||||
}
|
||||
|
||||
String dstIp = _networkMgr.getIpInNetwork(ipAddress.getAssociatedWithVmId(), networkId);
|
||||
String dstIp = _networkModel.getIpInNetwork(ipAddress.getAssociatedWithVmId(), networkId);
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
|
@ -398,19 +401,19 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
boolean performedIpAssoc = false;
|
||||
boolean result = false;
|
||||
try {
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Unable to find network by id");
|
||||
}
|
||||
|
||||
// Check that vm has a nic in the network
|
||||
Nic guestNic = _networkMgr.getNicInNetwork(vmId, networkId);
|
||||
Nic guestNic = _networkModel.getNicInNetwork(vmId, networkId);
|
||||
if (guestNic == null) {
|
||||
throw new InvalidParameterValueException("Vm doesn't belong to the network with specified id");
|
||||
}
|
||||
|
||||
|
||||
if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
|
||||
if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
|
||||
throw new InvalidParameterValueException("Unable to create static nat rule; StaticNat service is not " +
|
||||
"supported in network with specified id");
|
||||
}
|
||||
|
|
@ -426,7 +429,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipAddress.getVpcId() != null && ipAddress.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.StaticNat, networkId);
|
||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, networkId);
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ networkId + ", so assigning");
|
||||
try {
|
||||
|
|
@ -439,7 +442,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
performedIpAssoc = true;
|
||||
}
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
_networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
|
||||
}
|
||||
|
||||
if (ipAddress.getAssociatedWithNetworkId() == null) {
|
||||
|
|
@ -512,7 +515,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
Long networkId = oldIP.getAssociatedWithNetworkId();
|
||||
boolean reassignStaticNat = false;
|
||||
if (networkId != null) {
|
||||
Network guestNetwork = _networkMgr.getNetwork(networkId);
|
||||
Network guestNetwork = _networkModel.getNetwork(networkId);
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
reassignStaticNat = true;
|
||||
|
|
@ -875,7 +878,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
List<StaticNat> staticNats = new ArrayList<StaticNat>();
|
||||
for (IPAddressVO ip : ips) {
|
||||
// Get nic IP4 address
|
||||
String dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), networkId);
|
||||
String dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), networkId);
|
||||
StaticNatImpl staticNat = new StaticNatImpl(ip.getAllocatedToAccountId(), ip.getAllocatedInDomainId(), networkId, ip.getId(), dstIp, false);
|
||||
staticNats.add(staticNat);
|
||||
}
|
||||
|
|
@ -1170,7 +1173,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
// if network has elastic IP functionality supported, we first have to disable static nat on old ip in order to
|
||||
// re-enable it on the new one enable static nat takes care of that
|
||||
Network guestNetwork = _networkMgr.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
||||
Network guestNetwork = _networkModel.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
getSystemIpAndEnableStaticNatForVm(_vmDao.findById(vmId), true);
|
||||
|
|
@ -1256,9 +1259,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
String dstIp;
|
||||
if (forRevoke) {
|
||||
dstIp = _networkMgr.getIpInNetworkIncludingRemoved(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
dstIp = _networkModel.getIpInNetworkIncludingRemoved(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
} else {
|
||||
dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), rule.getNetworkId());
|
||||
}
|
||||
|
||||
return new StaticNatRuleImpl(ruleVO, dstIp);
|
||||
|
|
@ -1326,7 +1329,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
}
|
||||
|
||||
UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId());
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");
|
||||
ex.addProxyObject(vm, vm.getId(), "vmId");
|
||||
|
|
@ -1342,9 +1345,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
String dstIp;
|
||||
if (forRevoke) {
|
||||
dstIp = _networkMgr.getIpInNetworkIncludingRemoved(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
dstIp = _networkModel.getIpInNetworkIncludingRemoved(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
} else {
|
||||
dstIp = _networkMgr.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
dstIp = _networkModel.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
}
|
||||
|
||||
StaticNatImpl staticNat = new StaticNatImpl(sourceIp.getAllocatedToAccountId(), sourceIp.getAllocatedInDomainId(),
|
||||
|
|
@ -1360,7 +1363,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
// enable static nat if eIp capability is supported
|
||||
List<? extends Nic> nics = _nicDao.listByVmId(vm.getId());
|
||||
for (Nic nic : nics) {
|
||||
Network guestNetwork = _networkMgr.getNetwork(nic.getNetworkId());
|
||||
Network guestNetwork = _networkModel.getNetwork(nic.getNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
// check if there is already static nat enabled
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ import com.cloud.exception.ResourceInUseException;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.security.SecurityGroupWork.Step;
|
||||
import com.cloud.network.security.SecurityRule.SecurityRuleType;
|
||||
import com.cloud.network.security.dao.SecurityGroupDao;
|
||||
|
|
@ -150,6 +151,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
DomainManager _domainMgr;
|
||||
|
|
@ -351,7 +354,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
if (rule.getAllowedNetworkId() != null) {
|
||||
List<SecurityGroupVMMapVO> allowedInstances = _securityGroupVMMapDao.listBySecurityGroup(rule.getAllowedNetworkId(), State.Running);
|
||||
for (SecurityGroupVMMapVO ngmapVO : allowedInstances) {
|
||||
Nic defaultNic = _networkMgr.getDefaultNic(ngmapVO.getInstanceId());
|
||||
Nic defaultNic = _networkModel.getDefaultNic(ngmapVO.getInstanceId());
|
||||
if (defaultNic != null) {
|
||||
String cidr = defaultNic.getIp4Address();
|
||||
cidr = cidr + "/32";
|
||||
|
|
@ -1248,8 +1251,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
VirtualMachine vm = _vmDao.findByIdIncludingRemoved(vmId);
|
||||
List<NicProfile> nics = _networkMgr.getNicProfiles(vm);
|
||||
for (NicProfile nic : nics) {
|
||||
Network network = _networkMgr.getNetwork(nic.getNetworkId());
|
||||
if (_networkMgr.isSecurityGroupSupportedInNetwork(network) && vm.getHypervisorType() != HypervisorType.VMware) {
|
||||
Network network = _networkModel.getNetwork(nic.getNetworkId());
|
||||
if (_networkModel.isSecurityGroupSupportedInNetwork(network) && vm.getHypervisorType() != HypervisorType.VMware) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.firewall.NetworkACLService;
|
||||
|
|
@ -78,7 +78,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
|
|||
@Inject
|
||||
FirewallRulesDao _firewallDao;
|
||||
@Inject
|
||||
NetworkManager _networkMgr;
|
||||
NetworkModel _networkMgr;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ import com.cloud.network.Network.GuestType;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
|
@ -137,6 +139,10 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
@Inject
|
||||
NetworkManager _ntwkMgr;
|
||||
@Inject
|
||||
NetworkModel _ntwkModel;
|
||||
@Inject
|
||||
NetworkService _ntwkSvc;
|
||||
@Inject
|
||||
IPAddressDao _ipAddressDao;
|
||||
@Inject
|
||||
DomainRouterDao _routerDao;
|
||||
|
|
@ -544,12 +550,12 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
|
||||
if (networkDomain == null) {
|
||||
// 1) Get networkDomain from the corresponding account
|
||||
networkDomain = _ntwkMgr.getAccountNetworkDomain(owner.getId(), zoneId);
|
||||
networkDomain = _ntwkModel.getAccountNetworkDomain(owner.getId(), zoneId);
|
||||
|
||||
|
||||
// 2) If null, generate networkDomain using domain suffix from the global config variables
|
||||
if (networkDomain == null) {
|
||||
networkDomain = "cs" + Long.toHexString(owner.getId()) + _ntwkMgr.getDefaultNetworkDomain();
|
||||
networkDomain = "cs" + Long.toHexString(owner.getId()) + _ntwkModel.getDefaultNetworkDomain();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -561,7 +567,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
{
|
||||
//the provider has to be enabled at least in one network in the zone
|
||||
for (PhysicalNetwork pNtwk : _pNtwkDao.listByZone(zoneId)) {
|
||||
if (_ntwkMgr.isProviderEnabledInPhysicalNetwork(pNtwk.getId(), Provider.VPCVirtualRouter.getName())) {
|
||||
if (_ntwkModel.isProviderEnabledInPhysicalNetwork(pNtwk.getId(), Provider.VPCVirtualRouter.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -958,7 +964,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
}
|
||||
|
||||
//2) validate network offering attributes
|
||||
List<Service> svcs = _ntwkMgr.listNetworkOfferingServices(guestNtwkOff.getId());
|
||||
List<Service> svcs = _ntwkModel.listNetworkOfferingServices(guestNtwkOff.getId());
|
||||
validateNtwkOffForVpc(guestNtwkOff, svcs);
|
||||
|
||||
//3) Check services/providers against VPC providers
|
||||
|
|
@ -974,14 +980,14 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
}
|
||||
|
||||
//4) Only one network in the VPC can support LB
|
||||
if (_ntwkMgr.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.Lb)) {
|
||||
if (_ntwkModel.areServicesSupportedByNetworkOffering(guestNtwkOff.getId(), Service.Lb)) {
|
||||
List<? extends Network> networks = getVpcNetworks(vpc.getId());
|
||||
for (Network network : networks) {
|
||||
if (networkId != null && network.getId() == networkId.longValue()) {
|
||||
//skip my own network
|
||||
continue;
|
||||
} else {
|
||||
if (_ntwkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
if (_ntwkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
throw new InvalidParameterValueException("LB service is already supported " +
|
||||
"by network " + network + " in VPC " + vpc);
|
||||
}
|
||||
|
|
@ -993,7 +999,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
@Override
|
||||
public void validateNtwkOffForVpc(NetworkOffering guestNtwkOff, List<Service> supportedSvcs) {
|
||||
//1) in current release, only vpc provider is supported by Vpc offering
|
||||
List<Provider> providers = _ntwkMgr.getNtwkOffDistinctProviders(guestNtwkOff.getId());
|
||||
List<Provider> providers = _ntwkModel.getNtwkOffDistinctProviders(guestNtwkOff.getId());
|
||||
for (Provider provider : providers) {
|
||||
if (provider != Provider.VPCVirtualRouter) {
|
||||
throw new InvalidParameterValueException("Only provider of type " + Provider.VPCVirtualRouter.getName()
|
||||
|
|
@ -1088,7 +1094,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
|
||||
protected VpcProvider getVpcElement() {
|
||||
if (vpcElement == null) {
|
||||
vpcElement = ((VpcProvider)_ntwkMgr.getElementImplementingProvider(Provider.VPCVirtualRouter.getName()));
|
||||
vpcElement = ((VpcProvider)_ntwkModel.getElementImplementingProvider(Provider.VPCVirtualRouter.getName()));
|
||||
}
|
||||
|
||||
if (vpcElement == null) {
|
||||
|
|
@ -1216,7 +1222,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
}
|
||||
|
||||
protected PrivateGateway getPrivateGatewayProfile(VpcGateway gateway) {
|
||||
Network network = _ntwkMgr.getNetwork(gateway.getNetworkId());
|
||||
Network network = _ntwkModel.getNetwork(gateway.getNetworkId());
|
||||
return new PrivateGatewayProfile(gateway, network.getPhysicalNetworkId());
|
||||
}
|
||||
|
||||
|
|
@ -1243,7 +1249,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
|
||||
//Validate physical network
|
||||
if (physicalNetworkId == null) {
|
||||
List<? extends PhysicalNetwork> pNtwks = _ntwkMgr.getPhysicalNtwksSupportingTrafficType(vpc.getZoneId(), TrafficType.Guest);
|
||||
List<? extends PhysicalNetwork> pNtwks = _ntwkModel.getPhysicalNtwksSupportingTrafficType(vpc.getZoneId(), TrafficType.Guest);
|
||||
if (pNtwks.isEmpty() || pNtwks.size() != 1) {
|
||||
throw new InvalidParameterValueException("Physical network can't be determined; pass physical network id");
|
||||
}
|
||||
|
|
@ -1255,7 +1261,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
s_logger.debug("Creating Private gateway for VPC " + vpc);
|
||||
//1) create private network
|
||||
String networkName = "vpc-" + vpc.getName() + "-privateNetwork";
|
||||
Network privateNtwk = _ntwkMgr.createPrivateNetwork(networkName, networkName, physicalNetworkId,
|
||||
Network privateNtwk = _ntwkSvc.createPrivateNetwork(networkName, networkName, physicalNetworkId,
|
||||
vlan, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId);
|
||||
|
||||
//2) create gateway entry
|
||||
|
|
@ -1767,7 +1773,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
Account caller = UserContext.current().getCaller();
|
||||
Account owner = null;
|
||||
|
||||
IpAddress ipToAssoc = _ntwkMgr.getIp(ipId);
|
||||
IpAddress ipToAssoc = _ntwkModel.getIp(ipId);
|
||||
if (ipToAssoc != null) {
|
||||
_accountMgr.checkAccess(caller, null, true, ipToAssoc);
|
||||
owner = _accountMgr.getAccount(ipToAssoc.getAllocatedToAccountId());
|
||||
|
|
@ -1826,7 +1832,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
boolean success = false;
|
||||
try {
|
||||
//unassign ip from the VPC router
|
||||
success = _ntwkMgr.applyIpAssociations(_ntwkMgr.getNetwork(networkId), true);
|
||||
success = _ntwkMgr.applyIpAssociations(_ntwkModel.getNetwork(networkId), true);
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
throw new CloudRuntimeException("Failed to apply ip associations for network id=" + networkId +
|
||||
" as a part of unassigning ip " + ipId + " from vpc", ex);
|
||||
|
|
@ -1953,7 +1959,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
|||
validateNtkwOffForVpc(ntwkOffId, null, null, null, vpc, networkId, null);
|
||||
}
|
||||
|
||||
return _ntwkMgr.updateGuestNetwork(networkId, name, displayText, callerAccount, callerUser, domainSuffix,
|
||||
return _ntwkSvc.updateGuestNetwork(networkId, name, displayText, callerAccount, callerUser, domainSuffix,
|
||||
ntwkOffId, changeCidr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package com.cloud.network.vpn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.RemoteAccessVpnVO;
|
||||
|
|
@ -52,6 +53,7 @@ import com.cloud.network.dao.FirewallRulesDao;
|
|||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDao;
|
||||
import com.cloud.network.dao.VpnUserDao;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.RemoteAccessVPNServiceProvider;
|
||||
import com.cloud.network.rules.FirewallManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
|
|
@ -68,6 +70,7 @@ import com.cloud.utils.NumbersUtil;
|
|||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.PasswordGenerator;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
|
@ -91,12 +94,15 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
@Inject IPAddressDao _ipAddressDao;
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject DomainManager _domainMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
@Inject RulesManager _rulesMgr;
|
||||
@Inject DomainDao _domainDao;
|
||||
@Inject FirewallRulesDao _rulesDao;
|
||||
@Inject FirewallManager _firewallMgr;
|
||||
@Inject UsageEventDao _usageEventDao;
|
||||
@Inject(adapter = RemoteAccessVPNServiceProvider.class)
|
||||
Adapters<RemoteAccessVPNServiceProvider> _vpnServiceProviders;
|
||||
|
||||
|
||||
int _userLimit;
|
||||
int _pskLength;
|
||||
|
|
@ -227,10 +233,9 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
_remoteAccessVpnDao.update(vpn.getServerAddressId(), vpn);
|
||||
|
||||
|
||||
List<? extends RemoteAccessVPNServiceProvider> elements = _networkMgr.getRemoteAccessVpnElements();
|
||||
boolean success = false;
|
||||
try {
|
||||
for (RemoteAccessVPNServiceProvider element : elements) {
|
||||
for (RemoteAccessVPNServiceProvider element : _vpnServiceProviders) {
|
||||
if (element.stopVpn(network, vpn)) {
|
||||
success = true;
|
||||
break;
|
||||
|
|
@ -374,7 +379,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
|
||||
Network network = _networkMgr.getNetwork(vpn.getNetworkId());
|
||||
|
||||
List<? extends RemoteAccessVPNServiceProvider > elements = _networkMgr.getRemoteAccessVpnElements();
|
||||
boolean started = false;
|
||||
try {
|
||||
boolean firewallOpened = true;
|
||||
|
|
@ -383,7 +387,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
}
|
||||
|
||||
if (firewallOpened) {
|
||||
for (RemoteAccessVPNServiceProvider element : elements) {
|
||||
for (RemoteAccessVPNServiceProvider element : _vpnServiceProviders) {
|
||||
if (element.startVpn(network, vpn)) {
|
||||
started = true;
|
||||
break;
|
||||
|
|
@ -432,12 +436,10 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
}
|
||||
}
|
||||
|
||||
List<? extends RemoteAccessVPNServiceProvider> elements = _networkMgr.getRemoteAccessVpnElements();
|
||||
|
||||
boolean success = true;
|
||||
|
||||
boolean[] finals = new boolean[users.size()];
|
||||
for (RemoteAccessVPNServiceProvider element : elements) {
|
||||
for (RemoteAccessVPNServiceProvider element : _vpnServiceProviders) {
|
||||
s_logger.debug("Applying vpn access to " + element.getName());
|
||||
for (RemoteAccessVpnVO vpn : vpns) {
|
||||
try {
|
||||
|
|
@ -630,4 +632,12 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
|||
return _remoteAccessVpnDao.findById(vpnId);
|
||||
}
|
||||
|
||||
public List<RemoteAccessVPNServiceProvider> getRemoteAccessVPNServiceProviders() {
|
||||
List<RemoteAccessVPNServiceProvider> result = new ArrayList<RemoteAccessVPNServiceProvider>();
|
||||
for (Enumeration<RemoteAccessVPNServiceProvider> e = _vpnServiceProviders.enumeration(); e.hasMoreElements();) {
|
||||
result.add(e.nextElement());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteCustomerGatewayVO;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
|
|
@ -68,6 +67,7 @@ import com.cloud.user.dao.AccountDao;
|
|||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
|
@ -84,10 +84,11 @@ import com.cloud.vm.DomainRouterVO;
|
|||
public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(Site2SiteVpnManagerImpl.class);
|
||||
|
||||
@Inject (adapter = Site2SiteVpnServiceProvider.class)
|
||||
Adapters<Site2SiteVpnServiceProvider> _s2sProviders;
|
||||
@Inject Site2SiteCustomerGatewayDao _customerGatewayDao;
|
||||
@Inject Site2SiteVpnGatewayDao _vpnGatewayDao;
|
||||
@Inject Site2SiteVpnConnectionDao _vpnConnectionDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject VpcDao _vpcDao;
|
||||
@Inject IPAddressDao _ipAddressDao;
|
||||
@Inject AccountDao _accountDao;
|
||||
|
|
@ -107,6 +108,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
|
|||
Map<String, String> configs = configDao.getConfiguration(params);
|
||||
_connLimit = NumbersUtil.parseInt(configs.get(Config.Site2SiteVpnConnectionPerVpnGatewayLimit.key()), 4);
|
||||
_subnetsLimit = NumbersUtil.parseInt(configs.get(Config.Site2SiteVpnSubnetsPerCustomerGatewayLimit.key()), 10);
|
||||
assert (_s2sProviders.enumeration().hasMoreElements()): "Did not get injected with a list of S2S providers!";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -327,9 +329,8 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
|
|||
conn.setState(State.Pending);
|
||||
_vpnConnectionDao.persist(conn);
|
||||
|
||||
List <? extends Site2SiteVpnServiceProvider> elements = _networkMgr.getSite2SiteVpnElements();
|
||||
boolean result = true;
|
||||
for (Site2SiteVpnServiceProvider element : elements) {
|
||||
for (Site2SiteVpnServiceProvider element : _s2sProviders) {
|
||||
result = result & element.startSite2SiteVpn(conn);
|
||||
}
|
||||
|
||||
|
|
@ -527,9 +528,8 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
|
|||
conn.setState(State.Disconnected);
|
||||
_vpnConnectionDao.persist(conn);
|
||||
|
||||
List <? extends Site2SiteVpnServiceProvider> elements = _networkMgr.getSite2SiteVpnElements();
|
||||
boolean result = true;
|
||||
for (Site2SiteVpnServiceProvider element : elements) {
|
||||
for (Site2SiteVpnServiceProvider element : _s2sProviders) {
|
||||
result = result & element.stopSite2SiteVpn(conn);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import com.cloud.dc.ClusterVO;
|
|||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.net.UrlUtil;
|
||||
|
|
@ -43,7 +43,7 @@ public abstract class DiscovererBase implements Discoverer {
|
|||
private static final Logger s_logger = Logger.getLogger(DiscovererBase.class);
|
||||
@Inject protected ClusterDao _clusterDao;
|
||||
@Inject protected ConfigurationDao _configDao;
|
||||
@Inject protected NetworkManager _networkMgr;
|
||||
@Inject protected NetworkModel _networkMgr;
|
||||
@Inject protected HostDao _hostDao;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class DummyHostServerResource extends ServerResourceBase {
|
|||
cmd.setPublicIpAddress(getHostStoragePrivateIp());
|
||||
cmd.setPublicMacAddress(getHostStorageMacAddress().toString());
|
||||
cmd.setPublicNetmask("255.255.0.0");
|
||||
cmd.setVersion("1.0");
|
||||
cmd.setVersion(DummyHostServerResource.class.getPackage().getImplementationVersion());
|
||||
|
||||
return new StartupCommand[] {cmd};
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue