cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/3] git commit: api_refactor: router apis for admin pkg
Date Wed, 05 Dec 2012 23:32:08 GMT
Updated Branches:
  refs/heads/api_refactoring ceddaf122 -> c59de6cbd


api_refactor: router apis for admin pkg

- Fix missing api mapping in commands.prop
- Refactor package namespace

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>


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

Branch: refs/heads/api_refactoring
Commit: c59de6cbde30c0b75d4c1557ccd14ee7505a160b
Parents: 55f2bd8
Author: Rohit Yadav <bhaisaab@apache.org>
Authored: Wed Dec 5 15:23:31 2012 -0800
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Wed Dec 5 15:23:31 2012 -0800

----------------------------------------------------------------------
 .../commands/ConfigureVirtualRouterElementCmd.java |  128 -------------
 .../commands/CreateVirtualRouterElementCmd.java    |  117 ------------
 .../com/cloud/api/commands/DestroyRouterCmd.java   |  111 -----------
 api/src/com/cloud/api/commands/ListRoutersCmd.java |  146 ---------------
 .../api/commands/ListVirtualRouterElementsCmd.java |  110 -----------
 .../com/cloud/api/commands/RebootRouterCmd.java    |  109 -----------
 api/src/com/cloud/api/commands/StartRouterCmd.java |  114 -----------
 api/src/com/cloud/api/commands/StopRouterCmd.java  |  116 ------------
 .../com/cloud/api/commands/UpgradeRouterCmd.java   |   90 ---------
 .../network/VirtualNetworkApplianceService.java    |    2 +-
 .../element/VirtualRouterElementService.java       |    4 +-
 api/src/com/cloud/server/ManagementService.java    |    2 +-
 .../command/ConfigureVirtualRouterElementCmd.java  |  128 +++++++++++++
 .../command/CreateVirtualRouterElementCmd.java     |  117 ++++++++++++
 .../api/admin/router/command/DestroyRouterCmd.java |  111 +++++++++++
 .../api/admin/router/command/ListRoutersCmd.java   |  146 +++++++++++++++
 .../command/ListVirtualRouterElementsCmd.java      |  110 +++++++++++
 .../api/admin/router/command/RebootRouterCmd.java  |  109 +++++++++++
 .../api/admin/router/command/StartRouterCmd.java   |  114 +++++++++++
 .../api/admin/router/command/StopRouterCmd.java    |  116 ++++++++++++
 .../api/admin/router/command/UpgradeRouterCmd.java |   90 +++++++++
 .../datacenter/command/ListHypervisorsCmd.java     |    2 +-
 client/tomcatconf/commands.properties.in           |   17 +-
 .../network/element/VirtualRouterElement.java      |    4 +-
 .../router/VirtualNetworkApplianceManagerImpl.java |    2 +-
 .../src/com/cloud/server/ManagementServerImpl.java |    2 +-
 26 files changed, 1059 insertions(+), 1058 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java b/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
deleted file mode 100644
index c130637..0000000
--- a/api/src/com/cloud/api/commands/ConfigureVirtualRouterElementCmd.java
+++ /dev/null
@@ -1,128 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.PlugService;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.VirtualRouterProviderResponse;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.element.VirtualRouterElementService;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=VirtualRouterProviderResponse.class, description="Configures a virtual router element.")
-public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(ConfigureVirtualRouterElementCmd.class.getName());
-    private static final String s_name = "configurevirtualrouterelementresponse";
-
-    @PlugService
-    private VirtualRouterElementService _service;
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName = "virtual_router_providers")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the virtual router provider")
-    private Long id;
-
-    @IdentityMapper(entityTableName = "physical_network_service_providers")
-    @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enabled/Disabled the service provider")
-    private Boolean enabled;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
-    }
-
-    public Boolean getEnabled() {
-        return enabled;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public static String getResultObjectName() {
-        return "boolean";
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "configuring virtual router provider: " + id;
-    }
-
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.None;
-    }
-
-    public Long getInstanceId() {
-        return id;
-    }
-
-    @Override
-    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
-        UserContext.current().setEventDetails("Virtual router element: " + id);
-        VirtualRouterProvider result = _service.configure(this);
-        if (result != null){
-            VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
-            routerResponse.setResponseName(getCommandName());
-            this.setResponseObject(routerResponse);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure the virtual router provider");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/CreateVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateVirtualRouterElementCmd.java b/api/src/com/cloud/api/commands/CreateVirtualRouterElementCmd.java
deleted file mode 100644
index bdeedbe..0000000
--- a/api/src/com/cloud/api/commands/CreateVirtualRouterElementCmd.java
+++ /dev/null
@@ -1,117 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCreateCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.PlugService;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.VirtualRouterProviderResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
-import com.cloud.network.element.VirtualRouterElementService;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=VirtualRouterProviderResponse.class, description="Create a virtual router element.")
-public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
-    public static final Logger s_logger = Logger.getLogger(CreateVirtualRouterElementCmd.class.getName());
-    private static final String s_name = "createvirtualrouterelementresponse";
-
-    @PlugService
-    private VirtualRouterElementService _service;
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.LONG, required=true, description="the network service provider ID of the virtual router element")
-    @IdentityMapper(entityTableName="physical_network_service_providers")
-    private Long nspId;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public void setNspId(Long nspId) {
-        this.nspId = nspId;
-    }
-
-    @Override
-    public String getEntityTable() {
-        return "virtual_router_providers";
-    }
-
-    public Long getNspId() {
-        return nspId;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public void execute(){
-        UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
-        VirtualRouterProvider result = _service.getCreatedElement(getEntityId());
-        if (result != null) {
-            VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
-            response.setResponseName(getCommandName());
-            this.setResponseObject(response);
-        }else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
-        }
-    }
-
-    @Override
-    public void create() throws ResourceAllocationException {
-        VirtualRouterProvider result = _service.addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
-        if (result != null) {
-            setEntityId(result.getId());
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
-        }
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "Adding physical network ServiceProvider Virtual Router: " + getEntityId();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/DestroyRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DestroyRouterCmd.java b/api/src/com/cloud/api/commands/DestroyRouterCmd.java
deleted file mode 100644
index 7c52479..0000000
--- a/api/src/com/cloud/api/commands/DestroyRouterCmd.java
+++ /dev/null
@@ -1,111 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.DomainRouterResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description = "Destroys a router.", responseObject = DomainRouterResponse.class)
-public class DestroyRouterCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(DestroyRouterCmd.class.getName());
-    private static final String s_name = "destroyrouterresponse";
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the router")
-    private Long id;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
-        if (router != null) {
-            return router.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_ROUTER_DESTROY;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "destroying router: " + getId();
-    }
-
-    @Override
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.DomainRouter;
-    }
-
-    @Override
-    public Long getInstanceId() {
-        return getId();
-    }
-
-    @Override
-    public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
-        UserContext ctx = UserContext.current();
-        ctx.setEventDetails("Router Id: "+getId());
-
-        VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCaller(), ctx.getCallerUserId());
-        if (result != null) {
-            DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
-            response.setResponseName(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy router");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/ListRoutersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListRoutersCmd.java b/api/src/com/cloud/api/commands/ListRoutersCmd.java
deleted file mode 100644
index d4c41fc..0000000
--- a/api/src/com/cloud/api/commands/ListRoutersCmd.java
+++ /dev/null
@@ -1,146 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.DomainRouterResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.utils.Pair;
-
-@Implementation(description="List routers.", responseObject=DomainRouterResponse.class)
-public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
-    public static final Logger s_logger = Logger.getLogger(ListRoutersCmd.class.getName());
-
-    private static final String s_name = "listroutersresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="the host ID of the router")
-    private Long hostId;
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the disk router")
-    private Long id;
-
-    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the router")
-    private String routerName;
-
-    @IdentityMapper(entityTableName="host_pod_ref")
-    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID of the router")
-    private Long podId;
-
-    @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the router")
-    private String state;
-
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID of the router")
-    private Long zoneId;
-
-    @IdentityMapper(entityTableName="networks")
-    @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="list by network id")
-    private Long networkId;
-
-    @IdentityMapper(entityTableName="vpc")
-    @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List networks by VPC")
-    private Long vpcId;
-
-    @Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC routers")
-    private Boolean forVpc;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getHostId() {
-        return hostId;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getRouterName() {
-        return routerName;
-    }
-
-    public Long getPodId() {
-        return podId;
-    }
-
-    public String getState() {
-        return state;
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    public Long getNetworkId() {
-        return networkId;
-    }
-
-    public Long getVpcId() {
-        return vpcId;
-    }
-
-    public Boolean getForVpc() {
-        return forVpc;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.DomainRouter;
-    }
-
-    @Override
-    public void execute(){
-        Pair<List<? extends VirtualRouter>, Integer> result = _mgr.searchForRouters(this);
-        ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>();
-        List<DomainRouterResponse> routerResponses = new ArrayList<DomainRouterResponse>();
-        for (VirtualRouter router : result.first()) {
-            DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
-            routerResponse.setObjectName("router");
-            routerResponses.add(routerResponse);
-        }
-
-        response.setResponses(routerResponses, result.second());
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/ListVirtualRouterElementsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVirtualRouterElementsCmd.java b/api/src/com/cloud/api/commands/ListVirtualRouterElementsCmd.java
deleted file mode 100644
index aa24467..0000000
--- a/api/src/com/cloud/api/commands/ListVirtualRouterElementsCmd.java
+++ /dev/null
@@ -1,110 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cloudstack.api.user.network.command.ListNetworkOfferingsCmd;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.PlugService;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.VirtualRouterProviderResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.element.VirtualRouterElementService;
-
-@Implementation(description="Lists all available virtual router elements.", responseObject=VirtualRouterProviderResponse.class)
-public class ListVirtualRouterElementsCmd extends BaseListCmd {
-    public static final Logger s_logger = Logger.getLogger(ListNetworkOfferingsCmd.class.getName());
-    private static final String _name = "listvirtualrouterelementsresponse";
-
-    @PlugService
-    private VirtualRouterElementService _service;
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-    @IdentityMapper(entityTableName = "virtual_router_providers")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list virtual router elements by id")
-    private Long id;
-
-    @IdentityMapper(entityTableName = "physical_network_service_providers")
-    @Parameter(name=ApiConstants.NSP_ID, type=CommandType.LONG, description="list virtual router elements by network service provider id")
-    private Long nspId;
-
-    @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, description="list network offerings by enabled state")
-    private Boolean enabled;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setNspId(Long nspId) {
-        this.nspId = nspId;
-    }
-
-    public Long getNspId() {
-        return nspId;
-    }
-
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
-    }
-
-    public Boolean getEnabled() {
-        return enabled;
-    }
-
-    @Override
-    public String getCommandName() {
-        return _name;
-    }
-
-    @Override
-    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
-        List<? extends VirtualRouterProvider> providers = _service.searchForVirtualRouterElement(this);
-        ListResponse<VirtualRouterProviderResponse> response = new ListResponse<VirtualRouterProviderResponse>();
-        List<VirtualRouterProviderResponse> providerResponses = new ArrayList<VirtualRouterProviderResponse>();
-        for (VirtualRouterProvider provider : providers) {
-            VirtualRouterProviderResponse providerResponse = _responseGenerator.createVirtualRouterProviderResponse(provider);
-            providerResponses.add(providerResponse);
-        }
-        response.setResponses(providerResponses);
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/RebootRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/RebootRouterCmd.java b/api/src/com/cloud/api/commands/RebootRouterCmd.java
deleted file mode 100644
index 5e3e87f..0000000
--- a/api/src/com/cloud/api/commands/RebootRouterCmd.java
+++ /dev/null
@@ -1,109 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.DomainRouterResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Starts a router.", responseObject=DomainRouterResponse.class)
-public class RebootRouterCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(RebootRouterCmd.class.getName());
-    private static final String s_name = "rebootrouterresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the router")
-    private Long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
-        if (router != null) {
-            return router.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_ROUTER_REBOOT;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "rebooting router: " + getId();
-    }
-
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.DomainRouter;
-    }
-
-    public Long getInstanceId() {
-        return getId();
-    }
-
-
-    @Override
-    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
-        UserContext.current().setEventDetails("Router Id: "+getId());
-        VirtualRouter result = _routerService.rebootRouter(this.getId(), true);
-        if (result != null){
-            DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
-            response.setResponseName("router");
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reboot router");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/StartRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/StartRouterCmd.java b/api/src/com/cloud/api/commands/StartRouterCmd.java
deleted file mode 100644
index d4b12e8..0000000
--- a/api/src/com/cloud/api/commands/StartRouterCmd.java
+++ /dev/null
@@ -1,114 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.DomainRouterResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-
-@Implementation(responseObject=DomainRouterResponse.class, description="Starts a router.")
-public class StartRouterCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(StartRouterCmd.class.getName());
-    private static final String s_name = "startrouterresponse";
-
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the router")
-    private Long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public static String getResultObjectName() {
-        return "router";
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
-        if (router != null) {
-            return router.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_ROUTER_START;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "starting router: " + getId();
-    }
-
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.DomainRouter;
-    }
-
-    public Long getInstanceId() {
-        return getId();
-    }
-
-    @Override
-    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
-        UserContext.current().setEventDetails("Router Id: "+getId());
-        VirtualRouter result = _routerService.startRouter(id);
-        if (result != null){
-            DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
-            routerResponse.setResponseName(getCommandName());
-            this.setResponseObject(routerResponse);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start router");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/StopRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/StopRouterCmd.java b/api/src/com/cloud/api/commands/StopRouterCmd.java
deleted file mode 100644
index eb93bb6..0000000
--- a/api/src/com/cloud/api/commands/StopRouterCmd.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.DomainRouterResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description = "Stops a router.", responseObject = DomainRouterResponse.class)
-public class StopRouterCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(StopRouterCmd.class.getName());
-    private static final String s_name = "stoprouterresponse";
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the router")
-    private Long id;
-
-    @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
-    private Boolean forced;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
-        if (router != null) {
-            return router.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_ROUTER_STOP;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "stopping router: " + getId();
-    }
-
-    @Override
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.DomainRouter;
-    }
-
-    @Override
-    public Long getInstanceId() {
-        return getId();
-    }
-
-    public boolean isForced() {
-        return (forced != null) ? forced : false;
-    }
-
-    @Override
-    public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
-        UserContext.current().setEventDetails("Router Id: "+getId());
-        VirtualRouter result = _routerService.stopRouter(getId(), isForced());
-        if (result != null) {
-            DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
-            response.setResponseName(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/api/commands/UpgradeRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpgradeRouterCmd.java b/api/src/com/cloud/api/commands/UpgradeRouterCmd.java
deleted file mode 100644
index c916a5c..0000000
--- a/api/src/com/cloud/api/commands/UpgradeRouterCmd.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.DomainRouterResponse;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.user.Account;
-
-@Implementation(description="Upgrades domain router to a new service offering", responseObject=DomainRouterResponse.class)
-public class UpgradeRouterCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(UpgradeRouterCmd.class.getName());
-    private static final String s_name = "changeserviceforrouterresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the router")
-    private Long id;
-
-    @IdentityMapper(entityTableName="disk_offering")
-    @Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.LONG, required=true, description="the service offering ID to apply to the domain router")
-    private Long serviceOfferingId;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    public Long getServiceOfferingId() {
-        return serviceOfferingId;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-         return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
-        if (router != null) {
-            return router.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public void execute(){
-        VirtualRouter router = _routerService.upgradeRouter(this);
-        if (router != null){
-            DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
-            routerResponse.setResponseName(getCommandName());
-            this.setResponseObject(routerResponse);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to upgrade router");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/network/VirtualNetworkApplianceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/VirtualNetworkApplianceService.java b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
index fc63615..088fcc2 100644
--- a/api/src/com/cloud/network/VirtualNetworkApplianceService.java
+++ b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
@@ -16,7 +16,7 @@
 // under the License.
 package com.cloud.network;
 
-import com.cloud.api.commands.UpgradeRouterCmd;
+import org.apache.cloudstack.api.admin.router.command.UpgradeRouterCmd;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/network/element/VirtualRouterElementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/element/VirtualRouterElementService.java b/api/src/com/cloud/network/element/VirtualRouterElementService.java
index bf8cad2..05707e8 100644
--- a/api/src/com/cloud/network/element/VirtualRouterElementService.java
+++ b/api/src/com/cloud/network/element/VirtualRouterElementService.java
@@ -18,8 +18,8 @@ package com.cloud.network.element;
 
 import java.util.List;
 
-import com.cloud.api.commands.ConfigureVirtualRouterElementCmd;
-import com.cloud.api.commands.ListVirtualRouterElementsCmd;
+import org.apache.cloudstack.api.admin.router.command.ConfigureVirtualRouterElementCmd;
+import org.apache.cloudstack.api.admin.router.command.ListVirtualRouterElementsCmd;
 import com.cloud.network.VirtualRouterProvider;
 import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
 import com.cloud.utils.component.PluggableService;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index e2bc484..78f2cb5 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -24,6 +24,7 @@ import java.util.Set;
 
 import com.cloud.alert.Alert;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.admin.router.command.ListRoutersCmd;
 import org.apache.cloudstack.api.user.address.command.ListPublicIpAddressesCmd;
 import org.apache.cloudstack.api.user.resource.command.ListCapabilitiesCmd;
 import org.apache.cloudstack.api.user.guest.command.ListGuestOsCmd;
@@ -46,7 +47,6 @@ import org.apache.cloudstack.api.user.guest.command.ListGuestOsCategoriesCmd;
 import com.cloud.api.commands.ListHostsCmd;
 import org.apache.cloudstack.api.user.iso.command.ListIsosCmd;
 import com.cloud.api.commands.ListPodsByCmd;
-import com.cloud.api.commands.ListRoutersCmd;
 import org.apache.cloudstack.api.user.ssh.command.ListSSHKeyPairsCmd;
 import com.cloud.api.commands.ListStoragePoolsCmd;
 import com.cloud.api.commands.ListSystemVMsCmd;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/org/apache/cloudstack/api/admin/router/command/ConfigureVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/router/command/ConfigureVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/admin/router/command/ConfigureVirtualRouterElementCmd.java
new file mode 100644
index 0000000..e17a988
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/router/command/ConfigureVirtualRouterElementCmd.java
@@ -0,0 +1,128 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.router.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.PlugService;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.VirtualRouterProviderResponse;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.network.element.VirtualRouterElementService;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(responseObject=VirtualRouterProviderResponse.class, description="Configures a virtual router element.")
+public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(ConfigureVirtualRouterElementCmd.class.getName());
+    private static final String s_name = "configurevirtualrouterelementresponse";
+
+    @PlugService
+    private VirtualRouterElementService _service;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "virtual_router_providers")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the virtual router provider")
+    private Long id;
+
+    @IdentityMapper(entityTableName = "physical_network_service_providers")
+    @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enabled/Disabled the service provider")
+    private Boolean enabled;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setEnabled(Boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    public Boolean getEnabled() {
+        return enabled;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "boolean";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "configuring virtual router provider: " + id;
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.None;
+    }
+
+    public Long getInstanceId() {
+        return id;
+    }
+
+    @Override
+    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
+        UserContext.current().setEventDetails("Virtual router element: " + id);
+        VirtualRouterProvider result = _service.configure(this);
+        if (result != null){
+            VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
+            routerResponse.setResponseName(getCommandName());
+            this.setResponseObject(routerResponse);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure the virtual router provider");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/org/apache/cloudstack/api/admin/router/command/CreateVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/router/command/CreateVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/admin/router/command/CreateVirtualRouterElementCmd.java
new file mode 100644
index 0000000..5c88c2d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/router/command/CreateVirtualRouterElementCmd.java
@@ -0,0 +1,117 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.router.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.PlugService;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.VirtualRouterProviderResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.element.VirtualRouterElementService;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(responseObject=VirtualRouterProviderResponse.class, description="Create a virtual router element.")
+public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateVirtualRouterElementCmd.class.getName());
+    private static final String s_name = "createvirtualrouterelementresponse";
+
+    @PlugService
+    private VirtualRouterElementService _service;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.LONG, required=true, description="the network service provider ID of the virtual router element")
+    @IdentityMapper(entityTableName="physical_network_service_providers")
+    private Long nspId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public void setNspId(Long nspId) {
+        this.nspId = nspId;
+    }
+
+    @Override
+    public String getEntityTable() {
+        return "virtual_router_providers";
+    }
+
+    public Long getNspId() {
+        return nspId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
+        VirtualRouterProvider result = _service.getCreatedElement(getEntityId());
+        if (result != null) {
+            VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        }else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
+        }
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        VirtualRouterProvider result = _service.addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
+        if (result != null) {
+            setEntityId(result.getId());
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "Adding physical network ServiceProvider Virtual Router: " + getEntityId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/org/apache/cloudstack/api/admin/router/command/DestroyRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/router/command/DestroyRouterCmd.java b/api/src/org/apache/cloudstack/api/admin/router/command/DestroyRouterCmd.java
new file mode 100644
index 0000000..1408a57
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/router/command/DestroyRouterCmd.java
@@ -0,0 +1,111 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.router.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.DomainRouterResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description = "Destroys a router.", responseObject = DomainRouterResponse.class)
+public class DestroyRouterCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DestroyRouterCmd.class.getName());
+    private static final String s_name = "destroyrouterresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="vm_instance")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the router")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
+        if (router != null) {
+            return router.getAccountId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_ROUTER_DESTROY;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "destroying router: " + getId();
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.DomainRouter;
+    }
+
+    @Override
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
+        UserContext ctx = UserContext.current();
+        ctx.setEventDetails("Router Id: "+getId());
+
+        VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCaller(), ctx.getCallerUserId());
+        if (result != null) {
+            DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy router");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/org/apache/cloudstack/api/admin/router/command/ListRoutersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/router/command/ListRoutersCmd.java b/api/src/org/apache/cloudstack/api/admin/router/command/ListRoutersCmd.java
new file mode 100644
index 0000000..1659bea
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/router/command/ListRoutersCmd.java
@@ -0,0 +1,146 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.router.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.DomainRouterResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.utils.Pair;
+
+@Implementation(description="List routers.", responseObject=DomainRouterResponse.class)
+public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListRoutersCmd.class.getName());
+
+    private static final String s_name = "listroutersresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="the host ID of the router")
+    private Long hostId;
+
+    @IdentityMapper(entityTableName="vm_instance")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the disk router")
+    private Long id;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the router")
+    private String routerName;
+
+    @IdentityMapper(entityTableName="host_pod_ref")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID of the router")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the router")
+    private String state;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID of the router")
+    private Long zoneId;
+
+    @IdentityMapper(entityTableName="networks")
+    @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="list by network id")
+    private Long networkId;
+
+    @IdentityMapper(entityTableName="vpc")
+    @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List networks by VPC")
+    private Long vpcId;
+
+    @Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC routers")
+    private Boolean forVpc;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getRouterName() {
+        return routerName;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public Long getNetworkId() {
+        return networkId;
+    }
+
+    public Long getVpcId() {
+        return vpcId;
+    }
+
+    public Boolean getForVpc() {
+        return forVpc;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.DomainRouter;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends VirtualRouter>, Integer> result = _mgr.searchForRouters(this);
+        ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>();
+        List<DomainRouterResponse> routerResponses = new ArrayList<DomainRouterResponse>();
+        for (VirtualRouter router : result.first()) {
+            DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
+            routerResponse.setObjectName("router");
+            routerResponses.add(routerResponse);
+        }
+
+        response.setResponses(routerResponses, result.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/org/apache/cloudstack/api/admin/router/command/ListVirtualRouterElementsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/router/command/ListVirtualRouterElementsCmd.java b/api/src/org/apache/cloudstack/api/admin/router/command/ListVirtualRouterElementsCmd.java
new file mode 100644
index 0000000..6206de5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/router/command/ListVirtualRouterElementsCmd.java
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.router.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.user.network.command.ListNetworkOfferingsCmd;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.PlugService;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.ListResponse;
+import com.cloud.api.response.VirtualRouterProviderResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.network.element.VirtualRouterElementService;
+
+@Implementation(description="Lists all available virtual router elements.", responseObject=VirtualRouterProviderResponse.class)
+public class ListVirtualRouterElementsCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListNetworkOfferingsCmd.class.getName());
+    private static final String _name = "listvirtualrouterelementsresponse";
+
+    @PlugService
+    private VirtualRouterElementService _service;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @IdentityMapper(entityTableName = "virtual_router_providers")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list virtual router elements by id")
+    private Long id;
+
+    @IdentityMapper(entityTableName = "physical_network_service_providers")
+    @Parameter(name=ApiConstants.NSP_ID, type=CommandType.LONG, description="list virtual router elements by network service provider id")
+    private Long nspId;
+
+    @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, description="list network offerings by enabled state")
+    private Boolean enabled;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setNspId(Long nspId) {
+        this.nspId = nspId;
+    }
+
+    public Long getNspId() {
+        return nspId;
+    }
+
+    public void setEnabled(Boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    public Boolean getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public String getCommandName() {
+        return _name;
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+        List<? extends VirtualRouterProvider> providers = _service.searchForVirtualRouterElement(this);
+        ListResponse<VirtualRouterProviderResponse> response = new ListResponse<VirtualRouterProviderResponse>();
+        List<VirtualRouterProviderResponse> providerResponses = new ArrayList<VirtualRouterProviderResponse>();
+        for (VirtualRouterProvider provider : providers) {
+            VirtualRouterProviderResponse providerResponse = _responseGenerator.createVirtualRouterProviderResponse(provider);
+            providerResponses.add(providerResponse);
+        }
+        response.setResponses(providerResponses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/org/apache/cloudstack/api/admin/router/command/RebootRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/router/command/RebootRouterCmd.java b/api/src/org/apache/cloudstack/api/admin/router/command/RebootRouterCmd.java
new file mode 100644
index 0000000..be1ef24
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/router/command/RebootRouterCmd.java
@@ -0,0 +1,109 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.router.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.DomainRouterResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Starts a router.", responseObject=DomainRouterResponse.class)
+public class RebootRouterCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(RebootRouterCmd.class.getName());
+    private static final String s_name = "rebootrouterresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="vm_instance")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the router")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
+        if (router != null) {
+            return router.getAccountId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_ROUTER_REBOOT;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "rebooting router: " + getId();
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.DomainRouter;
+    }
+
+    public Long getInstanceId() {
+        return getId();
+    }
+
+
+    @Override
+    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
+        UserContext.current().setEventDetails("Router Id: "+getId());
+        VirtualRouter result = _routerService.rebootRouter(this.getId(), true);
+        if (result != null){
+            DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
+            response.setResponseName("router");
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reboot router");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c59de6cb/api/src/org/apache/cloudstack/api/admin/router/command/StartRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/router/command/StartRouterCmd.java b/api/src/org/apache/cloudstack/api/admin/router/command/StartRouterCmd.java
new file mode 100644
index 0000000..cf3b5f1
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/router/command/StartRouterCmd.java
@@ -0,0 +1,114 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.admin.router.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.DomainRouterResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+
+@Implementation(responseObject=DomainRouterResponse.class, description="Starts a router.")
+public class StartRouterCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(StartRouterCmd.class.getName());
+    private static final String s_name = "startrouterresponse";
+
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="vm_instance")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the router")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "router";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
+        if (router != null) {
+            return router.getAccountId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_ROUTER_START;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "starting router: " + getId();
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.DomainRouter;
+    }
+
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
+        UserContext.current().setEventDetails("Router Id: "+getId());
+        VirtualRouter result = _routerService.startRouter(id);
+        if (result != null){
+            DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
+            routerResponse.setResponseName(getCommandName());
+            this.setResponseObject(routerResponse);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start router");
+        }
+    }
+}


Mime
View raw message