You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/23 01:14:01 UTC

[1/2] git commit: api: Refactor and move VPN related api cmd classes to command.user.vpn

Updated Branches:
  refs/heads/api_refactoring a15da0493 -> 97514a069


api: Refactor and move VPN related api cmd classes to command.user.vpn

Signed-off-by: Rohit Yadav <bh...@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/2140ff55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/2140ff55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/2140ff55

Branch: refs/heads/api_refactoring
Commit: 2140ff55ea986c8c0f2c7e2f2afcb5a5d55f2fed
Parents: a15da04
Author: Rohit Yadav <bh...@apache.org>
Authored: Fri Dec 21 19:43:25 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Sat Dec 22 16:13:37 2012 -0800

----------------------------------------------------------------------
 .../cloud/network/vpn/RemoteAccessVpnService.java  |    2 +-
 .../api/command/user/user/AddVpnUserCmd.java       |  154 ---------------
 .../api/command/user/user/ListVpnUsersCmd.java     |   84 --------
 .../api/command/user/user/RemoveVpnUserCmd.java    |  122 ------------
 .../api/command/user/vpn/AddVpnUserCmd.java        |  154 +++++++++++++++
 .../api/command/user/vpn/ListVpnUsersCmd.java      |   84 ++++++++
 .../api/command/user/vpn/RemoveVpnUserCmd.java     |  122 ++++++++++++
 .../cloud/api/commands/test/AddVpnUserCmdTest.java |    2 +-
 client/tomcatconf/commands.properties.in           |    6 +-
 .../network/vpn/RemoteAccessVpnManagerImpl.java    |    2 +-
 10 files changed, 366 insertions(+), 366 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
index b5828ac..81599a0 100644
--- a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
+++ b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java
@@ -18,7 +18,7 @@ package com.cloud.network.vpn;
 
 import java.util.List;
 
-import org.apache.cloudstack.api.command.user.user.ListVpnUsersCmd;
+import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;
 import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/src/org/apache/cloudstack/api/command/user/user/AddVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/user/AddVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/user/AddVpnUserCmd.java
deleted file mode 100644
index d8292f2..0000000
--- a/api/src/org/apache/cloudstack/api/command/user/user/AddVpnUserCmd.java
+++ /dev/null
@@ -1,154 +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 org.apache.cloudstack.api.command.user.user;
-
-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.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.DomainResponse;
-import org.apache.cloudstack.api.response.ProjectResponse;
-import org.apache.cloudstack.api.response.VpnUsersResponse;
-import com.cloud.domain.Domain;
-import com.cloud.event.EventTypes;
-import com.cloud.network.VpnUser;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Adds vpn users", responseObject=VpnUsersResponse.class)
-public class AddVpnUserCmd extends BaseAsyncCreateCmd {
-    public static final Logger s_logger = Logger.getLogger(AddVpnUserCmd.class.getName());
-
-    private static final String s_name = "addvpnuserresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="username for the vpn user")
-    private String userName;
-
-    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="password for the username")
-    private String password;
-
-    @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
-    private String accountName;
-
-    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType=ProjectResponse.class,
-            description="add vpn user to the specific project")
-    private Long projectId;
-
-    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
-            description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
-    private Long domainId;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-
-    public String getAccountName() {
-        return accountName;
-    }
-
-    public Long getDomainId() {
-        return domainId;
-    }
-
-    public String getUserName() {
-        return userName;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public Long getProjectId() {
-        return projectId;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
-        if (accountId == null) {
-            return UserContext.current().getCaller().getId();
-        }
-
-        return accountId;
-    }
-
-    public String getEntityTable() {
-        return "vpn_users";
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "Add Remote Access VPN user for account " + getEntityOwnerId() + " username= " + getUserName();
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_VPN_USER_ADD;
-    }
-
-    @Override
-    public void execute(){
-        VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
-        Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
-        if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
-        }
-
-        VpnUsersResponse vpnResponse = new VpnUsersResponse();
-        vpnResponse.setId(vpnUser.getUuid());
-        vpnResponse.setUserName(vpnUser.getUsername());
-        vpnResponse.setAccountName(account.getAccountName());
-
-        Domain domain = _entityMgr.findById(Domain.class, account.getDomainId());
-        if (domain != null) {
-            vpnResponse.setDomainId(domain.getUuid());
-            vpnResponse.setDomainName(domain.getName());
-        }
-
-        vpnResponse.setResponseName(getCommandName());
-        vpnResponse.setObjectName("vpnuser");
-        this.setResponseObject(vpnResponse);
-    }
-
-    @Override
-    public void create() {
-        Account owner = _accountService.getAccount(getEntityOwnerId());
-
-        VpnUser vpnUser = _ravService.addVpnUser(owner.getId(), userName, password);
-        if (vpnUser == null) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
-        }
-        setEntityId(vpnUser.getId());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/src/org/apache/cloudstack/api/command/user/user/ListVpnUsersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/user/ListVpnUsersCmd.java b/api/src/org/apache/cloudstack/api/command/user/user/ListVpnUsersCmd.java
deleted file mode 100644
index f98d3c8..0000000
--- a/api/src/org/apache/cloudstack/api/command/user/user/ListVpnUsersCmd.java
+++ /dev/null
@@ -1,84 +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 org.apache.cloudstack.api.command.user.user;
-
-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.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cloudstack.api.response.VpnUsersResponse;
-import com.cloud.network.VpnUser;
-import com.cloud.utils.Pair;
-
-@Implementation(description="Lists vpn users", responseObject=VpnUsersResponse.class)
-public class ListVpnUsersCmd extends BaseListProjectAndAccountResourcesCmd {
-    public static final Logger s_logger = Logger.getLogger (ListVpnUsersCmd.class.getName());
-
-    private static final String s_name = "listvpnusersresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpnUsersResponse.class,
-            description="The uuid of the Vpn user")
-    private Long id;
-
-    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of the vpn user.")
-    private String userName;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getUsername() {
-        return userName;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public void execute(){
-        Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
-
-        ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
-        List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
-        for (VpnUser vpnUser : vpnUsers.first()) {
-            vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
-        }
-
-        response.setResponses(vpnResponses, vpnUsers.second());
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/src/org/apache/cloudstack/api/command/user/user/RemoveVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/user/RemoveVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/user/RemoveVpnUserCmd.java
deleted file mode 100644
index eee343c..0000000
--- a/api/src/org/apache/cloudstack/api/command/user/user/RemoveVpnUserCmd.java
+++ /dev/null
@@ -1,122 +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 org.apache.cloudstack.api.command.user.user;
-
-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.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.DomainResponse;
-import org.apache.cloudstack.api.response.ProjectResponse;
-import org.apache.cloudstack.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Removes vpn user", responseObject=SuccessResponse.class)
-public class RemoveVpnUserCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(RemoveVpnUserCmd.class.getName());
-
-    private static final String s_name = "removevpnuserresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="username for the vpn user")
-    private String userName;
-
-    @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
-    private String accountName;
-
-    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType=ProjectResponse.class,
-            description="remove vpn user from the project")
-    private Long projectId;
-
-    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
-            description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
-    private Long domainId;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-
-    public String getAccountName() {
-        return accountName;
-    }
-
-    public Long getDomainId() {
-        return domainId;
-    }
-
-    public String getUserName() {
-        return userName;
-    }
-
-    public Long getProjecId() {
-        return projectId;
-    }
-
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
-        if (accountId == null) {
-            return UserContext.current().getCaller().getId();
-        }
-
-        return accountId;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return "Remove Remote Access VPN user for account " + getEntityOwnerId() + " username= " + getUserName();
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_VPN_USER_REMOVE;
-    }
-
-    @Override
-    public void execute(){
-        Account owner = _accountService.getAccount(getEntityOwnerId());
-        boolean result = _ravService.removeVpnUser(owner.getId(), userName, UserContext.current().getCaller());
-        if (!result) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove vpn user");
-        }
-
-        if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to apply vpn user removal");
-        }
-        SuccessResponse response = new SuccessResponse(getCommandName());
-        setResponseObject(response);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
new file mode 100644
index 0000000..ee20521
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
@@ -0,0 +1,154 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.vpn;
+
+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.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.response.VpnUsersResponse;
+import com.cloud.domain.Domain;
+import com.cloud.event.EventTypes;
+import com.cloud.network.VpnUser;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Adds vpn users", responseObject=VpnUsersResponse.class)
+public class AddVpnUserCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(AddVpnUserCmd.class.getName());
+
+    private static final String s_name = "addvpnuserresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="username for the vpn user")
+    private String userName;
+
+    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="password for the username")
+    private String password;
+
+    @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
+    private String accountName;
+
+    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType=ProjectResponse.class,
+            description="add vpn user to the specific project")
+    private Long projectId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+            description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
+    private Long domainId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public Long getProjectId() {
+        return projectId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        if (accountId == null) {
+            return UserContext.current().getCaller().getId();
+        }
+
+        return accountId;
+    }
+
+    public String getEntityTable() {
+        return "vpn_users";
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Add Remote Access VPN user for account " + getEntityOwnerId() + " username= " + getUserName();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_VPN_USER_ADD;
+    }
+
+    @Override
+    public void execute(){
+        VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
+        Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
+        if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
+        }
+
+        VpnUsersResponse vpnResponse = new VpnUsersResponse();
+        vpnResponse.setId(vpnUser.getUuid());
+        vpnResponse.setUserName(vpnUser.getUsername());
+        vpnResponse.setAccountName(account.getAccountName());
+
+        Domain domain = _entityMgr.findById(Domain.class, account.getDomainId());
+        if (domain != null) {
+            vpnResponse.setDomainId(domain.getUuid());
+            vpnResponse.setDomainName(domain.getName());
+        }
+
+        vpnResponse.setResponseName(getCommandName());
+        vpnResponse.setObjectName("vpnuser");
+        this.setResponseObject(vpnResponse);
+    }
+
+    @Override
+    public void create() {
+        Account owner = _accountService.getAccount(getEntityOwnerId());
+
+        VpnUser vpnUser = _ravService.addVpnUser(owner.getId(), userName, password);
+        if (vpnUser == null) {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
+        }
+        setEntityId(vpnUser.getId());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java
new file mode 100644
index 0000000..6ac950e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java
@@ -0,0 +1,84 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.vpn;
+
+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.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.VpnUsersResponse;
+import com.cloud.network.VpnUser;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists vpn users", responseObject=VpnUsersResponse.class)
+public class ListVpnUsersCmd extends BaseListProjectAndAccountResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger (ListVpnUsersCmd.class.getName());
+
+    private static final String s_name = "listvpnusersresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpnUsersResponse.class,
+            description="The uuid of the Vpn user")
+    private Long id;
+
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of the vpn user.")
+    private String userName;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getUsername() {
+        return userName;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
+
+        ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
+        List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
+        for (VpnUser vpnUser : vpnUsers.first()) {
+            vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
+        }
+
+        response.setResponses(vpnResponses, vpnUsers.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
new file mode 100644
index 0000000..2dbb0ad
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.vpn;
+
+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.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Removes vpn user", responseObject=SuccessResponse.class)
+public class RemoveVpnUserCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(RemoveVpnUserCmd.class.getName());
+
+    private static final String s_name = "removevpnuserresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="username for the vpn user")
+    private String userName;
+
+    @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
+    private String accountName;
+
+    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType=ProjectResponse.class,
+            description="remove vpn user from the project")
+    private Long projectId;
+
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+            description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
+    private Long domainId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public Long getProjecId() {
+        return projectId;
+    }
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        if (accountId == null) {
+            return UserContext.current().getCaller().getId();
+        }
+
+        return accountId;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Remove Remote Access VPN user for account " + getEntityOwnerId() + " username= " + getUserName();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_VPN_USER_REMOVE;
+    }
+
+    @Override
+    public void execute(){
+        Account owner = _accountService.getAccount(getEntityOwnerId());
+        boolean result = _ravService.removeVpnUser(owner.getId(), userName, UserContext.current().getCaller());
+        if (!result) {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove vpn user");
+        }
+
+        if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to apply vpn user removal");
+        }
+        SuccessResponse response = new SuccessResponse(getCommandName());
+        setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/api/test/src/com/cloud/api/commands/test/AddVpnUserCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/src/com/cloud/api/commands/test/AddVpnUserCmdTest.java b/api/test/src/com/cloud/api/commands/test/AddVpnUserCmdTest.java
index f5dd1ce..11ef43e 100644
--- a/api/test/src/com/cloud/api/commands/test/AddVpnUserCmdTest.java
+++ b/api/test/src/com/cloud/api/commands/test/AddVpnUserCmdTest.java
@@ -19,7 +19,7 @@ package src.com.cloud.api.commands.test;
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
-import org.apache.cloudstack.api.command.user.user.AddVpnUserCmd;
+import org.apache.cloudstack.api.command.user.vpn.AddVpnUserCmd;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index ccb98bf..df77687 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -298,9 +298,9 @@ createRemoteAccessVpn=org.apache.cloudstack.api.command.user.vpn.CreateRemoteAcc
 deleteRemoteAccessVpn=org.apache.cloudstack.api.command.user.vpn.DeleteRemoteAccessVpnCmd;15
 listRemoteAccessVpns=org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;15
 
-addVpnUser=org.apache.cloudstack.api.command.user.user.AddVpnUserCmd;15
-removeVpnUser=org.apache.cloudstack.api.command.user.user.RemoveVpnUserCmd;15
-listVpnUsers=org.apache.cloudstack.api.command.user.user.ListVpnUsersCmd;15
+addVpnUser=org.apache.cloudstack.api.command.user.vpn.AddVpnUserCmd;15
+removeVpnUser=org.apache.cloudstack.api.command.user.vpn.RemoveVpnUserCmd;15
+listVpnUsers=org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;15
 
 #### network offering commands
 createNetworkOffering=org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;1

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2140ff55/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index 46b5af9..67d6b8c 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -23,7 +23,7 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
-import org.apache.cloudstack.api.command.user.user.ListVpnUsersCmd;
+import org.apache.cloudstack.api.command.user.vpn.ListVpnUsersCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd;