mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
remove finduser, findaccount, finddomain APIs
This commit is contained in:
parent
cd9e4e999e
commit
def9fd1f2e
@ -16,8 +16,6 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.region;
|
package com.cloud.region;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -29,8 +27,6 @@ public interface Region {
|
|||||||
|
|
||||||
public void setName(String name);
|
public void setName(String name);
|
||||||
|
|
||||||
public Date getRemoved();
|
|
||||||
|
|
||||||
public String getEndPoint();
|
public String getEndPoint();
|
||||||
|
|
||||||
public String getApiKey();
|
public String getApiKey();
|
||||||
|
|||||||
@ -200,7 +200,4 @@ public interface AccountService {
|
|||||||
|
|
||||||
void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException;
|
void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException;
|
||||||
|
|
||||||
User findUser(String username, Long domainId);
|
|
||||||
|
|
||||||
Account findAccount(Long id);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,9 +39,6 @@ import org.apache.cloudstack.api.response.DomainResponse;
|
|||||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||||
import org.apache.cloudstack.api.response.EventResponse;
|
import org.apache.cloudstack.api.response.EventResponse;
|
||||||
import org.apache.cloudstack.api.response.ExtractResponse;
|
import org.apache.cloudstack.api.response.ExtractResponse;
|
||||||
import org.apache.cloudstack.api.response.FindAccountResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FindDomainResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FindUserResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||||
import org.apache.cloudstack.api.response.GuestOSResponse;
|
import org.apache.cloudstack.api.response.GuestOSResponse;
|
||||||
@ -365,11 +362,6 @@ public interface ResponseGenerator {
|
|||||||
|
|
||||||
Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result);
|
Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result);
|
||||||
|
|
||||||
FindUserResponse createFindUserResponse(User user);
|
|
||||||
|
|
||||||
FindAccountResponse createFindAccountResponse(Account account);
|
|
||||||
|
|
||||||
FindDomainResponse createFindDomainResponse(Domain domain);
|
|
||||||
CounterResponse createCounterResponse(Counter ctr);
|
CounterResponse createCounterResponse(Counter ctr);
|
||||||
|
|
||||||
ConditionResponse createConditionResponse(Condition cndn);
|
ConditionResponse createConditionResponse(Condition cndn);
|
||||||
|
|||||||
@ -1,76 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package org.apache.cloudstack.api.command.admin.account;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.response.AccountResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FindAccountResponse;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
|
|
||||||
@APICommand(name = "findAccount", 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 /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.ID, type=CommandType.UUID, entityType=AccountResponse.class, 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package org.apache.cloudstack.api.command.admin.domain;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.response.DomainResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FindDomainResponse;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
|
|
||||||
@APICommand(name = "findDomain", 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 /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.ID, type=CommandType.UUID, entityType=DomainResponse.class, 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,83 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package org.apache.cloudstack.api.command.admin.user;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.response.DomainResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FindUserResponse;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.user.User;
|
|
||||||
|
|
||||||
@APICommand(name = "findUser", 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;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,106 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package org.apache.cloudstack.api.response;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
import org.apache.cloudstack.api.EntityReference;
|
|
||||||
|
|
||||||
import com.cloud.serializer.Param;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@EntityReference(value = Account.class)
|
|
||||||
public class FindAccountResponse extends BaseResponse {
|
|
||||||
@SerializedName(ApiConstants.ID) @Param(description="the id of the account")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@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 String domainId;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.DEFAULT_ZONE_ID) @Param(description="the default zone of the account")
|
|
||||||
private String defaultZoneId;
|
|
||||||
|
|
||||||
@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 setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountType(Short accountType) {
|
|
||||||
this.accountType = accountType;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 setRegionId(int regionId) {
|
|
||||||
this.regionId = regionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDomainId() {
|
|
||||||
return domainId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDomainId(String domainId) {
|
|
||||||
this.domainId = domainId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefaultZoneId() {
|
|
||||||
return defaultZoneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultZoneId(String defaultZoneId) {
|
|
||||||
this.defaultZoneId = defaultZoneId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,103 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package org.apache.cloudstack.api.response;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
import org.apache.cloudstack.api.EntityReference;
|
|
||||||
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.serializer.Param;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
@EntityReference(value = Domain.class)
|
|
||||||
public class FindDomainResponse extends BaseResponse {
|
|
||||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of the domain")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@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 String parent;
|
|
||||||
|
|
||||||
@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 void setDomainName(String domainName) {
|
|
||||||
this.domainName = domainName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLevel(Integer level) {
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHasChild(boolean hasChild) {
|
|
||||||
this.hasChild = hasChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNetworkDomain(String networkDomain) {
|
|
||||||
this.networkDomain = networkDomain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPath(String path) {
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegionId(int regionId) {
|
|
||||||
this.regionId = regionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParent(String parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(String state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,193 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package org.apache.cloudstack.api.response;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
import org.apache.cloudstack.api.EntityReference;
|
|
||||||
|
|
||||||
import com.cloud.serializer.Param;
|
|
||||||
import com.cloud.user.User;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
@EntityReference(value = User.class)
|
|
||||||
public class FindUserResponse extends BaseResponse {
|
|
||||||
@SerializedName("id") @Param(description="the user ID")
|
|
||||||
private String id ;
|
|
||||||
|
|
||||||
@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 String accountId;
|
|
||||||
|
|
||||||
@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 String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = 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 String getAccountId() {
|
|
||||||
return accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountId(String accountId) {
|
|
||||||
this.accountId = 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -25,9 +25,9 @@ import javax.naming.ConfigurationException;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.region.RegionManager;
|
|
||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
import com.cloud.user.UserAccount;
|
import com.cloud.user.UserAccount;
|
||||||
|
import com.cloud.user.dao.UserAccountDao;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@ -40,14 +40,14 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
public class MD5UserAuthenticator extends DefaultUserAuthenticator {
|
public class MD5UserAuthenticator extends DefaultUserAuthenticator {
|
||||||
public static final Logger s_logger = Logger.getLogger(MD5UserAuthenticator.class);
|
public static final Logger s_logger = Logger.getLogger(MD5UserAuthenticator.class);
|
||||||
|
|
||||||
private RegionManager _regionMgr;
|
private UserAccountDao _userAccountDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters ) {
|
public boolean authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters ) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Retrieving user: " + username);
|
s_logger.debug("Retrieving user: " + username);
|
||||||
}
|
}
|
||||||
UserAccount user = _regionMgr.getUserAccount(username, domainId);
|
UserAccount user = _userAccountDao.getUserAccount(username, domainId);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
s_logger.debug("Unable to find user with " + username + " in domain " + domainId);
|
s_logger.debug("Unable to find user with " + username + " in domain " + domainId);
|
||||||
return false;
|
return false;
|
||||||
@ -64,7 +64,7 @@ public class MD5UserAuthenticator extends DefaultUserAuthenticator {
|
|||||||
throws ConfigurationException {
|
throws ConfigurationException {
|
||||||
super.configure(name, params);
|
super.configure(name, params);
|
||||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||||
_regionMgr = locator.getManager(RegionManager.class);
|
_userAccountDao = locator.getDao(UserAccountDao.class);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -78,9 +78,6 @@ import org.apache.cloudstack.api.response.DomainResponse;
|
|||||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||||
import org.apache.cloudstack.api.response.EventResponse;
|
import org.apache.cloudstack.api.response.EventResponse;
|
||||||
import org.apache.cloudstack.api.response.ExtractResponse;
|
import org.apache.cloudstack.api.response.ExtractResponse;
|
||||||
import org.apache.cloudstack.api.response.FindAccountResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FindDomainResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FindUserResponse;
|
|
||||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||||
import org.apache.cloudstack.api.response.GuestOSResponse;
|
import org.apache.cloudstack.api.response.GuestOSResponse;
|
||||||
@ -3113,69 +3110,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FindUserResponse createFindUserResponse(User user) {
|
|
||||||
FindUserResponse userResponse = new FindUserResponse();
|
|
||||||
userResponse.setId(user.getUuid());
|
|
||||||
userResponse.setUsername(user.getUsername());
|
|
||||||
userResponse.setPassword(user.getPassword());
|
|
||||||
userResponse.setFirstname(user.getFirstname());
|
|
||||||
userResponse.setLastname(user.getLastname());
|
|
||||||
Account account = ApiDBUtils.findAccountById(user.getAccountId());
|
|
||||||
if(account != null){
|
|
||||||
userResponse.setAccountId(account.getUuid());
|
|
||||||
}
|
|
||||||
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.getUuid());
|
|
||||||
accountResponse.setName(account.getAccountName());
|
|
||||||
accountResponse.setAccountType(account.getType());
|
|
||||||
DataCenterVO zone = ApiDBUtils.findZoneById(account.getDefaultZoneId());
|
|
||||||
if(zone != null){
|
|
||||||
accountResponse.setDefaultZoneId(zone.getUuid());
|
|
||||||
}
|
|
||||||
Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
|
|
||||||
if(domain != null){
|
|
||||||
accountResponse.setDomainId(domain.getUuid());
|
|
||||||
}
|
|
||||||
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.getUuid());
|
|
||||||
domainResponse.setLevel(domain.getLevel());
|
|
||||||
domainResponse.setNetworkDomain(domain.getNetworkDomain());
|
|
||||||
Domain parentDomain = ApiDBUtils.findDomainById(domain.getParent());
|
|
||||||
if (parentDomain != null) {
|
|
||||||
domainResponse.setParent(parentDomain.getUuid());
|
|
||||||
}
|
|
||||||
domainResponse.setPath(domain.getPath());
|
|
||||||
domainResponse.setObjectName("domain");
|
|
||||||
domainResponse.setRegionId(domain.getRegionId());
|
|
||||||
return domainResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuestOSResponse createGuestOSResponse(GuestOS guestOS) {
|
public GuestOSResponse createGuestOSResponse(GuestOS guestOS) {
|
||||||
GuestOSResponse response = new GuestOSResponse();
|
GuestOSResponse response = new GuestOSResponse();
|
||||||
|
|||||||
@ -754,7 +754,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
if (domainPath == null || domainPath.trim().length() == 0) {
|
if (domainPath == null || domainPath.trim().length() == 0) {
|
||||||
domainId = DomainVO.ROOT_DOMAIN;
|
domainId = DomainVO.ROOT_DOMAIN;
|
||||||
} else {
|
} else {
|
||||||
Domain domainObj = _regionMgr.findDomainByPath(domainPath);
|
Domain domainObj = _domainMgr.findDomainByPath(domainPath);
|
||||||
if (domainObj != null) {
|
if (domainObj != null) {
|
||||||
domainId = domainObj.getId();
|
domainId = domainObj.getId();
|
||||||
} else { // if an unknown path is passed in, fail the login call
|
} else { // if an unknown path is passed in, fail the login call
|
||||||
|
|||||||
@ -18,10 +18,6 @@ package com.cloud.region;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.user.UserAccount;
|
|
||||||
|
|
||||||
|
|
||||||
public interface RegionManager {
|
public interface RegionManager {
|
||||||
public boolean propogateAddAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
|
public boolean propogateAddAccount(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);
|
Map<String, String> details, String accountUUID, String userUUID);
|
||||||
@ -31,6 +27,4 @@ public interface RegionManager {
|
|||||||
String firstName, String lastName, String email, String timeZone,
|
String firstName, String lastName, String email, String timeZone,
|
||||||
String accountName, String domainUUId, String userUUID);
|
String accountName, String domainUUId, String userUUID);
|
||||||
public void propogateAddDomain(String name, Long parentId, String networkDomain, String uuid);
|
public void propogateAddDomain(String name, Long parentId, String networkDomain, String uuid);
|
||||||
UserAccount getUserAccount(String username, Long domainId);
|
|
||||||
Domain findDomainByPath(String domainPath);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,6 +99,72 @@ public class RegionManagerImpl implements RegionManager, RegionService, Manager{
|
|||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||||
|
if( _regionDao.findById(id) == null ){
|
||||||
|
RegionVO region = new RegionVO(id, name, endPoint, apiKey, secretKey);
|
||||||
|
return _regionDao.persist(region);
|
||||||
|
} else {
|
||||||
|
throw new InvalidParameterValueException("Region with id: "+id+" already exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||||
|
RegionVO region = _regionDao.findById(id);
|
||||||
|
|
||||||
|
if(region == null){
|
||||||
|
throw new InvalidParameterValueException("Region with id: "+id+" does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(name != null){
|
||||||
|
region.setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(endPoint != null){
|
||||||
|
region.setEndPoint(endPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(apiKey != null){
|
||||||
|
region.setApiKey(apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(secretKey != null){
|
||||||
|
region.setSecretKey(secretKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
_regionDao.update(id, region);
|
||||||
|
return _regionDao.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeRegion(int id) {
|
||||||
|
RegionVO region = _regionDao.findById(id);
|
||||||
|
if(region != null){
|
||||||
|
return _regionDao.remove(id);
|
||||||
|
} else {
|
||||||
|
throw new InvalidParameterValueException("Failed to delete Region: " + id + ", Region not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RegionVO> listRegions(ListRegionsCmd cmd) {
|
||||||
|
if(cmd.getId() != null){
|
||||||
|
List<RegionVO> regions = new ArrayList<RegionVO>();
|
||||||
|
regions.add(_regionDao.findById(cmd.getId()));
|
||||||
|
return regions;
|
||||||
|
}
|
||||||
|
return _regionDao.listAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int _id) {
|
||||||
|
this._id = _id;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean propogateAddAccount(String userName, String password, String firstName, String lastName, String email, String timezone,
|
public boolean propogateAddAccount(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) {
|
String accountName, short accountType, Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID) {
|
||||||
@ -249,73 +315,6 @@ public class RegionManagerImpl implements RegionManager, RegionService, Manager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
|
||||||
if( _regionDao.findById(id) == null ){
|
|
||||||
RegionVO region = new RegionVO(id, name, endPoint, apiKey, secretKey);
|
|
||||||
return _regionDao.persist(region);
|
|
||||||
} else {
|
|
||||||
throw new InvalidParameterValueException("Region with id: "+id+" already exists");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
|
||||||
RegionVO region = _regionDao.findById(id);
|
|
||||||
|
|
||||||
if(region == null){
|
|
||||||
throw new InvalidParameterValueException("Region with id: "+id+" does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(name != null){
|
|
||||||
region.setName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(endPoint != null){
|
|
||||||
region.setEndPoint(endPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(apiKey != null){
|
|
||||||
region.setApiKey(apiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(secretKey != null){
|
|
||||||
region.setSecretKey(secretKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
_regionDao.update(id, region);
|
|
||||||
return _regionDao.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean removeRegion(int id) {
|
|
||||||
//Remove complete row, instead of soft delete
|
|
||||||
RegionVO region = _regionDao.findById(id);
|
|
||||||
if(region != null){
|
|
||||||
return _regionDao.remove(id);
|
|
||||||
} else {
|
|
||||||
throw new InvalidParameterValueException("Failed to delete Region: " + id + ", Region not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return _id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int _id) {
|
|
||||||
this._id = _id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<RegionVO> listRegions(ListRegionsCmd cmd) {
|
|
||||||
if(cmd.getId() != null){
|
|
||||||
List<RegionVO> regions = new ArrayList<RegionVO>();
|
|
||||||
regions.add(_regionDao.findById(cmd.getId()));
|
|
||||||
return regions;
|
|
||||||
}
|
|
||||||
return _regionDao.listAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Account disableAccount(String accountName, Long domainId, Long accountId, Boolean lockRequested) throws ConcurrentOperationException, ResourceUnavailableException {
|
public Account disableAccount(String accountName, Long domainId, Long accountId, Boolean lockRequested) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||||
Account account = null;
|
Account account = null;
|
||||||
@ -775,148 +774,4 @@ public class RegionManagerImpl implements RegionManager, RegionService, Manager{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserAccount getUserAccount(String username, Long domainId) {
|
|
||||||
UserAccount user = _userAccountDao.getUserAccount(username, domainId);
|
|
||||||
if(user != null){
|
|
||||||
return user;
|
|
||||||
} else {
|
|
||||||
DomainVO domain = _domainDao.findById(domainId);
|
|
||||||
if(domain == null){
|
|
||||||
//Lookup Domain
|
|
||||||
s_logger.debug("Domain with Id :"+domainId+" doesn't exist");
|
|
||||||
}
|
|
||||||
String command = "findUser";
|
|
||||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
||||||
params.add(new NameValuePair(ApiConstants.USERNAME, username));
|
|
||||||
params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid()));
|
|
||||||
RegionUser regionuser = null;
|
|
||||||
List<RegionVO> regions = _regionDao.listAll();
|
|
||||||
boolean sourceCheck = false;
|
|
||||||
for (Region region : regions){
|
|
||||||
if(region.getId() == getId()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
s_logger.debug("Looking up user :"+username+" in Region: "+region.getId());
|
|
||||||
regionuser = RegionsApiUtil.makeUserAPICall(region, command, params);
|
|
||||||
if(regionuser != null){
|
|
||||||
s_logger.debug("Found user :"+username+" in Region: "+region.getId());
|
|
||||||
if(regionuser.getRegionId() != region.getId()){
|
|
||||||
sourceCheck = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(regionuser == null){
|
|
||||||
s_logger.debug("User :"+username+" not found in any Region");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sourceCheck){
|
|
||||||
if(regionuser.getRegionId() == getId()){
|
|
||||||
s_logger.debug("Current Region is the source Region for found user: " +username+ ". Ignoring..");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_logger.debug("Verifying user: " +username+ " in source Region: "+regionuser.getRegionId());
|
|
||||||
|
|
||||||
//Verify user in source Region
|
|
||||||
Region sourceRegion = _regionDao.findById(regionuser.getRegionId());
|
|
||||||
if(sourceRegion != null){
|
|
||||||
regionuser = RegionsApiUtil.makeUserAPICall(sourceRegion, command, params);
|
|
||||||
if(regionuser != null && sourceRegion.getId() == regionuser.getRegionId()){
|
|
||||||
s_logger.debug("Found User :"+username+" in Source Region: "+sourceRegion.getId()+" Add to local Region");
|
|
||||||
} else {
|
|
||||||
s_logger.debug("User :"+username+" not found in Source Region: "+sourceRegion.getId());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
s_logger.debug("Source Region :"+regionuser.getRegionId()+" not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(regionuser != null){
|
|
||||||
Long accountId = _identityDao.getIdentityId("account", regionuser.getAccountuuid());
|
|
||||||
if(accountId == null){
|
|
||||||
//Lookup Account
|
|
||||||
}
|
|
||||||
regionuser.setAccountId(accountId);
|
|
||||||
UserVO newuser = (UserVO)regionuser;
|
|
||||||
_userDao.persist(newuser);
|
|
||||||
return _userAccountDao.getUserAccount(username, domainId);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainVO findDomainByPath(String domainPath) {
|
|
||||||
DomainVO domain = (DomainVO)_domainMgr.findDomainByPath(domainPath);
|
|
||||||
if(domain != null){
|
|
||||||
return domain;
|
|
||||||
} else {
|
|
||||||
String command = "findDomain";
|
|
||||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
||||||
params.add(new NameValuePair(ApiConstants.DOMAIN, domainPath));
|
|
||||||
boolean sourceCheck = false;
|
|
||||||
RegionDomain regiondomain = null;
|
|
||||||
List<RegionVO> regions = _regionDao.listAll();
|
|
||||||
for (Region region : regions){
|
|
||||||
if(region.getId() == getId()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
s_logger.debug("Looking up domain :"+domainPath+" in Region: "+region.getId());
|
|
||||||
regiondomain = RegionsApiUtil.makeDomainAPICall(region, command, params);
|
|
||||||
if(regiondomain != null){
|
|
||||||
s_logger.debug("Found domain :"+domainPath+" in Region: "+region.getId());
|
|
||||||
if(regiondomain.getRegionId() != region.getId()){
|
|
||||||
sourceCheck = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(regiondomain == null){
|
|
||||||
s_logger.debug("Domain :"+domainPath+" not found in any Region");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sourceCheck){
|
|
||||||
if(regiondomain.getRegionId() == getId()){
|
|
||||||
s_logger.debug("Current Region is the source Region for found domain: " +domainPath+ ". Ignoring..");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_logger.debug("Verifying domain: " +domainPath+ " in source Region: "+regiondomain.getRegionId());
|
|
||||||
|
|
||||||
//Verify user in source Region
|
|
||||||
Region sourceRegion = _regionDao.findById(regiondomain.getRegionId());
|
|
||||||
if(sourceRegion != null){
|
|
||||||
DomainVO sourceDomain = RegionsApiUtil.makeDomainAPICall(sourceRegion, command, params);
|
|
||||||
if(sourceDomain != null && sourceRegion.getId() == sourceDomain.getRegionId()){
|
|
||||||
s_logger.debug("Found Domain :"+domainPath+" in Source Region: "+sourceRegion.getId()+" Add to local Region");
|
|
||||||
} else {
|
|
||||||
s_logger.debug("Domain :"+domainPath+" not found in Source Region: "+sourceRegion.getId());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
s_logger.debug("Source Region :"+regiondomain.getRegionId()+" not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(regiondomain != null){
|
|
||||||
Long parentId = _identityDao.getIdentityId("domain", regiondomain.getParentUuid());
|
|
||||||
if(parentId == null){
|
|
||||||
//lookup ParentDomain
|
|
||||||
}
|
|
||||||
regiondomain.setParent(parentId);
|
|
||||||
regiondomain.setState(Domain.State.Active);
|
|
||||||
_domainDao.persist((DomainVO)regiondomain);
|
|
||||||
}
|
|
||||||
return (DomainVO)_domainMgr.findDomainByPath(domainPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,14 +16,11 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.region;
|
package com.cloud.region;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="region")
|
@Table(name="region")
|
||||||
@ -45,9 +42,6 @@ public class RegionVO implements Region{
|
|||||||
@Column(name="secret_key")
|
@Column(name="secret_key")
|
||||||
private String secretKey;
|
private String secretKey;
|
||||||
|
|
||||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
|
||||||
private Date removed;
|
|
||||||
|
|
||||||
public RegionVO() {
|
public RegionVO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,10 +65,6 @@ public class RegionVO implements Region{
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getRemoved() {
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEndPoint() {
|
public String getEndPoint() {
|
||||||
return endPoint;
|
return endPoint;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2240,24 +2240,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public User findUser(String username, Long domainId) {
|
|
||||||
UserAccount userAccount = _userAccountDao.getUserAccount(username, domainId);
|
|
||||||
if(userAccount == null){
|
|
||||||
throw new InvalidParameterValueException("Unable to find user account by name: "+username);
|
|
||||||
}
|
|
||||||
User user = _userDao.findById(userAccount.getId());
|
|
||||||
if(user == null){
|
|
||||||
throw new InvalidParameterValueException("Unable to find user by name: "+username);
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Account findAccount(Long id) {
|
|
||||||
return _accountDao.findById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildACLViewSearchBuilder(SearchBuilder<? extends ControlledViewEntity> sb, Long domainId,
|
public void buildACLViewSearchBuilder(SearchBuilder<? extends ControlledViewEntity> sb, Long domainId,
|
||||||
boolean isRecursive, List<Long> permittedAccounts, ListProjectResourcesCriteria listProjectResourcesCriteria) {
|
boolean isRecursive, List<Long> permittedAccounts, ListProjectResourcesCriteria listProjectResourcesCriteria) {
|
||||||
|
|||||||
@ -28,11 +28,9 @@ import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
|||||||
import com.cloud.api.query.vo.ControlledViewEntity;
|
import com.cloud.api.query.vo.ControlledViewEntity;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
|
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
|
||||||
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
|
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
|
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
||||||
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
|
|
||||||
|
|
||||||
import com.cloud.domain.Domain;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
@ -342,18 +340,6 @@ public class MockAccountManagerImpl implements Manager, AccountManager, AccountS
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public User findUser(String username, Long domainId) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Account findAccount(Long id) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Account createAccount(String accountName, short accountType,
|
public Account createAccount(String accountName, short accountType,
|
||||||
Long domainId, String networkDomain, Map details, String uuid,
|
Long domainId, String networkDomain, Map details, String uuid,
|
||||||
|
|||||||
@ -2262,7 +2262,6 @@ CREATE TABLE `cloud`.`region` (
|
|||||||
`end_point` varchar(255) NOT NULL,
|
`end_point` varchar(255) NOT NULL,
|
||||||
`api_key` varchar(255),
|
`api_key` varchar(255),
|
||||||
`secret_key` varchar(255),
|
`secret_key` varchar(255),
|
||||||
`removed` datetime COMMENT 'date removed if not null',
|
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user