You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2013/02/01 07:32:04 UTC

[14/40] git commit: refs/heads/master - Added Mock ApiServer, Regions API calls with api keys

Added Mock ApiServer, Regions API calls with api keys


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

Branch: refs/heads/master
Commit: f0f33bf4da7948f2109d0e07a4d80c4e362d86b8
Parents: 89779cc
Author: Kishan Kavala <ki...@cloud.com>
Authored: Wed Oct 17 14:16:36 2012 +0530
Committer: Kishan Kavala <ki...@cloud.com>
Committed: Wed Oct 17 14:16:36 2012 +0530

----------------------------------------------------------------------
 api/src/com/cloud/api/ResponseGenerator.java       |    9 +
 api/src/com/cloud/api/commands/AddRegionCmd.java   |   24 +-
 .../com/cloud/api/commands/CreateAccountCmd.java   |    6 +-
 .../com/cloud/api/commands/CreateDomainCmd.java    |    6 +-
 api/src/com/cloud/api/commands/CreateUserCmd.java  |    6 +-
 api/src/com/cloud/api/commands/FindAccountCmd.java |   77 ++
 api/src/com/cloud/api/commands/FindDomainCmd.java  |   90 ++
 api/src/com/cloud/api/commands/FindUserCmd.java    |   84 ++
 api/src/com/cloud/api/commands/ListRegionsCmd.java |   13 +-
 .../com/cloud/api/commands/RemoveRegionCmd.java    |   11 +-
 .../com/cloud/api/commands/UpdateDomainCmd.java    |    2 +-
 .../com/cloud/api/commands/UpdateRegionCmd.java    |   27 +-
 .../cloud/api/response/FindAccountResponse.java    |   95 ++
 .../com/cloud/api/response/FindDomainResponse.java |  111 +++
 .../com/cloud/api/response/FindUserResponse.java   |  189 ++++
 api/src/com/cloud/api/response/RegionResponse.java |    6 +-
 api/src/com/cloud/domain/Domain.java               |    2 +
 api/src/com/cloud/region/Region.java               |   11 +-
 api/src/com/cloud/region/RegionService.java        |    6 +-
 api/src/com/cloud/server/ManagementService.java    |    9 -
 api/src/com/cloud/user/Account.java                |    2 +-
 api/src/com/cloud/user/AccountService.java         |    7 +-
 api/src/com/cloud/user/DomainService.java          |   20 +-
 api/src/com/cloud/user/User.java                   |    3 +-
 client/tomcatconf/commands.properties.in           |    3 +
 client/tomcatconf/components-regions.xml.in        |   52 ++
 client/tomcatconf/components.xml.in                |    1 +
 client/tomcatconf/db.properties.in                 |    1 +
 client/tomcatconf/environment.properties.in        |    2 +-
 core/src/com/cloud/user/AccountVO.java             |   14 +-
 core/src/com/cloud/user/UserVO.java                |    8 +-
 .../cloud/server/auth/MD5UserAuthenticator.java    |    8 +-
 server/src/com/cloud/api/ApiResponseHelper.java    |   55 ++
 server/src/com/cloud/api/ApiServer.java            |    7 +-
 server/src/com/cloud/api/MockApiServer.java        |  638 ++++++++++++++
 server/src/com/cloud/domain/DomainVO.java          |   10 +-
 server/src/com/cloud/domain/dao/DomainDaoImpl.java |   10 +-
 .../src/com/cloud/projects/ProjectManagerImpl.java |    2 +-
 .../src/com/cloud/region/FindDomainResponse.java   |   36 +
 server/src/com/cloud/region/FindUserResponse.java  |   34 +
 server/src/com/cloud/region/RegionAccount.java     |  287 ++++++
 server/src/com/cloud/region/RegionDomain.java      |   61 ++
 server/src/com/cloud/region/RegionManager.java     |    9 +-
 server/src/com/cloud/region/RegionManagerImpl.java |  635 ++++++++------
 server/src/com/cloud/region/RegionUser.java        |   76 ++
 server/src/com/cloud/region/RegionVO.java          |   44 +-
 server/src/com/cloud/region/RegionsApiUtil.java    |  285 ++++++
 server/src/com/cloud/region/dao/RegionDao.java     |    2 +-
 server/src/com/cloud/region/dao/RegionDaoImpl.java |    2 +-
 .../com/cloud/server/ConfigurationServerImpl.java  |   15 +-
 .../src/com/cloud/server/ManagementServerImpl.java |   93 --
 server/src/com/cloud/user/AccountManager.java      |    2 +-
 server/src/com/cloud/user/AccountManagerImpl.java  |   23 +-
 server/src/com/cloud/user/DomainManager.java       |   11 +-
 server/src/com/cloud/user/DomainManagerImpl.java   |   98 ++-
 server/src/com/cloud/user/dao/AccountDaoImpl.java  |    1 -
 .../src/com/cloud/user/dao/UserAccountDaoImpl.java |    1 +
 server/src/com/cloud/user/dao/UserDaoImpl.java     |    9 +-
 .../test/com/cloud/async/TestAsyncJobManager.java  |   12 +-
 .../security/MockSecurityGroupManagerImpl.java     |  198 +++++
 .../com/cloud/storage/MockStorageManagerImpl.java  |  679 +++++++++++++++
 .../com/cloud/user/MockAccountManagerImpl.java     |   61 +-
 .../test/com/cloud/user/MockDomainManagerImpl.java |   34 +-
 .../test/com/cloud/vm/MockUserVmManagerImpl.java   |    3 +-
 .../cloud/vpc/MockConfigurationManagerImpl.java    |    3 +-
 setup/db/create-schema.sql                         |   15 +-
 utils/conf/db.properties                           |    1 +
 utils/src/com/cloud/utils/db/GenericDao.java       |    2 +
 utils/src/com/cloud/utils/db/GenericDaoBase.java   |    5 +
 utils/src/com/cloud/utils/db/Transaction.java      |    7 +
 70 files changed, 3812 insertions(+), 559 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/ResponseGenerator.java b/api/src/com/cloud/api/ResponseGenerator.java
index b245e42..b61922e 100755
--- a/api/src/com/cloud/api/ResponseGenerator.java
+++ b/api/src/com/cloud/api/ResponseGenerator.java
@@ -34,6 +34,9 @@ import com.cloud.api.response.DomainResponse;
 import com.cloud.api.response.DomainRouterResponse;
 import com.cloud.api.response.EventResponse;
 import com.cloud.api.response.ExtractResponse;
+import com.cloud.api.response.FindAccountResponse;
+import com.cloud.api.response.FindDomainResponse;
+import com.cloud.api.response.FindUserResponse;
 import com.cloud.api.response.FirewallResponse;
 import com.cloud.api.response.FirewallRuleResponse;
 import com.cloud.api.response.HostResponse;
@@ -344,4 +347,10 @@ public interface ResponseGenerator {
     Site2SiteCustomerGatewayResponse createSite2SiteCustomerGatewayResponse(Site2SiteCustomerGateway result);
 
     Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result);
+
+	FindUserResponse createFindUserResponse(User user);
+
+	FindAccountResponse createFindAccountResponse(Account account);
+
+	FindDomainResponse createFindDomainResponse(Domain domain);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/AddRegionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AddRegionCmd.java b/api/src/com/cloud/api/commands/AddRegionCmd.java
index 0338b91..f2fd91f 100644
--- a/api/src/com/cloud/api/commands/AddRegionCmd.java
+++ b/api/src/com/cloud/api/commands/AddRegionCmd.java
@@ -36,20 +36,26 @@ public class AddRegionCmd extends BaseCmd {
     /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="Id of the Region")
-    private Long id;
+    @Parameter(name=ApiConstants.ID, type=CommandType.INTEGER, required=true, description="Id of the Region")
+    private Integer id;
     
     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="adds Region with this name")
     private String regionName;
 
     @Parameter(name=ApiConstants.END_POINT, type=CommandType.STRING, required=true, description="end_point of the Region")
     private String endPoint;
+
+    @Parameter(name=ApiConstants.API_KEY, type=CommandType.STRING, description="API key")
+    private String apiKey;
+    
+    @Parameter(name=ApiConstants.SECRET_KEY, type=CommandType.STRING, description="Secret Key")
+    private String secretKey;
     
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
 
-    public Long getId() {
+    public Integer getId() {
         return id;
     }
     
@@ -59,8 +65,16 @@ public class AddRegionCmd extends BaseCmd {
 
     public String getEndPoint() {
         return endPoint;
-    }  
+    }
 
+    public String getApiKey() {
+        return apiKey;
+    }
+    
+    public String getSecretKey() {
+        return secretKey;
+    }
+    
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
@@ -77,7 +91,7 @@ public class AddRegionCmd extends BaseCmd {
     
     @Override
     public void execute(){
-        Region region = _regionService.addRegion(getId(), getRegionName(), getEndPoint());
+        Region region = _regionService.addRegion(getId(), getRegionName(), getEndPoint(), getApiKey(), getSecretKey());
         if (region != null) {
         	RegionResponse response = _responseGenerator.createRegionResponse(region);
             response.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/CreateAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAccountCmd.java b/api/src/com/cloud/api/commands/CreateAccountCmd.java
index 21a51a6..e778a02 100755
--- a/api/src/com/cloud/api/commands/CreateAccountCmd.java
+++ b/api/src/com/cloud/api/commands/CreateAccountCmd.java
@@ -86,8 +86,8 @@ public class CreateAccountCmd extends BaseCmd {
     @Parameter(name=ApiConstants.USER_ID, type=CommandType.STRING, description="User UUID, required for adding account from another Region")
     private String userUUID;
 
-    @Parameter(name=ApiConstants.REGION_ID, type=CommandType.LONG, description="Id of the Region creating the account")
-    private Long regionId;
+    @Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, description="Id of the Region creating the account")
+    private Integer regionId;
 
     
     /////////////////////////////////////////////////////
@@ -152,7 +152,7 @@ public class CreateAccountCmd extends BaseCmd {
 		return userUUID;
 	}
 
-	public Long getRegionId() {
+	public Integer getRegionId() {
 		return regionId;
 	}
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/CreateDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateDomainCmd.java b/api/src/com/cloud/api/commands/CreateDomainCmd.java
index 29fd050..7644dba 100644
--- a/api/src/com/cloud/api/commands/CreateDomainCmd.java
+++ b/api/src/com/cloud/api/commands/CreateDomainCmd.java
@@ -53,8 +53,8 @@ public class CreateDomainCmd extends BaseCmd {
     @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.STRING, description="Domain UUID, required for adding domain from another Region")
     private String domainUUID;
     
-    @Parameter(name=ApiConstants.REGION_ID, type=CommandType.LONG, description="Id of the Region creating the Domain")
-    private Long regionId;
+    @Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, description="Id of the Region creating the Domain")
+    private Integer regionId;
     
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
@@ -76,7 +76,7 @@ public class CreateDomainCmd extends BaseCmd {
         return domainUUID;
     }
     
-	public Long getRegionId() {
+	public Integer getRegionId() {
 		return regionId;
 	}
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/CreateUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateUserCmd.java b/api/src/com/cloud/api/commands/CreateUserCmd.java
index 66a27f0..dcc75aa 100644
--- a/api/src/com/cloud/api/commands/CreateUserCmd.java
+++ b/api/src/com/cloud/api/commands/CreateUserCmd.java
@@ -68,8 +68,8 @@ public class CreateUserCmd extends BaseCmd {
     @Parameter(name=ApiConstants.USER_ID, type=CommandType.STRING, description="User UUID, required for adding account from another Region")
     private String userUUID;
     
-    @Parameter(name=ApiConstants.REGION_ID, type=CommandType.LONG, description="Id of the Region creating the User")
-    private Long regionId;
+    @Parameter(name=ApiConstants.REGION_ID, type=CommandType.INTEGER, description="Id of the Region creating the User")
+    private Integer regionId;
     
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
@@ -111,7 +111,7 @@ public class CreateUserCmd extends BaseCmd {
 		return userUUID;
 	}
     
-	public Long getRegionId() {
+	public Integer getRegionId() {
 		return regionId;
 	}
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/FindAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/FindAccountCmd.java b/api/src/com/cloud/api/commands/FindAccountCmd.java
new file mode 100644
index 0000000..3c8610a
--- /dev/null
+++ b/api/src/com/cloud/api/commands/FindAccountCmd.java
@@ -0,0 +1,77 @@
+// 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 com.cloud.api.ApiConstants;
+import com.cloud.api.BaseCmd;
+import com.cloud.api.IdentityMapper;
+import com.cloud.api.Implementation;
+import com.cloud.api.Parameter;
+import com.cloud.api.response.FindAccountResponse;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.Account;
+
+@Implementation(description="Find account by ID", responseObject=FindAccountResponse.class)
+public class FindAccountCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(FindAccountCmd.class.getName());
+
+    private static final String s_name = "findaccountresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="account")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required=true, description = "Id of the account")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+	public Long getId() {
+		return id;
+	}
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+	@Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+	@Override
+	public long getEntityOwnerId() {
+		return 0;
+	}
+	
+    @Override
+    public void execute(){
+        Account result = _accountService.findAccount(getId());
+        if(result != null){
+        	FindAccountResponse response = _responseGenerator.createFindAccountResponse(result);
+        	response.setResponseName(getCommandName());
+        	this.setResponseObject(response);
+        } else {
+            throw new InvalidParameterValueException("Account with specified Id does not exist");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/FindDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/FindDomainCmd.java b/api/src/com/cloud/api/commands/FindDomainCmd.java
new file mode 100644
index 0000000..cb299d1
--- /dev/null
+++ b/api/src/com/cloud/api/commands/FindDomainCmd.java
@@ -0,0 +1,90 @@
+// 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 com.cloud.api.ApiConstants;
+import com.cloud.api.BaseCmd;
+import com.cloud.api.IdentityMapper;
+import com.cloud.api.Implementation;
+import com.cloud.api.Parameter;
+import com.cloud.api.response.FindDomainResponse;
+import com.cloud.domain.Domain;
+import com.cloud.exception.InvalidParameterValueException;
+
+@Implementation(description="Find account by ID", responseObject=FindDomainResponse.class)
+public class FindDomainCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(FindDomainCmd.class.getName());
+
+    private static final String s_name = "finddomainresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "Id of the domain")
+    private Long id;
+
+    @Parameter(name = ApiConstants.DOMAIN, type = CommandType.STRING, description = "Path of the domain")
+    private String domain;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+	public Long getId() {
+		return id;
+	}
+
+	public String getDomain() {
+		return domain;
+	}
+	
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+	@Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+	@Override
+	public long getEntityOwnerId() {
+		return 0;
+	}
+	
+    @Override
+    public void execute(){
+    	Domain result = null;
+    	if(getId() != null){
+    		result = _domainService.getDomain(getId());	
+    	} else if (getDomain() != null){
+    		result = _domainService.findDomainByPath(getDomain());
+    	}
+        
+        if(result != null){
+        	FindDomainResponse response = _responseGenerator.createFindDomainResponse(result);
+        	response.setResponseName(getCommandName());
+        	this.setResponseObject(response);
+        } else {
+            throw new InvalidParameterValueException("Domain with specified Id does not exist");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/FindUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/FindUserCmd.java b/api/src/com/cloud/api/commands/FindUserCmd.java
new file mode 100644
index 0000000..cd46ffd
--- /dev/null
+++ b/api/src/com/cloud/api/commands/FindUserCmd.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 com.cloud.api.commands;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiConstants;
+import com.cloud.api.BaseCmd;
+import com.cloud.api.IdentityMapper;
+import com.cloud.api.Implementation;
+import com.cloud.api.Parameter;
+import com.cloud.api.response.FindUserResponse;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.User;
+
+@Implementation(description="Find user by name and domain", responseObject=FindUserResponse.class)
+public class FindUserCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(FindUserCmd.class.getName());
+
+    private static final String s_name = "finduserresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="find user with specified username")
+    private String username;
+    
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, required=true, description = "Domain the user belongs to")
+    private Long domainId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+	public String getUserName() {
+		return username;
+	}
+	
+	public Long getDomainId() {
+		return domainId;
+	}
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+	@Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+	@Override
+	public long getEntityOwnerId() {
+		return 0;
+	}
+	
+    @Override
+    public void execute(){
+        User result = _accountService.findUser(getUserName(), getDomainId());
+        if(result != null){
+        	FindUserResponse response = _responseGenerator.createFindUserResponse(result);
+        	response.setResponseName(getCommandName());
+        	this.setResponseObject(response);
+        } else {
+            throw new InvalidParameterValueException("User with specified name and domainId does not exist");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/ListRegionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListRegionsCmd.java b/api/src/com/cloud/api/commands/ListRegionsCmd.java
index 38f24d4..53b7a6e 100644
--- a/api/src/com/cloud/api/commands/ListRegionsCmd.java
+++ b/api/src/com/cloud/api/commands/ListRegionsCmd.java
@@ -25,14 +25,13 @@ import com.cloud.api.ApiConstants;
 import com.cloud.api.BaseListCmd;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
-import com.cloud.api.response.DomainResponse;
 import com.cloud.api.response.ListResponse;
 import com.cloud.api.response.RegionResponse;
 import com.cloud.region.Region;
 
-@Implementation(description="Lists Regions", responseObject=DomainResponse.class)
+@Implementation(description="Lists Regions", responseObject=RegionResponse.class)
 public class ListRegionsCmd extends BaseListCmd {
-	public static final Logger s_logger = Logger.getLogger(ListDomainsCmd.class.getName());
+	public static final Logger s_logger = Logger.getLogger(ListRegionsCmd.class.getName());
 	
     private static final String s_name = "listregionsresponse";
 
@@ -40,17 +39,17 @@ public class ListRegionsCmd extends BaseListCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="List domain by domain ID.")
-    private Long id;
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="List Region by region ID.")
+    private Integer id;
 
-    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="List domain by domain name.")
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="List Region by region name.")
     private String domainName;
     
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
 
-    public Long getId() {
+    public Integer getId() {
         return id;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/RemoveRegionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/RemoveRegionCmd.java b/api/src/com/cloud/api/commands/RemoveRegionCmd.java
index 2facc10..a42ce4b 100644
--- a/api/src/com/cloud/api/commands/RemoveRegionCmd.java
+++ b/api/src/com/cloud/api/commands/RemoveRegionCmd.java
@@ -19,17 +19,12 @@ package com.cloud.api.commands;
 import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
 import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
 import com.cloud.api.ServerApiException;
 import com.cloud.api.response.SuccessResponse;
-import com.cloud.domain.Domain;
-import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @Implementation(description="Removes specified region", responseObject=SuccessResponse.class)
 public class RemoveRegionCmd extends BaseCmd {
@@ -40,14 +35,14 @@ public class RemoveRegionCmd extends BaseCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="ID of the region to delete")
-    private Long id;
+    @Parameter(name=ApiConstants.ID, type=CommandType.INTEGER, required=true, description="ID of the region to delete")
+    private Integer id;
 
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
 
-    public Long getId() {
+    public Integer getId() {
         return id;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/UpdateDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateDomainCmd.java b/api/src/com/cloud/api/commands/UpdateDomainCmd.java
index 20a0664..0152aa6 100644
--- a/api/src/com/cloud/api/commands/UpdateDomainCmd.java
+++ b/api/src/com/cloud/api/commands/UpdateDomainCmd.java
@@ -93,7 +93,7 @@ public class UpdateDomainCmd extends BaseCmd {
         boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
         Domain domain = null;
     	if(isPopagate){
-    		domain = _mgr.updateDomain(this);
+    		domain = _domainService.updateDomain(this);
         } else {
         	domain = _regionService.updateDomain(this);
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/commands/UpdateRegionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateRegionCmd.java b/api/src/com/cloud/api/commands/UpdateRegionCmd.java
index bbdb3b0..f1f1dba 100644
--- a/api/src/com/cloud/api/commands/UpdateRegionCmd.java
+++ b/api/src/com/cloud/api/commands/UpdateRegionCmd.java
@@ -20,18 +20,14 @@ import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiConstants;
 import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
 import com.cloud.api.ServerApiException;
-import com.cloud.api.response.DomainResponse;
 import com.cloud.api.response.RegionResponse;
-import com.cloud.domain.Domain;
 import com.cloud.region.Region;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
-@Implementation(description="Updates a region", responseObject=DomainResponse.class)
+@Implementation(description="Updates a region", responseObject=RegionResponse.class)
 public class UpdateRegionCmd extends BaseCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateRegionCmd.class.getName());
     private static final String s_name = "updateregionresponse";
@@ -40,8 +36,8 @@ public class UpdateRegionCmd extends BaseCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="ID of region to update")
-    private Long id;
+    @Parameter(name=ApiConstants.ID, type=CommandType.INTEGER, required=true, description="ID of region to update")
+    private Integer id;
 
     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="updates region with this name")
     private String regionName;
@@ -49,11 +45,17 @@ public class UpdateRegionCmd extends BaseCmd {
     @Parameter(name=ApiConstants.END_POINT, type=CommandType.STRING, description="updates region with this end point")
     private String endPoint;
 
+    @Parameter(name=ApiConstants.API_KEY, type=CommandType.STRING, description="API key")
+    private String apiKey;
+    
+    @Parameter(name=ApiConstants.SECRET_KEY, type=CommandType.STRING, description="Secret Key")
+    private String secretKey;
+    
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
 
-    public Long getId() {
+    public Integer getId() {
         return id;
     }
 
@@ -65,6 +67,13 @@ public class UpdateRegionCmd extends BaseCmd {
         return endPoint;
     }
 
+    public String getApiKey() {
+        return apiKey;
+    }
+    
+    public String getSecretKey() {
+        return secretKey;
+    }
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
@@ -81,7 +90,7 @@ public class UpdateRegionCmd extends BaseCmd {
     
     @Override
     public void execute(){
-    	Region region = _regionService.updateRegion(getId(), getRegionName(), getEndPoint());
+    	Region region = _regionService.updateRegion(getId(), getRegionName(), getEndPoint(), getApiKey(), getSecretKey());
     	if (region != null) {
     		RegionResponse response = _responseGenerator.createRegionResponse(region);
     		response.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/response/FindAccountResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/FindAccountResponse.java b/api/src/com/cloud/api/response/FindAccountResponse.java
new file mode 100755
index 0000000..bf79abd
--- /dev/null
+++ b/api/src/com/cloud/api/response/FindAccountResponse.java
@@ -0,0 +1,95 @@
+// 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.response;
+
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.api.ApiConstants;
+import com.cloud.serializer.Param;
+import com.cloud.utils.IdentityProxy;
+import com.google.gson.annotations.SerializedName;
+
+@SuppressWarnings("unused")
+public class FindAccountResponse extends BaseResponse {
+    @SerializedName(ApiConstants.ID) @Param(description="the id of the account")
+    private IdentityProxy id = new IdentityProxy("account");
+
+    @SerializedName(ApiConstants.NAME) @Param(description="the name of the account")
+    private String name;
+
+    @SerializedName(ApiConstants.ACCOUNT_TYPE) @Param(description="account type (admin, domain-admin, user)")
+    private Short accountType;
+
+    @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="id of the Domain the account belongs too")
+    private IdentityProxy domainId = new IdentityProxy("domain");
+
+    @SerializedName(ApiConstants.DEFAULT_ZONE_ID) @Param(description="the default zone of the account")
+    private IdentityProxy defaultZoneId = new IdentityProxy("data_center");
+
+    @SerializedName(ApiConstants.STATE) @Param(description="the state of the account")
+    private String state;
+
+    @SerializedName(ApiConstants.NETWORK_DOMAIN) @Param(description="the network domain")
+    private String networkDomain;
+    
+    @SerializedName(ApiConstants.ACCOUNT_DETAILS) @Param(description="details for the account")
+    private Map<String, String> details;
+
+    @SerializedName("regionId") @Param(description="source region id of the user")
+    private int regionId;
+    
+    public void setId(Long id) {
+        this.id.setValue(id);
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setAccountType(Short accountType) {
+        this.accountType = accountType;
+    }
+
+    public void setDomainId(Long domainId) {
+        this.domainId.setValue(domainId);
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public void setNetworkDomain(String networkDomain) {
+        this.networkDomain = networkDomain;
+    }
+    
+    public void setDetails(Map<String, String> details) {
+    	this.details = details;
+    }
+
+    public void setDefaultZone(Long defaultZoneId) {
+    	this.defaultZoneId.setValue(defaultZoneId);
+    }
+    
+	public int getRegionId() {
+		return regionId;
+	}
+
+	public void setRegionId(int regionId) {
+		this.regionId = regionId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/response/FindDomainResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/FindDomainResponse.java b/api/src/com/cloud/api/response/FindDomainResponse.java
new file mode 100644
index 0000000..befb632
--- /dev/null
+++ b/api/src/com/cloud/api/response/FindDomainResponse.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 com.cloud.api.response;
+
+import com.cloud.api.ApiConstants;
+import com.cloud.utils.IdentityProxy;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+public class FindDomainResponse extends BaseResponse {
+    @SerializedName(ApiConstants.ID) @Param(description="the ID of the domain")
+    private IdentityProxy id = new IdentityProxy("domain");
+
+    @SerializedName(ApiConstants.NAME) @Param(description="the name of the domain")
+    private String domainName;
+
+    @SerializedName(ApiConstants.LEVEL) @Param(description="the level of the domain")
+    private Integer level;
+
+    @SerializedName("parentdomainid") @Param(description="the domain ID of the parent domain")
+    private IdentityProxy parent = new IdentityProxy("domain");
+
+    @SerializedName("haschild") @Param(description="whether the domain has one or more sub-domains")
+    private boolean hasChild;
+    
+    @SerializedName(ApiConstants.NETWORK_DOMAIN) @Param(description="the network domain")
+    private String networkDomain;
+
+    @SerializedName(ApiConstants.PATH) @Param(description="the path of the domain")
+    private String path;
+    
+    @SerializedName(ApiConstants.STATE) @Param(description="the state of the domain")
+    private String state;
+    
+    @SerializedName("regionId") @Param(description="source region id of the user")
+    private int regionId;
+    
+    public Long getId() {
+        return id.getValue();
+    }
+
+    public void setId(Long id) {
+        this.id.setValue(id);
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public void setDomainName(String domainName) {
+        this.domainName = domainName;
+    }
+
+    public Integer getLevel() {
+        return level;
+    }
+
+    public void setLevel(Integer level) {
+        this.level = level;
+    }
+
+    public Long getParent() {
+        return parent.getValue();
+    }
+
+    public void setParent(Long parent) {
+        this.parent.setValue(parent);
+    }
+
+    public boolean getHasChild() {
+        return hasChild;
+    }
+
+    public void setHasChild(boolean hasChild) {
+        this.hasChild = hasChild;
+    }
+
+    public void setNetworkDomain(String networkDomain) {
+        this.networkDomain = networkDomain;
+    }
+
+	public String getPath() {
+		return path;
+	}
+
+	public void setPath(String path) {
+		this.path = path;
+	}
+    
+	public int getRegionId() {
+		return regionId;
+	}
+
+	public void setRegionId(int regionId) {
+		this.regionId = regionId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/response/FindUserResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/FindUserResponse.java b/api/src/com/cloud/api/response/FindUserResponse.java
new file mode 100644
index 0000000..3532f2c
--- /dev/null
+++ b/api/src/com/cloud/api/response/FindUserResponse.java
@@ -0,0 +1,189 @@
+// 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.response;
+
+import java.util.Date;
+
+import com.cloud.serializer.Param;
+import com.cloud.utils.IdentityProxy;
+import com.google.gson.annotations.SerializedName;
+
+public class FindUserResponse extends BaseResponse {
+    @SerializedName("id") @Param(description="the user ID")
+    private IdentityProxy id = new IdentityProxy("user");
+
+    @SerializedName("username") @Param(description="the user name")
+    private String username;
+
+    @SerializedName("password") @Param(description="the password of the user")
+    private String password;
+    
+    @SerializedName("firstname") @Param(description="the user firstname")
+    private String firstname;
+
+    @SerializedName("lastname") @Param(description="the user lastname")
+    private String lastname;
+
+    @SerializedName("accountId") @Param(description="the account ID of the user")
+    private IdentityProxy accountId = new IdentityProxy("account");
+    
+    @SerializedName("email") @Param(description="the user email address")
+    private String email;
+
+    @SerializedName("state") @Param(description="the user state")
+    private String state;
+
+    @SerializedName("apikey") @Param(description="the api key of the user")
+    private String apiKey;
+
+    @SerializedName("secretkey") @Param(description="the secret key of the user")
+    private String secretKey;
+ 
+    @SerializedName("created") @Param(description="the date and time the user account was created")
+    private Date created;
+
+    @SerializedName("timezone") @Param(description="the timezone user was created in")
+    private String timezone;
+    
+    @SerializedName("registrationtoken") @Param(description="the registration token")
+    private String registrationToken;
+    
+    @SerializedName("registered") @Param(description="registration flag")
+    boolean registered;
+    
+    @SerializedName("regionId") @Param(description="source region id of the user")
+    private int regionId;
+    
+    public Long getId() {
+        return id.getValue();
+    }
+
+    public void setId(Long id) {
+        this.id.setValue(id);
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getFirstname() {
+        return firstname;
+    }
+
+    public void setFirstname(String firstname) {
+        this.firstname = firstname;
+    }
+
+    public String getLastname() {
+        return lastname;
+    }
+
+    public void setLastname(String lastname) {
+        this.lastname = lastname;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getTimezone() {
+        return timezone;
+    }
+
+    public void setTimezone(String timezone) {
+        this.timezone = timezone;
+    }
+
+    public String getApiKey() {
+        return apiKey;
+    }
+
+    public void setApiKey(String apiKey) {
+        this.apiKey = apiKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+    public Long getAccountId() {
+        return accountId.getValue();
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId.setValue(accountId);
+    }
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getRegistrationToken() {
+		return registrationToken;
+	}
+
+	public void setRegistrationToken(String registrationToken) {
+		this.registrationToken = registrationToken;
+	}
+
+	public boolean isRegistered() {
+		return registered;
+	}
+
+	public void setRegistered(boolean registered) {
+		this.registered = registered;
+	}
+
+	public int getRegionId() {
+		return regionId;
+	}
+
+	public void setRegionId(int regionId) {
+		this.regionId = regionId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/api/response/RegionResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/RegionResponse.java b/api/src/com/cloud/api/response/RegionResponse.java
index c507621..92f97c7 100644
--- a/api/src/com/cloud/api/response/RegionResponse.java
+++ b/api/src/com/cloud/api/response/RegionResponse.java
@@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName;
 
 public class RegionResponse extends BaseResponse {
     @SerializedName(ApiConstants.ID) @Param(description="the ID of the region")
-    private Long id;
+    private Integer id;
 
     @SerializedName(ApiConstants.NAME) @Param(description="the name of the region")
     private String name;
@@ -30,11 +30,11 @@ public class RegionResponse extends BaseResponse {
     @SerializedName(ApiConstants.END_POINT) @Param(description="the end point of the region")
     private String endPoint;
 
-	public Long getId() {
+	public Integer getId() {
 		return id;
 	}
 
-	public void setId(Long id) {
+	public void setId(Integer id) {
 		this.id = id;
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/domain/Domain.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/domain/Domain.java b/api/src/com/cloud/domain/Domain.java
index 5986347..4c713ea 100644
--- a/api/src/com/cloud/domain/Domain.java
+++ b/api/src/com/cloud/domain/Domain.java
@@ -59,4 +59,6 @@ public interface Domain extends OwnedBy {
     String getNetworkDomain();
     
     public String getUuid();
+    
+    int getRegionId();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/region/Region.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/region/Region.java b/api/src/com/cloud/region/Region.java
index 5fb8d32..3096af5 100644
--- a/api/src/com/cloud/region/Region.java
+++ b/api/src/com/cloud/region/Region.java
@@ -22,19 +22,18 @@ import java.util.Date;
  *
  */
 public interface Region  {
-    public static enum State {
-        Up, Down
-    };
     
-    public long getId();
+    public int getId();
 
 	public String getName();
 
 	public void setName(String name);
 
-	public Region.State getStatus();
-    
 	public Date getRemoved();
 	
 	public String getEndPoint();
+	
+	public String getApiKey();
+	
+	public String getSecretKey();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/region/RegionService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/region/RegionService.java b/api/src/com/cloud/region/RegionService.java
index 8fa5058..a10bcfa 100644
--- a/api/src/com/cloud/region/RegionService.java
+++ b/api/src/com/cloud/region/RegionService.java
@@ -31,9 +31,9 @@ import com.cloud.user.UserAccount;
 
 
 public interface RegionService {
-	public Region addRegion(long id, String name, String endPoint);
-	public Region updateRegion(long id, String name, String endPoint);
-	public boolean removeRegion(long id);
+	public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey);
+	public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey);
+	public boolean removeRegion(int id);
 	public List<? extends Region> listRegions(ListRegionsCmd cmd);
 	boolean deleteUserAccount(long accountId);
 	Account updateAccount(UpdateAccountCmd cmd);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/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 8dcc398..25d6250 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -221,15 +221,6 @@ public interface ManagementService {
     VirtualMachine upgradeSystemVM(UpgradeSystemVMCmd cmd);
 
     /**
-     * update an existing domain
-     * 
-     * @param cmd
-     *            - the command containing domainId and new domainName
-     * @return Domain object if the command succeeded
-     */
-    Domain updateDomain(UpdateDomainCmd cmd);
-
-    /**
      * Searches for alerts
      * 
      * @param c

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/user/Account.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/Account.java b/api/src/com/cloud/user/Account.java
index 6ae93e2..d7d67ac 100755
--- a/api/src/com/cloud/user/Account.java
+++ b/api/src/com/cloud/user/Account.java
@@ -62,7 +62,7 @@ public interface Account extends ControlledEntity {
     
     public Long getDefaultZoneId();
     
-    public long getRegionId();
+    public int getRegionId();
     
     public String getUuid();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/user/AccountService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index a389dd2..b168205 100755
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -62,7 +62,7 @@ public interface AccountService {
      * @return the user if created successfully, null otherwise
      */
     UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
-            Map<String, String> details, String accountUUID, String userUUID, Long regionId);
+            Map<String, String> details, String accountUUID, String userUUID, Integer regionId);
 
     /**
      * Deletes a user by userId
@@ -163,7 +163,7 @@ public interface AccountService {
 
     User getSystemUser();
 
-    User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID, Long regionId);
+    User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID, Integer regionId);
 
     boolean deleteUser(DeleteUserCmd deleteUserCmd);
 
@@ -202,4 +202,7 @@ public interface AccountService {
 
     void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException;
 
+	User findUser(String username, Long domainId);
+
+	Account findAccount(Long id);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/user/DomainService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/DomainService.java b/api/src/com/cloud/user/DomainService.java
index 4de14d1..e2221b6 100644
--- a/api/src/com/cloud/user/DomainService.java
+++ b/api/src/com/cloud/user/DomainService.java
@@ -20,12 +20,13 @@ import java.util.List;
 
 import com.cloud.api.commands.ListDomainChildrenCmd;
 import com.cloud.api.commands.ListDomainsCmd;
+import com.cloud.api.commands.UpdateDomainCmd;
 import com.cloud.domain.Domain;
 import com.cloud.exception.PermissionDeniedException;
 
 public interface DomainService {
 
-    Domain createDomain(String name, Long parentId, String networkDomain, String domainUUID, Long regionId);
+    Domain createDomain(String name, Long parentId, String networkDomain, String domainUUID, Integer regionId);
 
     Domain getDomain(long id);
 
@@ -44,5 +45,22 @@ public interface DomainService {
 
     List<? extends Domain> searchForDomainChildren(ListDomainChildrenCmd cmd)
             throws PermissionDeniedException;
+    /**
+     * update an existing domain
+     * 
+     * @param cmd
+     *            - the command containing domainId and new domainName
+     * @return Domain object if the command succeeded
+     */
+    Domain updateDomain(UpdateDomainCmd cmd);
+
+    /**
+     * find the domain by its path
+     * 
+     * @param domainPath
+     *            the path to use to lookup a domain
+     * @return domainVO the domain with the matching path, or null if no domain with the given path exists
+     */
+    Domain findDomainByPath(String domainPath);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/api/src/com/cloud/user/User.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/User.java b/api/src/com/cloud/user/User.java
index c625c16..916ce60 100644
--- a/api/src/com/cloud/user/User.java
+++ b/api/src/com/cloud/user/User.java
@@ -68,5 +68,6 @@ public interface User extends OwnedBy {
     String getRegistrationToken();
 
     boolean isRegistered();
-
+    
+    public int getRegionId();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 5ee333c..f873b1a 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -27,6 +27,7 @@ enableAccount=com.cloud.api.commands.EnableAccountCmd;7
 ###lockAccount=com.cloud.api.commands.LockAccountCmd;7
 listAccounts=com.cloud.api.commands.ListAccountsCmd;15
 markDefaultZoneForAccount=com.cloud.api.commands.MarkDefaultZoneForAccountCmd;1
+findAccount=com.cloud.api.commands.FindAccountCmd;1
 
 #### User commands
 createUser=com.cloud.api.commands.CreateUserCmd;3
@@ -37,6 +38,7 @@ listUsers=com.cloud.api.commands.ListUsersCmd;7
 disableUser=com.cloud.api.commands.DisableUserCmd;7
 enableUser=com.cloud.api.commands.EnableUserCmd;7
 getUser=com.cloud.api.commands.GetUserCmd;1
+findUser=com.cloud.api.commands.FindUserCmd;1
 
 #### Domain commands
 createDomain=com.cloud.api.commands.CreateDomainCmd;1
@@ -44,6 +46,7 @@ updateDomain=com.cloud.api.commands.UpdateDomainCmd;1
 deleteDomain=com.cloud.api.commands.DeleteDomainCmd;1
 listDomains=com.cloud.api.commands.ListDomainsCmd;7
 listDomainChildren=com.cloud.api.commands.ListDomainChildrenCmd;7
+findDomain=com.cloud.api.commands.FindDomainCmd;1
 
 ####Cloud Identifier commands
 getCloudIdentifier=com.cloud.api.commands.GetCloudIdentifierCmd;15

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/client/tomcatconf/components-regions.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/components-regions.xml.in b/client/tomcatconf/components-regions.xml.in
new file mode 100755
index 0000000..60a2d00
--- /dev/null
+++ b/client/tomcatconf/components-regions.xml.in
@@ -0,0 +1,52 @@
+<?xml version="1.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.
+-->
+<!--
+  components.xml is the configuration file for the VM Ops
+  insertion servers.  Someone can quickly pull together an
+  insertion server by selecting the correct adapters to use.
+
+  Here are some places to look for information.
+    - To find out the general functionality that each Manager 
+      or Adapter provide, look at the javadoc for the interface
+      that it implements.  The interface is usually the
+      "key" attribute in the declaration.
+    - To find specific implementation of each Manager or
+      Adapter, look at the javadoc for the actual class.  The 
+      class can be found in the <class> element.
+    - To find out the configuration parameters for each Manager 
+      or Adapter, look at the javadoc for the actual implementation
+      class.  It should be documented in the description of the 
+      class.
+    - To know more about the components.xml in general, look for
+      the javadoc for ComponentLocator.java.
+
+  If you found that the Manager or Adapter are not properly 
+  documented, please contact the author.
+-->
+<components.xml>
+    <management-server class="com.cloud.server.MockManagementServerImpl" library="com.cloud.configuration.RegionsComponentLibrary">
+        <dao name="Configuration configuration server" class="com.cloud.vpc.dao.MockConfigurationDaoImpl">
+             <param name="premium">true</param>
+        </dao>
+        <adapters key="com.cloud.acl.SecurityChecker">
+            <adapter name="DomainChecker" class="com.cloud.acl.DomainChecker"/>
+        </adapters>        
+    </management-server>
+</components.xml>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/client/tomcatconf/components.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in
index 5730b83..99a2eab 100755
--- a/client/tomcatconf/components.xml.in
+++ b/client/tomcatconf/components.xml.in
@@ -206,6 +206,7 @@ under the License.
         <dao name="Site2SiteCustomerGatewayDao" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" singleton="false"/>
         <dao name="Site2SiteVpnGatewayDao" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" singleton="false"/>
         <dao name="Site2SiteVpnConnectionDao" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" singleton="false"/>
+        <dao name="RegionDao" class="com.cloud.region.dao.RegionDaoImpl" singleton="false"/>
     </configuration-server>
     
     <awsapi-ec2server class="com.cloud.bridge.service.EC2MainServlet">

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/client/tomcatconf/db.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/db.properties.in b/client/tomcatconf/db.properties.in
index f39d8fe..5582ecc 100644
--- a/client/tomcatconf/db.properties.in
+++ b/client/tomcatconf/db.properties.in
@@ -19,6 +19,7 @@
 # in which the management server(Tomcat) is running
 cluster.node.IP=127.0.0.1
 cluster.servlet.port=9090
+region.id=1
 
 # CloudStack database settings
 db.cloud.username=@DBUSER@

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/client/tomcatconf/environment.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/environment.properties.in b/client/tomcatconf/environment.properties.in
index 49544a1..f2956cc 100644
--- a/client/tomcatconf/environment.properties.in
+++ b/client/tomcatconf/environment.properties.in
@@ -19,4 +19,4 @@
 
 paths.script=@COMMONLIBDIR@
 mount.parent=@MSMNTDIR@
-cloud-stack-components-specification=@COMPONENTS-SPEC@
+cloud-stack-components-specification=components.xml

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/core/src/com/cloud/user/AccountVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/user/AccountVO.java b/core/src/com/cloud/user/AccountVO.java
index 9848306..644e091 100644
--- a/core/src/com/cloud/user/AccountVO.java
+++ b/core/src/com/cloud/user/AccountVO.java
@@ -68,7 +68,7 @@ public class AccountVO implements Account, Identity {
     private Long defaultZoneId = null;
 
     @Column(name="region_id")
-    private long regionId;
+    private int regionId;
     
     public AccountVO() {
     	this.uuid = UUID.randomUUID().toString();
@@ -79,7 +79,7 @@ public class AccountVO implements Account, Identity {
     	this.uuid = UUID.randomUUID().toString();
     }
     
-    public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid, long regionId) {
+    public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid, int regionId) {
         this.accountName = accountName;
         this.domainId = domainId;
         this.networkDomain = networkDomain;
@@ -102,7 +102,11 @@ public class AccountVO implements Account, Identity {
         return id;
     }
 
-    @Override
+    public void setId(long id) {
+		this.id = id;
+	}
+
+	@Override
     public String getAccountName() {
         return accountName;
     }
@@ -180,11 +184,11 @@ public class AccountVO implements Account, Identity {
     	this.uuid = uuid;
     }
 
-	public long getRegionId() {
+	public int getRegionId() {
 		return regionId;
 	}
 
-	public void setRegionId(long regionId) {
+	public void setRegionId(int regionId) {
 		this.regionId = regionId;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/core/src/com/cloud/user/UserVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/user/UserVO.java b/core/src/com/cloud/user/UserVO.java
index f227f31..eb5aeae 100644
--- a/core/src/com/cloud/user/UserVO.java
+++ b/core/src/com/cloud/user/UserVO.java
@@ -93,7 +93,7 @@ public class UserVO implements User, Identity {
     private String uuid;
 
     @Column(name="region_id")
-    private long regionId;
+    private int regionId;
     
     public UserVO() {
         this.uuid = UUID.randomUUID().toString();
@@ -104,7 +104,7 @@ public class UserVO implements User, Identity {
         this.uuid = UUID.randomUUID().toString();
     }
     
-    public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, long regionId) {
+    public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, int regionId) {
         this.accountId = accountId;
         this.username = username;
         this.password = password;
@@ -265,11 +265,11 @@ public class UserVO implements User, Identity {
         this.uuid = uuid;
     }
     
-	public long getRegionId() {
+	public int getRegionId() {
 		return regionId;
 	}
 
-	public void setRegionId(long regionId) {
+	public void setRegionId(int regionId) {
 		this.regionId = regionId;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java b/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java
index f4b6f02..cd6d724 100644
--- a/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java
+++ b/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java
@@ -22,10 +22,12 @@ import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
 
+import com.cloud.region.RegionManager;
 import com.cloud.server.ManagementServer;
 import com.cloud.user.UserAccount;
 import com.cloud.user.dao.UserAccountDao;
 import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.component.Inject;
 
 /**
  * Simple UserAuthenticator that performs a MD5 hash of the password before 
@@ -36,14 +38,14 @@ import com.cloud.utils.component.ComponentLocator;
 public class MD5UserAuthenticator extends DefaultUserAuthenticator {
 	public static final Logger s_logger = Logger.getLogger(MD5UserAuthenticator.class);
 	
-	private UserAccountDao _userAccountDao;
+    private RegionManager _regionMgr;
 	
 	@Override
 	public boolean authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters ) {
 		if (s_logger.isDebugEnabled()) {
             s_logger.debug("Retrieving user: " + username);
         }
-        UserAccount user = _userAccountDao.getUserAccount(username, domainId);
+        UserAccount user = _regionMgr.getUserAccount(username, domainId);
         if (user == null) {
             s_logger.debug("Unable to find user with " + username + " in domain " + domainId);
             return false;
@@ -84,7 +86,7 @@ public class MD5UserAuthenticator extends DefaultUserAuthenticator {
 			throws ConfigurationException {
 		super.configure(name, params);
 		ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
-		_userAccountDao = locator.getDao(UserAccountDao.class);
+		_regionMgr = locator.getManager(RegionManager.class);
 		return true;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index f66480e..6b84ac0 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -50,6 +50,9 @@ import com.cloud.api.response.DomainResponse;
 import com.cloud.api.response.DomainRouterResponse;
 import com.cloud.api.response.EventResponse;
 import com.cloud.api.response.ExtractResponse;
+import com.cloud.api.response.FindAccountResponse;
+import com.cloud.api.response.FindDomainResponse;
+import com.cloud.api.response.FindUserResponse;
 import com.cloud.api.response.FirewallResponse;
 import com.cloud.api.response.FirewallRuleResponse;
 import com.cloud.api.response.HostResponse;
@@ -200,6 +203,7 @@ import com.cloud.storage.snapshot.SnapshotPolicy;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.test.PodZoneConfig;
 import com.cloud.user.Account;
+import com.cloud.user.AccountVO;
 import com.cloud.user.User;
 import com.cloud.user.UserAccount;
 import com.cloud.user.UserContext;
@@ -3927,4 +3931,55 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setObjectName("vpnconnection");
         return response;
     }
+    
+    @Override
+    public FindUserResponse createFindUserResponse(User user) {
+    	FindUserResponse userResponse = new FindUserResponse();
+    	userResponse.setId(user.getId());
+    	userResponse.setUsername(user.getUsername());
+    	userResponse.setPassword(user.getPassword());
+        userResponse.setFirstname(user.getFirstname());        
+        userResponse.setLastname(user.getLastname());
+        userResponse.setAccountId(user.getAccountId());
+        userResponse.setEmail(user.getEmail());
+        userResponse.setState(user.getState().toString());
+        userResponse.setApiKey(user.getApiKey());
+        userResponse.setSecretKey(user.getSecretKey());        
+        userResponse.setCreated(user.getCreated());        
+        userResponse.setTimezone(user.getTimezone());
+        userResponse.setRegistrationToken(user.getRegistrationToken());
+        userResponse.setRegistered(user.isRegistered());
+        userResponse.setRegionId(user.getRegionId());
+        userResponse.setObjectName("user");
+
+        return userResponse;
+    }
+
+	@Override
+	public FindAccountResponse createFindAccountResponse(Account account) {
+		FindAccountResponse accountResponse = new FindAccountResponse();
+		accountResponse.setId(account.getId());
+		accountResponse.setName(account.getAccountName());
+		accountResponse.setAccountType(account.getType());
+		accountResponse.setDefaultZone(account.getDefaultZoneId());
+		accountResponse.setDomainId(account.getDomainId());
+		accountResponse.setRegionId(account.getRegionId());
+		accountResponse.setState(account.getState().toString());
+		accountResponse.setObjectName("account");
+		return accountResponse;
+	}
+
+	@Override
+	public FindDomainResponse createFindDomainResponse(Domain domain) {
+		FindDomainResponse domainResponse = new FindDomainResponse();
+        domainResponse.setDomainName(domain.getName());
+        domainResponse.setId(domain.getId());
+        domainResponse.setLevel(domain.getLevel());
+        domainResponse.setNetworkDomain(domain.getNetworkDomain());
+        domainResponse.setParent(domain.getParent());
+        domainResponse.setPath(domain.getPath());
+        domainResponse.setObjectName("domain");
+        domainResponse.setRegionId(domain.getRegionId());
+		return domainResponse;
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0f33bf4/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index eb5e770..50c0125 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -97,6 +97,7 @@ import com.cloud.event.EventUtils;
 import com.cloud.exception.CloudAuthenticationException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.PermissionDeniedException;
+import com.cloud.region.RegionManager;
 import com.cloud.server.ManagementServer;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
@@ -133,7 +134,8 @@ public class ApiServer implements HttpRequestHandler {
     private AsyncJobManager _asyncMgr = null;
     private Account _systemAccount = null;
     private User _systemUser = null;
-
+    private RegionManager _regionMgr = null;
+    
     private static int _workerCount = 0;
 
     private static ApiServer s_instance = null;
@@ -276,6 +278,7 @@ public class ApiServer implements HttpRequestHandler {
         _systemUser = _accountMgr.getSystemUser();
         _dispatcher = ApiDispatcher.getInstance();
         _domainMgr = locator.getManager(DomainManager.class);
+        _regionMgr = locator.getManager(RegionManager.class);
 
         Integer apiPort = null; // api port, null by default
         ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
@@ -785,7 +788,7 @@ public class ApiServer implements HttpRequestHandler {
             if (domainPath == null || domainPath.trim().length() == 0) {
                 domainId = DomainVO.ROOT_DOMAIN;
             } else {
-                Domain domainObj = _domainMgr.findDomainByPath(domainPath);
+                Domain domainObj = _regionMgr.findDomainByPath(domainPath);
                 if (domainObj != null) {
                     domainId = domainObj.getId();
                 } else { // if an unknown path is passed in, fail the login call