VPC: intermidiate checkin to Static Routes

Conflicts:

	api/src/com/cloud/api/ApiConstants.java
This commit is contained in:
Alena Prokharchyk 2012-06-25 18:02:02 -07:00
parent 8be74c033f
commit ce876e24de
22 changed files with 561 additions and 11 deletions

View File

@ -360,7 +360,7 @@ public class ApiConstants {
public static final String VPC_OFF_ID = "vpcofferingid"; public static final String VPC_OFF_ID = "vpcofferingid";
public static final String NETWORK = "network"; public static final String NETWORK = "network";
public static final String VPC_ID = "vpcid"; public static final String VPC_ID = "vpcid";
public static final String GATEWAY_ID = "gatewaycid"; public static final String GATEWAY_ID = "gatewayid";
public enum HostDetails { public enum HostDetails {
all, capacity, events, stats, min; all, capacity, events, stats, min;

View File

@ -27,6 +27,8 @@ import com.cloud.user.UserContext;
public abstract class BaseAsyncCmd extends BaseCmd { public abstract class BaseAsyncCmd extends BaseCmd {
public static final String ipAddressSyncObject = "ipaddress"; public static final String ipAddressSyncObject = "ipaddress";
public static final String networkSyncObject = "network"; public static final String networkSyncObject = "network";
public static final String vpcSyncObject = "vpc";
private AsyncJob job; private AsyncJob job;

View File

@ -15,6 +15,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants; import com.cloud.api.ApiConstants;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseAsyncCreateCmd; import com.cloud.api.BaseAsyncCreateCmd;
import com.cloud.api.BaseCmd; import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityMapper; import com.cloud.api.IdentityMapper;
@ -22,12 +23,15 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter; import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException; import com.cloud.api.ServerApiException;
import com.cloud.api.response.PrivateGatewayResponse; import com.cloud.api.response.PrivateGatewayResponse;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.vpc.PrivateGateway; import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account; import com.cloud.user.Account;
/** /**
@ -148,11 +152,30 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd {
@Override @Override
public String getEventDescription() { public String getEventDescription() {
return "creating private gateway"; return "creating private gateway";
} }
@Override @Override
public String getEntityTable() { public String getEntityTable() {
return "vpc_gateways"; return "vpc_gateways";
} }
@Override
public String getSyncObjType() {
return BaseAsyncCmd.vpcSyncObject;
}
@Override
public Long getSyncObjId() {
Vpc vpc = _vpcService.getVpc(vpcId);
if (vpc == null) {
throw new InvalidParameterValueException("Invalid id is specified for the vpc");
}
return vpc.getId();
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.PrivateGateway;
}
} }

View File

@ -0,0 +1,149 @@
// Copyright 2012 Citrix Systems, Inc. Licensed under the
// Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. Citrix Systems, Inc.
// reserves all rights not expressly granted by the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseAsyncCreateCmd;
import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityMapper;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.StaticRouteResponse;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.user.UserContext;
/**
* @author Alena Prokharchyk
*/
@Implementation(description="Creates a static route", responseObject=StaticRouteResponse.class)
public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{
private static final String s_name = "createstaticrouteresponse";
public static final Logger s_logger = Logger.getLogger(CreateStaticRouteCmd.class.getName());
@IdentityMapper(entityTableName="vpc_gateways")
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, required=true,
description="the gateway id we are creating static route for")
private Long gatewayId;
@Parameter(name = ApiConstants.CIDR, required = true, type = CommandType.STRING, description = "static route cidr")
private String cidr;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public long getGatewayId() {
return gatewayId;
}
public String getCidr() {
return cidr;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void create() throws ResourceAllocationException {
try {
StaticRoute result = _vpcService.createStaticRoute(getGatewayId(), getCidr());
setEntityId(result.getId());
} catch (NetworkRuleConflictException ex) {
s_logger.info("Network rule conflict: " + ex.getMessage());
s_logger.trace("Network rule conflict: ", ex);
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
}
}
@Override
public String getEntityTable() {
return "static_routes";
}
@Override
public String getEventType() {
return EventTypes.EVENT_STATIC_ROUTE_CREATE;
}
@Override
public String getEventDescription() {
return "creating static route";
}
@Override
public void execute() {
boolean success = false;
StaticRoute route = _entityMgr.findById(StaticRoute.class, getEntityId());
try {
UserContext.current().setEventDetails("Static route Id: " + getEntityId());
success = _vpcService.applyStaticRoutes(route.getVpcId());
// State is different after the route is applied, so get new object here
route = _entityMgr.findById(StaticRoute.class, getEntityId());
StaticRouteResponse routeResponse = new StaticRouteResponse();
if (route != null) {
routeResponse = _responseGenerator.createStaticRouteResponse(route);
setResponseObject(routeResponse);
}
routeResponse.setResponseName(getCommandName());
} finally {
if (!success || route == null) {
_vpcService.revokeStaticRoute(getEntityId());
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create static route");
}
}
}
@Override
public String getCommandName() {
return s_name;
}
@Override
public long getEntityOwnerId() {
PrivateGateway gateway = _vpcService.getVpcPrivateGateway(gatewayId);
if (gateway == null) {
throw new InvalidParameterValueException("Invalid gateway id is specified");
}
return _vpcService.getVpc(gateway.getVpcId()).getAccountId();
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.vpcSyncObject;
}
@Override
public Long getSyncObjId() {
PrivateGateway privateGateway = _vpcService.getVpcPrivateGateway(gatewayId);
if (privateGateway == null) {
throw new InvalidParameterValueException("Invalid id is specified for the gateway");
}
return privateGateway.getVpcId();
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.StaticRoute;
}
}

View File

@ -107,7 +107,7 @@ public class DeletePrivateGatewayCmd extends BaseAsyncCmd {
@Override @Override
public AsyncJob.Type getInstanceType() { public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.Vpc; return AsyncJob.Type.PrivateGateway;
} }
} }

View File

@ -0,0 +1,124 @@
// Copyright 2012 Citrix Systems, Inc. Licensed under the
// Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. Citrix Systems, Inc.
// reserves all rights not expressly granted by the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityMapper;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.user.UserContext;
/**
* @author Alena Prokharchyk
*/
@Implementation(description="Deletes a static route", responseObject=SuccessResponse.class)
public class DeleteStaticRouteCmd extends BaseAsyncCmd{
public static final Logger s_logger = Logger.getLogger(DeleteStaticRouteCmd.class.getName());
private static final String s_name = "deletestaticrouteresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@IdentityMapper(entityTableName="static_routes")
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the static route")
private Long id;
// unexposed parameter needed for events logging
@IdentityMapper(entityTableName="account")
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
private Long ownerId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public String getEventType() {
return EventTypes.EVENT_STATIC_ROUTE_DELETE;
}
@Override
public String getEventDescription() {
return ("Deleting static route id=" + id);
}
@Override
public long getEntityOwnerId() {
if (ownerId == null) {
StaticRoute route = _entityMgr.findById(StaticRoute.class, id);
if (route == null) {
throw new InvalidParameterValueException("Unable to find static route by id=" + id);
} else {
ownerId = route.getAccountId();
}
}
return ownerId;
}
@Override
public void execute() throws ResourceUnavailableException {
UserContext.current().setEventDetails("Route Id: " + id);
boolean result = _vpcService.revokeStaticRoute(id);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete static route");
}
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.vpcSyncObject;
}
@Override
public Long getSyncObjId() {
StaticRoute route = _vpcService.getStaticRoute(id);
if (route == null) {
throw new InvalidParameterValueException("Invalid id is specified for the static route");
}
return route.getVpcId();
}
@Override
public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.StaticRoute;
}
}

View File

@ -33,7 +33,6 @@ import com.cloud.network.rules.FirewallRule;
@Implementation(description="Lists all firewall rules for an IP address.", responseObject=FirewallResponse.class) @Implementation(description="Lists all firewall rules for an IP address.", responseObject=FirewallResponse.class)
public class ListFirewallRulesCmd extends BaseListProjectAndAccountResourcesCmd { public class ListFirewallRulesCmd extends BaseListProjectAndAccountResourcesCmd {
public static final Logger s_logger = Logger.getLogger(ListFirewallRulesCmd.class.getName()); public static final Logger s_logger = Logger.getLogger(ListFirewallRulesCmd.class.getName());
private static final String s_name = "listfirewallrulesresponse"; private static final String s_name = "listfirewallrulesresponse";
///////////////////////////////////////////////////// /////////////////////////////////////////////////////

View File

@ -0,0 +1,86 @@
// Copyright 2012 Citrix Systems, Inc. Licensed under the
// Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. Citrix Systems, Inc.
// reserves all rights not expressly granted by the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.api.commands;
import java.util.ArrayList;
import java.util.List;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
import com.cloud.api.IdentityMapper;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.StaticRouteResponse;
import com.cloud.network.vpc.StaticRoute;
/**
* @author Alena Prokharchyk
*/
@Implementation(description="Lists all static routes", responseObject=StaticRouteResponse.class)
public class ListStaticRoutesCmd extends BaseListProjectAndAccountResourcesCmd {
private static final String s_name = "liststaticroutesresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@IdentityMapper(entityTableName="static_routes")
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list static route by id")
private Long id;
@IdentityMapper(entityTableName="vpc")
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list static routes by vpc id")
private Long vpcId;
@IdentityMapper(entityTableName="vpc_gateways")
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, description="list static routes by gateway id")
private Long gatewayId;
public Long getId() {
return id;
}
public Long getVpcId() {
return vpcId;
}
public Long getGatewayId() {
return gatewayId;
}
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
@Override
public void execute(){
List<? extends StaticRoute> result = _vpcService.listStaticRoutes(this);
ListResponse<StaticRouteResponse> response = new ListResponse<StaticRouteResponse>();
List<StaticRouteResponse> routeResponses = new ArrayList<StaticRouteResponse>();
for (StaticRoute route : result) {
StaticRouteResponse ruleData = _responseGenerator.createStaticRouteResponse(route);
routeResponses.add(ruleData);
}
response.setResponses(routeResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}

View File

@ -41,7 +41,8 @@ public interface AsyncJob extends Identity {
FirewallRule, FirewallRule,
Account, Account,
User, User,
Vpc PrivateGateway,
StaticRoute
} }
Long getId(); Long getId();

View File

@ -274,4 +274,8 @@ public class EventTypes {
// Private gateway // Private gateway
public static final String EVENT_PRIVATE_GATEWAY_CREATE = "PRIVATE.GATEWAY.CREATE"; public static final String EVENT_PRIVATE_GATEWAY_CREATE = "PRIVATE.GATEWAY.CREATE";
public static final String EVENT_PRIVATE_GATEWAY_DELETE = "PRIVATE.GATEWAY.DELETE"; public static final String EVENT_PRIVATE_GATEWAY_DELETE = "PRIVATE.GATEWAY.DELETE";
// Static routes
public static final String EVENT_STATIC_ROUTE_CREATE = "STATIC.ROUTE.CREATE";
public static final String EVENT_STATIC_ROUTE_DELETE = "STATIC.ROUTE.DELETE";
} }

View File

@ -12,12 +12,15 @@
// Automatically generated by addcopyright.py at 04/03/2012 // Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.network.element; package com.cloud.network.element;
import java.util.List;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException; import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.vpc.PrivateGateway; import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.Vpc;
import com.cloud.vm.ReservationContext; import com.cloud.vm.ReservationContext;
@ -44,5 +47,6 @@ public interface VpcProvider extends NetworkElement{
boolean createPrivateGateway(PrivateGateway gateway) throws ConcurrentOperationException, ResourceUnavailableException; boolean createPrivateGateway(PrivateGateway gateway) throws ConcurrentOperationException, ResourceUnavailableException;
boolean deletePrivateGateway(PrivateGateway privateGateway) throws ConcurrentOperationException, ResourceUnavailableException; boolean deletePrivateGateway(PrivateGateway privateGateway) throws ConcurrentOperationException, ResourceUnavailableException;
boolean applyStaticRoutes(Vpc vpc, List<? extends StaticRoute> routes) throws ResourceUnavailableException;
} }

View File

@ -12,11 +12,13 @@
// Automatically generated by addcopyright.py at 04/03/2012 // Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.network.vpc; package com.cloud.network.vpc;
import com.cloud.acl.ControlledEntity;
/** /**
* @author Alena Prokharchyk * @author Alena Prokharchyk
*/ */
public interface StaticRoute { public interface StaticRoute extends ControlledEntity{
enum State { enum State {
Staged, // route been created but has never got through network rule conflict detection. Routes in this state can not be sent to VPC virtual router. Staged, // route been created but has never got through network rule conflict detection. Routes in this state can not be sent to VPC virtual router.
Add, // Add means the route has been created and has gone through network rule conflict detection. Add, // Add means the route has been created and has gone through network rule conflict detection.

View File

@ -17,8 +17,10 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import com.cloud.api.commands.ListPrivateGatewaysCmd; import com.cloud.api.commands.ListPrivateGatewaysCmd;
import com.cloud.api.commands.ListStaticRoutesCmd;
import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network; import com.cloud.network.Network;
@ -178,4 +180,35 @@ public interface VpcService {
*/ */
public List<PrivateGateway> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd); public List<PrivateGateway> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd);
/**
* @param routeId
* @return
*/
StaticRoute getStaticRoute(long routeId);
/**
* @param vpcId
* @return
*/
public boolean applyStaticRoutes(long vpcId);
/**
* @param routeId
* @return TODO
*/
public boolean revokeStaticRoute(long routeId);
/**
* @param gatewayId
* @param cidr
* @return
*/
public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException;
/**
* @param listStaticRoutesCmd
* @return
*/
public List<? extends StaticRoute> listStaticRoutes(ListStaticRoutesCmd cmd);
} }

View File

@ -362,6 +362,6 @@ deleteNetworkACL=com.cloud.api.commands.DeleteNetworkACLCmd;15
listNetworkACLs=com.cloud.api.commands.ListNetworkACLsCmd;15 listNetworkACLs=com.cloud.api.commands.ListNetworkACLsCmd;15
#### Static route commands #### Static route commands
#createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15 createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15
#deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15 deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15
#listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15 listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15

View File

@ -126,6 +126,7 @@ import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
import com.cloud.network.vpc.NetworkACLManagerImpl; import com.cloud.network.vpc.NetworkACLManagerImpl;
import com.cloud.network.vpc.VpcManagerImpl; import com.cloud.network.vpc.VpcManagerImpl;
import com.cloud.network.vpc.Dao.PrivateIpDaoImpl; import com.cloud.network.vpc.Dao.PrivateIpDaoImpl;
import com.cloud.network.vpc.Dao.StaticRouteDaoImpl;
import com.cloud.network.vpc.Dao.VpcDaoImpl; import com.cloud.network.vpc.Dao.VpcDaoImpl;
import com.cloud.network.vpc.Dao.VpcGatewayDaoImpl; import com.cloud.network.vpc.Dao.VpcGatewayDaoImpl;
import com.cloud.network.vpc.Dao.VpcOfferingDaoImpl; import com.cloud.network.vpc.Dao.VpcOfferingDaoImpl;
@ -342,6 +343,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
addDao("VpcOfferingServiceMapDao", VpcOfferingServiceMapDaoImpl.class); addDao("VpcOfferingServiceMapDao", VpcOfferingServiceMapDaoImpl.class);
addDao("PrivateIpDao", PrivateIpDaoImpl.class); addDao("PrivateIpDao", PrivateIpDaoImpl.class);
addDao("VpcGatewayDao", VpcGatewayDaoImpl.class); addDao("VpcGatewayDao", VpcGatewayDaoImpl.class);
addDao("StaticRouteDao", StaticRouteDaoImpl.class);
} }
@Override @Override

View File

@ -40,6 +40,7 @@ import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.NetworkACL; import com.cloud.network.rules.NetworkACL;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcGateway; import com.cloud.network.vpc.VpcGateway;
import com.cloud.network.vpc.VpcManager; import com.cloud.network.vpc.VpcManager;
@ -401,4 +402,13 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
protected VirtualRouterProviderType getVirtualRouterProvider() { protected VirtualRouterProviderType getVirtualRouterProvider() {
return VirtualRouterProviderType.VPCVirtualRouter; return VirtualRouterProviderType.VPCVirtualRouter;
} }
/* (non-Javadoc)
* @see com.cloud.network.element.VpcProvider#applyStaticRoutes(com.cloud.network.vpc.Vpc, java.util.List)
*/
@Override
public boolean applyStaticRoutes(Vpc vpc, List<? extends StaticRoute> routes) throws ResourceUnavailableException {
// TODO Auto-generated method stub
return false;
}
} }

View File

@ -0,0 +1,23 @@
// Copyright 2012 Citrix Systems, Inc. Licensed under the
// Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. Citrix Systems, Inc.
// reserves all rights not expressly granted by the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.network.vpc.Dao;
import com.cloud.network.vpc.StaticRouteVO;
import com.cloud.utils.db.GenericDao;
/**
* @author Alena Prokharchyk
*/
public interface StaticRouteDao extends GenericDao<StaticRouteVO, Long>{
}

View File

@ -0,0 +1,29 @@
// Copyright 2012 Citrix Systems, Inc. Licensed under the
// Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. Citrix Systems, Inc.
// reserves all rights not expressly granted by the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.network.vpc.Dao;
import javax.ejb.Local;
import com.cloud.network.vpc.StaticRouteVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
/**
* @author Alena Prokharchyk
*/
@Local(value = StaticRouteDao.class)
@DB(txn = false)
public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> implements StaticRouteDao{
}

View File

@ -55,8 +55,18 @@ public class StaticRouteVO implements Identity, StaticRoute{
@Column(name="vpc_id") @Column(name="vpc_id")
private Long vpcId; private Long vpcId;
@Column(name = "account_id")
long accountId;
@Column(name = "domain_id")
long domainId;
@Column(name=GenericDao.CREATED_COLUMN) @Column(name=GenericDao.CREATED_COLUMN)
Date created; Date created;
protected StaticRouteVO(){
this.uuid = UUID.randomUUID().toString();
}
/** /**
* @param vpcGatewayId * @param vpcGatewayId
@ -101,4 +111,14 @@ public class StaticRouteVO implements Identity, StaticRoute{
public long getId() { public long getId() {
return id; return id;
} }
@Override
public long getAccountId() {
return accountId;
}
@Override
public long getDomainId() {
return domainId;
}
} }

View File

@ -25,6 +25,7 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.api.commands.ListPrivateGatewaysCmd; import com.cloud.api.commands.ListPrivateGatewaysCmd;
import com.cloud.api.commands.ListStaticRoutesCmd;
import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter;
@ -34,6 +35,7 @@ import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
@ -53,6 +55,7 @@ import com.cloud.network.dao.NetworkDao;
import com.cloud.network.element.VpcProvider; import com.cloud.network.element.VpcProvider;
import com.cloud.network.vpc.VpcOffering.State; import com.cloud.network.vpc.VpcOffering.State;
import com.cloud.network.vpc.Dao.PrivateIpDao; import com.cloud.network.vpc.Dao.PrivateIpDao;
import com.cloud.network.vpc.Dao.StaticRouteDao;
import com.cloud.network.vpc.Dao.VpcDao; import com.cloud.network.vpc.Dao.VpcDao;
import com.cloud.network.vpc.Dao.VpcGatewayDao; import com.cloud.network.vpc.Dao.VpcGatewayDao;
import com.cloud.network.vpc.Dao.VpcOfferingDao; import com.cloud.network.vpc.Dao.VpcOfferingDao;
@ -111,6 +114,8 @@ public class VpcManagerImpl implements VpcManager, Manager{
VpcGatewayDao _vpcGatewayDao; VpcGatewayDao _vpcGatewayDao;
@Inject @Inject
PrivateIpDao _privateIpDao; PrivateIpDao _privateIpDao;
@Inject
StaticRouteDao _staticRouteDao;
private VpcProvider vpcElement = null; private VpcProvider vpcElement = null;
@ -1098,4 +1103,33 @@ public class VpcManagerImpl implements VpcManager, Manager{
return privateGtws; return privateGtws;
} }
@Override
public StaticRoute getStaticRoute(long routeId) {
return _staticRouteDao.findById(routeId);
}
@Override
public boolean applyStaticRoutes(long vpcId) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean revokeStaticRoute(long routeId) {
// TODO Auto-generated method stub
return false;
}
@Override
public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<? extends StaticRoute> listStaticRoutes(ListStaticRoutesCmd cmd) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@ -118,6 +118,7 @@ known_categories = {
'Pool': 'Pool', 'Pool': 'Pool',
'VPC': 'VPC', 'VPC': 'VPC',
'PrivateGateway': 'VPC', 'PrivateGateway': 'VPC',
'StaticRoute': 'VPC',
} }

View File

@ -2242,10 +2242,14 @@ CREATE TABLE `cloud`.`static_routes` (
`cidr` varchar(18) COMMENT 'cidr for the static route', `cidr` varchar(18) COMMENT 'cidr for the static route',
`state` char(32) NOT NULL COMMENT 'current state of this rule', `state` char(32) NOT NULL COMMENT 'current state of this rule',
`vpc_id` bigint unsigned COMMENT 'vpc the firewall rule is associated with', `vpc_id` bigint unsigned COMMENT 'vpc the firewall rule is associated with',
`account_id` bigint unsigned NOT NULL COMMENT 'owner id',
`domain_id` bigint unsigned NOT NULL COMMENT 'domain id',
`created` datetime COMMENT 'Date created', `created` datetime COMMENT 'Date created',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
CONSTRAINT `fk_static_routes__vpc_gateway_id` FOREIGN KEY(`vpc_gateway_id`) REFERENCES `vpc_gateways`(`id`) ON DELETE CASCADE, CONSTRAINT `fk_static_routes__vpc_gateway_id` FOREIGN KEY(`vpc_gateway_id`) REFERENCES `vpc_gateways`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_static_routes__vpc_id` FOREIGN KEY (`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE, CONSTRAINT `fk_static_routes__vpc_id` FOREIGN KEY (`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_static_routes__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_static_routes__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
CONSTRAINT `uc_static_routes__uuid` UNIQUE (`uuid`) CONSTRAINT `uc_static_routes__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;