mirror of https://github.com/apache/cloudstack.git
NAAS: Configuring Zone
- Create Zone changes and changes to data_center table to remove vlan, securityGroup fields - Physical Network lifecycle APIs - Physical Network Service Provider APIs - DB schema changes
This commit is contained in:
parent
c5acad39d9
commit
654eaec663
|
|
@ -277,5 +277,12 @@ public class ApiConstants {
|
|||
public static final String GATEWAY_SERVICE = "gatewayservice";
|
||||
public static final String SERVICE_PROVIDER_LIST = "serviceproviderlist";
|
||||
public static final String PROVIDER = "provider";
|
||||
public static final String NETWORK_SPEED = "networkspeed";
|
||||
public static final String BROADCAST_DOMAIN_RANGE = "broadcastdomainrange";
|
||||
public static final String ISOLATION_METHODS = "isolationmethods";
|
||||
public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid";
|
||||
public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";
|
||||
public static final String ENABLED = "enabled";
|
||||
public static final String SERVICE_NAME = "servicename";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,15 +43,18 @@ import com.cloud.api.response.ListResponse;
|
|||
import com.cloud.api.response.LoadBalancerResponse;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.api.response.NetworkResponse;
|
||||
import com.cloud.api.response.PhysicalNetworkResponse;
|
||||
import com.cloud.api.response.PodResponse;
|
||||
import com.cloud.api.response.ProjectAccountResponse;
|
||||
import com.cloud.api.response.ProjectInvitationResponse;
|
||||
import com.cloud.api.response.ProjectResponse;
|
||||
import com.cloud.api.response.ProviderResponse;
|
||||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.api.response.ResourceCountResponse;
|
||||
import com.cloud.api.response.ResourceLimitResponse;
|
||||
import com.cloud.api.response.SecurityGroupResponse;
|
||||
import com.cloud.api.response.ServiceOfferingResponse;
|
||||
import com.cloud.api.response.ServiceResponse;
|
||||
import com.cloud.api.response.SnapshotPolicyResponse;
|
||||
import com.cloud.api.response.SnapshotResponse;
|
||||
import com.cloud.api.response.StoragePoolResponse;
|
||||
|
|
@ -79,6 +82,10 @@ import com.cloud.host.Host;
|
|||
import com.cloud.hypervisor.HypervisorCapabilities;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
|
|
@ -233,4 +240,12 @@ public interface ResponseGenerator {
|
|||
|
||||
SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine systemVM);
|
||||
|
||||
PhysicalNetworkResponse createPhysicalNetworkResponse(PhysicalNetwork result);
|
||||
|
||||
ServiceResponse createNetworkServiceResponse(Service service);
|
||||
|
||||
ProviderResponse createNetworkServiceProviderResponse(Provider serviceProvider);
|
||||
|
||||
ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.ProviderResponse;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Adds a network serviceProvider to a physical network", responseObject=ProviderResponse.class)
|
||||
public class AddNetworkServiceProviderCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AddNetworkServiceProviderCmd.class.getName());
|
||||
|
||||
private static final String s_name = "addnetworkserviceproviderresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID to add the provider to")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.DEST_PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the destination Physical Network ID to bridge to")
|
||||
private Long destinationPhysicalNetworkId;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name for the physical network service provider")
|
||||
private String name;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public String getProviderName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Long getDestinationPhysicalNetworkId() {
|
||||
return destinationPhysicalNetworkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
PhysicalNetworkServiceProvider result = _networkService.addProviderToPhysicalNetwork(getPhysicalNetworkId(), getProviderName(), getDestinationPhysicalNetworkId());
|
||||
if (result != null) {
|
||||
ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.PhysicalNetworkResponse;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Creates a physical network", responseObject=PhysicalNetworkResponse.class)
|
||||
public class CreatePhysicalNetworkCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreatePhysicalNetworkCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createphysicalnetworkresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the physical network")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the physical network")
|
||||
private String vlan;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_SPEED, type=CommandType.STRING, description="the speed for the physical network[1G/10G]")
|
||||
private String speed;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a physical network")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name=ApiConstants.BROADCAST_DOMAIN_RANGE, type=CommandType.STRING, description="the broadcast domain range for the physical network[Pod or Zone]")
|
||||
private String broadcastDomainRange;
|
||||
|
||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")
|
||||
private List<String> tags;
|
||||
|
||||
@Parameter(name=ApiConstants.ISOLATION_METHODS, type=CommandType.LIST, collectionType=CommandType.STRING, description="the isolation method for the physical network[VLAN/L3/GRE]")
|
||||
private List<String> isolationMethods;
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public String getBroadcastDomainRange() {
|
||||
return broadcastDomainRange;
|
||||
}
|
||||
|
||||
public List<String> getIsolationMethods() {
|
||||
return isolationMethods;
|
||||
}
|
||||
|
||||
public String getNetworkSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
PhysicalNetwork result = _networkService.createPhysicalNetwork(getZoneId(),getVlan(),getNetworkSpeed(), getIsolationMethods(),getBroadcastDomainRange(),getDomainId(), getTags());
|
||||
if (result != null) {
|
||||
PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,9 +57,6 @@ public class CreateZoneCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the Zone")
|
||||
private String zoneName;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the Zone")
|
||||
private String vlan;
|
||||
|
||||
@Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="Network domain name for the networks in the zone")
|
||||
private String domain;
|
||||
|
||||
|
|
@ -69,9 +66,6 @@ public class CreateZoneCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.NETWORK_TYPE, type=CommandType.STRING, required=true, description="network type of the zone, can be Basic or Advanced")
|
||||
private String networkType;
|
||||
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_EANBLED, type=CommandType.BOOLEAN, description="true if network is security group enabled, false otherwise")
|
||||
private Boolean securitygroupenabled;
|
||||
|
||||
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this Zone for allocation of new resources")
|
||||
private String allocationState;
|
||||
|
||||
|
|
@ -103,10 +97,6 @@ public class CreateZoneCmd extends BaseCmd {
|
|||
return zoneName;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
|
@ -119,13 +109,6 @@ public class CreateZoneCmd extends BaseCmd {
|
|||
return networkType;
|
||||
}
|
||||
|
||||
public Boolean isSecurityGroupEnabled() {
|
||||
if (securitygroupenabled == null) {
|
||||
return false;
|
||||
}
|
||||
return securitygroupenabled;
|
||||
}
|
||||
|
||||
public String getAllocationState() {
|
||||
return allocationState;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Deletes a Network Service Provider.", responseObject=SuccessResponse.class)
|
||||
public class DeleteNetworkServiceProviderCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteNetworkServiceProviderCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletenetworkserviceproviderresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network service provider")
|
||||
private Long id;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
boolean result = _networkService.deleteNetworkServiceProvider(getId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network service provider");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Deletes a Physical Network.", responseObject=SuccessResponse.class)
|
||||
public class DeletePhysicalNetworkCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeletePhysicalNetworkCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletephysicalnetworkresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Physical network")
|
||||
private Long id;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
boolean result = _networkService.deletePhysicalNetwork(getId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete physical network");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.ProviderResponse;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
@Implementation(description="Lists network serviceproviders for a given physical network.", responseObject=ProviderResponse.class)
|
||||
public class ListNetworkServiceProvidersCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListNetworkServiceProvidersCmd.class.getName());
|
||||
private static final String _name = "listnetworkserviceprovidersresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID to add the provider to")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public void setPhysicalNetworkId(Long physicalNetworkId) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
public Long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends PhysicalNetworkServiceProvider> serviceProviders = _networkService.listNetworkServiceProviders(getPhysicalNetworkId());
|
||||
ListResponse<ProviderResponse> response = new ListResponse<ProviderResponse>();
|
||||
List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
|
||||
for (PhysicalNetworkServiceProvider serviceProvider : serviceProviders) {
|
||||
ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
|
||||
serviceProvidersResponses.add(serviceProviderResponse);
|
||||
}
|
||||
|
||||
response.setResponses(serviceProvidersResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.ServiceResponse;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
@Implementation(description="Lists all network services provided by CloudStack.", responseObject=ServiceResponse.class)
|
||||
public class ListNetworkServicesCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListNetworkServicesCmd.class.getName());
|
||||
private static final String _name = "listnetworkservicesresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends Network.Service> services = _networkService.listNetworkServices();
|
||||
ListResponse<ServiceResponse> response = new ListResponse<ServiceResponse>();
|
||||
List<ServiceResponse> servicesResponses = new ArrayList<ServiceResponse>();
|
||||
for (Network.Service service : services) {
|
||||
ServiceResponse serviceResponse = _responseGenerator.createNetworkServiceResponse(service);
|
||||
servicesResponses.add(serviceResponse);
|
||||
}
|
||||
|
||||
response.setResponses(servicesResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.PhysicalNetworkResponse;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Lists physical networks", responseObject=PhysicalNetworkResponse.class)
|
||||
public class ListPhysicalNetworksCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListPhysicalNetworksCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listphysicalnetworksresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list physical network by id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the physical network")
|
||||
private Long zoneId;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends PhysicalNetwork> result = _networkService.searchPhysicalNetworks(getId(),getZoneId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal());
|
||||
if (result != null) {
|
||||
ListResponse<PhysicalNetworkResponse> response = new ListResponse<PhysicalNetworkResponse>();
|
||||
List<PhysicalNetworkResponse> networkResponses = new ArrayList<PhysicalNetworkResponse>();
|
||||
for (PhysicalNetwork network : result) {
|
||||
PhysicalNetworkResponse networkResponse = _responseGenerator.createPhysicalNetworkResponse(network);
|
||||
networkResponses.add(networkResponse);
|
||||
}
|
||||
response.setResponses(networkResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to search for physical networks");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.ProviderResponse;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
@Implementation(description="Lists all network serviceproviders supported by CloudStack.", responseObject=ProviderResponse.class)
|
||||
public class ListSupportedNetworkServiceProvidersCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListSupportedNetworkServiceProvidersCmd.class.getName());
|
||||
private static final String _name = "listsupportednetworkserviceprovidersresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.SERVICE_NAME, type=CommandType.STRING, description="network service name")
|
||||
private String serviceName;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends Network.Provider> serviceProviders = _networkService.listSupportedNetworkServiceProviders(getServiceName());
|
||||
ListResponse<ProviderResponse> response = new ListResponse<ProviderResponse>();
|
||||
List<ProviderResponse> serviceProvidersResponses = new ArrayList<ProviderResponse>();
|
||||
for (Network.Provider serviceProvider : serviceProviders) {
|
||||
ProviderResponse serviceProviderResponse = _responseGenerator.createNetworkServiceProviderResponse(serviceProvider);
|
||||
serviceProvidersResponses.add(serviceProviderResponse);
|
||||
}
|
||||
|
||||
response.setResponses(serviceProvidersResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.ProviderResponse;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Updates a network serviceProvider of a physical network", responseObject=ProviderResponse.class)
|
||||
public class UpdateNetworkServiceProviderCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateNetworkServiceProviderCmd.class.getName());
|
||||
|
||||
private static final String s_name = "updatenetworkserviceproviderresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, description="true/false enable/disable the physical network service provider")
|
||||
private Boolean enabled;
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="network service provider id")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
PhysicalNetworkServiceProvider result = _networkService.updateNetworkServiceProvider(getId(), isEnabled());
|
||||
if (result != null) {
|
||||
ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.PhysicalNetworkResponse;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Updates a physical network", responseObject=PhysicalNetworkResponse.class)
|
||||
public class UpdatePhysicalNetworkCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdatePhysicalNetworkCmd.class.getName());
|
||||
|
||||
private static final String s_name = "updatephysicalnetworkresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="physical network id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_SPEED, type=CommandType.STRING, description="the speed for the physical network[1G/10G]")
|
||||
private String speed;
|
||||
|
||||
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")
|
||||
private List<String> tags;
|
||||
|
||||
@Parameter(name=ApiConstants.ISOLATION_METHODS, type=CommandType.LIST, collectionType=CommandType.STRING, description="the isolation method for the physical network[VLAN/L3/GRE]")
|
||||
private List<String> isolationMethods;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="Enabled/Disabled")
|
||||
private String state;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the physical network")
|
||||
private String vlan;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<String> getIsolationMethods() {
|
||||
return isolationMethods;
|
||||
}
|
||||
|
||||
public String getNetworkSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(),getNetworkSpeed(), getIsolationMethods(), getTags(), getVlan(), getState());
|
||||
if (result != null) {
|
||||
PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -63,9 +63,6 @@ public class UpdateZoneCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the Zone")
|
||||
private String zoneName;
|
||||
|
||||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the Zone")
|
||||
private String vlan;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_PUBLIC, type=CommandType.BOOLEAN, description="updates a private zone to public if set, but not vice-versa")
|
||||
private Boolean isPublic;
|
||||
|
||||
|
|
@ -116,10 +113,6 @@ public class UpdateZoneCmd extends BaseCmd {
|
|||
return zoneName;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
}
|
||||
|
||||
public Boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,148 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class PhysicalNetworkResponse extends BaseResponse{
|
||||
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the id of the physical network")
|
||||
private Long id;
|
||||
|
||||
@SerializedName(ApiConstants.BROADCAST_DOMAIN_RANGE) @Param(description="Broadcast domain range of the physical network")
|
||||
private String broadcastDomainRange;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the physical network")
|
||||
private Long zoneId;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="state of the physical network")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the vlan of the physical network")
|
||||
private String vlan;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the physical network owner")
|
||||
private Long domainId;
|
||||
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="comma separated tag")
|
||||
private String tags;
|
||||
|
||||
@SerializedName(ApiConstants.ISOLATION_METHODS) @Param(description="isolation methods")
|
||||
private String isolationMethods;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_SPEED) @Param(description="the speed of the physical network")
|
||||
private String networkSpeed;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
public void setVlan(String vlan) {
|
||||
this.vlan = vlan;
|
||||
}
|
||||
|
||||
public String getVlan() {
|
||||
return this.vlan;
|
||||
}
|
||||
|
||||
|
||||
public void setTags(List<String> tags) {
|
||||
if (tags == null || tags.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (String tag : tags) {
|
||||
buf.append(tag).append(",");
|
||||
}
|
||||
|
||||
this.tags = buf.delete(buf.length()-1, buf.length()).toString();
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setBroadcastDomainRange(String broadcastDomainRange) {
|
||||
this.broadcastDomainRange = broadcastDomainRange;
|
||||
}
|
||||
|
||||
public String getBroadcastDomainRange() {
|
||||
return broadcastDomainRange;
|
||||
}
|
||||
|
||||
public void setNetworkSpeed(String networkSpeed) {
|
||||
this.networkSpeed = networkSpeed;
|
||||
}
|
||||
|
||||
public String getNetworkSpeed() {
|
||||
return networkSpeed;
|
||||
}
|
||||
|
||||
public void setIsolationMethods(List<String> isolationMethods) {
|
||||
if (isolationMethods == null || isolationMethods.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (String isolationMethod : isolationMethods) {
|
||||
buf.append(isolationMethod).append(",");
|
||||
}
|
||||
|
||||
this.isolationMethods = buf.delete(buf.length()-1, buf.length()).toString();
|
||||
}
|
||||
|
||||
public String getIsolationMethods() {
|
||||
return isolationMethods;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,8 +17,6 @@
|
|||
*/
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -29,7 +27,53 @@ public class ProviderResponse extends BaseResponse {
|
|||
@SerializedName(ApiConstants.NAME) @Param(description="the provider name")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network this belongs to")
|
||||
private Long physicalNetworkId;
|
||||
|
||||
@SerializedName(ApiConstants.DEST_PHYSICAL_NETWORK_ID) @Param(description="the destination physical network")
|
||||
private Long destinationPhysicalNetworkId;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="state of the network provider")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.ID) @Param(description="id of the network provider")
|
||||
private Long id;
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setPhysicalNetworkId(long physicalNetworkId) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
public long getphysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public void setDestinationPhysicalNetworkId(long destPhysicalNetworkId) {
|
||||
this.destinationPhysicalNetworkId = destPhysicalNetworkId;
|
||||
}
|
||||
|
||||
public long getDestinationPhysicalNetworkId() {
|
||||
return destinationPhysicalNetworkId;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ public interface DataCenter extends Grouping {
|
|||
Long getDomainId();
|
||||
String getDescription();
|
||||
String getDomain();
|
||||
String getVnet();
|
||||
|
||||
NetworkType getNetworkType();
|
||||
String getInternalDns1();
|
||||
|
|
|
|||
|
|
@ -101,6 +101,10 @@ public interface Network extends ControlledEntity {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Service> listAllServices(){
|
||||
return supportedServices;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Provider {
|
||||
|
|
@ -265,4 +269,6 @@ public interface Network extends ControlledEntity {
|
|||
Type getType();
|
||||
|
||||
boolean getIsShared();
|
||||
|
||||
long getPhysicalNetworkId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class NetworkProfile implements Network {
|
|||
private Network.Type type;
|
||||
private GuestIpType guestIpType;
|
||||
private boolean isShared;
|
||||
private long physicalNetworkId;
|
||||
|
||||
public NetworkProfile(Network network) {
|
||||
this.id = network.getId();
|
||||
|
|
@ -76,6 +77,7 @@ public class NetworkProfile implements Network {
|
|||
this.type = network.getType();
|
||||
this.guestIpType = network.getGuestType();
|
||||
this.isShared = network.getIsShared();
|
||||
this.physicalNetworkId = network.getPhysicalNetworkId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -212,4 +214,9 @@ public class NetworkProfile implements Network {
|
|||
public boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ 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.offering.NetworkOffering;
|
||||
|
|
@ -88,4 +89,24 @@ public interface NetworkService {
|
|||
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||
|
||||
Map<String, Set<String>> listNetworkOfferingServices(long networkOfferingId);
|
||||
|
||||
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags);
|
||||
|
||||
List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize);
|
||||
|
||||
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> isolationMethods, List<String> tags, String newVnetRangeString, String state);
|
||||
|
||||
boolean deletePhysicalNetwork(Long id);
|
||||
|
||||
List<? extends Service> listNetworkServices();
|
||||
|
||||
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
|
||||
|
||||
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName, Long destinationPhysicalNetworkId);
|
||||
|
||||
List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId);
|
||||
|
||||
PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, Boolean enabled);
|
||||
|
||||
boolean deleteNetworkServiceProvider(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This defines the specifics of a physical network present in a data center
|
||||
*
|
||||
*/
|
||||
public interface PhysicalNetwork {
|
||||
|
||||
public enum State {
|
||||
Disabled,
|
||||
Enabled;
|
||||
}
|
||||
|
||||
public enum IsolationMethod {
|
||||
VLAN,
|
||||
L3,
|
||||
GRE;
|
||||
}
|
||||
|
||||
public enum BroadcastDomainRange {
|
||||
Pod,
|
||||
Zone;
|
||||
}
|
||||
|
||||
long getId();
|
||||
|
||||
BroadcastDomainRange getBroadcastDomainRange();
|
||||
|
||||
//TrafficType getTrafficType();
|
||||
|
||||
long getDataCenterId();
|
||||
|
||||
State getState();
|
||||
|
||||
List<String> getTags();
|
||||
|
||||
List<String> getIsolationMethods();
|
||||
|
||||
Long getDomainId();
|
||||
|
||||
String getVnet();
|
||||
|
||||
String getSpeed();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This defines the specifics of a physical network service provider
|
||||
*
|
||||
*/
|
||||
public interface PhysicalNetworkServiceProvider {
|
||||
|
||||
public enum State {
|
||||
Disabled,
|
||||
Enabled;
|
||||
}
|
||||
|
||||
long getId();
|
||||
|
||||
State getState();
|
||||
|
||||
long getPhysicalNetworkId();
|
||||
|
||||
String getProviderName();
|
||||
|
||||
long getDestinationPhysicalNetworkId();
|
||||
|
||||
void setState(State state);
|
||||
}
|
||||
|
|
@ -286,4 +286,18 @@ listFirewallRules=com.cloud.api.commands.ListFirewallRulesCmd;15
|
|||
|
||||
#### hypervisor capabilities commands
|
||||
updateHypervisorCapabilities=com.cloud.api.commands.UpdateHypervisorCapabilitiesCmd;1
|
||||
listHypervisorCapabilities=com.cloud.api.commands.ListHypervisorCapabilitiesCmd;1
|
||||
listHypervisorCapabilities=com.cloud.api.commands.ListHypervisorCapabilitiesCmd;1
|
||||
|
||||
#### Physical Network commands
|
||||
createPhysicalNetwork=com.cloud.api.commands.CreatePhysicalNetworkCmd;1
|
||||
deletePhysicalNetwork=com.cloud.api.commands.DeletePhysicalNetworkCmd;1
|
||||
listPhysicalNetworks=com.cloud.api.commands.ListPhysicalNetworksCmd;1
|
||||
updatePhysicalNetwork=com.cloud.api.commands.UpdatePhysicalNetworkCmd;1
|
||||
|
||||
#### Physical Network Service Provider commands
|
||||
listNetworkServices=com.cloud.api.commands.ListNetworkServicesCmd;1
|
||||
listSupportedNetworkServiceProviders=com.cloud.api.commands.ListSupportedNetworkServiceProvidersCmd;1
|
||||
addNetworkServiceProvider=com.cloud.api.commands.AddNetworkServiceProviderCmd;1
|
||||
deleteNetworkServiceProvider=com.cloud.api.commands.DeleteNetworkServiceProviderCmd;1
|
||||
listNetworkServiceProviders=com.cloud.api.commands.ListNetworkServiceProvidersCmd;1
|
||||
updateNetworkServiceProvider=com.cloud.api.commands.UpdateNetworkServiceProviderCmd;1
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ import com.cloud.api.response.LoadBalancerResponse;
|
|||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.api.response.NetworkResponse;
|
||||
import com.cloud.api.response.NicResponse;
|
||||
import com.cloud.api.response.PhysicalNetworkResponse;
|
||||
import com.cloud.api.response.PodResponse;
|
||||
import com.cloud.api.response.ProjectAccountResponse;
|
||||
import com.cloud.api.response.ProjectInvitationResponse;
|
||||
|
|
@ -116,9 +117,12 @@ import com.cloud.network.IPAddressVO;
|
|||
import com.cloud.network.IpAddress;
|
||||
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.NetworkProfile;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
|
|
@ -786,7 +790,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
zoneResponse.setDns2(dataCenter.getDns2());
|
||||
zoneResponse.setInternalDns1(dataCenter.getInternalDns1());
|
||||
zoneResponse.setInternalDns2(dataCenter.getInternalDns2());
|
||||
zoneResponse.setVlan(dataCenter.getVnet());
|
||||
zoneResponse.setGuestCidrAddress(dataCenter.getGuestNetworkCidr());
|
||||
}
|
||||
|
||||
|
|
@ -2529,6 +2532,69 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
vmResponse.setRole(router.getRole().toString());
|
||||
}
|
||||
}
|
||||
vmResponse.setObjectName("systemvminstance");
|
||||
return vmResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhysicalNetworkResponse createPhysicalNetworkResponse(PhysicalNetwork result) {
|
||||
PhysicalNetworkResponse response = new PhysicalNetworkResponse();
|
||||
|
||||
response.setZoneId(result.getDataCenterId());
|
||||
response.setNetworkSpeed(result.getSpeed());
|
||||
response.setVlan(result.getVnet());
|
||||
response.setDomainId(result.getDomainId());
|
||||
response.setId(result.getId());
|
||||
if(result.getBroadcastDomainRange() != null){
|
||||
response.setBroadcastDomainRange(result.getBroadcastDomainRange().toString());
|
||||
}
|
||||
response.setIsolationMethods(result.getIsolationMethods());
|
||||
response.setTags(result.getTags());
|
||||
if(result.getState() != null){
|
||||
response.setState(result.getState().toString());
|
||||
}
|
||||
response.setObjectName("physicalnetwork");
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceResponse createNetworkServiceResponse(Service service){
|
||||
ServiceResponse response = new ServiceResponse();
|
||||
response.setName(service.getName());
|
||||
|
||||
// set list of capabilities required for the service
|
||||
List<CapabilityResponse> capabilityResponses = new ArrayList<CapabilityResponse>();
|
||||
Capability[] capabilities = service.getCapabilities();
|
||||
for(Capability cap : capabilities){
|
||||
CapabilityResponse capabilityResponse = new CapabilityResponse();
|
||||
capabilityResponse.setName(cap.getName());
|
||||
capabilityResponse.setObjectName("capability");
|
||||
capabilityResponses.add(capabilityResponse);
|
||||
}
|
||||
response.setCapabilities(capabilityResponses);
|
||||
|
||||
response.setObjectName("networkservice");
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProviderResponse createNetworkServiceProviderResponse(Provider serviceProvider) {
|
||||
ProviderResponse response = new ProviderResponse();
|
||||
response.setName(serviceProvider.getName());
|
||||
response.setObjectName("networkserviceprovider");
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result){
|
||||
ProviderResponse response = new ProviderResponse();
|
||||
response.setId(result.getId());
|
||||
response.setName(result.getProviderName());
|
||||
response.setPhysicalNetworkId(result.getPhysicalNetworkId());
|
||||
response.setDestinationPhysicalNetworkId(result.getDestinationPhysicalNetworkId());
|
||||
response.setState(result.getState().toString());
|
||||
response.setObjectName("networkserviceprovider");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
|||
* @param dns2
|
||||
* @param internalDns1
|
||||
* @param internalDns2
|
||||
* @param vnetRange
|
||||
* @param guestCidr
|
||||
* @param zoneType
|
||||
* @param allocationState
|
||||
|
|
@ -122,7 +121,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
|||
* @throws
|
||||
* @throws
|
||||
*/
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId, NetworkType zoneType, boolean isSecurityGroupEnabled, String allocationState, String networkDomain);
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId, NetworkType zoneType, String allocationState, String networkDomain);
|
||||
|
||||
/**
|
||||
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated IP addresses.
|
||||
|
|
@ -190,7 +189,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
|||
|
||||
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
||||
|
||||
void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled) throws ConcurrentOperationException;
|
||||
void createDefaultNetworks(long zoneId) throws ConcurrentOperationException;
|
||||
|
||||
HostPodVO getPod(long id);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,6 @@ import com.cloud.user.UserContext;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
|
|
@ -962,10 +961,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
return !vmInstances.isEmpty();
|
||||
}
|
||||
|
||||
private boolean zoneHasAllocatedVnets(long zoneId) {
|
||||
return !_zoneDao.listAllocatedVnets(zoneId).isEmpty();
|
||||
}
|
||||
|
||||
@DB
|
||||
protected void checkIfZoneIsDeletable(long zoneId) {
|
||||
List<List<String>> tablesToCheck = new ArrayList<List<String>>();
|
||||
|
|
@ -1185,7 +1180,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String dns2 = cmd.getDns2();
|
||||
String internalDns1 = cmd.getInternalDns1();
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String newVnetRangeString = cmd.getVlan();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
List<String> dnsSearchOrder = cmd.getDnsSearchOrder();
|
||||
Boolean isPublic = cmd.isPublic();
|
||||
|
|
@ -1234,15 +1228,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
zoneName = zone.getName();
|
||||
}
|
||||
|
||||
// if zone is of Basic type, don't allow to add vnet range and cidr
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
if (newVnetRangeString != null) {
|
||||
throw new InvalidParameterValueException("Can't add vnet range for the zone that supports " + zone.getNetworkType() + " network");
|
||||
} else if (guestCidr != null) {
|
||||
throw new InvalidParameterValueException("Can't add cidr for the zone that supports " + zone.getNetworkType() + " network");
|
||||
}
|
||||
}
|
||||
|
||||
if ((guestCidr != null) && !NetUtils.validateGuestCidr(guestCidr)) {
|
||||
throw new InvalidParameterValueException("Please enter a valid guest cidr");
|
||||
}
|
||||
|
|
@ -1252,63 +1237,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new InvalidParameterValueException("A zone with ID: " + zoneId + " does not exist.");
|
||||
}
|
||||
|
||||
// Vnet range can be extended only
|
||||
boolean replaceVnet = false;
|
||||
ArrayList<Pair<Integer, Integer>> vnetsToAdd = new ArrayList<Pair<Integer, Integer>>(2);
|
||||
|
||||
if (newVnetRangeString != null) {
|
||||
Integer newStartVnet = 0;
|
||||
Integer newEndVnet = 0;
|
||||
String[] newVnetRange = newVnetRangeString.split("-");
|
||||
|
||||
if (newVnetRange.length < 2) {
|
||||
throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096");
|
||||
}
|
||||
|
||||
if (newVnetRange[0] == null || newVnetRange[1] == null) {
|
||||
throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096");
|
||||
}
|
||||
|
||||
try {
|
||||
newStartVnet = Integer.parseInt(newVnetRange[0]);
|
||||
newEndVnet = Integer.parseInt(newVnetRange[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
s_logger.warn("Unable to parse vnet range:", e);
|
||||
throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096");
|
||||
}
|
||||
|
||||
if (newStartVnet < 0 || newEndVnet > 4096) {
|
||||
throw new InvalidParameterValueException("Vnet range has to be between 0-4096");
|
||||
}
|
||||
|
||||
if (newStartVnet > newEndVnet) {
|
||||
throw new InvalidParameterValueException("Vnet range has to be between 0-4096 and start range should be lesser than or equal to stop range");
|
||||
}
|
||||
|
||||
if (zoneHasAllocatedVnets(zoneId)) {
|
||||
String[] existingRange = zone.getVnet().split("-");
|
||||
int existingStartVnet = Integer.parseInt(existingRange[0]);
|
||||
int existingEndVnet = Integer.parseInt(existingRange[1]);
|
||||
|
||||
//check if vnet is being extended
|
||||
if (!(newStartVnet.intValue() <= existingStartVnet && newEndVnet.intValue() >= existingEndVnet)) {
|
||||
throw new InvalidParameterValueException("Can's shrink existing vnet range as it the range has vnets allocated. Only extending existing vnet is supported");
|
||||
}
|
||||
|
||||
if (newStartVnet < existingStartVnet) {
|
||||
vnetsToAdd.add(new Pair<Integer, Integer>(newStartVnet, existingStartVnet - 1));
|
||||
}
|
||||
|
||||
if (newEndVnet > existingEndVnet) {
|
||||
vnetsToAdd.add(new Pair<Integer, Integer>(existingEndVnet + 1, newEndVnet));
|
||||
}
|
||||
|
||||
} else {
|
||||
vnetsToAdd.add(new Pair<Integer, Integer>(newStartVnet, newEndVnet));
|
||||
replaceVnet = true;
|
||||
}
|
||||
}
|
||||
|
||||
String oldZoneName = zone.getName();
|
||||
|
||||
if (zoneName == null) {
|
||||
|
|
@ -1362,10 +1290,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
zone.setGuestNetworkCidr(guestCidr);
|
||||
zone.setDomain(networkDomain);
|
||||
|
||||
if (newVnetRangeString != null) {
|
||||
zone.setVnet(newVnetRangeString);
|
||||
}
|
||||
|
||||
// update a private zone to public; not vice versa
|
||||
if (isPublic != null && isPublic) {
|
||||
zone.setDomainId(null);
|
||||
|
|
@ -1396,44 +1320,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new CloudRuntimeException("Failed to edit zone. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
if (replaceVnet) {
|
||||
s_logger.debug("Deleting existing vnet range for the zone id=" + zoneId + " as a part of updateZone call");
|
||||
_zoneDao.deleteVnet(zoneId);
|
||||
}
|
||||
|
||||
for (Pair<Integer, Integer> vnetToAdd : vnetsToAdd) {
|
||||
s_logger.debug("Adding vnet range " + vnetToAdd.first() + "-" + vnetToAdd.second() + " for the zone id=" + zoneId + " as a part of updateZone call");
|
||||
_zoneDao.addVnet(zone.getId(), vnetToAdd.first(), vnetToAdd.second());
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return zone;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId,
|
||||
NetworkType zoneType, boolean isSecurityGroupEnabled, String allocationStateStr, String networkDomain) {
|
||||
int vnetStart = 0;
|
||||
int vnetEnd = 0;
|
||||
if (vnetRange != null) {
|
||||
String[] tokens = vnetRange.split("-");
|
||||
try {
|
||||
vnetStart = Integer.parseInt(tokens[0]);
|
||||
if (tokens.length == 1) {
|
||||
vnetEnd = vnetStart;
|
||||
} else {
|
||||
vnetEnd = Integer.parseInt(tokens[1]);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidParameterValueException("Please specify valid integers for the vlan range.");
|
||||
}
|
||||
|
||||
if ((vnetStart > vnetEnd) || (vnetStart < 0) || (vnetEnd > 4096)) {
|
||||
s_logger.warn("Invalid vnet range: start range:" + vnetStart + " end range:" + vnetEnd);
|
||||
throw new InvalidParameterValueException("Vnet range should be between 0-4096 and start range should be lesser than or equal to end range");
|
||||
}
|
||||
}
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId,
|
||||
NetworkType zoneType, String allocationStateStr, String networkDomain) {
|
||||
|
||||
// checking the following params outside checkzoneparams method as we do not use these params for updatezone
|
||||
// hence the method below is generic to check for common params
|
||||
|
|
@ -1458,20 +1352,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
try {
|
||||
txn.start();
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domain, domainId, zoneType, isSecurityGroupEnabled, zoneToken, networkDomain);
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain);
|
||||
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
|
||||
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
|
||||
zone.setAllocationState(allocationState);
|
||||
}
|
||||
zone = _zoneDao.persist(zone);
|
||||
|
||||
// Add vnet entries for the new zone if zone type is Advanced
|
||||
if (vnetRange != null) {
|
||||
_zoneDao.addVnet(zone.getId(), vnetStart, vnetEnd);
|
||||
}
|
||||
|
||||
// Create deafult networks
|
||||
createDefaultNetworks(zone.getId(), isSecurityGroupEnabled);
|
||||
createDefaultNetworks(zone.getId());
|
||||
txn.commit();
|
||||
return zone;
|
||||
} catch (Exception ex) {
|
||||
|
|
@ -1484,7 +1373,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
@Override
|
||||
public void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled) throws ConcurrentOperationException {
|
||||
public void createDefaultNetworks(long zoneId) throws ConcurrentOperationException {
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
String networkDomain = null;
|
||||
// Create public, management, control and storage networks as a part of the zone creation
|
||||
|
|
@ -1509,7 +1398,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||
} /*else if (offering.getTrafficType() == TrafficType.Guest) {
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
isNetworkDefault = true;
|
||||
broadcastDomainType = BroadcastDomainType.Native;
|
||||
|
|
@ -1522,7 +1411,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
networkDomain = "cs" + Long.toHexString(Account.ACCOUNT_ID_SYSTEM) + _networkMgr.getGlobalGuestDomainSuffix();
|
||||
}
|
||||
}*/
|
||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||
userNetwork.setNetworkDomain(networkDomain);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, isNetworkDefault, false, null, null, true);
|
||||
|
|
@ -1539,7 +1428,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String dns2 = cmd.getDns2();
|
||||
String internalDns1 = cmd.getInternalDns1();
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String vnetRange = cmd.getVlan();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String type = cmd.getNetworkType();
|
||||
|
|
@ -1557,16 +1445,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
isBasic = true;
|
||||
}
|
||||
|
||||
Boolean securityGroupEnabled = cmd.isSecurityGroupEnabled();
|
||||
|
||||
NetworkType zoneType = isBasic ? NetworkType.Basic : NetworkType.Advanced;
|
||||
|
||||
// Guest cidr is required for Advanced zone creation; error out when the parameter specified for Basic zone
|
||||
/*Guest cidr is required for Advanced zone creation; error out when the parameter specified for Basic zone
|
||||
if (zoneType == NetworkType.Advanced && guestCidr == null && !securityGroupEnabled) {
|
||||
throw new InvalidParameterValueException("guestCidrAddress parameter is required for Advanced zone creation");
|
||||
} else if (zoneType == NetworkType.Basic && guestCidr != null) {
|
||||
throw new InvalidParameterValueException("guestCidrAddress parameter is not supported for Basic zone");
|
||||
}
|
||||
}*/
|
||||
|
||||
DomainVO domainVO = null;
|
||||
|
||||
|
|
@ -1578,17 +1464,16 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
domainVO = _domainDao.findById(domainId);
|
||||
}
|
||||
|
||||
// Verify zone type
|
||||
/* Verify zone type
|
||||
if (zoneType == NetworkType.Basic && vnetRange != null) {
|
||||
vnetRange = null;
|
||||
}
|
||||
|
||||
if (zoneType == NetworkType.Basic) {
|
||||
securityGroupEnabled = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, vnetRange, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType, securityGroupEnabled,
|
||||
allocationState, networkDomain);
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType, allocationState, networkDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2149,10 +2034,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
throw new InvalidParameterValueException("Only Direct Untagged and Virtual networks are supported in the zone " + zone.getId() + " of type " + zone.getNetworkType());
|
||||
}
|
||||
|
||||
// don't allow to create a virtual vlan when zone's vnet is NULL in Advanced zone
|
||||
//TODO
|
||||
/* don't allow to create a virtual vlan when zone's vnet is NULL in Advanced zone
|
||||
if ((zone.getNetworkType() == NetworkType.Advanced && zone.getVnet() == null) && forVirtualNetwork) {
|
||||
throw new InvalidParameterValueException("Can't add virtual network to the zone id=" + zone.getId() + " as zone doesn't have guest vlan configured");
|
||||
}
|
||||
}*/
|
||||
|
||||
VlanType vlanType = forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached;
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ import com.cloud.network.dao.LoadBalancerVMMapDaoImpl;
|
|||
import com.cloud.network.dao.NetworkDaoImpl;
|
||||
import com.cloud.network.dao.NetworkDomainDaoImpl;
|
||||
import com.cloud.network.dao.NetworkRuleConfigDaoImpl;
|
||||
import com.cloud.network.dao.PhysicalNetworkDaoImpl;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.firewall.FirewallManagerImpl;
|
||||
|
|
@ -285,6 +287,8 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
info = addDao("HypervisorCapabilitiesDao",HypervisorCapabilitiesDaoImpl.class);
|
||||
info.addParameter("cache.size", "100");
|
||||
info.addParameter("cache.time.to.live", "600");
|
||||
addDao("PhysicalNetworkDao", PhysicalNetworkDaoImpl.class);
|
||||
addDao("PhysicalNetworkServiceProviderDao", PhysicalNetworkServiceProviderDaoImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -67,9 +67,6 @@ public class DataCenterVO implements DataCenter {
|
|||
@Column(name="router_mac_address", updatable = false, nullable=false)
|
||||
private String routerMacAddress = "02:00:00:00:00:01";
|
||||
|
||||
@Column(name="vnet")
|
||||
private String vnet = null;
|
||||
|
||||
@Column(name="guest_network_cidr")
|
||||
private String guestNetworkCidr = null;
|
||||
|
||||
|
|
@ -104,9 +101,6 @@ public class DataCenterVO implements DataCenter {
|
|||
@Column(name="firewall_provider")
|
||||
private String firewallProvider;
|
||||
|
||||
@Column(name="is_security_group_enabled")
|
||||
boolean securityGroupEnabled;
|
||||
|
||||
@Column(name="mac_address", updatable = false, nullable=false)
|
||||
@TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
|
||||
private long macAddress = 1;
|
||||
|
|
@ -172,26 +166,24 @@ public class DataCenterVO implements DataCenter {
|
|||
this.firewallProvider = firewallProvider;
|
||||
}
|
||||
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr, domain, domainId, zoneType, false, zoneToken, domainSuffix);
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix);
|
||||
this.id = id;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
}
|
||||
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, NetworkType zoneType, boolean securityGroupEnabled, String zoneToken, String domainSuffix) {
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.internalDns1 = dns3;
|
||||
this.internalDns2 = dns4;
|
||||
this.vnet = vnet;
|
||||
this.guestNetworkCidr = guestCidr;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.networkType = zoneType;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.securityGroupEnabled = securityGroupEnabled;
|
||||
|
||||
if (zoneType == NetworkType.Advanced) {
|
||||
loadBalancerProvider = Provider.VirtualRouter.getName();
|
||||
|
|
@ -248,20 +240,11 @@ public class DataCenterVO implements DataCenter {
|
|||
return routerMacAddress;
|
||||
}
|
||||
|
||||
public void setVnet(String vnet) {
|
||||
this.vnet = vnet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVnet() {
|
||||
return vnet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
|
|
@ -345,11 +328,10 @@ public class DataCenterVO implements DataCenter {
|
|||
|
||||
@Override
|
||||
public boolean isSecurityGroupEnabled() {
|
||||
return securityGroupEnabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setSecurityGroupEnabled(boolean enabled) {
|
||||
this.securityGroupEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@ public class DataCenterVnetVO {
|
|||
|
||||
@Column(name="vnet", updatable=false, nullable=false)
|
||||
protected String vnet;
|
||||
|
||||
|
||||
@Column(name="physical_network_id", updatable=false, nullable=false)
|
||||
protected long physicalNetworkId;
|
||||
|
||||
@Column(name="data_center_id", updatable=false, nullable=false)
|
||||
protected long dataCenterId;
|
||||
|
||||
|
|
@ -61,9 +64,10 @@ public class DataCenterVnetVO {
|
|||
this.takenAt = taken;
|
||||
}
|
||||
|
||||
public DataCenterVnetVO(String vnet, long dcId) {
|
||||
public DataCenterVnetVO(String vnet, long dcId, long physicalNetworkId) {
|
||||
this.vnet = vnet;
|
||||
this.dataCenterId = dcId;
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
this.takenAt = null;
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +98,10 @@ public class DataCenterVnetVO {
|
|||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
protected DataCenterVnetVO() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
|
|||
String[] getNextAvailableMacAddressPair(long id, long mask);
|
||||
Pair<String, Long> allocatePrivateIpAddress(long id, long podId, long instanceId, String reservationId);
|
||||
String allocateLinkLocalIpAddress(long id, long podId, long instanceId, String reservationId);
|
||||
String allocateVnet(long dcId, long accountId, String reservationId);
|
||||
String allocateVnet(long dcId, long physicalNetworkId, long accountId, String reservationId);
|
||||
|
||||
void releaseVnet(String vnet, long dcId, long accountId, String reservationId);
|
||||
void releaseVnet(String vnet, long dcId, long physicalNetworkId, long accountId, String reservationId);
|
||||
void releasePrivateIpAddress(String ipAddress, long dcId, Long instanceId);
|
||||
void releasePrivateIpAddress(long nicId, String reservationId);
|
||||
void releaseLinkLocalIpAddress(String ipAddress, long dcId, Long instanceId);
|
||||
|
|
@ -52,11 +52,7 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
|
|||
|
||||
List<DataCenterVnetVO> findVnet(long dcId, String vnet);
|
||||
|
||||
void addVnet(long dcId, int start, int end);
|
||||
|
||||
void deleteVnet(long dcId);
|
||||
|
||||
List<DataCenterVnetVO> listAllocatedVnets(long dcId);
|
||||
|
||||
String allocatePodVlan(long podId, long accountId);
|
||||
|
||||
|
|
@ -66,8 +62,6 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
|
|||
|
||||
List<DataCenterVO> findChildZones(Object[] ids);
|
||||
|
||||
List<DataCenterVO> listSecurityGroupEnabledZones();
|
||||
|
||||
void loadDetails(DataCenterVO zone);
|
||||
void saveDetails(DataCenterVO zone);
|
||||
|
||||
|
|
@ -75,4 +69,8 @@ public interface DataCenterDao extends GenericDao<DataCenterVO, Long> {
|
|||
List<DataCenterVO> listEnabledZones();
|
||||
DataCenterVO findByToken(String zoneToken);
|
||||
DataCenterVO findByTokenOrIdOrName(String tokenIdOrName);
|
||||
|
||||
void addVnet(long dcId, long physicalNetworkId, int start, int end);
|
||||
void deleteVnet(long dcId, long physicalNetworkId);
|
||||
List<DataCenterVnetVO> listAllocatedVnets(long dcId, long physicalNetworkId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import com.cloud.dc.DataCenterIpAddressVO;
|
|||
import com.cloud.dc.DataCenterLinkLocalIpAddressVO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.DataCenterVnetVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.PodVlanVO;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
|
|
@ -61,7 +60,6 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
protected SearchBuilder<DataCenterVO> ListZonesByDomainIdSearch;
|
||||
protected SearchBuilder<DataCenterVO> PublicZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> ChildZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> securityGroupSearch;
|
||||
protected SearchBuilder<DataCenterVO> DisabledZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> TokenSearch;
|
||||
|
||||
|
|
@ -112,15 +110,8 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> listSecurityGroupEnabledZones() {
|
||||
SearchCriteria<DataCenterVO> sc = securityGroupSearch.create();
|
||||
sc.setParameters("isSgEnabled", true);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseVnet(String vnet, long dcId, long accountId, String reservationId) {
|
||||
_vnetAllocDao.release(vnet, dcId, accountId, reservationId);
|
||||
public void releaseVnet(String vnet, long dcId, long physicalNetworkId, long accountId, String reservationId) {
|
||||
_vnetAllocDao.release(vnet, dcId, physicalNetworkId, accountId, reservationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -159,8 +150,8 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public String allocateVnet(long dataCenterId, long accountId, String reservationId) {
|
||||
DataCenterVnetVO vo = _vnetAllocDao.take(dataCenterId, accountId, reservationId);
|
||||
public String allocateVnet(long dataCenterId, long physicalNetworkId, long accountId, String reservationId) {
|
||||
DataCenterVnetVO vo = _vnetAllocDao.take(dataCenterId, physicalNetworkId, accountId, reservationId);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -214,21 +205,28 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
return vo.getIpAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVnet(long dcId, int start, int end) {
|
||||
_vnetAllocDao.add(dcId, start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVnet(long dcId) {
|
||||
_vnetAllocDao.delete(dcId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVnetVO> listAllocatedVnets(long dcId) {
|
||||
return _vnetAllocDao.listAllocatedVnets(dcId);
|
||||
public void addVnet(long dcId, long physicalNetworkId, int start, int end) {
|
||||
_vnetAllocDao.add(dcId, physicalNetworkId, start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVnet(long dcId, long physicalNetworkId) {
|
||||
_vnetAllocDao.delete(dcId, physicalNetworkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataCenterVnetVO> listAllocatedVnets(long dcId, long physicalNetworkId) {
|
||||
return _vnetAllocDao.listAllocatedVnets(dcId, physicalNetworkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPrivateIpAddress(long dcId,long podId, String start, String end) {
|
||||
_ipAllocDao.addIpRange(dcId, podId, start, end);
|
||||
|
|
@ -276,10 +274,6 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
|||
ChildZonesSearch.and("domainid", ChildZonesSearch.entity().getDomainId(), SearchCriteria.Op.IN);
|
||||
ChildZonesSearch.done();
|
||||
|
||||
securityGroupSearch = createSearchBuilder();
|
||||
securityGroupSearch.and("isSgEnabled", securityGroupSearch.entity().isSecurityGroupEnabled(), SearchCriteria.Op.EQ);
|
||||
securityGroupSearch.done();
|
||||
|
||||
DisabledZonesSearch = createSearchBuilder();
|
||||
DisabledZonesSearch.and("allocationState", DisabledZonesSearch.entity().getAllocationState(), SearchCriteria.Op.EQ);
|
||||
DisabledZonesSearch.done();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
|
||||
/**
|
||||
* DataCenterVnetDaoImpl maintains the one-to-many relationship between
|
||||
* data center and the vnet that appears within its network.
|
||||
* data center/physical_network and the vnet that appears within the physical network.
|
||||
*/
|
||||
@DB(txn=false)
|
||||
public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long> implements GenericDao<DataCenterVnetVO, Long> {
|
||||
|
|
@ -47,7 +47,14 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
sc.setParameters("dc", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
public List<DataCenterVnetVO> listAllocatedVnets(long dcId, long physicalNetworkId) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = DcSearchAllocated.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
public List<DataCenterVnetVO> findVnet(long dcId, String vnet) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = VnetDcSearch.create();;
|
||||
sc.setParameters("dc", dcId);
|
||||
|
|
@ -55,9 +62,18 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
public List<DataCenterVnetVO> findVnet(long dcId, long physicalNetworkId, String vnet) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = VnetDcSearch.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
sc.setParameters("vnet", vnet);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@DB
|
||||
public void add(long dcId, int start, int end) {
|
||||
String insertVnet = "INSERT INTO `cloud`.`op_dc_vnet_alloc` (vnet, data_center_id) VALUES ( ?, ?)";
|
||||
public void add(long dcId, long physicalNetworkId, int start, int end) {
|
||||
String insertVnet = "INSERT INTO `cloud`.`op_dc_vnet_alloc` (vnet, data_center_id, physical_network_id) VALUES ( ?, ?, ?)";
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
|
|
@ -66,6 +82,7 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
for (int i = start; i <= end; i++) {
|
||||
stmt.setString(1, String.valueOf(i));
|
||||
stmt.setLong(2, dcId);
|
||||
stmt.setLong(3, physicalNetworkId);
|
||||
stmt.addBatch();
|
||||
}
|
||||
stmt.executeBatch();
|
||||
|
|
@ -78,14 +95,22 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
public void delete(long dcId) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = VnetDcSearch.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
remove(sc);
|
||||
}
|
||||
|
||||
public void delete(long dcId, long physicalNetworkId) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = VnetDcSearch.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
|
||||
remove(sc);
|
||||
}
|
||||
|
||||
@DB
|
||||
public DataCenterVnetVO take(long dcId, long accountId, String reservationId) {
|
||||
public DataCenterVnetVO take(long dcId, long physicalNetworkId, long accountId, String reservationId) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = FreeVnetSearch.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
Date now = new Date();
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
|
@ -102,10 +127,11 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
return vo;
|
||||
}
|
||||
|
||||
public void release(String vnet, long dcId, long accountId, String reservationId) {
|
||||
public void release(String vnet, long dcId, long physicalNetworkId, long accountId, String reservationId) {
|
||||
SearchCriteria<DataCenterVnetVO> sc = VnetDcSearchAllocated.create();
|
||||
sc.setParameters("vnet", vnet);
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
sc.setParameters("account", accountId);
|
||||
sc.setParameters("reservation", reservationId);
|
||||
|
||||
|
|
@ -124,25 +150,30 @@ public class DataCenterVnetDaoImpl extends GenericDaoBase<DataCenterVnetVO, Long
|
|||
super();
|
||||
DcSearchAllocated = createSearchBuilder();
|
||||
DcSearchAllocated.and("dc", DcSearchAllocated.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
DcSearchAllocated.and("physicalNetworkId", DcSearchAllocated.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
|
||||
DcSearchAllocated.and("allocated", DcSearchAllocated.entity().getTakenAt(), SearchCriteria.Op.NNULL);
|
||||
DcSearchAllocated.done();
|
||||
|
||||
FreeVnetSearch = createSearchBuilder();
|
||||
FreeVnetSearch.and("dc", FreeVnetSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
FreeVnetSearch.and("physicalNetworkId", FreeVnetSearch.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
|
||||
FreeVnetSearch.and("taken", FreeVnetSearch.entity().getTakenAt(), SearchCriteria.Op.NULL);
|
||||
FreeVnetSearch.done();
|
||||
|
||||
VnetDcSearch = createSearchBuilder();
|
||||
VnetDcSearch.and("vnet", VnetDcSearch.entity().getVnet(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearch.and("dc", VnetDcSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearch.and("physicalNetworkId", VnetDcSearch.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearch.done();
|
||||
|
||||
VnetDcSearchAllocated = createSearchBuilder();
|
||||
VnetDcSearchAllocated.and("vnet", VnetDcSearchAllocated.entity().getVnet(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearchAllocated.and("dc", VnetDcSearchAllocated.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearchAllocated.and("physicalNetworkId", VnetDcSearchAllocated.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearchAllocated.and("taken", VnetDcSearchAllocated.entity().getTakenAt(), SearchCriteria.Op.NNULL);
|
||||
VnetDcSearchAllocated.and("account", VnetDcSearchAllocated.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearchAllocated.and("reservation", VnetDcSearchAllocated.entity().getReservationId(), SearchCriteria.Op.EQ);
|
||||
VnetDcSearchAllocated.done();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import com.cloud.api.commands.DeleteExternalFirewallCmd;
|
|||
import com.cloud.api.commands.DeleteExternalLoadBalancerCmd;
|
||||
import com.cloud.api.commands.ListExternalFirewallsCmd;
|
||||
import com.cloud.api.commands.ListExternalLoadBalancersCmd;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
|
|
@ -91,7 +90,7 @@ public interface ExternalNetworkManager extends Manager {
|
|||
|
||||
// General methods
|
||||
|
||||
public int getVlanOffset(DataCenter zone, int vlanTag);
|
||||
public int getVlanOffset(long physicalNetworkId, int vlanTag);
|
||||
|
||||
public int getGloballyConfiguredCidrSize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ import com.cloud.network.dao.IPAddressDao;
|
|||
import com.cloud.network.dao.InlineLoadBalancerNicMapDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.VpnUserDao;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
|
|
@ -147,6 +148,7 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager {
|
|||
@Inject VpnUserDao _vpnUsersDao;
|
||||
@Inject InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject PhysicalNetworkDao _physicalNetworkDao;
|
||||
|
||||
ScheduledExecutorService _executor;
|
||||
int _externalNetworkStatsInterval;
|
||||
|
|
@ -902,7 +904,7 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager {
|
|||
String[] ipRange = vpn.getIpRange().split("-");
|
||||
DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
|
||||
int vlanTag = Integer.parseInt(network.getBroadcastUri().getHost());
|
||||
int offset = getVlanOffset(zone, vlanTag);
|
||||
int offset = getVlanOffset(network.getPhysicalNetworkId(), vlanTag);
|
||||
int cidrSize = getGloballyConfiguredCidrSize();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
|
@ -980,12 +982,16 @@ public class ExternalNetworkManagerImpl implements ExternalNetworkManager {
|
|||
return (detail != null && detail.getValue().equals("true"));
|
||||
}
|
||||
|
||||
public int getVlanOffset(DataCenter zone, int vlanTag) {
|
||||
if (zone.getVnet() == null) {
|
||||
throw new CloudRuntimeException("Could not find vlan range for zone " + zone.getName() + ".");
|
||||
public int getVlanOffset(long physicalNetworkId, int vlanTag) {
|
||||
PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (pNetwork == null) {
|
||||
throw new CloudRuntimeException("Could not find the physical Network " + physicalNetworkId + ".");
|
||||
}
|
||||
|
||||
String vlanRange[] = zone.getVnet().split("-");
|
||||
if (pNetwork.getVnet() == null) {
|
||||
throw new CloudRuntimeException("Could not find vlan range for physical Network " + physicalNetworkId + ".");
|
||||
}
|
||||
String vlanRange[] = pNetwork.getVnet().split("-");
|
||||
int lowestVlanTag = Integer.valueOf(vlanRange[0]);
|
||||
return vlanTag - lowestVlanTag;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ package com.cloud.network;
|
|||
|
||||
import java.net.URI;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
|
@ -56,6 +59,7 @@ import com.cloud.dc.AccountVlanMapVO;
|
|||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.DataCenterVnetVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodVlanMapVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
|
|
@ -92,11 +96,15 @@ import com.cloud.network.Network.Service;
|
|||
import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork.BroadcastDomainRange;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkDomainDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
|
||||
import com.cloud.network.element.FirewallServiceProvider;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.PasswordServiceProvider;
|
||||
|
|
@ -236,7 +244,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
@Inject DomainManager _domainMgr;
|
||||
@Inject ProjectManager _projectMgr;
|
||||
@Inject NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
||||
|
||||
@Inject PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject PhysicalNetworkServiceProviderDao _pNSPDao;
|
||||
|
||||
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
|
|
@ -3389,4 +3398,475 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String> isolationMethods, String broadcastDomainRangeStr, Long domainId, List<String> tags) {
|
||||
// Check if zone exists
|
||||
if (zoneId == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid zone.");
|
||||
}
|
||||
|
||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid zone.");
|
||||
}
|
||||
|
||||
if (tags != null && tags.size() > 1) {
|
||||
throw new InvalidParameterException("Only one tag can be specified for a physical network at this time");
|
||||
}
|
||||
|
||||
if (isolationMethods != null && isolationMethods.size() > 1) {
|
||||
throw new InvalidParameterException("Only one isolationMethod can be specified for a physical network at this time");
|
||||
}
|
||||
|
||||
int vnetStart = 0;
|
||||
int vnetEnd = 0;
|
||||
if (vnetRange != null) {
|
||||
String[] tokens = vnetRange.split("-");
|
||||
try {
|
||||
vnetStart = Integer.parseInt(tokens[0]);
|
||||
if (tokens.length == 1) {
|
||||
vnetEnd = vnetStart;
|
||||
} else {
|
||||
vnetEnd = Integer.parseInt(tokens[1]);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidParameterValueException("Please specify valid integers for the vlan range.");
|
||||
}
|
||||
|
||||
if ((vnetStart > vnetEnd) || (vnetStart < 0) || (vnetEnd > 4096)) {
|
||||
s_logger.warn("Invalid vnet range: start range:" + vnetStart + " end range:" + vnetEnd);
|
||||
throw new InvalidParameterValueException("Vnet range should be between 0-4096 and start range should be lesser than or equal to end range");
|
||||
}
|
||||
}
|
||||
|
||||
BroadcastDomainRange broadcastDomainRange = null;
|
||||
if (broadcastDomainRangeStr != null && !broadcastDomainRangeStr.isEmpty()) {
|
||||
try {
|
||||
broadcastDomainRange = PhysicalNetwork.BroadcastDomainRange.valueOf(broadcastDomainRangeStr);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new InvalidParameterValueException("Unable to resolve broadcastDomainRange '" + broadcastDomainRangeStr + "' to a supported value {Pod or Zone}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
// Create the new physical network in the database
|
||||
PhysicalNetworkVO pNetwork = new PhysicalNetworkVO(zoneId, vnetRange, networkSpeed, domainId, broadcastDomainRange);
|
||||
pNetwork.setTags(tags);
|
||||
pNetwork.setIsolationMethods(isolationMethods);
|
||||
|
||||
pNetwork = _physicalNetworkDao.persist(pNetwork);
|
||||
|
||||
// Add vnet entries for the new zone if zone type is Advanced
|
||||
if (vnetRange != null) {
|
||||
_dcDao.addVnet(zone.getId(), pNetwork.getId(), vnetStart, vnetEnd);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return pNetwork;
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new CloudRuntimeException("Fail to create a physical network");
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize){
|
||||
Filter searchFilter = new Filter(PhysicalNetworkVO.class, "id", Boolean.TRUE, startIndex, pageSize);
|
||||
SearchCriteria<PhysicalNetworkVO> sc = _physicalNetworkDao.createSearchCriteria();
|
||||
|
||||
if (id != null) {
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, id);
|
||||
}
|
||||
|
||||
if (zoneId != null) {
|
||||
sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
|
||||
}
|
||||
return _physicalNetworkDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> isolationMethods, List<String> tags, String newVnetRangeString, String state) {
|
||||
|
||||
// verify input parameters
|
||||
PhysicalNetworkVO network = _physicalNetworkDao.findById(id);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Network id=" + id + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
if (tags != null && tags.size() > 1) {
|
||||
throw new InvalidParameterException("Unable to support more than one tag on network yet");
|
||||
}
|
||||
|
||||
if (isolationMethods != null && isolationMethods.size() > 1) {
|
||||
throw new InvalidParameterException("Only one isolationMethod can be specified for a physical network at this time");
|
||||
}
|
||||
|
||||
PhysicalNetwork.State networkState = null;
|
||||
if (state != null && !state.isEmpty()) {
|
||||
try {
|
||||
networkState = PhysicalNetwork.State.valueOf(state);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new InvalidParameterValueException("Unable to resolve state '" + state + "' to a supported value {Enabled or Disabled}");
|
||||
}
|
||||
}
|
||||
|
||||
if(state != null){
|
||||
network.setState(networkState);
|
||||
}
|
||||
|
||||
if (tags != null) {
|
||||
network.setTags(tags);
|
||||
}
|
||||
|
||||
if (isolationMethods != null) {
|
||||
for(String isMethod : isolationMethods){
|
||||
PhysicalNetwork.IsolationMethod isolationMethodVal = null;
|
||||
if (isMethod != null && !isMethod.isEmpty()) {
|
||||
try {
|
||||
isolationMethodVal = PhysicalNetwork.IsolationMethod.valueOf(isMethod);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new InvalidParameterValueException("Unable to resolve IsolationMethod '" + isMethod + "' to a supported value {VLAN or L3 or GRE}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network.setIsolationMethods(isolationMethods);
|
||||
}
|
||||
|
||||
if(networkSpeed != null){
|
||||
network.setSpeed(networkSpeed);
|
||||
}
|
||||
|
||||
// Vnet range can be extended only
|
||||
boolean replaceVnet = false;
|
||||
ArrayList<Pair<Integer, Integer>> vnetsToAdd = new ArrayList<Pair<Integer, Integer>>(2);
|
||||
|
||||
if (newVnetRangeString != null) {
|
||||
Integer newStartVnet = 0;
|
||||
Integer newEndVnet = 0;
|
||||
String[] newVnetRange = newVnetRangeString.split("-");
|
||||
|
||||
if (newVnetRange.length < 2) {
|
||||
throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096");
|
||||
}
|
||||
|
||||
if (newVnetRange[0] == null || newVnetRange[1] == null) {
|
||||
throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096");
|
||||
}
|
||||
|
||||
try {
|
||||
newStartVnet = Integer.parseInt(newVnetRange[0]);
|
||||
newEndVnet = Integer.parseInt(newVnetRange[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
s_logger.warn("Unable to parse vnet range:", e);
|
||||
throw new InvalidParameterValueException("Please provide valid vnet range between 0-4096");
|
||||
}
|
||||
|
||||
if (newStartVnet < 0 || newEndVnet > 4096) {
|
||||
throw new InvalidParameterValueException("Vnet range has to be between 0-4096");
|
||||
}
|
||||
|
||||
if (newStartVnet > newEndVnet) {
|
||||
throw new InvalidParameterValueException("Vnet range has to be between 0-4096 and start range should be lesser than or equal to stop range");
|
||||
}
|
||||
|
||||
if (physicalNetworkHasAllocatedVnets(network.getDataCenterId(), network.getId())) {
|
||||
String[] existingRange = network.getVnet().split("-");
|
||||
int existingStartVnet = Integer.parseInt(existingRange[0]);
|
||||
int existingEndVnet = Integer.parseInt(existingRange[1]);
|
||||
|
||||
//check if vnet is being extended
|
||||
if (!(newStartVnet.intValue() > existingStartVnet && newEndVnet.intValue() < existingEndVnet)) {
|
||||
throw new InvalidParameterValueException("Can's shrink existing vnet range as it the range has vnets allocated. Only extending existing vnet is supported");
|
||||
}
|
||||
|
||||
if (newStartVnet < existingStartVnet) {
|
||||
vnetsToAdd.add(new Pair<Integer, Integer>(newStartVnet, existingStartVnet - 1));
|
||||
}
|
||||
|
||||
if (newEndVnet > existingEndVnet) {
|
||||
vnetsToAdd.add(new Pair<Integer, Integer>(existingEndVnet + 1, newEndVnet));
|
||||
}
|
||||
|
||||
} else {
|
||||
vnetsToAdd.add(new Pair<Integer, Integer>(newStartVnet, newEndVnet));
|
||||
replaceVnet = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (newVnetRangeString != null) {
|
||||
network.setVnet(newVnetRangeString);
|
||||
}
|
||||
|
||||
|
||||
_physicalNetworkDao.update(id, network);
|
||||
|
||||
if (replaceVnet) {
|
||||
s_logger.debug("Deleting existing vnet range for the physicalNetwork id= "+id +" and zone id=" + network.getDataCenterId() + " as a part of updatePhysicalNetwork call");
|
||||
_dcDao.deleteVnet(network.getDataCenterId(), network.getId());
|
||||
}
|
||||
|
||||
for (Pair<Integer, Integer> vnetToAdd : vnetsToAdd) {
|
||||
s_logger.debug("Adding vnet range " + vnetToAdd.first() + "-" + vnetToAdd.second() + " for the physicalNetwork id= "+id +" and zone id=" + network.getDataCenterId() + " as a part of updatePhysicalNetwork call");
|
||||
_dcDao.addVnet(network.getDataCenterId(), network.getId(), vnetToAdd.first(), vnetToAdd.second());
|
||||
}
|
||||
|
||||
return network;
|
||||
}
|
||||
|
||||
private boolean physicalNetworkHasAllocatedVnets(long zoneId, long physicalNetworkId) {
|
||||
return !_dcDao.listAllocatedVnets(zoneId, physicalNetworkId).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePhysicalNetwork(Long physicalNetworkId) {
|
||||
|
||||
// verify input parameters
|
||||
PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Network id=" + physicalNetworkId + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
//delete physical network only if no network is associated to it
|
||||
List<NetworkVO> networks = _networksDao.listByPhysicalNetwork(physicalNetworkId);
|
||||
|
||||
if(networks != null && !networks.isEmpty()){
|
||||
s_logger.debug("Unable to remove the physical network id=" + physicalNetworkId + " as it has active networks associated.");
|
||||
return false;
|
||||
}
|
||||
|
||||
List<DataCenterVnetVO> allocatedVnets = _dcDao.listAllocatedVnets(network.getDataCenterId(), physicalNetworkId);
|
||||
|
||||
if(allocatedVnets != null && !allocatedVnets.isEmpty()){
|
||||
s_logger.debug("Unable to remove the physical network id=" + physicalNetworkId + " as it has active vnets associated.");
|
||||
return false;
|
||||
}
|
||||
//checkIfPhysicalNetworkIsDeletable(physicalNetworkId);
|
||||
|
||||
return _physicalNetworkDao.remove(physicalNetworkId);
|
||||
}
|
||||
|
||||
@DB
|
||||
private void checkIfPhysicalNetworkIsDeletable(Long physicalNetworkId) {
|
||||
List<List<String>> tablesToCheck = new ArrayList<List<String>>();
|
||||
|
||||
List<String> networks = new ArrayList<String>();
|
||||
networks.add(0, "networks");
|
||||
networks.add(1, "physical_network_id");
|
||||
networks.add(2, "there are networks associated to this physical network");
|
||||
tablesToCheck.add(networks);
|
||||
|
||||
/*List<String> privateIP = new ArrayList<String>();
|
||||
privateIP.add(0, "op_dc_ip_address_alloc");
|
||||
privateIP.add(1, "data_center_id");
|
||||
privateIP.add(2, "there are private IP addresses allocated for this zone");
|
||||
tablesToCheck.add(privateIP);
|
||||
|
||||
List<String> publicIP = new ArrayList<String>();
|
||||
publicIP.add(0, "user_ip_address");
|
||||
publicIP.add(1, "data_center_id");
|
||||
publicIP.add(2, "there are public IP addresses allocated for this zone");
|
||||
tablesToCheck.add(publicIP);
|
||||
|
||||
List<String> vmInstance = new ArrayList<String>();
|
||||
vmInstance.add(0, "vm_instance");
|
||||
vmInstance.add(1, "data_center_id");
|
||||
vmInstance.add(2, "there are virtual machines running in this zone");
|
||||
tablesToCheck.add(vmInstance);
|
||||
|
||||
List<String> volumes = new ArrayList<String>();
|
||||
volumes.add(0, "volumes");
|
||||
volumes.add(1, "data_center_id");
|
||||
volumes.add(2, "there are storage volumes for this zone");
|
||||
tablesToCheck.add(volumes);*/
|
||||
|
||||
List<String> vnet = new ArrayList<String>();
|
||||
vnet.add(0, "op_dc_vnet_alloc");
|
||||
vnet.add(1, "physical_network_id");
|
||||
vnet.add(2, "there are allocated vnets for this physical network");
|
||||
tablesToCheck.add(vnet);
|
||||
|
||||
for (List<String> table : tablesToCheck) {
|
||||
String tableName = table.get(0);
|
||||
String column = table.get(1);
|
||||
String errorMsg = table.get(2);
|
||||
|
||||
String dbName = "cloud";
|
||||
|
||||
String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
|
||||
|
||||
if (tableName.equals("op_dc_vnet_alloc")) {
|
||||
selectSql += " AND taken IS NOT NULL";
|
||||
}
|
||||
|
||||
if (tableName.equals("user_ip_address")) {
|
||||
selectSql += " AND state!='Free'";
|
||||
}
|
||||
|
||||
if (tableName.equals("op_dc_ip_address_alloc")) {
|
||||
selectSql += " AND taken IS NOT NULL";
|
||||
}
|
||||
|
||||
if (tableName.equals("host_pod_ref") || tableName.equals("host") || tableName.equals("volumes")) {
|
||||
selectSql += " AND removed is NULL";
|
||||
}
|
||||
|
||||
if (tableName.equals("vm_instance")) {
|
||||
selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "'";
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
|
||||
stmt.setLong(1, physicalNetworkId);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
if (rs != null && rs.next()) {
|
||||
throw new CloudRuntimeException("The Physical Network is not deletable because " + errorMsg);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new CloudRuntimeException("The Management Server failed to detect if physical network is deletable. Please contact Cloud Support.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Service> listNetworkServices(){
|
||||
return Service.listAllServices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName){
|
||||
Network.Service service = null;
|
||||
if(serviceName != null){
|
||||
service = Network.Service.getService(serviceName);
|
||||
if(service == null){
|
||||
throw new InvalidParameterValueException("Invalid Network Service=" + serviceName);
|
||||
}
|
||||
}
|
||||
|
||||
List<Provider> supportedProviders = new ArrayList<Provider>();
|
||||
for (NetworkElement element : _networkElements) {
|
||||
if(element.getProvider() != null){
|
||||
if(service != null){
|
||||
//chk if this serviceprovider supports this service
|
||||
if(isServiceProvided(element, service)){
|
||||
supportedProviders.add(element.getProvider());
|
||||
}
|
||||
}else{
|
||||
supportedProviders.add(element.getProvider());
|
||||
}
|
||||
}
|
||||
}
|
||||
return supportedProviders;
|
||||
}
|
||||
|
||||
private boolean isServiceProvided(NetworkElement element, Service service){
|
||||
if(element.getCapabilities() != null){
|
||||
return element.getCapabilities().containsKey(service);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName, Long destinationPhysicalNetworkId) {
|
||||
|
||||
// verify input parameters
|
||||
PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Physical Network id=" + physicalNetworkId + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
// verify input parameters
|
||||
if(destinationPhysicalNetworkId != null){
|
||||
PhysicalNetworkVO destNetwork = _physicalNetworkDao.findById(destinationPhysicalNetworkId);
|
||||
if (destNetwork == null) {
|
||||
throw new InvalidParameterValueException("Destination Physical Network id=" + destinationPhysicalNetworkId + "doesn't exist in the system");
|
||||
}
|
||||
}
|
||||
|
||||
if(providerName != null){
|
||||
Provider provider = Network.Provider.getProvider(providerName);
|
||||
if(provider == null){
|
||||
throw new InvalidParameterValueException("Invalid Network Service Provider=" + providerName);
|
||||
}
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
// Create the new physical network in the database
|
||||
PhysicalNetworkServiceProviderVO nsp = new PhysicalNetworkServiceProviderVO(physicalNetworkId, providerName);
|
||||
if(destinationPhysicalNetworkId != null){
|
||||
nsp.setDestinationPhysicalNetworkId(destinationPhysicalNetworkId);
|
||||
}
|
||||
nsp = _pNSPDao.persist(nsp);
|
||||
|
||||
txn.commit();
|
||||
return nsp;
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new CloudRuntimeException("Fail to add a provider to physical network");
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId) {
|
||||
PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Physical Network id=" + physicalNetworkId + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
return _pNSPDao.listBy(physicalNetworkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, Boolean enabled) {
|
||||
|
||||
PhysicalNetworkServiceProviderVO provider = _pNSPDao.findById(id);
|
||||
|
||||
if(provider == null){
|
||||
throw new InvalidParameterValueException("Network Service Provider id=" + id + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
if(enabled){
|
||||
//TODO: need to check if the provider is ready for the physical network.
|
||||
provider.setState(PhysicalNetworkServiceProvider.State.Enabled);
|
||||
}else{
|
||||
//do we need to do anything for the provider instances before disabling?
|
||||
provider.setState(PhysicalNetworkServiceProvider.State.Disabled);
|
||||
}
|
||||
|
||||
_pNSPDao.update(id, provider);
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteNetworkServiceProvider(Long id) {
|
||||
PhysicalNetworkServiceProviderVO provider = _pNSPDao.findById(id);
|
||||
|
||||
if(provider == null){
|
||||
throw new InvalidParameterValueException("Network Service Provider id=" + id + "doesn't exist in the system");
|
||||
}
|
||||
|
||||
//TODO provider instances?
|
||||
|
||||
return _pNSPDao.remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ public class NetworkVO implements Network {
|
|||
@Column(name="network_offering_id")
|
||||
long networkOfferingId;
|
||||
|
||||
@Column(name="physical_network_id")
|
||||
long physicalNetworkId;
|
||||
|
||||
@Column(name="data_center_id")
|
||||
long dataCenterId;
|
||||
|
||||
|
|
@ -181,6 +184,20 @@ public class NetworkVO implements Network {
|
|||
this.id = -1;
|
||||
this.guestType = guestType;
|
||||
}
|
||||
/**
|
||||
* Constructor to be used for the adapters because it only initializes what's needed.
|
||||
* @param trafficType
|
||||
* @param mode
|
||||
* @param broadcastDomainType
|
||||
* @param networkOfferingId
|
||||
* @param dataCenterId
|
||||
* @param state TODO
|
||||
* @param physicalNetworkId
|
||||
*/
|
||||
public NetworkVO(TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, State state, long physicalNetworkId) {
|
||||
this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId, state);
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, boolean isDefault, boolean isSecurityGroupEnabled, boolean isDomainSpecific, String networkDomain, Type type, boolean isShared) {
|
||||
this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText,isDefault, isDomainSpecific, networkDomain, type, isShared);
|
||||
|
|
@ -196,6 +213,11 @@ public class NetworkVO implements Network {
|
|||
}
|
||||
}
|
||||
|
||||
public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault, boolean isSecurityGroupEnabled, boolean isDomainSpecific, String networkDomain, Type type, long physicalNetworkId) {
|
||||
this(id, that, offeringId, dataCenterId, guruName, domainId, accountId, related, name, displayText, isDefault, isSecurityGroupEnabled, isDomainSpecific, networkDomain, type);
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the actual DAO object.
|
||||
* @param trafficType
|
||||
|
|
@ -381,6 +403,15 @@ public class NetworkVO implements Network {
|
|||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public void setPhysicalNetworkId(long physicalNetworkId) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,207 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
/**
|
||||
* NetworkConfigurationVO contains information about a specific physical network.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="physical_network")
|
||||
public class PhysicalNetworkVO implements PhysicalNetwork {
|
||||
@Id
|
||||
@TableGenerator(name="physical_networks_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="physical_networks_seq", allocationSize=1)
|
||||
@Column(name="id")
|
||||
long id;
|
||||
|
||||
@Column(name="data_center_id")
|
||||
long dataCenterId;
|
||||
|
||||
@Column(name="vnet")
|
||||
private String vnet = null;
|
||||
|
||||
@Column(name="speed")
|
||||
private String speed = null;
|
||||
|
||||
@Column(name="domain_id")
|
||||
Long domainId = null;
|
||||
|
||||
@Column(name="broadcast_domain_range")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
BroadcastDomainRange broadcastDomainRange;
|
||||
|
||||
@Column(name="state")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
State state;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
Date removed;
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
|
||||
@ElementCollection(targetClass = String.class, fetch=FetchType.EAGER)
|
||||
@Column(name="tag")
|
||||
@CollectionTable(name="physical_network_tags", joinColumns=@JoinColumn(name="physical_network_id"))
|
||||
List<String> tags;
|
||||
|
||||
@ElementCollection(targetClass = String.class, fetch=FetchType.EAGER)
|
||||
@Column(name="isolation_method")
|
||||
@CollectionTable(name="physical_network_isolation_methods", joinColumns=@JoinColumn(name="physical_network_id"))
|
||||
List<String> isolationMethods;
|
||||
|
||||
public PhysicalNetworkVO(){
|
||||
|
||||
}
|
||||
|
||||
public PhysicalNetworkVO(long dataCenterId, String vnet, String speed, Long domainId, BroadcastDomainRange broadcastDomainRange) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.setVnet(vnet);
|
||||
this.setSpeed(speed);
|
||||
this.domainId = domainId;
|
||||
if(broadcastDomainRange != null){
|
||||
this.broadcastDomainRange = broadcastDomainRange;
|
||||
}else{
|
||||
this.broadcastDomainRange = BroadcastDomainRange.Pod;
|
||||
}
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTags() {
|
||||
return tags != null ? tags : new ArrayList<String>();
|
||||
}
|
||||
|
||||
public void addTag(String tag) {
|
||||
if (tags == null) {
|
||||
tags = new ArrayList<String>();
|
||||
}
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
public void setTags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BroadcastDomainRange getBroadcastDomainRange() {
|
||||
return broadcastDomainRange;
|
||||
}
|
||||
|
||||
public void setBroadcastDomainRange(BroadcastDomainRange broadcastDomainRange) {
|
||||
this.broadcastDomainRange = broadcastDomainRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getIsolationMethods() {
|
||||
return isolationMethods != null ? isolationMethods : new ArrayList<String>();
|
||||
}
|
||||
|
||||
public void addIsolationMethod(String isolationMethod) {
|
||||
if (isolationMethods == null) {
|
||||
isolationMethods = new ArrayList<String>();
|
||||
}
|
||||
isolationMethods.add(isolationMethod);
|
||||
}
|
||||
|
||||
public void setIsolationMethods(List<String> isolationMethods) {
|
||||
this.isolationMethods = isolationMethods;
|
||||
}
|
||||
|
||||
public void setVnet(String vnet) {
|
||||
this.vnet = vnet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVnet() {
|
||||
return vnet;
|
||||
}
|
||||
|
||||
public void setSpeed(String speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
}
|
||||
|
|
@ -66,4 +66,8 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long> {
|
|||
List<NetworkVO> listByZoneIncludingRemoved(long zoneId);
|
||||
|
||||
Long getNetworkCountByOfferingId(long offeringId);
|
||||
|
||||
List<NetworkVO> listByPhysicalNetwork(long physicalNetworkId);
|
||||
|
||||
List<NetworkVO> listSecurityGroupEnabledNetworks();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import java.util.Random;
|
|||
import javax.ejb.Local;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkAccountDaoImpl;
|
||||
import com.cloud.network.NetworkAccountVO;
|
||||
import com.cloud.network.NetworkDomainVO;
|
||||
|
|
@ -32,7 +32,6 @@ import com.cloud.network.NetworkVO;
|
|||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.storage.dao.VolumeDaoImpl.SumCount;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
@ -56,7 +55,9 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
|||
final SearchBuilder<NetworkVO> ZoneBroadcastUriSearch;
|
||||
final SearchBuilder<NetworkVO> ZoneSecurityGroupSearch;
|
||||
final GenericSearchBuilder<NetworkVO, Long> CountByOfferingId;
|
||||
|
||||
final SearchBuilder<NetworkVO> PhysicalNetworkSearch;
|
||||
final SearchBuilder<NetworkVO> securityGroupSearch;
|
||||
|
||||
NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class);
|
||||
NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class);
|
||||
NetworkOpDaoImpl _opDao = ComponentLocator.inject(NetworkOpDaoImpl.class);
|
||||
|
|
@ -78,6 +79,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
|||
AllFieldsSearch.and("guesttype", AllFieldsSearch.entity().getGuestType(), Op.EQ);
|
||||
AllFieldsSearch.and("related", AllFieldsSearch.entity().getRelated(), Op.EQ);
|
||||
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), Op.EQ);
|
||||
AllFieldsSearch.and("physicalNetwork", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
AccountSearch = createSearchBuilder();
|
||||
|
|
@ -121,6 +123,15 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
|||
CountByOfferingId.and("removed", CountByOfferingId.entity().getRemoved(), Op.NULL);
|
||||
CountByOfferingId.done();
|
||||
|
||||
|
||||
PhysicalNetworkSearch = createSearchBuilder();
|
||||
PhysicalNetworkSearch.and("physicalNetworkId", PhysicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
PhysicalNetworkSearch.done();
|
||||
|
||||
securityGroupSearch = createSearchBuilder();
|
||||
securityGroupSearch.and("isSgEnabled", securityGroupSearch.entity().isSecurityGroupEnabled(), SearchCriteria.Op.EQ);
|
||||
securityGroupSearch.done();
|
||||
|
||||
_tgMacAddress = _tgs.get("macAddress");
|
||||
|
||||
}
|
||||
|
|
@ -331,4 +342,18 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
|||
List<Long> results = customSearch(sc, null);
|
||||
return results.get(0);
|
||||
}
|
||||
|
||||
public List<NetworkVO> listByPhysicalNetwork(long physicalNetworkId){
|
||||
SearchCriteria<NetworkVO> sc = PhysicalNetworkSearch.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listSecurityGroupEnabledNetworks() {
|
||||
SearchCriteria<NetworkVO> sc = securityGroupSearch.create();
|
||||
sc.setParameters("isSgEnabled", true);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.PhysicalNetworkVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PhysicalNetworkDao extends GenericDao<PhysicalNetworkVO, Long> {
|
||||
List<PhysicalNetworkVO> listByZone(long zoneId);
|
||||
List<PhysicalNetworkVO> listByZoneIncludingRemoved(long zoneId);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.network.PhysicalNetworkVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Local(value=PhysicalNetworkDao.class) @DB(txn=false)
|
||||
public class PhysicalNetworkDaoImpl extends GenericDaoBase<PhysicalNetworkVO, Long> implements PhysicalNetworkDao {
|
||||
final SearchBuilder<PhysicalNetworkVO> ZoneSearch;
|
||||
|
||||
protected PhysicalNetworkDaoImpl() {
|
||||
super();
|
||||
ZoneSearch = createSearchBuilder();
|
||||
ZoneSearch.and("dataCenterId", ZoneSearch.entity().getDataCenterId(), Op.EQ);
|
||||
ZoneSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PhysicalNetworkVO> listByZone(long zoneId) {
|
||||
SearchCriteria<PhysicalNetworkVO> sc = ZoneSearch.create();
|
||||
sc.setParameters("dataCenterId", zoneId);
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PhysicalNetworkVO> listByZoneIncludingRemoved(long zoneId) {
|
||||
SearchCriteria<PhysicalNetworkVO> sc = ZoneSearch.create();
|
||||
sc.setParameters("dataCenterId", zoneId);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
|
||||
public class PhysicalNetworkIsolationMethodDaoImpl extends GenericDaoBase<PhysicalNetworkIsolationMethodVO, Long> implements GenericDao<PhysicalNetworkIsolationMethodVO, Long> {
|
||||
private final GenericSearchBuilder<PhysicalNetworkIsolationMethodVO, String> IsolationMethodSearch;
|
||||
private final SearchBuilder<PhysicalNetworkIsolationMethodVO> AllFieldsSearch;
|
||||
|
||||
protected PhysicalNetworkIsolationMethodDaoImpl() {
|
||||
super();
|
||||
IsolationMethodSearch = createSearchBuilder(String.class);
|
||||
IsolationMethodSearch.selectField(IsolationMethodSearch.entity().getIsolationMethod());
|
||||
IsolationMethodSearch.and("physicalNetworkId", IsolationMethodSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
IsolationMethodSearch.done();
|
||||
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
|
||||
AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
AllFieldsSearch.and("isolationMethod", AllFieldsSearch.entity().getIsolationMethod(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
}
|
||||
|
||||
public List<String> getAllIsolationMethod(long physicalNetworkId) {
|
||||
SearchCriteria<String> sc = IsolationMethodSearch.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
public String getIsolationMethod(long physicalNetworkId) {
|
||||
SearchCriteria<String> sc = IsolationMethodSearch.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
public int clearIsolationMethods(long physicalNetworkId) {
|
||||
SearchCriteria<PhysicalNetworkIsolationMethodVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
|
||||
return remove(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* This class is just used to work with the DAO. It shouldn't be used anywhere.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "physical_network_isolation_methods")
|
||||
public class PhysicalNetworkIsolationMethodVO {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "physical_network_id")
|
||||
private long physicalNetworkId;
|
||||
|
||||
@Column(name = "isolation_method")
|
||||
private String isolationMethod;
|
||||
|
||||
/**
|
||||
* There should never be a public constructor for this class. Since it's
|
||||
* only here to define the table for the DAO class.
|
||||
*/
|
||||
protected PhysicalNetworkIsolationMethodVO() {
|
||||
}
|
||||
|
||||
protected PhysicalNetworkIsolationMethodVO(long physicalNetworkId, String isolationMethod) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
this.isolationMethod = isolationMethod;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public String getIsolationMethod() {
|
||||
return isolationMethod;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface PhysicalNetworkServiceProviderDao extends GenericDao<PhysicalNetworkServiceProviderVO, Long> {
|
||||
List<PhysicalNetworkServiceProviderVO> listBy(long physicalNetworkId);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
@Local(value=PhysicalNetworkServiceProviderDao.class) @DB(txn=false)
|
||||
public class PhysicalNetworkServiceProviderDaoImpl extends GenericDaoBase<PhysicalNetworkServiceProviderVO, Long> implements PhysicalNetworkServiceProviderDao {
|
||||
final SearchBuilder<PhysicalNetworkServiceProviderVO> physicalNetworkSearch;
|
||||
|
||||
protected PhysicalNetworkServiceProviderDaoImpl() {
|
||||
super();
|
||||
physicalNetworkSearch = createSearchBuilder();
|
||||
physicalNetworkSearch.and("physicalNetworkId", physicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
physicalNetworkSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PhysicalNetworkServiceProviderVO> listBy(long physicalNetworkId) {
|
||||
SearchCriteria<PhysicalNetworkServiceProviderVO> sc = physicalNetworkSearch.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
|
||||
@Entity
|
||||
@Table(name = "physical_network_service_providers")
|
||||
public class PhysicalNetworkServiceProviderVO implements PhysicalNetworkServiceProvider {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "physical_network_id")
|
||||
private long physicalNetworkId;
|
||||
|
||||
@Column(name = "destination_physical_network_id")
|
||||
private long destPhysicalNetworkId;
|
||||
|
||||
|
||||
@Column(name = "provider_name")
|
||||
private String providerName;
|
||||
|
||||
@Column(name="state")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
State state;
|
||||
|
||||
public PhysicalNetworkServiceProviderVO() {
|
||||
}
|
||||
|
||||
public PhysicalNetworkServiceProviderVO(long physicalNetworkId, String name) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
this.providerName = name;
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderName() {
|
||||
return providerName;
|
||||
}
|
||||
|
||||
public void setDestinationPhysicalNetworkId(long destPhysicalNetworkId) {
|
||||
this.destPhysicalNetworkId = destPhysicalNetworkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDestinationPhysicalNetworkId() {
|
||||
return destPhysicalNetworkId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
|
||||
|
||||
public class PhysicalNetworkTagDaoImpl extends GenericDaoBase<PhysicalNetworkTagVO, Long> implements GenericDao<PhysicalNetworkTagVO, Long> {
|
||||
private final GenericSearchBuilder<PhysicalNetworkTagVO, String> TagSearch;
|
||||
private final SearchBuilder<PhysicalNetworkTagVO> AllFieldsSearch;
|
||||
|
||||
protected PhysicalNetworkTagDaoImpl() {
|
||||
super();
|
||||
TagSearch = createSearchBuilder(String.class);
|
||||
TagSearch.selectField(TagSearch.entity().getTag());
|
||||
TagSearch.and("physicalNetworkId", TagSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
TagSearch.done();
|
||||
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
|
||||
AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||
AllFieldsSearch.and("tag", AllFieldsSearch.entity().getTag(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
}
|
||||
|
||||
public List<String> getTags(long physicalNetworkId) {
|
||||
SearchCriteria<String> sc = TagSearch.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
public int clearTags(long physicalNetworkId) {
|
||||
SearchCriteria<PhysicalNetworkTagVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||
|
||||
return remove(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.dao;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* This class is just used to work with the DAO. It shouldn't be used anywhere.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "physical_network_tags")
|
||||
public class PhysicalNetworkTagVO {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
|
||||
@Column(name = "physical_network_id")
|
||||
private long physicalNetworkId;
|
||||
|
||||
@Column(name = "tag")
|
||||
private String tag;
|
||||
|
||||
/**
|
||||
* There should never be a public constructor for this class. Since it's
|
||||
* only here to define the table for the DAO class.
|
||||
*/
|
||||
protected PhysicalNetworkTagVO() {
|
||||
}
|
||||
|
||||
protected PhysicalNetworkTagVO(long physicalNetworkId, String tag) {
|
||||
this.physicalNetworkId = physicalNetworkId;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getPhysicalNetworkId() {
|
||||
return physicalNetworkId;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
// Get a vlan tag
|
||||
int vlanTag;
|
||||
if (config.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(zone.getId(), config.getAccountId(), context.getReservationId());
|
||||
String vnet = _dcDao.allocateVnet(zone.getId(), config.getPhysicalNetworkId(), config.getAccountId(), context.getReservationId());
|
||||
|
||||
try {
|
||||
vlanTag = Integer.parseInt(vnet);
|
||||
|
|
@ -130,7 +130,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
|||
}
|
||||
|
||||
// Determine the offset from the lowest vlan tag
|
||||
int offset = _externalNetworkMgr.getVlanOffset(zone, vlanTag);
|
||||
int offset = _externalNetworkMgr.getVlanOffset(config.getPhysicalNetworkId(), vlanTag);
|
||||
|
||||
// Determine the new gateway and CIDR
|
||||
String[] oldCidr = config.getCidr().split("/");
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
network.getDataCenterId(), State.Allocated);
|
||||
|
||||
if (network.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(dcId, network.getAccountId(), context.getReservationId());
|
||||
String vnet = _dcDao.allocateVnet(dcId, network.getPhysicalNetworkId(), network.getAccountId(), context.getReservationId());
|
||||
if (vnet == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
|
||||
s_logger.debug("Releasing vnet for the network id=" + profile.getId());
|
||||
if (profile.getBroadcastUri() != null) {
|
||||
_dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(), profile.getAccountId(), profile.getReservationId());
|
||||
_dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(), profile.getPhysicalNetworkId(), profile.getAccountId(), profile.getReservationId());
|
||||
EventUtils.saveEvent(UserContext.current().getCallerUserId(), profile.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_RELEASE, "Released Zone Vlan: "
|
||||
+profile.getBroadcastUri().getHost()+" for Network: "+profile.getId(), 0);
|
||||
profile.setBroadcastUri(null);
|
||||
|
|
|
|||
|
|
@ -3322,8 +3322,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
boolean securityGroupsEnabled = false;
|
||||
boolean elasticLoadBalancerEnabled = false;
|
||||
String supportELB = "false";
|
||||
List<DataCenterVO> dc = _dcDao.listSecurityGroupEnabledZones();
|
||||
if (dc != null && !dc.isEmpty()) {
|
||||
List<NetworkVO> networks = _networkDao.listSecurityGroupEnabledNetworks();
|
||||
if (networks != null && !networks.isEmpty()) {
|
||||
securityGroupsEnabled = true;
|
||||
String elbEnabled = _configDao.getValue(Config.ElasticLoadBalancerEnabled.key());
|
||||
elasticLoadBalancerEnabled = elbEnabled==null?false:Boolean.parseBoolean(elbEnabled);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public class DatabaseConfig {
|
|||
static {
|
||||
// initialize the objectNames ArrayList
|
||||
objectNames.add("zone");
|
||||
objectNames.add("physicalNetwork");
|
||||
objectNames.add("vlan");
|
||||
objectNames.add("pod");
|
||||
objectNames.add("cluster");
|
||||
|
|
@ -154,7 +155,6 @@ public class DatabaseConfig {
|
|||
fieldNames.add("tags");
|
||||
fieldNames.add("networktype");
|
||||
fieldNames.add("clusterId");
|
||||
|
||||
|
||||
|
||||
s_configurationDescriptions.put("host.stats.interval", "the interval in milliseconds when host stats are retrieved from agents");
|
||||
|
|
@ -431,6 +431,8 @@ public class DatabaseConfig {
|
|||
private void saveCurrentObject() {
|
||||
if ("zone".equals(_currentObjectName)) {
|
||||
saveZone();
|
||||
} else if ("physicalNetwork".equals(_currentObjectName)) {
|
||||
savePhysicalNetwork();
|
||||
} else if ("vlan".equals(_currentObjectName)) {
|
||||
saveVlan();
|
||||
} else if ("pod".equals(_currentObjectName)) {
|
||||
|
|
@ -618,7 +620,7 @@ public class DatabaseConfig {
|
|||
String dns2 = _currentObjectParams.get("dns2");
|
||||
String internalDns1 = _currentObjectParams.get("internalDns1");
|
||||
String internalDns2 = _currentObjectParams.get("internalDns2");
|
||||
String vnetRange = _currentObjectParams.get("vnet");
|
||||
//String vnetRange = _currentObjectParams.get("vnet");
|
||||
String guestNetworkCidr = _currentObjectParams.get("guestNetworkCidr");
|
||||
String networkType = _currentObjectParams.get("networktype");
|
||||
|
||||
|
|
@ -639,17 +641,27 @@ public class DatabaseConfig {
|
|||
if (!IPRangeConfig.validCIDR(guestNetworkCidr)) {
|
||||
printError("Please enter a valid value for guestNetworkCidr");
|
||||
}
|
||||
int vnetStart = -1;
|
||||
int vnetEnd = -1;
|
||||
if (vnetRange != null) {
|
||||
|
||||
pzc.saveZone(false, id, name, dns1, dns2, internalDns1, internalDns2, guestNetworkCidr, networkType);
|
||||
|
||||
}
|
||||
|
||||
private void savePhysicalNetwork() {
|
||||
long id = Long.parseLong(_currentObjectParams.get("id"));
|
||||
String zoneId = _currentObjectParams.get("zoneId");
|
||||
String vnetRange = _currentObjectParams.get("vnet");
|
||||
|
||||
int vnetStart = -1;
|
||||
int vnetEnd = -1;
|
||||
if (vnetRange != null) {
|
||||
String[] tokens = vnetRange.split("-");
|
||||
vnetStart = Integer.parseInt(tokens[0]);
|
||||
vnetEnd = Integer.parseInt(tokens[1]);
|
||||
}
|
||||
|
||||
pzc.saveZone(false, id, name, dns1, dns2, internalDns1, internalDns2, vnetStart, vnetEnd, guestNetworkCidr, networkType);
|
||||
long zoneDbId = Long.parseLong(zoneId);
|
||||
pzc.savePhysicalNetwork(false, id, zoneDbId, vnetStart, vnetEnd);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void saveVlan() {
|
||||
String zoneId = _currentObjectParams.get("zoneId");
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ public class PodZoneConfig {
|
|||
}
|
||||
|
||||
@DB
|
||||
public void saveZone(boolean printOutput, long id, String name, String dns1, String dns2, String dns3, String dns4, int vnetStart, int vnetEnd, String guestNetworkCidr, String networkType) {
|
||||
public void saveZone(boolean printOutput, long id, String name, String dns1, String dns2, String dns3, String dns4, String guestNetworkCidr, String networkType) {
|
||||
|
||||
if (printOutput) System.out.println("Saving zone, please wait...");
|
||||
|
||||
|
|
@ -299,10 +299,6 @@ public class PodZoneConfig {
|
|||
values += ",'" + networkType + "'";
|
||||
}
|
||||
|
||||
//save vnet information
|
||||
columns += ", vnet";
|
||||
values += ",'" + vnetStart + "-" + vnetEnd + "'";
|
||||
|
||||
|
||||
columns += ")";
|
||||
values += ")";
|
||||
|
|
@ -311,18 +307,46 @@ public class PodZoneConfig {
|
|||
|
||||
DatabaseConfig.saveSQL(sql, "Failed to save zone due to exception. Please contact Cloud Support.");
|
||||
|
||||
// Hardcode the vnet range to be the full range
|
||||
int begin = 0x64;
|
||||
if (printOutput) System.out.println("Successfully saved zone.");
|
||||
}
|
||||
|
||||
@DB
|
||||
public void savePhysicalNetwork(boolean printOutput, long id, long dcId, int vnetStart, int vnetEnd) {
|
||||
|
||||
if (printOutput) System.out.println("Saving physical network, please wait...");
|
||||
|
||||
String columns = null;
|
||||
String values = null;
|
||||
|
||||
columns = "(id ";
|
||||
values = "('" + id + "'";
|
||||
|
||||
columns += ", data_center_id ";
|
||||
values += ",'" + dcId + "'";
|
||||
|
||||
//save vnet information
|
||||
columns += ", vnet";
|
||||
values += ",'" + vnetStart + "-" + vnetEnd + "'";
|
||||
|
||||
|
||||
columns += ")";
|
||||
values += ")";
|
||||
|
||||
String sql = "INSERT INTO `cloud`.`physical_network` " + columns + " VALUES " + values;
|
||||
|
||||
DatabaseConfig.saveSQL(sql, "Failed to save physical network due to exception. Please contact Cloud Support.");
|
||||
|
||||
// Hardcode the vnet range to be the full range
|
||||
int begin = 0x64;
|
||||
int end = 64000;
|
||||
|
||||
// If vnet arguments were passed in, use them
|
||||
if (vnetStart != -1 && vnetEnd != -1) {
|
||||
begin = vnetStart;
|
||||
end = vnetEnd;
|
||||
begin = vnetStart;
|
||||
end = vnetEnd;
|
||||
}
|
||||
|
||||
long dcId = getZoneId(name);
|
||||
String insertVnet = "INSERT INTO `cloud`.`op_dc_vnet_alloc` (vnet, data_center_id) VALUES ( ?, ?)";
|
||||
String insertVnet = "INSERT INTO `cloud`.`op_dc_vnet_alloc` (vnet, data_center_id, physical_network_id) VALUES ( ?, ?, ?)";
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
|
|
@ -330,15 +354,16 @@ public class PodZoneConfig {
|
|||
for (int i = begin; i <= end; i++) {
|
||||
stmt.setString(1, Integer.toString(i));
|
||||
stmt.setLong(2, dcId);
|
||||
stmt.setLong(3, id);
|
||||
stmt.addBatch();
|
||||
}
|
||||
stmt.executeBatch();
|
||||
} catch (SQLException ex) {
|
||||
printError("Error creating vnet for the data center. Please contact Cloud Support.");
|
||||
printError("Error creating vnet for the physical network. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
if (printOutput) System.out.println("Successfully saved zone.");
|
||||
}
|
||||
|
||||
if (printOutput) System.out.println("Successfully saved physical network.");
|
||||
}
|
||||
|
||||
public void deleteZone(String name) {
|
||||
String sql = "DELETE FROM `cloud`.`data_center` WHERE name=\"" + name + "\"";
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ DROP TABLE IF EXISTS `cloud`.`data_center_details`;
|
|||
DROP TABLE IF EXISTS `cloud`.`network_tags`;
|
||||
DROP TABLE IF EXISTS `cloud`.`op_host_transfer`;
|
||||
DROP TABLE IF EXISTS `cloud`.`projects`;
|
||||
DROP TABLE IF EXISTS `cloud`.`physical_network`;
|
||||
|
||||
CREATE TABLE `cloud`.`version` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
|
|
@ -168,6 +169,7 @@ CREATE TABLE `cloud`.`networks` (
|
|||
`cidr` varchar(18) COMMENT 'network cidr',
|
||||
`mode` varchar(32) COMMENT 'How to retrieve ip address in this network',
|
||||
`network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id that this configuration is created from',
|
||||
`physical_network_id` bigint unsigned COMMENT 'physical network id that this configuration is based on',
|
||||
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this configuration is used in',
|
||||
`guru_name` varchar(255) NOT NULL COMMENT 'who is responsible for this type of network configuration',
|
||||
`state` varchar(32) NOT NULL COMMENT 'what state is this configuration in',
|
||||
|
|
@ -189,7 +191,7 @@ CREATE TABLE `cloud`.`networks` (
|
|||
`is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not',
|
||||
`type` char(32) COMMENT 'type of the network, can be Shared or Isolated',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`),
|
||||
CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`),
|
||||
CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_networks__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`),
|
||||
|
|
@ -371,6 +373,7 @@ INSERT INTO `cloud`.`sequence` (name, value) VALUES ('storage_pool_seq', 200);
|
|||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('volume_seq', 1);
|
||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('networks_seq', 200);
|
||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('checkpoint_seq', 1);
|
||||
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('physical_networks_seq', 200);
|
||||
|
||||
CREATE TABLE `cloud`.`volumes` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
|
||||
|
|
@ -483,7 +486,6 @@ CREATE TABLE `cloud`.`data_center` (
|
|||
`internal_dns2` varchar(255),
|
||||
`gateway` varchar(15),
|
||||
`netmask` varchar(15),
|
||||
`vnet` varchar(255),
|
||||
`router_mac_address` varchar(17) NOT NULL DEFAULT '02:00:00:00:00:01' COMMENT 'mac address for the router within the domain',
|
||||
`mac_address` bigint unsigned NOT NULL DEFAULT '1' COMMENT 'Next available mac address for the ethernet card interacting with public internet',
|
||||
`guest_network_cidr` varchar(18),
|
||||
|
|
@ -497,7 +499,6 @@ CREATE TABLE `cloud`.`data_center` (
|
|||
`lb_provider` char(64) DEFAULT 'VirtualRouter',
|
||||
`vpn_provider` char(64) DEFAULT 'VirtualRouter',
|
||||
`userdata_provider` char(64) DEFAULT 'VirtualRouter',
|
||||
`is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not',
|
||||
`allocation_state` varchar(32) NOT NULL DEFAULT 'Enabled' COMMENT 'Is this data center enabled for allocation for new resources',
|
||||
`zone_token` varchar(255),
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
|
|
@ -562,6 +563,7 @@ CREATE TABLE `cloud`.`host_pod_ref` (
|
|||
CREATE TABLE `cloud`.`op_dc_vnet_alloc` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary id',
|
||||
`vnet` varchar(18) NOT NULL COMMENT 'vnet',
|
||||
`physical_network_id` bigint unsigned NOT NULL COMMENT 'physical network the vnet belongs to',
|
||||
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center the vnet belongs to',
|
||||
`reservation_id` char(40) NULL COMMENT 'reservation id',
|
||||
`account_id` bigint unsigned NULL COMMENT 'account the vnet belongs to right now',
|
||||
|
|
@ -1734,5 +1736,57 @@ CREATE TABLE `ntwk_offering_service_map` (
|
|||
UNIQUE (`network_offering_id`, `service`, `provider`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`physical_network` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this physical network belongs to',
|
||||
`vnet` varchar(255),
|
||||
`speed` varchar(32),
|
||||
`domain_id` bigint unsigned COMMENT 'foreign key to domain id',
|
||||
`broadcast_domain_range` varchar(32) NOT NULL DEFAULT 'Pod' COMMENT 'range of broadcast domain : Pod/Zone',
|
||||
`state` varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'what state is this configuration in',
|
||||
`created` datetime COMMENT 'date created',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_physical_network__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_physical_network__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
|
||||
INDEX `i_physical_network__removed`(`removed`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`physical_network_tags` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network',
|
||||
`tag` varchar(255) NOT NULL COMMENT 'tag',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_physical_network_tags__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE,
|
||||
UNIQUE KEY(`physical_network_id`, `tag`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`physical_network_isolation_methods` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network',
|
||||
`isolation_method` varchar(255) NOT NULL COMMENT 'isolation method(VLAN, L3 or GRE)',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_physical_network_imethods__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE,
|
||||
UNIQUE KEY(`physical_network_id`, `isolation_method`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`physical_network_traffic_types` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network',
|
||||
`traffic_type` varchar(32) NOT NULL COMMENT 'type of traffic going through this network',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_physical_network_traffic_types__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE,
|
||||
UNIQUE KEY(`physical_network_id`, `traffic_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`physical_network_service_providers` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network',
|
||||
`provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name',
|
||||
`state` varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'provider state',
|
||||
`destination_physical_network_id` bigint unsigned COMMENT 'id of the physical network to bridge to',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_pnetwork_service_providers__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,16 @@
|
|||
<vnet>560-579</vnet>
|
||||
<guestNetworkCidr>10.1.1.0/24</guestNetworkCidr>
|
||||
</zone>
|
||||
</zones> -->
|
||||
</zones>
|
||||
|
||||
<physicalNetworks>
|
||||
<physicalNetwork>
|
||||
<id>200</id>
|
||||
<zoneId>1</zoneId>
|
||||
<vnet>1075-1089</vnet>
|
||||
</physicalNetwork>
|
||||
</physicalNetworks> -->
|
||||
|
||||
<!--
|
||||
ipAddressRange: It is possible to specify a single IP address. For example, to add 192.168.1.1
|
||||
as the only address, specify as <ipAddressRange>192.168.1.1<ipAddressRange>. To specify 192.168.1.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue