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
[18/40] Apply API refactoring changes. Make changes to Regions API to
work with new code
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
index 0000000,318dfda..32bc9d4
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java
@@@ -1,0 -1,126 +1,138 @@@
+ // 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.admin.account;
+
+ import org.apache.cloudstack.api.*;
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.response.AccountResponse;
+ import org.apache.cloudstack.api.response.DomainResponse;
+
+ import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.exception.ConcurrentOperationException;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "disableAccount", description="Disables an account", responseObject=AccountResponse.class)
+ public class DisableAccountCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(DisableAccountCmd.class.getName());
+ private static final String s_name = "disableaccountresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=AccountResponse.class,
+ description="Account id")
+ private Long id;
+
+ @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="Disables specified account.")
+ private String accountName;
+
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ description="Disables specified account in this domain.")
+ private Long domainId;
+
+ @Parameter(name=ApiConstants.LOCK, type=CommandType.BOOLEAN, required=true, description="If true, only lock the account; else disable the account")
+ private Boolean lockRequested;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_ACCOUNT_DISABLE;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = _entityMgr.findById(Account.class, getId());
+ if (account != null) {
+ return account.getAccountId();
+ }
+
+ account = _accountService.getActiveAccountByName(getAccountName(), getDomainId());
+ if (account != null) {
+ return account.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "disabling account: " + getAccountName() + " in domain: " + getDomainId();
+ }
+
+ @Override
+ public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
+ UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
- Account result = null;
- if(lockRequested)
- result = _accountService.lockAccount(getAccountName(), getDomainId(), getId());
- else
- result = _accountService.disableAccount(getAccountName(), getDomainId(), getId());
++ Account result = null;
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ if(isPopagate){
++ if(lockRequested)
++ result = _accountService.lockAccount(getAccountName(), getDomainId(), getId());
++ else
++ result = _accountService.disableAccount(getAccountName(), getDomainId(), getId());
++ } else {
++ result = _regionService.disableAccount(getAccountName(), getDomainId(), getId(), lockRequested);
++ }
+ if (result != null){
+ AccountResponse response = _responseGenerator.createAccountResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account" );
+ }
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.Account;
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java
index 0000000,2688ef1..08fe4c5
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java
@@@ -1,0 -1,102 +1,115 @@@
+ // 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.admin.account;
+
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseCmd;
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.AccountResponse;
+ import org.apache.cloudstack.api.response.DomainResponse;
+
+ import com.cloud.user.Account;
+
+ @APICommand(name = "enableAccount", description="Enables an account", responseObject=AccountResponse.class)
+ public class EnableAccountCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(EnableAccountCmd.class.getName());
+ private static final String s_name = "enableaccountresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=AccountResponse.class,
+ description="Account id")
+ private Long id;
+
+ @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="Enables specified account.")
+ private String accountName;
+
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ description="Enables specified account in this domain.")
+ private Long domainId;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = _entityMgr.findById(Account.class, getId());
+ if (account != null) {
+ return account.getAccountId();
+ }
+
+ account = _accountService.getActiveAccountByName(getAccountName(), getDomainId());
+ if (account != null) {
+ return account.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public void execute(){
- Account result = _accountService.enableAccount(getAccountName(), getDomainId(), getId());
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ Account result = null;
++ if(isPopagate){
++ result = _accountService.enableAccount(getAccountName(), getDomainId(), getId());
++ } else {
++ result = _regionService.enableAccount(getAccountName(), getDomainId(), getId());
++ }
+ if (result != null){
+ AccountResponse response = _responseGenerator.createAccountResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable account");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
index 0000000,ea6d907..ea46ba9
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
@@@ -1,0 -1,132 +1,145 @@@
+ // 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.admin.account;
+
+ import java.util.Collection;
+ import java.util.Map;
+
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseCmd;
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.AccountResponse;
+ import org.apache.cloudstack.api.response.DomainResponse;
+
+ import com.cloud.user.Account;
+
+ @APICommand(name = "updateAccount", description="Updates account information for the authenticated user", responseObject=AccountResponse.class)
+ public class UpdateAccountCmd extends BaseCmd{
+ public static final Logger s_logger = Logger.getLogger(UpdateAccountCmd.class.getName());
+ private static final String s_name = "updateaccountresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=AccountResponse.class,
+ description="Account id")
+ private Long id;
+
+ @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the current account name")
+ private String accountName;
+
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ description="the ID of the domain where the account exists")
+ private Long domainId;
+
+ @Parameter(name=ApiConstants.NEW_NAME, type=CommandType.STRING, required=true, description="new name for the account")
+ private String newName;
+
+ @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the account's networks; empty string will update domainName with NULL value")
+ private String networkDomain;
+
+ @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
+ private Map details;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public String getNewName() {
+ return newName;
+ }
+
+ public String getNetworkDomain() {
+ return networkDomain;
+ }
+
+ public Map getDetails() {
+ if (details == null || details.isEmpty()) {
+ return null;
+ }
+
+ Collection paramsCollection = details.values();
+ Map params = (Map) (paramsCollection.toArray())[0];
+ return params;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = _entityMgr.findById(Account.class, getId());
+ if (account != null) {
+ return account.getAccountId();
+ }
+ account = _accountService.getActiveAccountByName(getAccountName(), getDomainId());
+ if (account != null) {
+ return account.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public void execute(){
- Account result = _accountService.updateAccount(this);
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ Account result = null;
++ if(isPopagate){
++ result = _accountService.updateAccount(this);
++ } else {
++ result = _regionService.updateAccount(this);
++ }
+ if (result != null){
+ AccountResponse response = _responseGenerator.createAccountResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update account");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
index 0000000,61614d1..f51738c
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
@@@ -1,0 -1,90 +1,104 @@@
+ // 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.admin.domain;
+
+ import org.apache.cloudstack.api.*;
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.response.DomainResponse;
+ import com.cloud.domain.Domain;
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "createDomain", description="Creates a domain", responseObject=DomainResponse.class)
+ public class CreateDomainCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateDomainCmd.class.getName());
+
+ private static final String s_name = "createdomainresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="creates domain with this name")
+ private String domainName;
+
+ @Parameter(name=ApiConstants.PARENT_DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ description="assigns new domain a parent domain by domain ID of the parent. If no parent domain is specied, the ROOT domain is assumed.")
+ private Long parentDomainId;
+
+ @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for networks in the domain")
+ private String networkDomain;
+
++ @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.INTEGER, description="Id of the Region creating the Domain")
++ private Integer regionId;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public Long getParentDomainId() {
+ return parentDomainId;
+ }
+
+ public String getNetworkDomain() {
+ return networkDomain;
+ }
+
++ public String getDomainUUID() {
++ return domainUUID;
++ }
++
++ public Integer getRegionId() {
++ return regionId;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
- Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain());
++ Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID(), getRegionId());
+ if (domain != null) {
+ DomainResponse response = _responseGenerator.createDomainResponse(domain);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
index 0000000,3fda960..7c33c79
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
@@@ -1,0 -1,99 +1,111 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements. See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership. The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License. You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied. See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.admin.domain;
+
+ import org.apache.cloudstack.api.*;
+ import org.apache.cloudstack.api.response.DomainResponse;
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.response.SuccessResponse;
+ import com.cloud.domain.Domain;
+ import com.cloud.event.EventTypes;
+ import com.cloud.user.Account;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "deleteDomain", description="Deletes a specified domain", responseObject=SuccessResponse.class)
+ public class DeleteDomainCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(DeleteDomainCmd.class.getName());
+ private static final String s_name = "deletedomainresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ required=true, description="ID of domain to delete")
+ private Long id;
+
+ @Parameter(name=ApiConstants.CLEANUP, type=CommandType.BOOLEAN, description="true if all domain resources (child domains, accounts) have to be cleaned up, false otherwise")
+ private Boolean cleanup;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public Boolean getCleanup() {
+ return cleanup;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Domain domain = _entityMgr.findById(Domain.class, getId());
+ if (domain != null) {
+ return domain.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_DOMAIN_DELETE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "deleting domain: " + getId();
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("Domain Id: "+getId());
- boolean result = _domainService.deleteDomain(id, cleanup);
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ boolean result = false;
++ if(isPopagate){
++ result = _domainService.deleteDomain(id, cleanup);
++ } else {
++ result = _regionService.deleteDomain(id, cleanup);
++ }
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete domain");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
index 0000000,607120c..8de92be
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
@@@ -1,0 -1,89 +1,104 @@@
+ // 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.admin.domain;
+
+ import org.apache.cloudstack.api.*;
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.response.DomainResponse;
+ import com.cloud.domain.Domain;
+ import com.cloud.user.Account;
++import com.cloud.user.UserAccount;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "updateDomain", description="Updates a domain with a new name", responseObject=DomainResponse.class)
+ public class UpdateDomainCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateDomainCmd.class.getName());
+ private static final String s_name = "updatedomainresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ required=true, description="ID of domain to update")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="updates domain with this name")
+ private String domainName;
+
+ @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the domain's networks; empty string will update domainName with NULL value")
+ private String networkDomain;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getDomainName() {
+ return domainName;
+ }
+
+ public String getNetworkDomain() {
+ return networkDomain;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("Domain Id: "+getId());
- Domain domain = _mgr.updateDomain(this);
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ Domain domain = null;
++ if(isPopagate){
++ domain = _domainService.updateDomain(this);
++ } else {
++ domain = _regionService.updateDomain(this);
++ }
++
+ if (domain != null) {
+ DomainResponse response = _responseGenerator.createDomainResponse(domain);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update domain");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
index 0000000,1f1e3ab..1221aa4
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
@@@ -1,0 -1,144 +1,158 @@@
+ // 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.admin.user;
+
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseCmd;
+ import org.apache.cloudstack.api.APICommand;
+ 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.UserResponse;
+ import com.cloud.user.Account;
+ import com.cloud.user.User;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "createUser", description="Creates a user for an account that already exists", responseObject=UserResponse.class)
+ public class CreateUserCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateUserCmd.class.getName());
+
+ private static final String s_name = "createuserresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
+ private String accountName;
+
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
+ description="Creates the user under the specified domain. Has to be accompanied with the account parameter")
+ private Long domainId;
+
+ @Parameter(name=ApiConstants.EMAIL, type=CommandType.STRING, required=true, description="email")
+ private String email;
+
+ @Parameter(name=ApiConstants.FIRSTNAME, type=CommandType.STRING, required=true, description="firstname")
+ private String firstname;
+
+ @Parameter(name=ApiConstants.LASTNAME, type=CommandType.STRING, required=true, description="lastname")
+ private String lastname;
+
+ @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="Hashed password (Default is MD5). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section.")
+ private String password;
+
+ @Parameter(name=ApiConstants.TIMEZONE, type=CommandType.STRING, description="Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.")
+ private String timezone;
+
+ @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="Unique username.")
+ private String username;
+
++ @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.INTEGER, description="Id of the Region creating the User")
++ private Integer regionId;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public String getFirstName() {
+ return firstname;
+ }
+
+ public String getLastName() {
+ return lastname;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getTimezone() {
+ return timezone;
+ }
+
+ public String getUserName() {
+ return username;
+ }
+
++ public String getUserUUID() {
++ return userUUID;
++ }
++
++ public Integer getRegionId() {
++ return regionId;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = UserContext.current().getCaller();
+ if ((account == null) || isAdmin(account.getType())) {
+ if ((domainId != null) && (accountName != null)) {
+ Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
+ if (userAccount != null) {
+ return userAccount.getId();
+ }
+ }
+ }
+
+ if (account != null) {
+ return account.getId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("UserName: "+getUserName()+", FirstName :"+getFirstName()+", LastName: "+getLastName());
- User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId());
++ User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(), getUserUUID(), getRegionId());
+ if (user != null) {
+ UserResponse response = _responseGenerator.createUserResponse(user);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java
index 0000000,74a073c..329bd9a
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java
@@@ -1,0 -1,83 +1,96 @@@
+ // 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.admin.user;
+
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseCmd;
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.SuccessResponse;
+ import org.apache.cloudstack.api.response.UserResponse;
+ import com.cloud.user.Account;
+ import com.cloud.user.User;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "deleteUser", description="Creates a user for an account", responseObject=UserResponse.class)
+ public class DeleteUserCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(DeleteUserCmd.class.getName());
+
+ private static final String s_name = "deleteuserresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserResponse.class, required=true, description="Deletes a user")
+ private Long id;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ User user = _entityMgr.findById(User.class, getId());
+ if (user != null) {
+ return user.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("UserId: "+getId());
- boolean result = _accountService.deleteUser(this);
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ boolean result = false;
++ if(isPopagate){
++ result = _accountService.deleteUser(this);
++ } else {
++ result = _regionService.deleteUser(this);
++ }
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java
index 0000000,6b59de5..f3a3b2b
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java
@@@ -1,0 -1,104 +1,117 @@@
+ // Licensed to the Apache Software Foundation (ASF) under one
+ // or more contributor license agreements. See the NOTICE file
+ // distributed with this work for additional information
+ // regarding copyright ownership. The ASF licenses this file
+ // to you under the Apache License, Version 2.0 (the
+ // "License"); you may not use this file except in compliance
+ // with the License. You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing,
+ // software distributed under the License is distributed on an
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ // KIND, either express or implied. See the License for the
+ // specific language governing permissions and limitations
+ // under the License.
+ package org.apache.cloudstack.api.command.admin.user;
+
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.cloudstack.api.ApiErrorCode;
+ import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.Parameter;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.cloudstack.api.response.UserResponse;
+ import com.cloud.async.AsyncJob;
+ import com.cloud.event.EventTypes;
+ import com.cloud.user.Account;
+ import com.cloud.user.User;
+ import com.cloud.user.UserAccount;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "disableUser", description="Disables a user account", responseObject=UserResponse.class)
+ public class DisableUserCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(DisableUserCmd.class.getName());
+ private static final String s_name = "disableuserresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserResponse.class,
+ required=true, description="Disables user by user ID.")
+ private Long id;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_USER_DISABLE;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ User user = _entityMgr.findById(User.class, getId());
+ if (user != null) {
+ return user.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "disabling user: " + getId();
+ }
+
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("UserId: "+getId());
- UserAccount user = _accountService.disableUser(getId());
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ UserAccount user = null;
++ if(isPopagate){
++ user = _accountService.disableUser(getId());
++ } else {
++ user = _regionService.disableUser(getId());
++ }
++
+ if (user != null){
+ UserResponse response = _responseGenerator.createUserResponse(user);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable user");
+ }
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.User;
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java
index 0000000,bcd0f43..d6577fb
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java
@@@ -1,0 -1,82 +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 org.apache.cloudstack.api.command.admin.user;
+
+ import org.apache.cloudstack.api.*;
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.response.UserResponse;
+ import com.cloud.user.Account;
+ import com.cloud.user.User;
+ import com.cloud.user.UserAccount;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "enableUser", description="Enables a user account", responseObject=UserResponse.class)
+ public class EnableUserCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(EnableUserCmd.class.getName());
+ private static final String s_name = "enableuserresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserResponse.class,
+ required=true, description="Enables user by user ID.")
+ private Long id;
+
-
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ User user = _entityMgr.findById(User.class, getId());
+ if (user != null) {
+ return user.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("UserId: "+getId());
- UserAccount user = _accountService.enableUser(getId());
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ UserAccount user = null;
++ if(isPopagate){
++ user = _accountService.enableUser(getId());
++ } else {
++ user = _regionService.enableUser(getId());
++ }
++
+ if (user != null){
+ UserResponse response = _responseGenerator.createUserResponse(user);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable user");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java
index 0000000,00bfccc..7369933
mode 000000,100644..100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java
@@@ -1,0 -1,138 +1,152 @@@
+ // 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.admin.user;
+
+ import org.apache.cloudstack.api.*;
+ import org.apache.log4j.Logger;
+
+ import org.apache.cloudstack.api.APICommand;
+ import org.apache.cloudstack.api.response.UserResponse;
+ import com.cloud.user.Account;
+ import com.cloud.user.User;
+ import com.cloud.user.UserAccount;
+ import com.cloud.user.UserContext;
+
+ @APICommand(name = "updateUser", description="Updates a user account", responseObject=UserResponse.class)
+ public class UpdateUserCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(UpdateUserCmd.class.getName());
+
+ private static final String s_name = "updateuserresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.API_KEY, type=CommandType.STRING, description="The API key for the user. Must be specified with userSecretKey")
+ private String apiKey;
+
+ @Parameter(name=ApiConstants.EMAIL, type=CommandType.STRING, description="email")
+ private String email;
+
+ @Parameter(name=ApiConstants.FIRSTNAME, type=CommandType.STRING, description="first name")
+ private String firstname;
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserResponse.class,
+ required=true, description="User uuid")
+ private Long id;
+
+ @Parameter(name=ApiConstants.LASTNAME, type=CommandType.STRING, description="last name")
+ private String lastname;
+
+ @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="Hashed password (default is MD5). If you wish to use any other hasing algorithm, you would need to write a custom authentication adapter")
+ private String password;
+
+ @Parameter(name=ApiConstants.SECRET_KEY, type=CommandType.STRING, description="The secret key for the user. Must be specified with userApiKey")
+ private String secretKey;
+
+ @Parameter(name=ApiConstants.TIMEZONE, type=CommandType.STRING, description="Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.")
+ private String timezone;
+
+ @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="Unique username")
+ private String username;
+
++ @Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
++ private Boolean isPropagate;
++
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getApiKey() {
+ return apiKey;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getSecretKey() {
+ return secretKey;
+ }
+
+ public String getTimezone() {
+ return timezone;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
++ public Boolean getIsPropagate() {
++ return isPropagate;
++ }
++
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ User user = _entityMgr.findById(User.class, getId());
+ if (user != null) {
+ return user.getAccountId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("UserId: "+getId());
- UserAccount user = _accountService.updateUser(this);
++ boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
++ UserAccount user = null;
++ if(isPopagate){
++ user = _accountService.updateUser(this);
++ } else {
++ user = _regionService.updateUser(this);
++ }
++
+ if (user != null){
+ UserResponse response = _responseGenerator.createUserResponse(user);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update user");
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --cc client/tomcatconf/commands.properties.in
index f873b1a,3740fb0..9d42735
mode 100755,100644..100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@@ -236,180 -262,255 +262,261 @@@ resizeVolume=1
#### use that key...the key is stored in the db associated w/
#### the userId...every request to the developer API should be
#### checked against the key
- registerUserKeys=com.cloud.api.commands.RegisterCmd;1
+ registerUserKeys=15
### async-query command
- queryAsyncJobResult=com.cloud.api.commands.QueryAsyncJobResultCmd;15
- listAsyncJobs=com.cloud.api.commands.ListAsyncJobsCmd;15
+ queryAsyncJobResult=15
+ listAsyncJobs=15
#### storage pools commands
- listStoragePools=com.cloud.api.commands.ListStoragePoolsCmd;3
- createStoragePool=com.cloud.api.commands.CreateStoragePoolCmd;1
- updateStoragePool=com.cloud.api.commands.UpdateStoragePoolCmd;1
- deleteStoragePool=com.cloud.api.commands.DeletePoolCmd;1
- listClusters=com.cloud.api.commands.ListClustersCmd;3
- enableStorageMaintenance=com.cloud.api.commands.PreparePrimaryStorageForMaintenanceCmd;1
- cancelStorageMaintenance=com.cloud.api.commands.CancelPrimaryStorageMaintenanceCmd;1
+ listStoragePools=3
+ createStoragePool=1
+ updateStoragePool=1
+ deleteStoragePool=1
+ listClusters=3
+ enableStorageMaintenance=1
+ cancelStorageMaintenance=1
#### security group commands
- createSecurityGroup=com.cloud.api.commands.CreateSecurityGroupCmd;15
- deleteSecurityGroup=com.cloud.api.commands.DeleteSecurityGroupCmd;15
- authorizeSecurityGroupIngress=com.cloud.api.commands.AuthorizeSecurityGroupIngressCmd;15
- revokeSecurityGroupIngress=com.cloud.api.commands.RevokeSecurityGroupIngressCmd;15
- authorizeSecurityGroupEgress=com.cloud.api.commands.AuthorizeSecurityGroupEgressCmd;15
- revokeSecurityGroupEgress=com.cloud.api.commands.RevokeSecurityGroupEgressCmd;15
- listSecurityGroups=com.cloud.api.commands.ListSecurityGroupsCmd;15
+ createSecurityGroup=15
+ deleteSecurityGroup=15
+ authorizeSecurityGroupIngress=15
+ revokeSecurityGroupIngress=15
+ authorizeSecurityGroupEgress=15
+ revokeSecurityGroupEgress=15
+ listSecurityGroups=15
#### vm group commands
- createInstanceGroup=com.cloud.api.commands.CreateVMGroupCmd;15
- deleteInstanceGroup=com.cloud.api.commands.DeleteVMGroupCmd;15
- updateInstanceGroup=com.cloud.api.commands.UpdateVMGroupCmd;15
- listInstanceGroups=com.cloud.api.commands.ListVMGroupsCmd;15
+ createInstanceGroup=15
+ deleteInstanceGroup=15
+ updateInstanceGroup=15
+ listInstanceGroups=15
### Certificate commands
- uploadCustomCertificate=com.cloud.api.commands.UploadCustomCertificateCmd;1
+ uploadCustomCertificate=1
### other commands
- listHypervisors=com.cloud.api.commands.ListHypervisorsCmd;15
+ listHypervisors=15
### VPN
- createRemoteAccessVpn=com.cloud.api.commands.CreateRemoteAccessVpnCmd;15
- deleteRemoteAccessVpn=com.cloud.api.commands.DeleteRemoteAccessVpnCmd;15
- listRemoteAccessVpns=com.cloud.api.commands.ListRemoteAccessVpnsCmd;15
+ createRemoteAccessVpn=15
+ deleteRemoteAccessVpn=15
+ listRemoteAccessVpns=15
- addVpnUser=com.cloud.api.commands.AddVpnUserCmd;15
- removeVpnUser=com.cloud.api.commands.RemoveVpnUserCmd;15
- listVpnUsers=com.cloud.api.commands.ListVpnUsersCmd;15
+ addVpnUser=15
+ removeVpnUser=15
+ listVpnUsers=15
#### network offering commands
- createNetworkOffering=com.cloud.api.commands.CreateNetworkOfferingCmd;1
- updateNetworkOffering=com.cloud.api.commands.UpdateNetworkOfferingCmd;1
- deleteNetworkOffering=com.cloud.api.commands.DeleteNetworkOfferingCmd;1
- listNetworkOfferings=com.cloud.api.commands.ListNetworkOfferingsCmd;15
+ createNetworkOffering=1
+ updateNetworkOffering=1
+ deleteNetworkOffering=1
+ listNetworkOfferings=15
#### network commands
- createNetwork=com.cloud.api.commands.CreateNetworkCmd;15
- deleteNetwork=com.cloud.api.commands.DeleteNetworkCmd;15
- listNetworks=com.cloud.api.commands.ListNetworksCmd;15
- restartNetwork=com.cloud.api.commands.RestartNetworkCmd;15
- updateNetwork=com.cloud.api.commands.UpdateNetworkCmd;15
+ createNetwork=15
+ deleteNetwork=15
+ listNetworks=15
+ restartNetwork=15
+ updateNetwork=15
#### SSH key pair commands
- registerSSHKeyPair=com.cloud.api.commands.RegisterSSHKeyPairCmd;15
- createSSHKeyPair=com.cloud.api.commands.CreateSSHKeyPairCmd;15
- deleteSSHKeyPair=com.cloud.api.commands.DeleteSSHKeyPairCmd;15
- listSSHKeyPairs=com.cloud.api.commands.ListSSHKeyPairsCmd;15
+ registerSSHKeyPair=15
+ createSSHKeyPair=15
+ deleteSSHKeyPair=15
+ listSSHKeyPairs=15
#### Projects commands
- createProject=com.cloud.api.commands.CreateProjectCmd;15
- deleteProject=com.cloud.api.commands.DeleteProjectCmd;15
- updateProject=com.cloud.api.commands.UpdateProjectCmd;15
- activateProject=com.cloud.api.commands.ActivateProjectCmd;15
- suspendProject=com.cloud.api.commands.SuspendProjectCmd;15
- listProjects=com.cloud.api.commands.ListProjectsCmd;15
- addAccountToProject=com.cloud.api.commands.AddAccountToProjectCmd;15
- deleteAccountFromProject=com.cloud.api.commands.DeleteAccountFromProjectCmd;15
- listProjectAccounts=com.cloud.api.commands.ListProjectAccountsCmd;15
- listProjectInvitations=com.cloud.api.commands.ListProjectInvitationsCmd;15
- updateProjectInvitation=com.cloud.api.commands.UpdateProjectInvitationCmd;15
- deleteProjectInvitation=com.cloud.api.commands.DeleteProjectInvitationCmd;15
+ createProject=15
+ deleteProject=15
+ updateProject=15
+ activateProject=15
+ suspendProject=15
+ listProjects=15
+ addAccountToProject=15
+ deleteAccountFromProject=15
+ listProjectAccounts=15
+ listProjectInvitations=15
+ updateProjectInvitation=15
+ deleteProjectInvitation=15
####
- createFirewallRule=com.cloud.api.commands.CreateFirewallRuleCmd;15
- deleteFirewallRule=com.cloud.api.commands.DeleteFirewallRuleCmd;15
- listFirewallRules=com.cloud.api.commands.ListFirewallRulesCmd;15
+ createFirewallRule=15
+ deleteFirewallRule=15
+ listFirewallRules=15
#### hypervisor capabilities commands
- updateHypervisorCapabilities=com.cloud.api.commands.UpdateHypervisorCapabilitiesCmd;1
- listHypervisorCapabilities=com.cloud.api.commands.ListHypervisorCapabilitiesCmd;1
+ updateHypervisorCapabilities=1
+ listHypervisorCapabilities=1
#### Physical Network commands
- createPhysicalNetwork=com.cloud.api.commands.CreatePhysicalNetworkCmd;1
- deletePhysicalNetwork=com.cloud.api.commands.DeletePhysicalNetworkCmd;1
- listPhysicalNetworks=com.cloud.api.commands.ListPhysicalNetworksCmd;1
- updatePhysicalNetwork=com.cloud.api.commands.UpdatePhysicalNetworkCmd;1
+ createPhysicalNetwork=1
+ deletePhysicalNetwork=1
+ listPhysicalNetworks=1
+ updatePhysicalNetwork=1
#### Physical Network Service Provider commands
- listSupportedNetworkServices=com.cloud.api.commands.ListSupportedNetworkServicesCmd;1
- addNetworkServiceProvider=com.cloud.api.commands.AddNetworkServiceProviderCmd;1
- deleteNetworkServiceProvider=com.cloud.api.commands.DeleteNetworkServiceProviderCmd;1
- listNetworkServiceProviders=com.cloud.api.commands.ListNetworkServiceProvidersCmd;1
- updateNetworkServiceProvider=com.cloud.api.commands.UpdateNetworkServiceProviderCmd;1
+ listSupportedNetworkServices=1
+ addNetworkServiceProvider=1
+ deleteNetworkServiceProvider=1
+ listNetworkServiceProviders=1
+ updateNetworkServiceProvider=1
#### Physical Network Traffic Type commands
- addTrafficType=com.cloud.api.commands.AddTrafficTypeCmd;1
- deleteTrafficType=com.cloud.api.commands.DeleteTrafficTypeCmd;1
- listTrafficTypes=com.cloud.api.commands.ListTrafficTypesCmd;1
- updateTrafficType=com.cloud.api.commands.UpdateTrafficTypeCmd;1
- listTrafficTypeImplementors=com.cloud.api.commands.ListTrafficTypeImplementorsCmd;1
+ addTrafficType=1
+ deleteTrafficType=1
+ listTrafficTypes=1
+ updateTrafficType=1
+ listTrafficTypeImplementors=1
#### Storage Network commands
- createStorageNetworkIpRange=com.cloud.api.commands.CreateStorageNetworkIpRangeCmd;1
- deleteStorageNetworkIpRange=com.cloud.api.commands.DeleteStorageNetworkIpRangeCmd;1
- listStorageNetworkIpRange=com.cloud.api.commands.listStorageNetworkIpRangeCmd;1
- updateStorageNetworkIpRange=com.cloud.api.commands.UpdateStorageNetworkIpRangeCmd;1
+ createStorageNetworkIpRange=1
+ deleteStorageNetworkIpRange=1
+ listStorageNetworkIpRange=1
+ updateStorageNetworkIpRange=1
### Network Devices commands
- addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
- listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
- deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
-
- #### Region commands
- addRegion=com.cloud.api.commands.AddRegionCmd;1
- updateRegion=com.cloud.api.commands.UpdateRegionCmd;1
- removeRegion=com.cloud.api.commands.RemoveRegionCmd;1
- listRegions=com.cloud.api.commands.ListRegionsCmd;7
-
- ### Network Devices commands
- addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
- listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
- deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
+ addNetworkDevice=1
+ listNetworkDevice=1
+ deleteNetworkDevice=1
### VPC commands
- createVPC=com.cloud.api.commands.CreateVPCCmd;15
- listVPCs=com.cloud.api.commands.ListVPCsCmd;15
- deleteVPC=com.cloud.api.commands.DeleteVPCCmd;15
- updateVPC=com.cloud.api.commands.UpdateVPCCmd;15
- restartVPC=com.cloud.api.commands.RestartVPCCmd;15
+ createVPC=15
+ listVPCs=15
+ deleteVPC=15
+ updateVPC=15
+ restartVPC=15
#### VPC offering commands
- createVPCOffering=com.cloud.api.commands.CreateVPCOfferingCmd;1
- updateVPCOffering=com.cloud.api.commands.UpdateVPCOfferingCmd;1
- deleteVPCOffering=com.cloud.api.commands.DeleteVPCOfferingCmd;1
- listVPCOfferings=com.cloud.api.commands.ListVPCOfferingsCmd;15
+ createVPCOffering=1
+ updateVPCOffering=1
+ deleteVPCOffering=1
+ listVPCOfferings=15
#### Private gateway commands
- createPrivateGateway=com.cloud.api.commands.CreatePrivateGatewayCmd;1
- listPrivateGateways=com.cloud.api.commands.ListPrivateGatewaysCmd;15
- deletePrivateGateway=com.cloud.api.commands.DeletePrivateGatewayCmd;1
+ createPrivateGateway=1
+ listPrivateGateways=15
+ deletePrivateGateway=1
#### Network ACL commands
- createNetworkACL=com.cloud.api.commands.CreateNetworkACLCmd;15
- deleteNetworkACL=com.cloud.api.commands.DeleteNetworkACLCmd;15
- listNetworkACLs=com.cloud.api.commands.ListNetworkACLsCmd;15
+ createNetworkACL=15
+ deleteNetworkACL=15
+ listNetworkACLs=15
#### Static route commands
- createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15
- deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15
- listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15
+ createStaticRoute=15
+ deleteStaticRoute=15
+ listStaticRoutes=15
#### Tags commands
- createTags=com.cloud.api.commands.CreateTagsCmd;15
- deleteTags=com.cloud.api.commands.DeleteTagsCmd;15
- listTags=com.cloud.api.commands.ListTagsCmd;15
- <<<<<<< HEAD
- =======
+ createTags=15
+ deleteTags=15
+ listTags=15
### Site-to-site VPN commands
- createVpnCustomerGateway=com.cloud.api.commands.CreateVpnCustomerGatewayCmd;15
- createVpnGateway=com.cloud.api.commands.CreateVpnGatewayCmd;15
- createVpnConnection=com.cloud.api.commands.CreateVpnConnectionCmd;15
- deleteVpnCustomerGateway=com.cloud.api.commands.DeleteVpnCustomerGatewayCmd;15
- deleteVpnGateway=com.cloud.api.commands.DeleteVpnGatewayCmd;15
- deleteVpnConnection=com.cloud.api.commands.DeleteVpnConnectionCmd;15
- updateVpnCustomerGateway=com.cloud.api.commands.UpdateVpnCustomerGatewayCmd;15
- resetVpnConnection=com.cloud.api.commands.ResetVpnConnectionCmd;15
- listVpnCustomerGateways=com.cloud.api.commands.ListVpnCustomerGatewaysCmd;15
- listVpnGateways=com.cloud.api.commands.ListVpnGatewaysCmd;15
- listVpnConnections=com.cloud.api.commands.ListVpnConnectionsCmd;15
- >>>>>>> master
+ createVpnCustomerGateway=15
+ createVpnGateway=15
+ createVpnConnection=15
+ deleteVpnCustomerGateway=15
+ deleteVpnGateway=15
+ deleteVpnConnection=15
+ updateVpnCustomerGateway=15
+ resetVpnConnection=15
+ listVpnCustomerGateways=15
+ listVpnGateways=15
+ listVpnConnections=15
+
+ #### router commands
+ createVirtualRouterElement=7
+ configureVirtualRouterElement=7
+ listVirtualRouterElements=7
+
+ #### usage commands
+ generateUsageRecords=1
+ listUsageRecords=1
+ listUsageTypes=1
+
+ #### traffic monitor commands
+ addTrafficMonitor=1
+ deleteTrafficMonitor=1
+ listTrafficMonitors=1
+
+ #### Cisco Nexus 1000v Virtual Supervisor Module (VSM) commands
+ deleteCiscoNexusVSM=1
+ enableCiscoNexusVSM=1
+ disableCiscoNexusVSM=1
+ listCiscoNexusVSMs=1
+
+ #### f5 big ip load balancer commands
+
+ #Deprecated commands
+ addExternalLoadBalancer=1
+ deleteExternalLoadBalancer=1
+ listExternalLoadBalancers=1
+
+ addF5LoadBalancer=1
+ configureF5LoadBalancer=1
+ deleteF5LoadBalancer=1
+ listF5LoadBalancers=1
+ listF5LoadBalancerNetworks=1
+
+ #### juniper srx firewall commands
+ addExternalFirewall=1
+ deleteExternalFirewall=1
+ listExternalFirewalls=1
+
+ addSrxFirewall=1
+ deleteSrxFirewall=1
+ configureSrxFirewall=1
+ listSrxFirewalls=1
+ listSrxFirewallNetworks=1
+
+ ####Netapp integration commands
+ createVolumeOnFiler=15
+ destroyVolumeOnFiler=15
+ listVolumesOnFiler=15
+ createLunOnFiler=15
+ destroyLunOnFiler=15
+ listLunsOnFiler=15
+ associateLun=15
+ dissociateLun=15
+ createPool=15
+ deletePool=15
+ modifyPool=15
+ listPools=15
+
+ #### netscaler load balancer commands
+ addNetscalerLoadBalancer=1
+ deleteNetscalerLoadBalancer=1
+ configureNetscalerLoadBalancer=1
+ listNetscalerLoadBalancers=1
+ listNetscalerLoadBalancerNetworks=1
+
+ #### nicira nvp commands
+
+ addNiciraNvpDevice=1
+ deleteNiciraNvpDevice=1
+ listNiciraNvpDevices=1
+ listNiciraNvpDeviceNetworks=1
+
+ # Not implemented (yet)
+ #configureNiciraNvpDevice=1
+
+ #### host simulator commands
+
+ configureSimulator=1
+
+ #### api discovery commands
+
+ listApis=15
+
+ #### API Rate Limit service command
+
+ getApiLimit=15
+ resetApiLimit=1
++
++#### Region commands
++addRegion=1
++updateRegion=1
++removeRegion=1
++listRegions=15
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/client/tomcatconf/components.xml.in
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/client/tomcatconf/db.properties.in
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/core/src/com/cloud/user/AccountVO.java
----------------------------------------------------------------------
diff --cc core/src/com/cloud/user/AccountVO.java
index 644e091,922c8b9..fd37c77
--- a/core/src/com/cloud/user/AccountVO.java
+++ b/core/src/com/cloud/user/AccountVO.java
@@@ -28,8 -28,9 +28,7 @@@ import javax.persistence.GenerationType
import javax.persistence.Id;
import javax.persistence.Table;
- import com.cloud.api.Identity;
-import org.apache.cloudstack.api.Identity;
import com.cloud.utils.db.GenericDao;
-import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name="account")
@@@ -85,10 -83,9 +84,10 @@@ public class AccountVO implements Accou
this.networkDomain = networkDomain;
this.type = type;
this.state = State.enabled;
- this.uuid = UUID.randomUUID().toString();
+ this.uuid = uuid;
+ this.regionId = regionId;
}
-
+
public void setNeedsCleanup(boolean value) {
needsCleanup = value;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/core/src/com/cloud/user/UserVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1f57d925/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java
----------------------------------------------------------------------
diff --cc plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java
index cd6d724,b0cf0b0..4417a97
--- 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,12 -25,11 +25,11 @@@ import javax.naming.ConfigurationExcept
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;
+ import com.cloud.utils.exception.CloudRuntimeException;
/**
* Simple UserAuthenticator that performs a MD5 hash of the password before
@@@ -86,7 -64,28 +64,28 @@@ public class MD5UserAuthenticator exten
throws ConfigurationException {
super.configure(name, params);
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
- _userAccountDao = locator.getDao(UserAccountDao.class);
+ _regionMgr = locator.getManager(RegionManager.class);
return true;
}
+
+ @Override
+ public String encode(String password) {
+ MessageDigest md5 = null;
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ throw new CloudRuntimeException("Unable to hash password", e);
+ }
+
+ md5.reset();
+ BigInteger pwInt = new BigInteger(1, md5.digest(password.getBytes()));
+ String pwStr = pwInt.toString(16);
+ int padding = 32 - pwStr.length();
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < padding; i++) {
+ sb.append('0'); // make sure the MD5 password is 32 digits long
+ }
+ sb.append(pwStr);
+ return sb.toString();
+ }
}