Updated Branches:
  refs/heads/vpc ccec9192a -> ce876e24d

VPC: intermidiate checkin to Static Routes

Conflicts:

        api/src/com/cloud/api/ApiConstants.java


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ce876e24
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ce876e24
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ce876e24

Branch: refs/heads/vpc
Commit: ce876e24de13cb6de1ffd4cc4b304c379d6fb828
Parents: 8be74c0
Author: Alena Prokharchyk <[email protected]>
Authored: Mon Jun 25 18:02:02 2012 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Mon Jun 25 21:00:57 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/api/ApiConstants.java            |    2 +-
 api/src/com/cloud/api/BaseAsyncCmd.java            |    2 +
 .../api/commands/CreatePrivateGatewayCmd.java      |   25 +++-
 .../cloud/api/commands/CreateStaticRouteCmd.java   |  149 +++++++++++++++
 .../api/commands/DeletePrivateGatewayCmd.java      |    2 +-
 .../cloud/api/commands/DeleteStaticRouteCmd.java   |  124 ++++++++++++
 .../cloud/api/commands/ListFirewallRulesCmd.java   |    1 -
 .../cloud/api/commands/ListStaticRoutesCmd.java    |   86 +++++++++
 api/src/com/cloud/async/AsyncJob.java              |    3 +-
 api/src/com/cloud/event/EventTypes.java            |    4 +
 api/src/com/cloud/network/element/VpcProvider.java |    6 +-
 api/src/com/cloud/network/vpc/StaticRoute.java     |    4 +-
 api/src/com/cloud/network/vpc/VpcService.java      |   33 ++++
 client/tomcatconf/commands.properties.in           |    6 +-
 .../configuration/DefaultComponentLibrary.java     |    2 +
 .../network/element/VpcVirtualRouterElement.java   |   10 +
 .../com/cloud/network/vpc/Dao/StaticRouteDao.java  |   23 +++
 .../cloud/network/vpc/Dao/StaticRouteDaoImpl.java  |   29 +++
 .../src/com/cloud/network/vpc/StaticRouteVO.java   |   22 ++-
 .../src/com/cloud/network/vpc/VpcManagerImpl.java  |   34 ++++
 setup/apidoc/gen_toc.py                            |    1 +
 setup/db/create-schema.sql                         |    4 +
 22 files changed, 561 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/ApiConstants.java 
b/api/src/com/cloud/api/ApiConstants.java
index 419d577..29bae6b 100755
--- a/api/src/com/cloud/api/ApiConstants.java
+++ b/api/src/com/cloud/api/ApiConstants.java
@@ -360,7 +360,7 @@ public class ApiConstants {
     public static final String VPC_OFF_ID = "vpcofferingid";
     public static final String NETWORK = "network";
     public static final String VPC_ID = "vpcid";
-    public static final String GATEWAY_ID = "gatewaycid";
+    public static final String GATEWAY_ID = "gatewayid";
     
     public enum HostDetails {
         all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/BaseAsyncCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/BaseAsyncCmd.java 
b/api/src/com/cloud/api/BaseAsyncCmd.java
index 62cc9a0..2960e48 100644
--- a/api/src/com/cloud/api/BaseAsyncCmd.java
+++ b/api/src/com/cloud/api/BaseAsyncCmd.java
@@ -27,6 +27,8 @@ import com.cloud.user.UserContext;
 public abstract class BaseAsyncCmd extends BaseCmd {
     public static final String ipAddressSyncObject = "ipaddress";
     public static final String networkSyncObject = "network";
+    public static final String vpcSyncObject = "vpc";
+
 
     private AsyncJob job;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/commands/CreatePrivateGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreatePrivateGatewayCmd.java 
b/api/src/com/cloud/api/commands/CreatePrivateGatewayCmd.java
index 4f0fe03..0299c9e 100644
--- a/api/src/com/cloud/api/commands/CreatePrivateGatewayCmd.java
+++ b/api/src/com/cloud/api/commands/CreatePrivateGatewayCmd.java
@@ -15,6 +15,7 @@ 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;
@@ -22,12 +23,15 @@ import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
 import com.cloud.api.ServerApiException;
 import com.cloud.api.response.PrivateGatewayResponse;
+import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.vpc.PrivateGateway;
+import com.cloud.network.vpc.Vpc;
 import com.cloud.user.Account;
 
 /**
@@ -148,11 +152,30 @@ public class CreatePrivateGatewayCmd extends 
BaseAsyncCreateCmd {
     @Override
     public String getEventDescription() {
         return  "creating private gateway";
-
     }
     
     @Override
     public String getEntityTable() {
         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;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/commands/CreateStaticRouteCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateStaticRouteCmd.java 
b/api/src/com/cloud/api/commands/CreateStaticRouteCmd.java
new file mode 100644
index 0000000..805013e
--- /dev/null
+++ b/api/src/com/cloud/api/commands/CreateStaticRouteCmd.java
@@ -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;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java 
b/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java
index 2d3a3e2..89b941d 100644
--- a/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java
+++ b/api/src/com/cloud/api/commands/DeletePrivateGatewayCmd.java
@@ -107,7 +107,7 @@ public class DeletePrivateGatewayCmd extends BaseAsyncCmd {
     
     @Override
     public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.Vpc;
+        return AsyncJob.Type.PrivateGateway;
     }
     
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/commands/DeleteStaticRouteCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteStaticRouteCmd.java 
b/api/src/com/cloud/api/commands/DeleteStaticRouteCmd.java
new file mode 100644
index 0000000..a6fc85b
--- /dev/null
+++ b/api/src/com/cloud/api/commands/DeleteStaticRouteCmd.java
@@ -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;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java 
b/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
index 2827f0b..b43afd5 100644
--- a/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
+++ b/api/src/com/cloud/api/commands/ListFirewallRulesCmd.java
@@ -33,7 +33,6 @@ import com.cloud.network.rules.FirewallRule;
 @Implementation(description="Lists all firewall rules for an IP address.", 
responseObject=FirewallResponse.class)
 public class ListFirewallRulesCmd extends 
BaseListProjectAndAccountResourcesCmd {
     public static final Logger s_logger = 
Logger.getLogger(ListFirewallRulesCmd.class.getName());
-
     private static final String s_name = "listfirewallrulesresponse";
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java 
b/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java
new file mode 100644
index 0000000..f3e0021
--- /dev/null
+++ b/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java
@@ -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); 
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/async/AsyncJob.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/async/AsyncJob.java 
b/api/src/com/cloud/async/AsyncJob.java
index 12cf2a5..10279c5 100644
--- a/api/src/com/cloud/async/AsyncJob.java
+++ b/api/src/com/cloud/async/AsyncJob.java
@@ -41,7 +41,8 @@ public interface AsyncJob extends Identity {
         FirewallRule,
         Account,
         User,
-        Vpc
+        PrivateGateway,
+        StaticRoute
     }
 
     Long getId();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java 
b/api/src/com/cloud/event/EventTypes.java
index f478e4c..5fbb4bf 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -274,4 +274,8 @@ public class EventTypes {
     // Private gateway
     public static final String EVENT_PRIVATE_GATEWAY_CREATE = 
"PRIVATE.GATEWAY.CREATE";
     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";
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/network/element/VpcProvider.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/element/VpcProvider.java 
b/api/src/com/cloud/network/element/VpcProvider.java
index 4188fb6..34bdb51 100644
--- a/api/src/com/cloud/network/element/VpcProvider.java
+++ b/api/src/com/cloud/network/element/VpcProvider.java
@@ -12,12 +12,15 @@
 // Automatically generated by addcopyright.py at 04/03/2012
 package com.cloud.network.element;
 
+import java.util.List;
+
 import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InsufficientNetworkCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.vpc.PrivateGateway;
+import com.cloud.network.vpc.StaticRoute;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.vm.ReservationContext;
 
@@ -44,5 +47,6 @@ public interface VpcProvider extends NetworkElement{
     boolean createPrivateGateway(PrivateGateway gateway) throws 
ConcurrentOperationException, ResourceUnavailableException;
     
     boolean deletePrivateGateway(PrivateGateway privateGateway) throws 
ConcurrentOperationException, ResourceUnavailableException;
-
+    
+    boolean applyStaticRoutes(Vpc vpc, List<? extends StaticRoute> routes) 
throws ResourceUnavailableException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/network/vpc/StaticRoute.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/StaticRoute.java 
b/api/src/com/cloud/network/vpc/StaticRoute.java
index fee47ab..eb4d767 100644
--- a/api/src/com/cloud/network/vpc/StaticRoute.java
+++ b/api/src/com/cloud/network/vpc/StaticRoute.java
@@ -12,11 +12,13 @@
 // Automatically generated by addcopyright.py at 04/03/2012
 package com.cloud.network.vpc;
 
+import com.cloud.acl.ControlledEntity;
+
 
 /**
  * @author Alena Prokharchyk
  */
-public interface StaticRoute {
+public interface StaticRoute extends ControlledEntity{
     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.
         Add,    // Add means the route has been created and has gone through 
network rule conflict detection.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/api/src/com/cloud/network/vpc/VpcService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcService.java 
b/api/src/com/cloud/network/vpc/VpcService.java
index 926ad0f..d1faf23 100644
--- a/api/src/com/cloud/network/vpc/VpcService.java
+++ b/api/src/com/cloud/network/vpc/VpcService.java
@@ -17,8 +17,10 @@ import java.util.Map;
 import java.util.Set;
 
 import com.cloud.api.commands.ListPrivateGatewaysCmd;
+import com.cloud.api.commands.ListStaticRoutesCmd;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
@@ -178,4 +180,35 @@ public interface VpcService {
      */
     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);
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in 
b/client/tomcatconf/commands.properties.in
index 64f9415..fef9f52 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -362,6 +362,6 @@ 
deleteNetworkACL=com.cloud.api.commands.DeleteNetworkACLCmd;15
 listNetworkACLs=com.cloud.api.commands.ListNetworkACLsCmd;15
 
 #### Static route commands
-#createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15
-#deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15
-#listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15
+createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15
+deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15
+listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java 
b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index a4012b7..b6a8541 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -126,6 +126,7 @@ import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
 import com.cloud.network.vpc.NetworkACLManagerImpl;
 import com.cloud.network.vpc.VpcManagerImpl;
 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.VpcGatewayDaoImpl;
 import com.cloud.network.vpc.Dao.VpcOfferingDaoImpl;
@@ -342,6 +343,7 @@ public class DefaultComponentLibrary extends 
ComponentLibraryBase implements Com
         addDao("VpcOfferingServiceMapDao", VpcOfferingServiceMapDaoImpl.class);
         addDao("PrivateIpDao", PrivateIpDaoImpl.class);
         addDao("VpcGatewayDao", VpcGatewayDaoImpl.class);
+        addDao("StaticRouteDao", StaticRouteDaoImpl.class);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java 
b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
index dcd1218..e9a2cf5 100644
--- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -40,6 +40,7 @@ import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.NetworkACL;
+import com.cloud.network.vpc.StaticRoute;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.network.vpc.VpcGateway;
 import com.cloud.network.vpc.VpcManager;
@@ -401,4 +402,13 @@ public class VpcVirtualRouterElement extends 
VirtualRouterElement implements Vpc
     protected VirtualRouterProviderType getVirtualRouterProvider() {
         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;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java 
b/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java
new file mode 100644
index 0000000..f4bc80a
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/Dao/StaticRouteDao.java
@@ -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>{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java 
b/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java
new file mode 100644
index 0000000..b25b931
--- /dev/null
+++ b/server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java
@@ -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{
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/server/src/com/cloud/network/vpc/StaticRouteVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/StaticRouteVO.java 
b/server/src/com/cloud/network/vpc/StaticRouteVO.java
index 3b58c35..f8b59a0 100644
--- a/server/src/com/cloud/network/vpc/StaticRouteVO.java
+++ b/server/src/com/cloud/network/vpc/StaticRouteVO.java
@@ -55,8 +55,18 @@ public class StaticRouteVO implements Identity, StaticRoute{
     @Column(name="vpc_id")
     private Long vpcId;
     
+    @Column(name = "account_id")
+    long accountId;
+
+    @Column(name = "domain_id")
+    long domainId;
+    
     @Column(name=GenericDao.CREATED_COLUMN)
-    Date created;    
+    Date created;
+    
+    protected StaticRouteVO(){
+        this.uuid = UUID.randomUUID().toString();
+    }
     
     /**
      * @param vpcGatewayId
@@ -101,4 +111,14 @@ public class StaticRouteVO implements Identity, 
StaticRoute{
     public long getId() {
         return id;
     }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+
+    @Override
+    public long getDomainId() {
+        return domainId;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java 
b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index d3605a1..f21ca70 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -25,6 +25,7 @@ import javax.naming.ConfigurationException;
 import org.apache.log4j.Logger;
 
 import com.cloud.api.commands.ListPrivateGatewaysCmd;
+import com.cloud.api.commands.ListStaticRoutesCmd;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.DataCenter;
@@ -34,6 +35,7 @@ import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.exception.ResourceAllocationException;
 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.vpc.VpcOffering.State;
 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.VpcGatewayDao;
 import com.cloud.network.vpc.Dao.VpcOfferingDao;
@@ -111,6 +114,8 @@ public class VpcManagerImpl implements VpcManager, Manager{
     VpcGatewayDao _vpcGatewayDao;
     @Inject
     PrivateIpDao _privateIpDao;
+    @Inject
+    StaticRouteDao _staticRouteDao;
     
     private VpcProvider vpcElement = null;
     
@@ -1098,4 +1103,33 @@ public class VpcManagerImpl implements VpcManager, 
Manager{
         
         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;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/setup/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/setup/apidoc/gen_toc.py b/setup/apidoc/gen_toc.py
index 184153a..c544e9f 100644
--- a/setup/apidoc/gen_toc.py
+++ b/setup/apidoc/gen_toc.py
@@ -118,6 +118,7 @@ known_categories = {
     'Pool': 'Pool',
     'VPC': 'VPC', 
     'PrivateGateway': 'VPC',
+    'StaticRoute': 'VPC',
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ce876e24/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index c7f2cef..b03b24b 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -2242,10 +2242,14 @@ CREATE TABLE `cloud`.`static_routes` (
   `cidr` varchar(18) COMMENT 'cidr for the static route', 
   `state` char(32) NOT NULL COMMENT 'current state of this rule',
   `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',
   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_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`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 

Reply via email to