mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' into vim51_win8
Conflicts: setup/db/db/schema-410to420.sql
This commit is contained in:
commit
8aba25f18d
|
|
@ -37,6 +37,10 @@ public interface DataCenter extends InfrastructureEntity, Grouping, Identity, In
|
|||
|
||||
String getDns2();
|
||||
|
||||
String getIp6Dns1();
|
||||
|
||||
String getIp6Dns2();
|
||||
|
||||
String getGuestNetworkCidr();
|
||||
|
||||
String getName();
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public interface AccountService {
|
|||
* @return the user if created successfully, null otherwise
|
||||
*/
|
||||
UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
|
||||
Map<String, String> details, String accountUUID, String userUUID, Integer regionId);
|
||||
Map<String, String> details);
|
||||
|
||||
/**
|
||||
* Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses
|
||||
|
|
@ -77,7 +77,7 @@ public interface AccountService {
|
|||
|
||||
User getSystemUser();
|
||||
|
||||
User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID, Integer regionId);
|
||||
User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId);
|
||||
|
||||
boolean isAdmin(short accountType);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import com.cloud.utils.Pair;
|
|||
|
||||
public interface DomainService {
|
||||
|
||||
Domain createDomain(String name, Long parentId, String networkDomain, String domainUUID, Integer regionId);
|
||||
Domain createDomain(String name, Long parentId, String networkDomain);
|
||||
|
||||
Domain getDomain(long id);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public class NicProfile implements InternalIdentity {
|
|||
Integer deviceId;
|
||||
String dns1;
|
||||
String dns2;
|
||||
String ip6Dns1;
|
||||
String ip6Dns2;
|
||||
Integer networkRate;
|
||||
boolean isSecurityGroupEnabled;
|
||||
String name;
|
||||
|
|
@ -332,4 +334,20 @@ public class NicProfile implements InternalIdentity {
|
|||
this.requestedIpv6 = requestedIpv6;
|
||||
}
|
||||
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public void setIp6Dns1(String ip6Dns1) {
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
}
|
||||
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ public class ApiConstants {
|
|||
public static final String DISPLAY_TEXT = "displaytext";
|
||||
public static final String DNS1 = "dns1";
|
||||
public static final String DNS2 = "dns2";
|
||||
public static final String IP6_DNS1 = "ip6dns1";
|
||||
public static final String IP6_DNS2 = "ip6dns2";
|
||||
public static final String DOMAIN = "domain";
|
||||
public static final String DOMAIN_ID = "domainid";
|
||||
public static final String DURATION = "duration";
|
||||
|
|
@ -377,9 +379,8 @@ public class ApiConstants {
|
|||
public static final String VSM_CONFIG_STATE = "vsmconfigstate";
|
||||
public static final String VSM_DEVICE_STATE = "vsmdevicestate";
|
||||
public static final String ADD_VSM_FLAG = "addvsmflag";
|
||||
public static final String END_POINT = "endpoint";
|
||||
public static final String REGION_ID = "regionid";
|
||||
public static final String IS_PROPAGATE = "ispropagate";
|
||||
public static final String END_POINT = "endpoint";
|
||||
public static final String REGION_ID = "regionid";
|
||||
public static final String VPC_OFF_ID = "vpcofferingid";
|
||||
public static final String NETWORK = "network";
|
||||
public static final String VPC_ID = "vpcid";
|
||||
|
|
|
|||
|
|
@ -78,19 +78,6 @@ public class CreateAccountCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
|
||||
private Map<String, String> details;
|
||||
|
||||
//@Parameter(name = ApiConstants.REGION_DETAILS, type = CommandType.MAP, description = "details for account used to store region specific parameters")
|
||||
//private Map<String, String> regionDetails;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.STRING, description="Account UUID, required for adding account from another Region")
|
||||
private String accountUUID;
|
||||
|
||||
@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 account")
|
||||
private Integer regionId;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -145,18 +132,6 @@ public class CreateAccountCmd extends BaseCmd {
|
|||
return params;
|
||||
}
|
||||
|
||||
public String getAccountUUID() {
|
||||
return accountUUID;
|
||||
}
|
||||
|
||||
public String getUserUUID() {
|
||||
return userUUID;
|
||||
}
|
||||
|
||||
public Integer getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -174,8 +149,7 @@ public class CreateAccountCmd extends BaseCmd {
|
|||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
|
||||
UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getDomainId(), getNetworkDomain(), getDetails(),
|
||||
getAccountUUID(), getUserUUID(), getRegionId());
|
||||
UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getDomainId(), getNetworkDomain(), getDetails());
|
||||
if (userAccount != null) {
|
||||
AccountResponse response = _responseGenerator.createUserAccountResponse(userAccount);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -48,9 +48,6 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
|
|||
required=true, description="Account id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_PROPAGATE, type=CommandType.BOOLEAN, description="True if command is sent from another Region")
|
||||
private Boolean isPropagate;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -62,10 +59,6 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -58,9 +58,6 @@ public class DisableAccountCmd extends BaseAsyncCmd {
|
|||
@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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -79,14 +76,10 @@ public class DisableAccountCmd extends BaseAsyncCmd {
|
|||
return domainId;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
public Boolean getLockRequested() {
|
||||
return lockRequested;
|
||||
}
|
||||
|
||||
return lockRequested;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -124,7 +117,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
|
|||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
|
||||
Account result = _regionService.disableAccount(this);
|
||||
Account result = _regionService.disableAccount(this);
|
||||
if (result != null){
|
||||
AccountResponse response = _responseGenerator.createAccountResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -50,9 +50,6 @@ public class EnableAccountCmd extends BaseCmd {
|
|||
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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -71,9 +68,6 @@ public class EnableAccountCmd extends BaseCmd {
|
|||
return domainId;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
@ -101,7 +95,7 @@ public class EnableAccountCmd extends BaseCmd {
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Account result = _regionService.enableAccount(this);
|
||||
Account result = _regionService.enableAccount(this);
|
||||
if (result != null){
|
||||
AccountResponse response = _responseGenerator.createAccountResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@ public class UpdateAccountCmd extends BaseCmd{
|
|||
@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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -102,10 +99,7 @@ public class UpdateAccountCmd extends BaseCmd{
|
|||
return params;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -131,7 +125,7 @@ public class UpdateAccountCmd extends BaseCmd{
|
|||
|
||||
@Override
|
||||
public void execute(){
|
||||
Account result = _regionService.updateAccount(this);
|
||||
Account result = _regionService.updateAccount(this);
|
||||
if (result != null){
|
||||
AccountResponse response = _responseGenerator.createAccountResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -49,12 +49,6 @@ public class CreateDomainCmd extends BaseCmd {
|
|||
@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 ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -71,14 +65,6 @@ public class CreateDomainCmd extends BaseCmd {
|
|||
return networkDomain;
|
||||
}
|
||||
|
||||
public String getDomainUUID() {
|
||||
return domainUUID;
|
||||
}
|
||||
|
||||
public Integer getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -96,7 +82,7 @@ public class CreateDomainCmd extends BaseCmd {
|
|||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
|
||||
Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID(), getRegionId());
|
||||
Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain());
|
||||
if (domain != null) {
|
||||
DomainResponse response = _responseGenerator.createDomainResponse(domain);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -50,9 +50,6 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
|
|||
@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 propagate;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -67,10 +64,6 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
|
|||
return cleanup;
|
||||
}
|
||||
|
||||
public Boolean isPropagate() {
|
||||
return propagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -52,9 +52,6 @@ public class UpdateDomainCmd extends BaseCmd {
|
|||
@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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -73,10 +70,6 @@ public class UpdateDomainCmd extends BaseCmd {
|
|||
return networkDomain;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -65,12 +65,6 @@ public class CreateUserCmd extends BaseCmd {
|
|||
@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 ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -107,14 +101,6 @@ public class CreateUserCmd extends BaseCmd {
|
|||
return username;
|
||||
}
|
||||
|
||||
public String getUserUUID() {
|
||||
return userUUID;
|
||||
}
|
||||
|
||||
public Integer getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -146,7 +132,7 @@ public class CreateUserCmd extends BaseCmd {
|
|||
@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(), getUserUUID(), getRegionId());
|
||||
User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId());
|
||||
if (user != null) {
|
||||
UserResponse response = _responseGenerator.createUserResponse(user);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ public class DeleteUserCmd extends BaseCmd {
|
|||
@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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -58,10 +55,6 @@ public class DeleteUserCmd extends BaseCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -49,9 +49,6 @@ public class DisableUserCmd extends BaseAsyncCmd {
|
|||
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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -62,10 +59,6 @@ public class DisableUserCmd extends BaseAsyncCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -46,9 +46,6 @@ public class EnableUserCmd extends BaseCmd {
|
|||
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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -59,10 +56,6 @@ public class EnableUserCmd extends BaseCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -71,9 +71,6 @@ public class UpdateUserCmd extends BaseCmd {
|
|||
@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;
|
||||
|
||||
@Inject RegionService _regionService;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -116,10 +113,6 @@ public class UpdateUserCmd extends BaseCmd {
|
|||
return username;
|
||||
}
|
||||
|
||||
public Boolean getIsPropagate() {
|
||||
return isPropagate;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ public class CreateZoneCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
|
||||
private String dns2;
|
||||
|
||||
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
|
||||
private String ip6Dns1;
|
||||
|
||||
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
|
||||
private String ip6Dns2;
|
||||
|
||||
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
|
||||
private String guestCidrAddress;
|
||||
|
||||
|
|
@ -89,6 +95,14 @@ public class CreateZoneCmd extends BaseCmd {
|
|||
return dns2;
|
||||
}
|
||||
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public String getGuestCidrAddress() {
|
||||
return guestCidrAddress;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ public class UpdateZoneCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
|
||||
private String dns2;
|
||||
|
||||
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
|
||||
private String ip6Dns1;
|
||||
|
||||
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
|
||||
private String ip6Dns2;
|
||||
|
||||
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
|
||||
private String guestCidrAddress;
|
||||
|
||||
|
|
@ -105,6 +111,14 @@ public class UpdateZoneCmd extends BaseCmd {
|
|||
return id;
|
||||
}
|
||||
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public String getInternalDns1() {
|
||||
return internalDns1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
|
|||
@SerializedName(ApiConstants.DNS2) @Param(description="the second DNS for the router")
|
||||
private String dns2;
|
||||
|
||||
@SerializedName(ApiConstants.IP6_DNS1) @Param(description="the first IPv6 DNS for the router")
|
||||
private String ip6Dns1;
|
||||
|
||||
@SerializedName(ApiConstants.IP6_DNS2) @Param(description="the second IPv6 DNS for the router")
|
||||
private String ip6Dns2;
|
||||
|
||||
@SerializedName("networkdomain") @Param(description="the network domain for the router")
|
||||
private String networkDomain;
|
||||
|
||||
|
|
@ -338,4 +344,20 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
|
|||
public void addNic(NicResponse nic) {
|
||||
this.nics.add(nic);
|
||||
}
|
||||
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public void setIp6Dns1(String ip6Dns1) {
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
}
|
||||
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ public class ZoneResponse extends BaseResponse {
|
|||
@SerializedName(ApiConstants.DNS2) @Param(description="the second DNS for the Zone")
|
||||
private String dns2;
|
||||
|
||||
@SerializedName(ApiConstants.IP6_DNS1) @Param(description="the first IPv6 DNS for the Zone")
|
||||
private String ip6Dns1;
|
||||
|
||||
@SerializedName(ApiConstants.IP6_DNS2) @Param(description="the second IPv6 DNS for the Zone")
|
||||
private String ip6Dns2;
|
||||
|
||||
@SerializedName(ApiConstants.INTERNAL_DNS1) @Param(description="the first internal DNS for the Zone")
|
||||
private String internalDns1;
|
||||
|
||||
|
|
@ -176,4 +182,20 @@ public class ZoneResponse extends BaseResponse {
|
|||
public void setLocalStorageEnabled(boolean localStorageEnabled) {
|
||||
this.localStorageEnabled = localStorageEnabled;
|
||||
}
|
||||
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public void setIp6Dns1(String ip6Dns1) {
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
}
|
||||
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,41 +38,41 @@ import com.cloud.user.UserAccount;
|
|||
|
||||
|
||||
public interface RegionService {
|
||||
/**
|
||||
* Adds a Region to the local Region
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Return added Region object
|
||||
*/
|
||||
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* Update details of the Region with specified Id
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Return updated Region object
|
||||
*/
|
||||
public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return True if region is successfully removed
|
||||
*/
|
||||
public boolean removeRegion(int id);
|
||||
|
||||
/** List all Regions or by Id/Name
|
||||
* @param id
|
||||
* @param name
|
||||
* @return List of Regions
|
||||
*/
|
||||
public List<? extends Region> listRegions(ListRegionsCmd cmd);
|
||||
|
||||
/**
|
||||
* Adds a Region to the local Region
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Return added Region object
|
||||
*/
|
||||
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* Update details of the Region with specified Id
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Return updated Region object
|
||||
*/
|
||||
public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return True if region is successfully removed
|
||||
*/
|
||||
public boolean removeRegion(int id);
|
||||
|
||||
/** List all Regions or by Id/Name
|
||||
* @param id
|
||||
* @param name
|
||||
* @return List of Regions
|
||||
*/
|
||||
public List<? extends Region> listRegions(ListRegionsCmd cmd);
|
||||
|
||||
/**
|
||||
* Deletes a user by userId
|
||||
* isPopagate flag is set to true if sent from peer Region
|
||||
|
|
@ -80,8 +80,8 @@ public interface RegionService {
|
|||
*
|
||||
* @return true if delete was successful, false otherwise
|
||||
*/
|
||||
boolean deleteUserAccount(DeleteAccountCmd cmd);
|
||||
|
||||
boolean deleteUserAccount(DeleteAccountCmd cmd);
|
||||
|
||||
/**
|
||||
* Updates an account
|
||||
* isPopagate falg is set to true if sent from peer Region
|
||||
|
|
@ -91,22 +91,22 @@ public interface RegionService {
|
|||
* @return updated account object
|
||||
*/
|
||||
Account updateAccount(UpdateAccountCmd cmd);
|
||||
|
||||
/**
|
||||
* Disables an account by accountName and domainId or accountId
|
||||
* @param cmd
|
||||
* @return
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
Account disableAccount(DisableAccountCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Enables an account by accountId
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
Account enableAccount(EnableAccountCmd cmd);
|
||||
|
||||
/**
|
||||
* Disables an account by accountName and domainId or accountId
|
||||
* @param cmd
|
||||
* @return
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
Account disableAccount(DisableAccountCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Enables an account by accountId
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
Account enableAccount(EnableAccountCmd cmd);
|
||||
|
||||
/**
|
||||
* Deletes user by Id
|
||||
|
|
@ -114,7 +114,7 @@ public interface RegionService {
|
|||
* @return true if delete was successful, false otherwise
|
||||
*/
|
||||
boolean deleteUser(DeleteUserCmd deleteUserCmd);
|
||||
|
||||
|
||||
/**
|
||||
* update an existing domain
|
||||
*
|
||||
|
|
@ -122,36 +122,36 @@ public interface RegionService {
|
|||
* - the command containing domainId and new domainName
|
||||
* @return Domain object if the command succeeded
|
||||
*/
|
||||
public Domain updateDomain(UpdateDomainCmd updateDomainCmd);
|
||||
|
||||
/**
|
||||
* Deletes domain
|
||||
* @param cmd
|
||||
* @return true if delete was successful, false otherwise
|
||||
*/
|
||||
public boolean deleteDomain(DeleteDomainCmd cmd);
|
||||
|
||||
public Domain updateDomain(UpdateDomainCmd updateDomainCmd);
|
||||
|
||||
/**
|
||||
* Deletes domain
|
||||
* @param cmd
|
||||
* @return true if delete was successful, false otherwise
|
||||
*/
|
||||
public boolean deleteDomain(DeleteDomainCmd cmd);
|
||||
|
||||
/**
|
||||
* Update a user by userId
|
||||
*
|
||||
* @param userId
|
||||
* @return UserAccount object
|
||||
*/
|
||||
public UserAccount updateUser(UpdateUserCmd updateUserCmd);
|
||||
|
||||
public UserAccount updateUser(UpdateUserCmd updateUserCmd);
|
||||
|
||||
/**
|
||||
* Disables a user by userId
|
||||
*
|
||||
* @param cmd
|
||||
* @return UserAccount object
|
||||
*/
|
||||
public UserAccount disableUser(DisableUserCmd cmd);
|
||||
|
||||
public UserAccount disableUser(DisableUserCmd cmd);
|
||||
|
||||
/**
|
||||
* Enables a user
|
||||
*
|
||||
* @param cmd
|
||||
* @return UserAccount object
|
||||
*/
|
||||
public UserAccount enableUser(EnableUserCmd cmd);
|
||||
public UserAccount enableUser(EnableUserCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,7 +268,15 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
|
||||
<exec executable="mkdir">
|
||||
<arg value="-p" />
|
||||
<arg value="${basedir}/target/generated-webapp/WEB-INF/classes/scripts" />
|
||||
</exec>
|
||||
<exec executable="cp">
|
||||
<arg value="-r" />
|
||||
<arg value="${basedir}/../scripts" />
|
||||
<arg value="${basedir}/target/generated-webapp/WEB-INF/classes/scripts" />
|
||||
</exec>
|
||||
<copy
|
||||
todir="${basedir}/target/generated-webapp/WEB-INF/">
|
||||
<fileset dir="${basedir}/WEB-INF/">
|
||||
|
|
@ -281,13 +289,6 @@
|
|||
<include name="resources/**/*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<exec executable="cp">
|
||||
<arg value="-r" />
|
||||
<arg value="${basedir}/../scripts" />
|
||||
<arg value="${basedir}/target/generated-webapp/WEB-INF/classes/" />
|
||||
</exec>
|
||||
|
||||
<copy todir="${basedir}/target/generated-webapp/WEB-INF/classes/vms">
|
||||
<fileset dir="${basedir}/../services/console-proxy/server/dist">
|
||||
<include name="systemvm.zip" />
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@
|
|||
</bean>
|
||||
|
||||
<bean id="HypervisorPlannerSelector" class="com.cloud.deploy.HypervisorVmPlannerSelector">
|
||||
<property name="name" value="BaremetalPlannerSelector"/>
|
||||
<property name="name" value="HypervisorPlannerSelector"/>
|
||||
</bean>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -216,9 +216,6 @@
|
|||
<property name="name" value="Bare Metal Agent"/>
|
||||
</bean>
|
||||
|
||||
<bean id="BaremetalPlannerSelector" class="com.cloud.baremetal.manager.BaremetalPlannerSelector">
|
||||
<property name="name" value="BaremetalPlannerSelector"/>
|
||||
</bean>
|
||||
|
||||
<bean id="HypervServerDiscoverer" class="com.cloud.hypervisor.hyperv.HypervServerDiscoverer">
|
||||
<property name="name" value="SCVMMServer"/>
|
||||
|
|
@ -308,6 +305,14 @@
|
|||
<property name="name" value="BaremetalGuru"/>
|
||||
</bean>
|
||||
|
||||
<bean id="BaremetalPlannerSelector" class="com.cloud.baremetal.manager.BaremetalPlannerSelector">
|
||||
<property name="name" value="BaremetalPlannerSelector"/>
|
||||
</bean>
|
||||
|
||||
<bean id="HypervisorPlannerSelector" class="com.cloud.deploy.HypervisorVmPlannerSelector">
|
||||
<property name="name" value="HypervisorPlannerSelector"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
DAO with customized configuration
|
||||
-->
|
||||
|
|
|
|||
|
|
@ -68,32 +68,32 @@ public class AccountVO implements Account {
|
|||
|
||||
@Column(name="region_id")
|
||||
private int regionId;
|
||||
|
||||
|
||||
public AccountVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public AccountVO(long id) {
|
||||
this.id = id;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid, int regionId) {
|
||||
|
||||
public AccountVO(String accountName, long domainId, String networkDomain, short type, int regionId) {
|
||||
this.accountName = accountName;
|
||||
this.domainId = domainId;
|
||||
this.networkDomain = networkDomain;
|
||||
this.type = type;
|
||||
this.state = State.enabled;
|
||||
this.uuid = uuid;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.regionId = regionId;
|
||||
}
|
||||
|
||||
public void setNeedsCleanup(boolean value) {
|
||||
needsCleanup = value;
|
||||
needsCleanup = value;
|
||||
}
|
||||
|
||||
public boolean getNeedsCleanup() {
|
||||
return needsCleanup;
|
||||
return needsCleanup;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -102,10 +102,10 @@ public class AccountVO implements Account {
|
|||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
|
@ -134,11 +134,11 @@ public class AccountVO implements Account {
|
|||
|
||||
@Override
|
||||
public Long getDefaultZoneId() {
|
||||
return defaultZoneId;
|
||||
return defaultZoneId;
|
||||
}
|
||||
|
||||
public void setDefaultZoneId(Long defaultZoneId) {
|
||||
this.defaultZoneId = defaultZoneId;
|
||||
this.defaultZoneId = defaultZoneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -176,18 +176,14 @@ public class AccountVO implements Account {
|
|||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public int getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(int regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
public int getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class UserVO implements User, Identity, InternalIdentity {
|
|||
|
||||
@Column(name="region_id")
|
||||
private int regionId;
|
||||
|
||||
|
||||
public UserVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
|
@ -104,8 +104,8 @@ public class UserVO implements User, Identity, InternalIdentity {
|
|||
this.id = id;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, int regionId) {
|
||||
|
||||
public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, int regionId) {
|
||||
this.accountId = accountId;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
|
|
@ -114,10 +114,10 @@ public class UserVO implements User, Identity, InternalIdentity {
|
|||
this.email = email;
|
||||
this.timezone = timezone;
|
||||
this.state = State.enabled;
|
||||
this.uuid = uuid;
|
||||
this.regionId = regionId;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.regionId = regionId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
|
|
@ -265,12 +265,9 @@ public class UserVO implements User, Identity, InternalIdentity {
|
|||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public int getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(int regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
public int getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="user_vm_clone_setting")
|
||||
public class UserVmCloneSettingVO {
|
||||
|
||||
@Column(name="vm_id")
|
||||
private Long vmId;
|
||||
|
||||
@Column(name="clone_type")
|
||||
private String cloneType;
|
||||
|
||||
public UserVmCloneSettingVO() {
|
||||
|
||||
}
|
||||
|
||||
public UserVmCloneSettingVO(long id,
|
||||
String cloneType) {
|
||||
this.vmId = id;
|
||||
this.cloneType = cloneType;
|
||||
}
|
||||
|
||||
public long getVmId() {
|
||||
return this.vmId;
|
||||
}
|
||||
|
||||
public String getCloneType() {
|
||||
return this.cloneType;
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +61,12 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
|
|||
@Column(name="dns2")
|
||||
private String dns2 = null;
|
||||
|
||||
@Column(name="ip6Dns1")
|
||||
private String ip6Dns1 = null;
|
||||
|
||||
@Column(name="ip6Dns2")
|
||||
private String ip6Dns2 = null;
|
||||
|
||||
@Column(name="internal_dns1")
|
||||
private String internalDns1 = null;
|
||||
|
||||
|
|
@ -201,13 +207,13 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
|
|||
}
|
||||
|
||||
public EngineDataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
|
||||
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
|
||||
this.id = id;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled) {
|
||||
public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.dns1 = dns1;
|
||||
|
|
@ -477,4 +483,22 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
|
|||
public State getState() {
|
||||
return engineState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public void setIp6Dns1(String ip6Dns1) {
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,10 +267,17 @@ public class CloudOrchestrator implements OrchestrationService {
|
|||
rootDiskOffering.first(diskOffering);
|
||||
rootDiskOffering.second(size);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
for (String uuid : networkNicMap.keySet()) {
|
||||
NetworkVO network = _networkDao.findByUuid(uuid);
|
||||
if(network != null){
|
||||
networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
|
||||
}
|
||||
}
|
||||
|
||||
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
|
||||
|
||||
if (_itMgr.allocate(vm, _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, null, null, plan, hypervisorType, null) == null) {
|
||||
if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class ProvisioningTest extends TestCase {
|
|||
@Before
|
||||
public void setUp() {
|
||||
EngineDataCenterVO dc = new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
|
||||
null, null, NetworkType.Basic, null, null, true, true);
|
||||
null, null, NetworkType.Basic, null, null, true, true, null, null);
|
||||
Mockito.when(dcDao.findByUuid(Mockito.anyString())).thenReturn(dc);
|
||||
Mockito.when(dcDao.persist((EngineDataCenterVO) Mockito.anyObject())).thenReturn(dc);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class DirectAgentTest extends CloudStackTestNGBase {
|
|||
}
|
||||
//create data center
|
||||
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
|
||||
null, null, NetworkType.Basic, null, null, true, true);
|
||||
null, null, NetworkType.Basic, null, null, true, true, null, null);
|
||||
dc = dcDao.persist(dc);
|
||||
dcId = dc.getId();
|
||||
//create pod
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
|
|||
}
|
||||
//create data center
|
||||
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
|
||||
null, null, NetworkType.Basic, null, null, true, true);
|
||||
null, null, NetworkType.Basic, null, null, true, true, null, null);
|
||||
dc = dcDao.persist(dc);
|
||||
dcId = dc.getId();
|
||||
//create pod
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ start() {
|
|||
echo -n $"Starting $PROGNAME: "
|
||||
if hostname --fqdn >/dev/null 2>&1 ; then
|
||||
$JSVC -cp "$CLASSPATH" -pidfile "$PIDFILE" \
|
||||
-errfile $LOGDIR/cloudstack-agent.out -outfile $LOGDIR/cloudstack-agent.out $CLASS
|
||||
-errfile $LOGDIR/cloudstack-agent.err -outfile $LOGDIR/cloudstack-agent.out $CLASS
|
||||
RETVAL=$?
|
||||
echo
|
||||
else
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ JCP="/usr/share/java/commons-daemon.jar"
|
|||
|
||||
# We need to append the JSVC daemon JAR to the classpath
|
||||
# AgentShell implements the JSVC daemon methods
|
||||
export CLASSPATH="$SCP:$DCP:$UCP:$JCP:/etc/sysconfig"
|
||||
export CLASSPATH="$SCP:$DCP:$UCP:$JCP:/etc/cloudstack/usage"
|
||||
|
||||
start() {
|
||||
if [ -s "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
|
||||
|
|
@ -81,7 +81,7 @@ start() {
|
|||
echo -n "Starting $PROGNAME" "$SHORTNAME"
|
||||
|
||||
if daemon --pidfile $PIDFILE $DAEMON -cp "$CLASSPATH" -pidfile "$PIDFILE" -user "$USER" \
|
||||
-errfile $LOGDIR/cloudstack-usage.out -outfile $LOGDIR/cloudstack-usage.out -Dpid=$$ $CLASS
|
||||
-errfile $LOGDIR/cloudstack-usage.err -outfile $LOGDIR/cloudstack-usage.out -Dpid=$$ $CLASS
|
||||
RETVAL=$?
|
||||
then
|
||||
rc=0
|
||||
|
|
|
|||
|
|
@ -262,6 +262,7 @@ install -D plugins/hypervisors/kvm/target/cloud-plugin-hypervisor-kvm-%{_maventa
|
|||
cp plugins/hypervisors/kvm/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
|
||||
|
||||
# Usage server
|
||||
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage
|
||||
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/lib
|
||||
install -D usage/target/cloud-usage-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/cloud-usage-%{_maventag}.jar
|
||||
cp usage/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/lib/
|
||||
|
|
@ -309,9 +310,9 @@ if [ "$1" == "1" ] ; then
|
|||
/sbin/chkconfig --level 345 cloud-management on > /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [ ! -f %{_datadir}/cloudstack/management/webapps/client/WEB-INF/classes/scripts/scripts/vm/hypervisor/xenserver/vhd-util ] ; then
|
||||
if [ ! -f %{_datadir}/cloudstack-common/scripts/vm/hypervisor/xenserver/vhd-util ] ; then
|
||||
echo Please download vhd-util from http://download.cloud.com.s3.amazonaws.com/tools/vhd-util and put it in
|
||||
echo %{_datadir}/cloudstack/management/webapps/client/WEB-INF/classes/scripts/vm/hypervisor/xenserver/
|
||||
echo %{_datadir}/cloudstack-common/scripts/vm/hypervisor/xenserver/
|
||||
fi
|
||||
|
||||
%post awsapi
|
||||
|
|
@ -407,6 +408,7 @@ fi
|
|||
%attr(0644,root,root) %{_datadir}/%{name}-usage/*.jar
|
||||
%attr(0644,root,root) %{_datadir}/%{name}-usage/lib/*.jar
|
||||
%dir /var/log/%{name}/usage
|
||||
%dir %{_sysconfdir}/%{name}/usage
|
||||
%doc LICENSE
|
||||
%doc NOTICE
|
||||
|
||||
|
|
|
|||
|
|
@ -363,6 +363,18 @@ setup_common() {
|
|||
echo "nameserver $NS2" >> /etc/dnsmasq-resolv.conf
|
||||
echo "nameserver $NS2" >> /etc/resolv.conf
|
||||
fi
|
||||
|
||||
if [ -n "$IP6_NS1" ]
|
||||
then
|
||||
echo "nameserver $IP6_NS1" >> /etc/dnsmasq-resolv.conf
|
||||
echo "nameserver $IP6_NS1" >> /etc/resolv.conf
|
||||
fi
|
||||
if [ -n "$IP6_NS2" ]
|
||||
then
|
||||
echo "nameserver $IP6_NS2" >> /etc/dnsmasq-resolv.conf
|
||||
echo "nameserver $IP6_NS2" >> /etc/resolv.conf
|
||||
fi
|
||||
|
||||
if [ -n "$MGMTNET" -a -n "$LOCAL_GW" ]
|
||||
then
|
||||
ip route add $MGMTNET via $LOCAL_GW dev eth1
|
||||
|
|
@ -453,17 +465,23 @@ setup_dnsmasq() {
|
|||
fi
|
||||
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
|
||||
[ $DEFAULT_GW ] && echo "dhcp-option=option:router,$DEFAULT_GW" >> /etc/dnsmasq.conf
|
||||
NS=$NS1
|
||||
[ -n "$NS2" ] && NS=$NS1,$NS2
|
||||
#for now set up ourself as the dns server as well
|
||||
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
|
||||
if [ "$USE_EXTERNAL_DNS" == "true" ]
|
||||
|
||||
[ $ETH0_IP ] && [ $NS1 ] && NS="$NS1,"
|
||||
[ $ETH0_IP ] && [ $NS2 ] && NS="$NS$NS2,"
|
||||
[ $ETH0_IP6 ] && [ $IP6_NS1 ] && NS6="[$IP6_NS1],"
|
||||
[ $ETH0_IP6 ] && [ $IP6_NS2 ] && NS6="$NS6[$IP6_NS2],"
|
||||
#for now set up ourself as the dns server as well
|
||||
sed -i -e "/^[#]*dhcp-option=6,.*$/d" /etc/dnsmasq.conf
|
||||
sed -i -e "/^[#]*dhcp-option=option6:dns-server,.*$/d" /etc/dnsmasq.conf
|
||||
if [ "$USE_EXTERNAL_DNS" != "true" ]
|
||||
then
|
||||
[ $ETH0_IP ] && echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
|
||||
else
|
||||
[ $ETH0_IP ] && echo "dhcp-option=6,$INTERNAL_DNS,$NS" >> /etc/dnsmasq.conf
|
||||
[ $ETH0_IP ] && NS="$INTERNAL_DNS,$NS"
|
||||
[ $ETH0_IP6 ] && NS6="[::],$NS6"
|
||||
fi
|
||||
[ $ETH0_IP6 ] && echo "dhcp-option=option6:dns-server,[::]" >> /etc/dnsmasq.conf
|
||||
NS=${NS%?}
|
||||
NS6=${NS6%?}
|
||||
[ $ETH0_IP ] && echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
|
||||
[ $ETH0_IP6 ] && echo "dhcp-option=option6:dns-server,$NS6" >> /etc/dnsmasq.conf
|
||||
}
|
||||
|
||||
setup_sshd(){
|
||||
|
|
@ -960,6 +978,12 @@ for i in $CMDLINE
|
|||
dns2)
|
||||
NS2=$VALUE
|
||||
;;
|
||||
ip6dns1)
|
||||
IP6_NS1=$VALUE
|
||||
;;
|
||||
ip6dns2)
|
||||
IP6_NS2=$VALUE
|
||||
;;
|
||||
domain)
|
||||
DOMAIN=$VALUE
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ do
|
|||
while read line
|
||||
do
|
||||
ip=`echo $line|cut -d " " -f 2|cut -d "/" -f 1`
|
||||
arping -I $i -A $ip -c 2 >> [RROUTER_LOG] 2>&1
|
||||
arping -I $i -A $ip -c 1 >> [RROUTER_LOG] 2>&1
|
||||
arping -I $i -A $ip -c 1 >> [RROUTER_LOG] 2>&1
|
||||
done < /tmp/iplist_$i
|
||||
done < /tmp/iflist
|
||||
sleep 1
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
|
||||
import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -60,6 +61,8 @@ public interface VmwareManager {
|
|||
|
||||
boolean getNexusVSwitchGlobalParameter();
|
||||
|
||||
boolean getFullCloneFlag();
|
||||
|
||||
Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId);
|
||||
|
||||
String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ import com.vmware.vim25.AboutInfo;
|
|||
import com.vmware.vim25.HostConnectSpec;
|
||||
import com.vmware.vim25.ManagedObjectReference;
|
||||
|
||||
|
||||
@Local(value = {VmwareManager.class})
|
||||
public class VmwareManagerImpl extends ManagerBase implements VmwareManager, VmwareStorageMount, Listener {
|
||||
private static final Logger s_logger = Logger.getLogger(VmwareManagerImpl.class);
|
||||
|
|
@ -131,6 +132,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
String _publicNetworkVSwitchName;
|
||||
String _guestNetworkVSwitchName;
|
||||
boolean _nexusVSwitchActive;
|
||||
boolean _fullCloneFlag;
|
||||
String _serviceConsoleName;
|
||||
String _managemetPortGroupName;
|
||||
String _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
|
||||
|
|
@ -199,11 +201,17 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
if(value == null) {
|
||||
_nexusVSwitchActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
_nexusVSwitchActive = Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
value = _configDao.getValue(Config.VmwareCreateFullClone.key());
|
||||
if (value == null) {
|
||||
_fullCloneFlag = false;
|
||||
} else {
|
||||
_fullCloneFlag = Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
_privateNetworkVSwitchName = _configDao.getValue(Config.VmwarePrivateNetworkVSwitch.key());
|
||||
|
||||
if (_privateNetworkVSwitchName == null) {
|
||||
|
|
@ -317,6 +325,11 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
return _nexusVSwitchActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFullCloneFlag() {
|
||||
return _fullCloneFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String composeWorkerName() {
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
|
|
@ -499,6 +512,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
params.put("public.network.vswitch.name", _publicNetworkVSwitchName);
|
||||
params.put("guest.network.vswitch.name", _guestNetworkVSwitchName);
|
||||
params.put("vmware.use.nexus.vswitch", _nexusVSwitchActive);
|
||||
params.put("vmware.create.full.clone", _fullCloneFlag);
|
||||
params.put("service.console.name", _serviceConsoleName);
|
||||
params.put("management.portgroup.name", _managemetPortGroupName);
|
||||
params.put("vmware.reserve.cpu", _reserveCpu);
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
|
|||
import com.cloud.agent.api.storage.DestroyCommand;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
|
||||
import com.cloud.agent.api.to.FirewallRuleTO;
|
||||
import com.cloud.agent.api.storage.ResizeVolumeAnswer;
|
||||
import com.cloud.agent.api.storage.ResizeVolumeCommand;
|
||||
import com.cloud.agent.api.to.FirewallRuleTO;
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.PortForwardingRuleTO;
|
||||
|
|
@ -193,6 +193,7 @@ import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
|
|||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostResourceSummary;
|
||||
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareGuestOsMapper;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||
|
|
@ -263,6 +264,7 @@ import com.vmware.vim25.VirtualMachinePowerState;
|
|||
import com.vmware.vim25.VirtualMachineRuntimeInfo;
|
||||
import com.vmware.vim25.VirtualSCSISharing;
|
||||
|
||||
|
||||
public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService {
|
||||
private static final Logger s_logger = Logger.getLogger(VmwareResource.class);
|
||||
|
||||
|
|
@ -292,6 +294,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
protected String _guestNetworkVSwitchName;
|
||||
protected VirtualSwitchType _vSwitchType = VirtualSwitchType.StandardVirtualSwitch;
|
||||
protected boolean _nexusVSwitch = false;
|
||||
protected boolean _fullCloneFlag = false;
|
||||
|
||||
protected boolean _reserveCpu = false;
|
||||
|
||||
|
|
@ -3710,9 +3713,17 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
dsMo.deleteFile(cmd.getVolume().getPath() + ".vmdk", morDc, true);
|
||||
|
||||
// root volume may be created via linked-clone, delete the delta disk as well
|
||||
if (s_logger.isInfoEnabled())
|
||||
if (_fullCloneFlag) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroy volume by derived name: " + cmd.getVolume().getPath() + "-flat.vmdk");
|
||||
}
|
||||
dsMo.deleteFile(cmd.getVolume().getPath() + "-flat.vmdk", morDc, true);
|
||||
} else {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroy volume by derived name: " + cmd.getVolume().getPath() + "-delta.vmdk");
|
||||
}
|
||||
dsMo.deleteFile(cmd.getVolume().getPath() + "-delta.vmdk", morDc, true);
|
||||
}
|
||||
return new Answer(cmd, true, "Success");
|
||||
}
|
||||
|
||||
|
|
@ -3814,6 +3825,70 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean createVMFullClone(VirtualMachineMO vmTemplate, DatacenterMO dcMo, DatastoreMO dsMo,
|
||||
String vmdkName, ManagedObjectReference morDatastore, ManagedObjectReference morPool) throws Exception {
|
||||
|
||||
if(dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmdkName))
|
||||
dsMo.deleteFile(String.format("[%s] %s/", dsMo.getName(), vmdkName), dcMo.getMor(), false);
|
||||
|
||||
s_logger.info("creating full clone from template");
|
||||
if (!vmTemplate.createFullClone(vmdkName, dcMo.getVmFolder(), morPool, morDatastore)) {
|
||||
String msg = "Unable to create full clone from the template";
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
// we can't rely on un-offical API (VirtualMachineMO.moveAllVmDiskFiles() any more, use hard-coded disk names that we know
|
||||
// to move files
|
||||
s_logger.info("Move volume out of volume-wrapper VM ");
|
||||
dsMo.moveDatastoreFile(String.format("[%s] %s/%s.vmdk", dsMo.getName(), vmdkName, vmdkName),
|
||||
dcMo.getMor(), dsMo.getMor(),
|
||||
String.format("[%s] %s.vmdk", dsMo.getName(), vmdkName), dcMo.getMor(), true);
|
||||
|
||||
dsMo.moveDatastoreFile(String.format("[%s] %s/%s-flat.vmdk", dsMo.getName(), vmdkName, vmdkName),
|
||||
dcMo.getMor(), dsMo.getMor(),
|
||||
String.format("[%s] %s-flat.vmdk", dsMo.getName(), vmdkName), dcMo.getMor(), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean createVMLinkedClone(VirtualMachineMO vmTemplate, DatacenterMO dcMo, DatastoreMO dsMo,
|
||||
String vmdkName, ManagedObjectReference morDatastore, ManagedObjectReference morPool) throws Exception {
|
||||
|
||||
ManagedObjectReference morBaseSnapshot = vmTemplate.getSnapshotMor("cloud.template.base");
|
||||
if (morBaseSnapshot == null) {
|
||||
String msg = "Unable to find template base snapshot, invalid template";
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
if(dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmdkName))
|
||||
dsMo.deleteFile(String.format("[%s] %s/", dsMo.getName(), vmdkName), dcMo.getMor(), false);
|
||||
|
||||
s_logger.info("creating linked clone from template");
|
||||
if (!vmTemplate.createLinkedClone(vmdkName, morBaseSnapshot, dcMo.getVmFolder(), morPool, morDatastore)) {
|
||||
String msg = "Unable to clone from the template";
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
// we can't rely on un-offical API (VirtualMachineMO.moveAllVmDiskFiles() any more, use hard-coded disk names that we know
|
||||
// to move files
|
||||
s_logger.info("Move volume out of volume-wrapper VM ");
|
||||
dsMo.moveDatastoreFile(String.format("[%s] %s/%s.vmdk", dsMo.getName(), vmdkName, vmdkName),
|
||||
dcMo.getMor(), dsMo.getMor(),
|
||||
String.format("[%s] %s.vmdk", dsMo.getName(), vmdkName), dcMo.getMor(), true);
|
||||
|
||||
dsMo.moveDatastoreFile(String.format("[%s] %s/%s-delta.vmdk", dsMo.getName(), vmdkName, vmdkName),
|
||||
dcMo.getMor(), dsMo.getMor(),
|
||||
String.format("[%s] %s-delta.vmdk", dsMo.getName(), vmdkName), dcMo.getMor(), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized CreateAnswer execute(CreateCommand cmd) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
|
|
@ -3873,37 +3948,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
|
||||
ManagedObjectReference morPool = hyperHost.getHyperHostOwnerResourcePool();
|
||||
ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();
|
||||
ManagedObjectReference morBaseSnapshot = vmTemplate.getSnapshotMor("cloud.template.base");
|
||||
if (morBaseSnapshot == null) {
|
||||
String msg = "Unable to find template base snapshot, invalid template";
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
if(dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmdkName))
|
||||
dsMo.deleteFile(String.format("[%s] %s/", dsMo.getName(), vmdkName), dcMo.getMor(), false);
|
||||
|
||||
s_logger.info("create linked clone from template");
|
||||
if (!vmTemplate.createLinkedClone(vmdkName, morBaseSnapshot, dcMo.getVmFolder(), morPool, morDatastore)) {
|
||||
String msg = "Unable to clone from the template";
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
//createVMLinkedClone(vmTemplate, dcMo, dsMo, vmdkName, morDatastore, morPool);
|
||||
if (!_fullCloneFlag) {
|
||||
createVMLinkedClone(vmTemplate, dcMo, dsMo, vmdkName, morDatastore, morPool);
|
||||
} else {
|
||||
createVMFullClone(vmTemplate, dcMo, dsMo, vmdkName, morDatastore, morPool);
|
||||
}
|
||||
|
||||
VirtualMachineMO vmMo = new ClusterMO(context, morCluster).findVmOnHyperHost(vmdkName);
|
||||
assert (vmMo != null);
|
||||
|
||||
// we can't rely on un-offical API (VirtualMachineMO.moveAllVmDiskFiles() any more, use hard-coded disk names that we know
|
||||
// to move files
|
||||
s_logger.info("Move volume out of volume-wrapper VM ");
|
||||
dsMo.moveDatastoreFile(String.format("[%s] %s/%s.vmdk", dsMo.getName(), vmdkName, vmdkName),
|
||||
dcMo.getMor(), dsMo.getMor(),
|
||||
String.format("[%s] %s.vmdk", dsMo.getName(), vmdkName), dcMo.getMor(), true);
|
||||
|
||||
dsMo.moveDatastoreFile(String.format("[%s] %s/%s-delta.vmdk", dsMo.getName(), vmdkName, vmdkName),
|
||||
dcMo.getMor(), dsMo.getMor(),
|
||||
String.format("[%s] %s-delta.vmdk", dsMo.getName(), vmdkName), dcMo.getMor(), true);
|
||||
|
||||
s_logger.info("detach disks from volume-wrapper VM " + vmdkName);
|
||||
vmMo.detachAllDisks();
|
||||
|
||||
|
|
@ -4906,6 +4960,13 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
if(value != null && value.equalsIgnoreCase("true"))
|
||||
_nexusVSwitch = true;
|
||||
|
||||
value = params.get("vmware.create.full.clone").toString();
|
||||
if (value != null && value.equalsIgnoreCase("true")) {
|
||||
_fullCloneFlag = true;
|
||||
} else {
|
||||
_fullCloneFlag = false;
|
||||
}
|
||||
|
||||
s_logger.info("VmwareResource network configuration info. private vSwitch: " + _privateNetworkVSwitchName + ", public vSwitch: " + _publicNetworkVSwitchName + ", guest network: "
|
||||
+ _guestNetworkVSwitchName);
|
||||
|
||||
|
|
|
|||
|
|
@ -427,8 +427,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
prodVersion = prodVersion.trim();
|
||||
}
|
||||
|
||||
if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4") ))
|
||||
return new XcpServerResource();
|
||||
if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4") || prodVersion.startsWith("1.6")))
|
||||
return new XcpServerResource();
|
||||
|
||||
if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0"))
|
||||
return new XenServer56Resource();
|
||||
|
|
@ -455,7 +455,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
return new XcpOssResource();
|
||||
}
|
||||
|
||||
String msg = "Only support XCP 1.0.0, 1.1.0, 1.5 beta; XenServer 5.6, XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion;
|
||||
String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion;
|
||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);
|
||||
s_logger.debug(msg);
|
||||
throw new RuntimeException(msg);
|
||||
|
|
@ -583,7 +583,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
String prodBrand = details.get("product_brand").trim();
|
||||
String prodVersion = details.get("product_version").trim();
|
||||
|
||||
if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4"))) {
|
||||
if(prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4") || prodVersion.startsWith("1.6"))) {
|
||||
resource = XcpServerResource.class.getName();
|
||||
} else if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) {
|
||||
resource = XenServer56Resource.class.getName();
|
||||
|
|
@ -605,7 +605,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
}
|
||||
|
||||
if( resource == null ){
|
||||
String msg = "Only support XCP 1.0.0, 1.1.0, 1.5 beta; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion;
|
||||
String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion;
|
||||
s_logger.debug(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class VolumeTest {
|
|||
public void setUp() {
|
||||
//create data center
|
||||
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
|
||||
null, null, NetworkType.Basic, null, null, true, true);
|
||||
null, null, NetworkType.Basic, null, null, true, true, null, null);
|
||||
dc = dcDao.persist(dc);
|
||||
dcId = dc.getId();
|
||||
//create pod
|
||||
|
|
@ -148,4 +148,4 @@ public class VolumeTest {
|
|||
public void createPrimaryDataStoreTest() {
|
||||
createPrimaryDataStore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ def can_bridge_firewall(privnic):
|
|||
execute("which iptables")
|
||||
except:
|
||||
print "no iptables on your host machine"
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
execute("which ebtables")
|
||||
except:
|
||||
print "no ebtables on your host machine"
|
||||
exit(2)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
if not os.path.exists('/var/run/cloud'):
|
||||
|
|
@ -813,6 +813,9 @@ if __name__ == '__main__':
|
|||
parser.add_option("--hostIp", dest="hostIp")
|
||||
parser.add_option("--hostMacAddr", dest="hostMacAddr")
|
||||
(option, args) = parser.parse_args()
|
||||
if len(args) == 0:
|
||||
logging.debug("No command to execute")
|
||||
sys.exit(1)
|
||||
cmd = args[0]
|
||||
if cmd == "can_bridge_firewall":
|
||||
can_bridge_firewall(args[1])
|
||||
|
|
@ -830,3 +833,6 @@ if __name__ == '__main__':
|
|||
cleanup_rules()
|
||||
elif cmd == "post_default_network_rules":
|
||||
post_default_network_rules(option.vmName, option.vmID, option.vmIP, option.vmMAC, option.vif, option.brname, option.dhcpSvr, option.hostIp, option.hostMacAddr)
|
||||
else:
|
||||
logging.debug("Unknown command: " + cmd)
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ under the License.
|
|||
<dao name="VM Instance dao" class="com.cloud.vm.dao.VMInstanceDaoImpl" />
|
||||
<dao name="Volume dao" class="com.cloud.storage.dao.VolumeDaoImpl" />
|
||||
<dao name="User VM dao" class="com.cloud.vm.dao.UserVmDaoImpl" />
|
||||
<dao name="User VM clone setting dao" class="com.cloud.vm.dao.UserVmCloneSettingDaoImpl" />
|
||||
<dao name="domain router dao" class="com.cloud.vm.dao.DomainRouterDaoImpl" />
|
||||
<dao name="Storage pool dao" class="com.cloud.storage.dao.StoragePoolDaoImpl" />
|
||||
<dao name="Account dao" class="com.cloud.user.dao.AccountDaoImpl" />
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ public class DataCenterJoinDaoImpl extends GenericDaoBase<DataCenterJoinVO, Long
|
|||
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
|
||||
zoneResponse.setDns1(dataCenter.getDns1());
|
||||
zoneResponse.setDns2(dataCenter.getDns2());
|
||||
zoneResponse.setIp6Dns1(dataCenter.getIp6Dns1());
|
||||
zoneResponse.setIp6Dns2(dataCenter.getIp6Dns2());
|
||||
zoneResponse.setInternalDns1(dataCenter.getInternalDns1());
|
||||
zoneResponse.setInternalDns2(dataCenter.getInternalDns2());
|
||||
// FIXME zoneResponse.setVlan(dataCenter.get.getVnet());
|
||||
|
|
|
|||
|
|
@ -151,6 +151,9 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
|
|||
routerResponse.setDns1(router.getDns1());
|
||||
routerResponse.setDns2(router.getDns2());
|
||||
|
||||
routerResponse.setIp6Dns1(router.getIp6Dns1());
|
||||
routerResponse.setIp6Dns2(router.getIp6Dns2());
|
||||
|
||||
routerResponse.setVpcId(router.getVpcUuid());
|
||||
|
||||
// set async job
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ public class DataCenterJoinVO extends BaseViewVO implements InternalIdentity, Id
|
|||
@Column(name="dns2")
|
||||
private String dns2 = null;
|
||||
|
||||
@Column(name="ip6_dns1")
|
||||
private String ip6Dns1 = null;
|
||||
|
||||
@Column(name="ip6_dns2")
|
||||
private String ip6Dns2 = null;
|
||||
|
||||
@Column(name="internal_dns1")
|
||||
private String internalDns1 = null;
|
||||
|
||||
|
|
@ -280,5 +286,21 @@ public class DataCenterJoinVO extends BaseViewVO implements InternalIdentity, Id
|
|||
this.domainPath = domainPath;
|
||||
}
|
||||
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public void setIp6Dns1(String ip6Dns1) {
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
}
|
||||
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,11 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
|
|||
@Column(name="dns2")
|
||||
private String dns2 = null;
|
||||
|
||||
@Column(name="ip6_dns1")
|
||||
private String ip6Dns1 = null;
|
||||
|
||||
@Column(name="ip6_dns2")
|
||||
private String ip6Dns2 = null;
|
||||
|
||||
@Column(name="host_id", updatable=true, nullable=true)
|
||||
private long hostId;
|
||||
|
|
@ -971,4 +976,19 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
|
|||
}
|
||||
|
||||
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public void setIp6Dns1(String ip6Dns1) {
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
}
|
||||
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public enum Config {
|
|||
SnapshotPollInterval("Snapshots", SnapshotManager.class, Integer.class, "snapshot.poll.interval", "300", "The time interval in seconds when the management server polls for snapshots to be scheduled.", null),
|
||||
SnapshotDeltaMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.delta.max", "16", "max delta snapshots between two full snapshots.", null),
|
||||
BackupSnapshotAferTakingSnapshot("Snapshots", SnapshotManager.class, Boolean.class, "snapshot.backup.rightafter", "true", "backup snapshot right after snapshot is taken", null),
|
||||
|
||||
|
||||
// Advanced
|
||||
JobExpireMinutes("Advanced", ManagementServer.class, String.class, "job.expire.minutes", "1440", "Time (in minutes) for async-jobs to be kept in system", null),
|
||||
JobCancelThresholdMinutes("Advanced", ManagementServer.class, String.class, "job.cancel.threshold.minutes", "60", "Time (in minutes) for async-jobs to be forcely cancelled if it has been in process for long", null),
|
||||
|
|
@ -255,6 +255,7 @@ public enum Config {
|
|||
VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null),
|
||||
VmwareGuestNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.guest.vswitch", null, "Specify the vSwitch on host for guest network", null),
|
||||
VmwareUseNexusVSwitch("Network", ManagementServer.class, Boolean.class, "vmware.use.nexus.vswitch", "false", "Enable/Disable Cisco Nexus 1000v vSwitch in VMware environment", null),
|
||||
VmwareCreateFullClone("Advanced", ManagementServer.class, Boolean.class, "vmware.create.full.clone", "false", "If set to true, creates guest VMs as full clones on ESX", null),
|
||||
VmwareServiceConsole("Advanced", ManagementServer.class, String.class, "vmware.service.console", "Service Console", "Specify the service console network name(for ESX hosts)", null),
|
||||
VmwareManagementPortGroup("Advanced", ManagementServer.class, String.class, "vmware.management.portgroup", "Management Network", "Specify the management network name(for ESXi hosts)", null),
|
||||
VmwareAdditionalVncPortRangeStart("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.start", "50000", "Start port number of additional VNC port range", null),
|
||||
|
|
@ -362,7 +363,7 @@ public enum Config {
|
|||
VpcMaxNetworks("Advanced", ManagementServer.class, Integer.class, "vpc.max.networks", "3", "Maximum number of networks per vpc", null),
|
||||
DetailBatchQuerySize("Advanced", ManagementServer.class, Integer.class, "detail.batch.query.size", "2000", "Default entity detail batch query size for listing", null),
|
||||
ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, Long.class, "concurrent.snapshots.threshold.perhost",
|
||||
null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null),
|
||||
null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null),
|
||||
NetworkIPv6SearchRetryMax("Network", ManagementServer.class, Integer.class, "network.ipv6.search.retry.max", "10000", "The maximum number of retrying times to search for an available IPv6 address in the table", null),
|
||||
|
||||
ExternalBaremetalSystemUrl("Advanced", ManagementServer.class, String.class, "external.baremetal.system.url", null, "url of external baremetal system that CloudStack will talk to", null),
|
||||
|
|
@ -375,14 +376,14 @@ public enum Config {
|
|||
ApiLimitMax("Advanced", ManagementServer.class, Integer.class, "api.throttling.max", "25", "Max allowed number of APIs within fixed interval", null),
|
||||
ApiLimitCacheSize("Advanced", ManagementServer.class, Integer.class, "api.throttling.cachesize", "50000", "Account based API count cache size", null),
|
||||
|
||||
|
||||
|
||||
// VMSnapshots
|
||||
VMSnapshotMax("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a vm", null),
|
||||
VMSnapshotCreateWait("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.create.wait", "600", "In second, timeout for create vm snapshot", null),
|
||||
VMSnapshotExpungeInterval("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.expunge.interval", "60", "The interval (in seconds) to wait before running the expunge thread.", null),
|
||||
VMSnapshotExpungeWorkers("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.expunge.workers", "1", "Number of workers performing expunge ", null);
|
||||
|
||||
|
||||
|
||||
|
||||
private final String _category;
|
||||
private final Class<?> _componentClass;
|
||||
private final Class<?> _type;
|
||||
|
|
|
|||
|
|
@ -129,12 +129,14 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
|||
* TODO
|
||||
* @param isSecurityGroupEnabled
|
||||
* TODO
|
||||
* @param ip6Dns1 TODO
|
||||
* @param ip6Dns2 TODO
|
||||
* @return
|
||||
* @throws
|
||||
* @throws
|
||||
*/
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId, NetworkType zoneType, String allocationState,
|
||||
String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled);
|
||||
String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2);
|
||||
|
||||
/**
|
||||
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated
|
||||
|
|
|
|||
|
|
@ -1092,7 +1092,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
|
||||
}
|
||||
|
||||
private void checkZoneParameters(String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, boolean checkForDuplicates, Long domainId, String allocationStateStr) {
|
||||
private void checkZoneParameters(String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, boolean checkForDuplicates, Long domainId, String allocationStateStr,
|
||||
String ip6Dns1, String ip6Dns2) {
|
||||
if (checkForDuplicates) {
|
||||
// Check if a zone with the specified name already exists
|
||||
if (validZone(zoneName)) {
|
||||
|
|
@ -1127,6 +1128,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
throw new InvalidParameterValueException("Please enter a valid IP address for internal DNS2");
|
||||
}
|
||||
|
||||
if (ip6Dns1 != null && ip6Dns1.length() > 0 && !NetUtils.isValidIpv6(ip6Dns1)) {
|
||||
throw new InvalidParameterValueException("Please enter a valid IPv6 address for IP6 DNS1");
|
||||
}
|
||||
|
||||
if (ip6Dns2 != null && ip6Dns2.length() > 0 && !NetUtils.isValidIpv6(ip6Dns2)) {
|
||||
throw new InvalidParameterValueException("Please enter a valid IPv6 address for IP6 DNS2");
|
||||
}
|
||||
|
||||
Grouping.AllocationState allocationState = null;
|
||||
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
|
||||
try {
|
||||
|
|
@ -1396,6 +1405,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
String zoneName = cmd.getZoneName();
|
||||
String dns1 = cmd.getDns1();
|
||||
String dns2 = cmd.getDns2();
|
||||
String ip6Dns1 = cmd.getIp6Dns1();
|
||||
String ip6Dns2 = cmd.getIp6Dns2();
|
||||
String internalDns1 = cmd.getInternalDns1();
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
|
|
@ -1473,6 +1484,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
dns2 = zone.getDns2();
|
||||
}
|
||||
|
||||
if (ip6Dns1 == null) {
|
||||
ip6Dns1 = zone.getIp6Dns1();
|
||||
}
|
||||
|
||||
if (ip6Dns2 == null) {
|
||||
ip6Dns2 = zone.getIp6Dns2();
|
||||
}
|
||||
|
||||
if (internalDns1 == null) {
|
||||
internalDns1 = zone.getInternalDns1();
|
||||
}
|
||||
|
|
@ -1495,20 +1514,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
|
||||
boolean checkForDuplicates = !zoneName.equals(oldZoneName);
|
||||
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr);// not
|
||||
// allowing
|
||||
// updating
|
||||
// domain
|
||||
// associated
|
||||
// with
|
||||
// a
|
||||
// zone,
|
||||
// once
|
||||
// created
|
||||
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr, ip6Dns1, ip6Dns2);// not allowing updating domain associated with a zone, once created
|
||||
|
||||
zone.setName(zoneName);
|
||||
zone.setDns1(dns1);
|
||||
zone.setDns2(dns2);
|
||||
zone.setIp6Dns1(ip6Dns1);
|
||||
zone.setIp6Dns2(ip6Dns2);
|
||||
zone.setInternalDns1(internalDns1);
|
||||
zone.setInternalDns2(internalDns2);
|
||||
zone.setGuestNetworkCidr(guestCidr);
|
||||
|
|
@ -1588,7 +1600,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
@Override
|
||||
@DB
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId,
|
||||
NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled) {
|
||||
NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2) {
|
||||
|
||||
// checking the following params outside checkzoneparams method as we do
|
||||
// not use these params for updatezone
|
||||
|
|
@ -1606,7 +1618,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
}
|
||||
|
||||
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId, allocationStateStr);
|
||||
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId, allocationStateStr, ip6Dns1, ip6Dns2);
|
||||
|
||||
byte[] bytes = (zoneName + System.currentTimeMillis()).getBytes();
|
||||
String zoneToken = UUID.nameUUIDFromBytes(bytes).toString();
|
||||
|
|
@ -1614,7 +1626,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
try {
|
||||
txn.start();
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled, isLocalStorageEnabled);
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
|
||||
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
|
||||
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
|
||||
zone.setAllocationState(allocationState);
|
||||
|
|
@ -1686,6 +1698,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
String zoneName = cmd.getZoneName();
|
||||
String dns1 = cmd.getDns1();
|
||||
String dns2 = cmd.getDns2();
|
||||
String ip6Dns1 = cmd.getIp6Dns1();
|
||||
String ip6Dns2 = cmd.getIp6Dns2();
|
||||
String internalDns1 = cmd.getInternalDns1();
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
|
|
@ -1729,7 +1743,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType, allocationState, networkDomain,
|
||||
isSecurityGroupEnabled, isLocalStorageEnabled);
|
||||
isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -59,6 +59,12 @@ public class DataCenterVO implements DataCenter {
|
|||
@Column(name="dns2")
|
||||
private String dns2 = null;
|
||||
|
||||
@Column(name="ip6_dns1")
|
||||
private String ip6Dns1 = null;
|
||||
|
||||
@Column(name="ip6_dns2")
|
||||
private String ip6Dns2 = null;
|
||||
|
||||
@Column(name="internal_dns1")
|
||||
private String internalDns1 = null;
|
||||
|
||||
|
|
@ -177,17 +183,19 @@ public class DataCenterVO implements DataCenter {
|
|||
}
|
||||
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
|
||||
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
|
||||
this.id = id;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled) {
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
this.internalDns1 = dns3;
|
||||
this.internalDns2 = dns4;
|
||||
this.guestNetworkCidr = guestCidr;
|
||||
|
|
@ -431,4 +439,22 @@ public class DataCenterVO implements DataCenter {
|
|||
public void setMacAddress(long macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIp6Dns1() {
|
||||
return ip6Dns1;
|
||||
}
|
||||
|
||||
public void setIp6Dns1(String ip6Dns1) {
|
||||
this.ip6Dns1 = ip6Dns1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIp6Dns2() {
|
||||
return ip6Dns2;
|
||||
}
|
||||
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,22 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.ExternalNetworkResourceUsageAnswer;
|
||||
import com.cloud.agent.api.ExternalNetworkResourceUsageCommand;
|
||||
|
|
@ -41,27 +25,30 @@ import com.cloud.dc.DataCenterVO;
|
|||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.host.DetailVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceDao;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceVO;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.InlineLoadBalancerNicMapDao;
|
||||
import com.cloud.network.dao.InlineLoadBalancerNicMapVO;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.LoadBalancerVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkExternalFirewallDao;
|
||||
import com.cloud.network.dao.NetworkExternalFirewallVO;
|
||||
import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkExternalLoadBalancerVO;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
|
|
@ -81,6 +68,20 @@ import com.cloud.vm.DomainRouterVO;
|
|||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@Local(value = { ExternalLoadBalancerUsageManager.class })
|
||||
|
|
@ -146,7 +147,7 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
ScheduledExecutorService _executor;
|
||||
private int _externalNetworkStatsInterval;
|
||||
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalLoadBalancerUsageManagerImpl.class);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_externalNetworkStatsInterval = NumbersUtil.parseInt(_configDao.getValue(Config.ExternalNetworkStatsInterval.key()), 300);
|
||||
|
|
@ -160,7 +161,7 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
@Override
|
||||
public boolean start() {
|
||||
if (_externalNetworkStatsInterval > 0) {
|
||||
_executor.scheduleAtFixedRate(new ExternalLoadBalancerDeviceNetworkUsageTask(), _externalNetworkStatsInterval, _externalNetworkStatsInterval, TimeUnit.SECONDS);
|
||||
_executor.scheduleAtFixedRate(new ExternalDeviceNetworkUsageTask(), _externalNetworkStatsInterval, _externalNetworkStatsInterval, TimeUnit.SECONDS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -170,6 +171,11 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
private ExternalLoadBalancerDeviceVO getExternalLoadBalancerForNetwork(Network network) {
|
||||
NetworkExternalLoadBalancerVO lbDeviceForNetwork = _networkExternalLBDao.findByNetworkId(network.getId());
|
||||
if (lbDeviceForNetwork != null) {
|
||||
|
|
@ -180,15 +186,21 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean externalLoadBalancerIsInline(HostVO externalLoadBalancer) {
|
||||
DetailVO detail = _hostDetailDao.findDetail(externalLoadBalancer.getId(), "inline");
|
||||
return (detail != null && detail.getValue().equals("true"));
|
||||
|
||||
private ExternalFirewallDeviceVO getExternalFirewallForNetwork(Network network) {
|
||||
NetworkExternalFirewallVO fwDeviceForNetwork = _networkExternalFirewallDao.findByNetworkId(network.getId());
|
||||
if (fwDeviceForNetwork != null) {
|
||||
long fwDeviceId = fwDeviceForNetwork.getExternalFirewallDeviceId();
|
||||
ExternalFirewallDeviceVO fwDevice = _externalFirewallDeviceDao.findById(fwDeviceId);
|
||||
assert(fwDevice != null);
|
||||
return fwDevice;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateExternalLoadBalancerNetworkUsageStats(long loadBalancerRuleId){
|
||||
|
||||
|
||||
LoadBalancerVO lb = _loadBalancerDao.findById(loadBalancerRuleId);
|
||||
if(lb == null){
|
||||
if(s_logger.isDebugEnabled()){
|
||||
|
|
@ -204,7 +216,8 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
}
|
||||
return;
|
||||
}
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = getExternalLoadBalancerForNetwork(network);
|
||||
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = getExternalLoadBalancerForNetwork(network);
|
||||
if (lbDeviceVO == null) {
|
||||
if(s_logger.isDebugEnabled()){
|
||||
s_logger.debug("Cannot update usage stats, No external LB device found");
|
||||
|
|
@ -235,24 +248,24 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
|
||||
String publicIp = _networkMgr.getIp(lb.getSourceIpAddressId()).getAddress().addr();
|
||||
DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
|
||||
String statsEntryIdentifier = "account " + account.getAccountName() + ", zone " + zone.getName() + ", network ID " + networkId + ", host ID " + externalLoadBalancer.getName();
|
||||
|
||||
String statsEntryIdentifier = "account " + account.getAccountName() + ", zone " + zone.getName() + ", network ID " + networkId + ", host ID " + externalLoadBalancer.getName();
|
||||
|
||||
long newCurrentBytesSent = 0;
|
||||
long newCurrentBytesReceived = 0;
|
||||
|
||||
|
||||
if (publicIp != null) {
|
||||
long[] bytesSentAndReceived = null;
|
||||
statsEntryIdentifier += ", public IP: " + publicIp;
|
||||
|
||||
if (externalLoadBalancer.getType().equals(Host.Type.ExternalLoadBalancer) && externalLoadBalancerIsInline(externalLoadBalancer)) {
|
||||
boolean inline = _networkMgr.isNetworkInlineMode(network);
|
||||
if (externalLoadBalancer.getType().equals(Host.Type.ExternalLoadBalancer) && inline) {
|
||||
// Look up stats for the guest IP address that's mapped to the public IP address
|
||||
InlineLoadBalancerNicMapVO mapping = _inlineLoadBalancerNicMapDao.findByPublicIpAddress(publicIp);
|
||||
|
||||
|
||||
if (mapping != null) {
|
||||
NicVO nic = _nicDao.findById(mapping.getNicId());
|
||||
String loadBalancingIpAddress = nic.getIp4Address();
|
||||
bytesSentAndReceived = lbAnswer.ipBytes.get(loadBalancingIpAddress);
|
||||
|
||||
|
||||
if (bytesSentAndReceived != null) {
|
||||
bytesSentAndReceived[0] = 0;
|
||||
}
|
||||
|
|
@ -260,39 +273,39 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
} else {
|
||||
bytesSentAndReceived = lbAnswer.ipBytes.get(publicIp);
|
||||
}
|
||||
|
||||
|
||||
if (bytesSentAndReceived == null) {
|
||||
s_logger.debug("Didn't get an external network usage answer for public IP " + publicIp);
|
||||
} else {
|
||||
newCurrentBytesSent += bytesSentAndReceived[0];
|
||||
newCurrentBytesReceived += bytesSentAndReceived[1];
|
||||
}
|
||||
|
||||
|
||||
UserStatisticsVO userStats;
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
txn.start();
|
||||
userStats = _userStatsDao.lock(accountId, zone.getId(), networkId, publicIp, externalLoadBalancer.getId(), externalLoadBalancer.getType().toString());
|
||||
|
||||
|
||||
if(userStats != null){
|
||||
long oldNetBytesSent = userStats.getNetBytesSent();
|
||||
long oldNetBytesReceived = userStats.getNetBytesReceived();
|
||||
long oldCurrentBytesSent = userStats.getCurrentBytesSent();
|
||||
long oldCurrentBytesReceived = userStats.getCurrentBytesReceived();
|
||||
String warning = "Received an external network stats byte count that was less than the stored value. Zone ID: " + userStats.getDataCenterId() + ", account ID: " + userStats.getAccountId() + ".";
|
||||
|
||||
|
||||
userStats.setCurrentBytesSent(newCurrentBytesSent);
|
||||
if (oldCurrentBytesSent > newCurrentBytesSent) {
|
||||
s_logger.warn(warning + "Stored bytes sent: " + oldCurrentBytesSent + ", new bytes sent: " + newCurrentBytesSent + ".");
|
||||
s_logger.warn(warning + "Stored bytes sent: " + oldCurrentBytesSent + ", new bytes sent: " + newCurrentBytesSent + ".");
|
||||
userStats.setNetBytesSent(oldNetBytesSent + oldCurrentBytesSent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userStats.setCurrentBytesReceived(newCurrentBytesReceived);
|
||||
if (oldCurrentBytesReceived > newCurrentBytesReceived) {
|
||||
s_logger.warn(warning + "Stored bytes received: " + oldCurrentBytesReceived + ", new bytes received: " + newCurrentBytesReceived + ".");
|
||||
s_logger.warn(warning + "Stored bytes received: " + oldCurrentBytesReceived + ", new bytes received: " + newCurrentBytesReceived + ".");
|
||||
userStats.setNetBytesReceived(oldNetBytesReceived + oldCurrentBytesReceived);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_userStatsDao.update(userStats.getId(), userStats)) {
|
||||
s_logger.debug("Successfully updated stats for " + statsEntryIdentifier);
|
||||
} else {
|
||||
|
|
@ -301,7 +314,7 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
}else {
|
||||
s_logger.warn("Unable to find user stats entry for " + statsEntryIdentifier);
|
||||
}
|
||||
|
||||
|
||||
txn.commit();
|
||||
}catch (final Exception e) {
|
||||
txn.rollback();
|
||||
|
|
@ -310,32 +323,32 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
}
|
||||
}
|
||||
|
||||
protected class ExternalLoadBalancerDeviceNetworkUsageTask implements Runnable {
|
||||
protected class ExternalDeviceNetworkUsageTask implements Runnable {
|
||||
|
||||
public ExternalLoadBalancerDeviceNetworkUsageTask() {
|
||||
public ExternalDeviceNetworkUsageTask() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("ExternalLoadBalancerUsageManagerImpl");
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("ExternalDeviceNetworkUsageManagerImpl");
|
||||
try {
|
||||
if (scanLock.lock(20)) {
|
||||
try {
|
||||
runExternalLoadBalancerNetworkUsageTask();
|
||||
runExternalDeviceNetworkUsageTask();
|
||||
} finally {
|
||||
scanLock.unlock();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Problems while getting external load balancer device usage", e);
|
||||
s_logger.warn("Problems while getting external device usage", e);
|
||||
} finally {
|
||||
scanLock.releaseRef();
|
||||
}
|
||||
}
|
||||
|
||||
private void runExternalLoadBalancerNetworkUsageTask() {
|
||||
s_logger.debug("External load balancer devices stats collector is running...");
|
||||
private void runExternalDeviceNetworkUsageTask() {
|
||||
s_logger.debug("External devices stats collector is running...");
|
||||
|
||||
for (DataCenterVO zone : _dcDao.listAll()) {
|
||||
List<DomainRouterVO> domainRoutersInZone = _routerDao.listByDataCenter(zone.getId());
|
||||
|
|
@ -343,6 +356,7 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
continue;
|
||||
}
|
||||
Map<Long, ExternalNetworkResourceUsageAnswer> lbDeviceUsageAnswerMap = new HashMap<Long, ExternalNetworkResourceUsageAnswer>();
|
||||
Map<Long, ExternalNetworkResourceUsageAnswer> fwDeviceUsageAnswerMap = new HashMap<Long, ExternalNetworkResourceUsageAnswer>();
|
||||
List<Long> accountsProcessed = new ArrayList<Long>();
|
||||
|
||||
for (DomainRouterVO domainRouter : domainRoutersInZone) {
|
||||
|
|
@ -368,45 +382,88 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
continue;
|
||||
}
|
||||
|
||||
ExternalFirewallDeviceVO fwDeviceVO = getExternalFirewallForNetwork(network);
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = getExternalLoadBalancerForNetwork(network);
|
||||
if (lbDeviceVO == null) {
|
||||
if (lbDeviceVO == null && fwDeviceVO == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get network stats from the external firewall
|
||||
ExternalNetworkResourceUsageAnswer firewallAnswer = null;
|
||||
HostVO externalFirewall = null;
|
||||
if(fwDeviceVO != null){
|
||||
externalFirewall = _hostDao.findById(fwDeviceVO.getHostId());
|
||||
if (externalFirewall != null) {
|
||||
Long fwDeviceId = new Long(externalFirewall.getId());
|
||||
if(!fwDeviceUsageAnswerMap.containsKey(fwDeviceId)){
|
||||
try{
|
||||
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();
|
||||
firewallAnswer = (ExternalNetworkResourceUsageAnswer) _agentMgr.easySend(externalFirewall.getId(), cmd);
|
||||
if (firewallAnswer == null || !firewallAnswer.getResult()) {
|
||||
String details = (firewallAnswer != null) ? firewallAnswer.getDetails() : "details unavailable";
|
||||
String msg = "Unable to get external firewall stats for network" + zone.getName() + " due to: " + details + ".";
|
||||
s_logger.error(msg);
|
||||
} else {
|
||||
fwDeviceUsageAnswerMap.put(fwDeviceId, firewallAnswer);
|
||||
}
|
||||
} catch (Exception e){
|
||||
String msg = "Unable to get external firewall stats for network" + zone.getName();
|
||||
s_logger.error(msg, e);
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Reusing usage Answer for device id " + fwDeviceId + "for Network " + network.getId());
|
||||
}
|
||||
firewallAnswer = fwDeviceUsageAnswerMap.get(fwDeviceId);
|
||||
}
|
||||
}}
|
||||
|
||||
// Get network stats from the external load balancer
|
||||
ExternalNetworkResourceUsageAnswer lbAnswer = null;
|
||||
HostVO externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
|
||||
if (externalLoadBalancer != null) {
|
||||
Long lbDeviceId = new Long(externalLoadBalancer.getId());
|
||||
if (!lbDeviceUsageAnswerMap.containsKey(lbDeviceId)) {
|
||||
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();
|
||||
lbAnswer = (ExternalNetworkResourceUsageAnswer) _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
if (lbAnswer == null || !lbAnswer.getResult()) {
|
||||
String details = (lbAnswer != null) ? lbAnswer.getDetails() : "details unavailable";
|
||||
String msg = "Unable to get external load balancer stats for " + zone.getName() + " due to: " + details + ".";
|
||||
s_logger.error(msg);
|
||||
continue;
|
||||
HostVO externalLoadBalancer = null;
|
||||
if(lbDeviceVO !=null){
|
||||
externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
|
||||
if (externalLoadBalancer != null) {
|
||||
Long lbDeviceId = new Long(externalLoadBalancer.getId());
|
||||
if (!lbDeviceUsageAnswerMap.containsKey(lbDeviceId)) {
|
||||
try {
|
||||
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();
|
||||
lbAnswer = (ExternalNetworkResourceUsageAnswer) _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
if (lbAnswer == null || !lbAnswer.getResult()) {
|
||||
String details = (lbAnswer != null) ? lbAnswer.getDetails() : "details unavailable";
|
||||
String msg = "Unable to get external load balancer stats for " + zone.getName() + " due to: " + details + ".";
|
||||
s_logger.error(msg);
|
||||
} else {
|
||||
lbDeviceUsageAnswerMap.put(lbDeviceId, lbAnswer);
|
||||
}
|
||||
} catch (Exception e){
|
||||
String msg = "Unable to get external load balancer stats for " + zone.getName();
|
||||
s_logger.error(msg, e);
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Reusing usage Answer for device id " + lbDeviceId + "for Network " + network.getId());
|
||||
}
|
||||
lbAnswer = lbDeviceUsageAnswerMap.get(lbDeviceId);
|
||||
}
|
||||
lbDeviceUsageAnswerMap.put(lbDeviceId, lbAnswer);
|
||||
} else {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Reusing usage Answer for device id " + lbDeviceId + "for Network " + network.getId());
|
||||
}
|
||||
lbAnswer = lbDeviceUsageAnswerMap.get(lbDeviceId);
|
||||
}
|
||||
}
|
||||
|
||||
if(firewallAnswer == null && lbAnswer == null){
|
||||
continue;
|
||||
}
|
||||
|
||||
AccountVO account = _accountDao.findById(accountId);
|
||||
if (account == null) {
|
||||
s_logger.debug("Skipping stats update for account with ID " + accountId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!manageStatsEntries(true, accountId, zoneId, network, externalLoadBalancer, lbAnswer)) {
|
||||
if (!manageStatsEntries(true, accountId, zoneId, network, externalFirewall, firewallAnswer, externalLoadBalancer, lbAnswer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
manageStatsEntries(false, accountId, zoneId, network, externalLoadBalancer, lbAnswer);
|
||||
manageStatsEntries(false, accountId, zoneId, network, externalFirewall, firewallAnswer, externalLoadBalancer, lbAnswer);
|
||||
}
|
||||
|
||||
accountsProcessed.add(new Long(accountId));
|
||||
|
|
@ -448,7 +505,7 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
}
|
||||
|
||||
// Updates an existing stats entry with new data from the specified usage answer.
|
||||
private boolean updateStatsEntry(long accountId, long zoneId, long networkId, String publicIp, long hostId, ExternalNetworkResourceUsageAnswer answer) {
|
||||
private boolean updateStatsEntry(long accountId, long zoneId, long networkId, String publicIp, long hostId, ExternalNetworkResourceUsageAnswer answer, boolean inline) {
|
||||
AccountVO account = _accountDao.findById(accountId);
|
||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||
NetworkVO network = _networkDao.findById(networkId);
|
||||
|
|
@ -462,7 +519,7 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
long[] bytesSentAndReceived = null;
|
||||
statsEntryIdentifier += ", public IP: " + publicIp;
|
||||
|
||||
if (host.getType().equals(Host.Type.ExternalLoadBalancer) && externalLoadBalancerIsInline(host)) {
|
||||
if (host.getType().equals(Host.Type.ExternalLoadBalancer) && inline) {
|
||||
// Look up stats for the guest IP address that's mapped to the public IP address
|
||||
InlineLoadBalancerNicMapVO mapping = _inlineLoadBalancerNicMapDao.findByPublicIpAddress(publicIp);
|
||||
|
||||
|
|
@ -520,11 +577,11 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
}
|
||||
}
|
||||
|
||||
private boolean createOrUpdateStatsEntry(boolean create, long accountId, long zoneId, long networkId, String publicIp, long hostId, ExternalNetworkResourceUsageAnswer answer) {
|
||||
private boolean createOrUpdateStatsEntry(boolean create, long accountId, long zoneId, long networkId, String publicIp, long hostId, ExternalNetworkResourceUsageAnswer answer, boolean inline) {
|
||||
if (create) {
|
||||
return createStatsEntry(accountId, zoneId, networkId, publicIp, hostId);
|
||||
} else {
|
||||
return updateStatsEntry(accountId, zoneId, networkId, publicIp, hostId, answer);
|
||||
return updateStatsEntry(accountId, zoneId, networkId, publicIp, hostId, answer, inline);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -534,19 +591,66 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
* balancing rules
|
||||
*/
|
||||
private boolean manageStatsEntries(boolean create, long accountId, long zoneId, Network network,
|
||||
HostVO externalLoadBalancer, ExternalNetworkResourceUsageAnswer lbAnswer) {
|
||||
HostVO externalFirewall, ExternalNetworkResourceUsageAnswer firewallAnswer,
|
||||
HostVO externalLoadBalancer, ExternalNetworkResourceUsageAnswer lbAnswer) {
|
||||
String accountErrorMsg = "Failed to update external network stats entry. Details: account ID = " + accountId;
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
try {
|
||||
txn.start();
|
||||
String networkErrorMsg = accountErrorMsg + ", network ID = " + network.getId();
|
||||
|
||||
boolean sharedSourceNat = false;
|
||||
Map<Network.Capability, String> sourceNatCapabilities = _networkMgr.getNetworkServiceCapabilities(network.getId(), Network.Service.SourceNat);
|
||||
if (sourceNatCapabilities != null) {
|
||||
String supportedSourceNatTypes = sourceNatCapabilities.get(Network.Capability.SupportedSourceNatTypes).toLowerCase();
|
||||
if (supportedSourceNatTypes.contains("zone")) {
|
||||
sharedSourceNat = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(externalFirewall != null && firewallAnswer != null){
|
||||
if (!sharedSourceNat) {
|
||||
// Manage the entry for this network's source NAT IP address
|
||||
List<IPAddressVO> sourceNatIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), true);
|
||||
if (sourceNatIps.size() == 1) {
|
||||
String publicIp = sourceNatIps.get(0).getAddress().addr();
|
||||
if (!createOrUpdateStatsEntry(create, accountId, zoneId, network.getId(), publicIp, externalFirewall.getId(), firewallAnswer, false)) {
|
||||
throw new ExecutionException(networkErrorMsg + ", source NAT IP = " + publicIp);
|
||||
}
|
||||
}
|
||||
|
||||
// Manage one entry for each static NAT rule in this network
|
||||
List<IPAddressVO> staticNatIps = _ipAddressDao.listStaticNatPublicIps(network.getId());
|
||||
for (IPAddressVO staticNatIp : staticNatIps) {
|
||||
String publicIp = staticNatIp.getAddress().addr();
|
||||
if (!createOrUpdateStatsEntry(create, accountId, zoneId, network.getId(), publicIp, externalFirewall.getId(), firewallAnswer, false)) {
|
||||
throw new ExecutionException(networkErrorMsg + ", static NAT rule public IP = " + publicIp);
|
||||
}
|
||||
}
|
||||
|
||||
// Manage one entry for each port forwarding rule in this network
|
||||
List<PortForwardingRuleVO> portForwardingRules = _portForwardingRulesDao.listByNetwork(network.getId());
|
||||
for (PortForwardingRuleVO portForwardingRule : portForwardingRules) {
|
||||
String publicIp = _networkMgr.getIp(portForwardingRule.getSourceIpAddressId()).getAddress().addr();
|
||||
if (!createOrUpdateStatsEntry(create, accountId, zoneId, network.getId(), publicIp, externalFirewall.getId(), firewallAnswer, false)) {
|
||||
throw new ExecutionException(networkErrorMsg + ", port forwarding rule public IP = " + publicIp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Manage the account-wide entry for the external firewall
|
||||
if (!createOrUpdateStatsEntry(create, accountId, zoneId, network.getId(), null, externalFirewall.getId(), firewallAnswer, false)) {
|
||||
throw new ExecutionException(networkErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If an external load balancer is added, manage one entry for each load balancing rule in this network
|
||||
if (externalLoadBalancer != null && lbAnswer != null) {
|
||||
boolean inline = _networkMgr.isNetworkInlineMode(network);
|
||||
List<LoadBalancerVO> loadBalancers = _loadBalancerDao.listByNetworkId(network.getId());
|
||||
for (LoadBalancerVO loadBalancer : loadBalancers) {
|
||||
String publicIp = _networkMgr.getIp(loadBalancer.getSourceIpAddressId()).getAddress().addr();
|
||||
if (!createOrUpdateStatsEntry(create, accountId, zoneId, network.getId(), publicIp, externalLoadBalancer.getId(), lbAnswer)) {
|
||||
if (!createOrUpdateStatsEntry(create, accountId, zoneId, network.getId(), publicIp, externalLoadBalancer.getId(), lbAnswer, inline)) {
|
||||
throw new ExecutionException(networkErrorMsg + ", load balancing rule public IP = " + publicIp);
|
||||
}
|
||||
}
|
||||
|
|
@ -561,4 +665,5 @@ public class ExternalLoadBalancerUsageManagerImpl extends ManagerBase implements
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3405,6 +3405,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
||||
nic.setMacAddress(ip.getMacAddress());
|
||||
}
|
||||
nic.setDns1(dc.getDns1());
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
if (network.getIp6Gateway() != null) {
|
||||
|
|
@ -3426,10 +3428,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
|
|||
nic.setMacAddress(ip.getMacAddress());
|
||||
}
|
||||
}
|
||||
nic.setIp6Dns1(dc.getIp6Dns1());
|
||||
nic.setIp6Dns2(dc.getIp6Dns2());
|
||||
}
|
||||
|
||||
nic.setDns1(dc.getDns1());
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
if (profile != null) {
|
||||
profile.setDns1(dc.getDns1());
|
||||
profile.setDns2(dc.getDns2());
|
||||
profile.setIp6Dns1(dc.getIp6Dns1());
|
||||
profile.setIp6Dns2(dc.getIp6Dns2());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import javax.inject.Inject;
|
|||
|
||||
import com.cloud.event.ActionEventUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
|
|
@ -77,7 +76,6 @@ import com.cloud.vm.dao.NicDao;
|
|||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
|
||||
@Component
|
||||
@Local(value = NetworkGuru.class)
|
||||
public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(GuestNetworkGuru.class);
|
||||
|
|
|
|||
|
|
@ -293,8 +293,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
UserVmDao _userVmDao;
|
||||
@Inject VMInstanceDao _vmDao;
|
||||
@Inject
|
||||
UserStatisticsDao _statsDao = null;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao = null;
|
||||
@Inject
|
||||
GuestOSDao _guestOSDao = null;
|
||||
|
|
@ -364,7 +362,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
private String _usageTimeZone = "GMT";
|
||||
private final long mgmtSrvrId = MacAddress.getMacAddress().toLong();
|
||||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 5; // 5 seconds
|
||||
|
||||
private static final int USAGE_AGGREGATION_RANGE_MIN = 10; // 10 minutes, same as com.cloud.usage.UsageManagerImpl.USAGE_AGGREGATION_RANGE_MIN
|
||||
private boolean _dailyOrHourly = false;
|
||||
|
||||
ScheduledExecutorService _executor;
|
||||
ScheduledExecutorService _checkExecutor;
|
||||
ScheduledExecutorService _networkStatsUpdateExecutor;
|
||||
|
|
@ -728,6 +728,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
cal.roll(Calendar.DAY_OF_YEAR, true);
|
||||
cal.add(Calendar.MILLISECOND, -1);
|
||||
endDate = cal.getTime().getTime();
|
||||
_dailyOrHourly = true;
|
||||
} else if (_usageAggregationRange == HOURLY_TIME) {
|
||||
cal.roll(Calendar.HOUR_OF_DAY, false);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
|
|
@ -736,8 +737,15 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
cal.roll(Calendar.HOUR_OF_DAY, true);
|
||||
cal.add(Calendar.MILLISECOND, -1);
|
||||
endDate = cal.getTime().getTime();
|
||||
_dailyOrHourly = true;
|
||||
} else {
|
||||
endDate = cal.getTime().getTime();
|
||||
_dailyOrHourly = false;
|
||||
}
|
||||
|
||||
if (_usageAggregationRange < USAGE_AGGREGATION_RANGE_MIN) {
|
||||
s_logger.warn("Usage stats job aggregation range is to small, using the minimum value of " + USAGE_AGGREGATION_RANGE_MIN);
|
||||
_usageAggregationRange = USAGE_AGGREGATION_RANGE_MIN;
|
||||
}
|
||||
|
||||
_networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), (endDate - System.currentTimeMillis()),
|
||||
|
|
@ -854,7 +862,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
|
||||
forVpc, routerNic.getIp4Address());
|
||||
String routerType = router.getType().toString();
|
||||
UserStatisticsVO previousStats = _statsDao.findBy(router.getAccountId(),
|
||||
UserStatisticsVO previousStats = _userStatsDao.findBy(router.getAccountId(),
|
||||
router.getDataCenterId(), network.getId(), (forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
|
||||
NetworkUsageAnswer answer = null;
|
||||
try {
|
||||
|
|
@ -876,7 +884,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
continue;
|
||||
}
|
||||
txn.start();
|
||||
UserStatisticsVO stats = _statsDao.lock(router.getAccountId(),
|
||||
UserStatisticsVO stats = _userStatsDao.lock(router.getAccountId(),
|
||||
router.getDataCenterId(), network.getId(), (forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
|
||||
if (stats == null) {
|
||||
s_logger.warn("unable to find stats for account: " + router.getAccountId());
|
||||
|
|
@ -912,7 +920,12 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
stats.setNetBytesSent(stats.getNetBytesSent() + stats.getCurrentBytesSent());
|
||||
}
|
||||
stats.setCurrentBytesSent(answer.getBytesSent());
|
||||
_statsDao.update(stats.getId(), stats);
|
||||
if (! _dailyOrHourly) {
|
||||
//update agg bytes
|
||||
stats.setAggBytesSent(stats.getNetBytesSent() + stats.getCurrentBytesSent());
|
||||
stats.setAggBytesReceived(stats.getNetBytesReceived() + stats.getCurrentBytesReceived());
|
||||
}
|
||||
_userStatsDao.update(stats.getId(), stats);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
|
|
@ -954,7 +967,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
try {
|
||||
txn.start();
|
||||
//get all stats with delta > 0
|
||||
List<UserStatisticsVO> updatedStats = _statsDao.listUpdatedStats();
|
||||
List<UserStatisticsVO> updatedStats = _userStatsDao.listUpdatedStats();
|
||||
Date updatedTime = new Date();
|
||||
for(UserStatisticsVO stat : updatedStats){
|
||||
//update agg bytes
|
||||
|
|
@ -1922,6 +1935,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
NicProfile controlNic = null;
|
||||
String defaultDns1 = null;
|
||||
String defaultDns2 = null;
|
||||
String defaultIp6Dns1 = null;
|
||||
String defaultIp6Dns2 = null;
|
||||
for (NicProfile nic : profile.getNics()) {
|
||||
int deviceId = nic.getDeviceId();
|
||||
boolean ipv4 = false, ipv6 = false;
|
||||
|
|
@ -1945,6 +1960,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
}
|
||||
defaultDns1 = nic.getDns1();
|
||||
defaultDns2 = nic.getDns2();
|
||||
defaultIp6Dns1 = nic.getIp6Dns1();
|
||||
defaultIp6Dns2 = nic.getIp6Dns2();
|
||||
}
|
||||
|
||||
if (nic.getTrafficType() == TrafficType.Management) {
|
||||
|
|
@ -2040,6 +2057,12 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
if (defaultDns2 != null) {
|
||||
buf.append(" dns2=").append(defaultDns2);
|
||||
}
|
||||
if (defaultIp6Dns1 != null) {
|
||||
buf.append(" ip6dns1=").append(defaultIp6Dns1);
|
||||
}
|
||||
if (defaultIp6Dns2 != null) {
|
||||
buf.append(" ip6dns2=").append(defaultIp6Dns2);
|
||||
}
|
||||
|
||||
boolean useExtDns = !dnsProvided;
|
||||
/* For backward compatibility */
|
||||
|
|
@ -3588,7 +3611,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
boolean forVpc = router.getVpcId() != null;
|
||||
final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
|
||||
forVpc, routerNic.getIp4Address());
|
||||
UserStatisticsVO previousStats = _statsDao.findBy(router.getAccountId(),
|
||||
UserStatisticsVO previousStats = _userStatsDao.findBy(router.getAccountId(),
|
||||
router.getDataCenterId(), network.getId(), null, router.getId(), router.getType().toString());
|
||||
NetworkUsageAnswer answer = null;
|
||||
try {
|
||||
|
|
@ -3610,7 +3633,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
continue;
|
||||
}
|
||||
txn.start();
|
||||
UserStatisticsVO stats = _statsDao.lock(router.getAccountId(),
|
||||
UserStatisticsVO stats = _userStatsDao.lock(router.getAccountId(),
|
||||
router.getDataCenterId(), network.getId(), null, router.getId(), router.getType().toString());
|
||||
if (stats == null) {
|
||||
s_logger.warn("unable to find stats for account: " + router.getAccountId());
|
||||
|
|
@ -3646,7 +3669,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||
stats.setNetBytesSent(stats.getNetBytesSent() + stats.getCurrentBytesSent());
|
||||
}
|
||||
stats.setCurrentBytesSent(answer.getBytesSent());
|
||||
_statsDao.update(stats.getId(), stats);
|
||||
_userStatsDao.update(stats.getId(), stats);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager {
|
|||
StringBuilder acctNm = new StringBuilder("PrjAcct-");
|
||||
acctNm.append(name).append("-").append(owner.getDomainId());
|
||||
|
||||
Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.ACCOUNT_TYPE_PROJECT, domainId, null, null, "", 0);
|
||||
Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.ACCOUNT_TYPE_PROJECT, domainId, null, null);
|
||||
|
||||
Project project = _projectDao.persist(new ProjectVO(name, displayText, owner.getDomainId(), projectAccount.getId()));
|
||||
|
||||
|
|
|
|||
|
|
@ -21,15 +21,12 @@ import java.util.Map;
|
|||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
|
||||
/**
|
||||
* Use this UserAuthenticator if users are already authenticated outside
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@Local(value={UserAuthenticator.class})
|
||||
public abstract class DefaultUserAuthenticator extends AdapterBase implements UserAuthenticator {
|
||||
private String _name = null;
|
||||
|
|
|
|||
|
|
@ -343,8 +343,14 @@ public class DownloadListener implements Listener {
|
|||
updateBuilder.setInstallPath(answer.getInstallPath());
|
||||
updateBuilder.setSize(answer.getTemplateSize());
|
||||
updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
|
||||
|
||||
|
||||
volumeHostDao.update(getVolumeHostId(), updateBuilder);
|
||||
|
||||
// Update volume size in Volume table.
|
||||
VolumeVO updateVolume = _volumeDao.createForUpdate();
|
||||
updateVolume.setSize(answer.getTemplateSize());
|
||||
_volumeDao.update(volume.getId(), updateVolume);
|
||||
|
||||
/*if (answer.getCheckSum() != null) {
|
||||
VMTemplateVO templateDaoBuilder = _vmTemplateDao.createForUpdate();
|
||||
templateDaoBuilder.setChecksum(answer.getCheckSum());
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
|
|||
//Exists then don't download
|
||||
if (volumeInfos.containsKey(volume.getId())){
|
||||
TemplateInfo volInfo = volumeInfos.remove(volume.getId());
|
||||
toBeDownloaded.remove(volumeHost);
|
||||
toBeDownloaded.remove(volumeHost);
|
||||
s_logger.info("Volume Sync found " + volume.getUuid() + " already in the volume host table");
|
||||
if (volumeHost.getDownloadState() != Status.DOWNLOADED) {
|
||||
volumeHost.setErrorString("");
|
||||
|
|
@ -735,13 +735,19 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
|
|||
}
|
||||
|
||||
} else { // Put them in right status
|
||||
volumeHost.setDownloadPercent(100);
|
||||
volumeHost.setDownloadState(Status.DOWNLOADED);
|
||||
volumeHost.setInstallPath(volInfo.getInstallPath());
|
||||
volumeHost.setSize(volInfo.getSize());
|
||||
volumeHost.setPhysicalSize(volInfo.getPhysicalSize());
|
||||
volumeHost.setLastUpdated(new Date());
|
||||
_volumeHostDao.update(volumeHost.getId(), volumeHost);
|
||||
volumeHost.setDownloadPercent(100);
|
||||
volumeHost.setDownloadState(Status.DOWNLOADED);
|
||||
volumeHost.setInstallPath(volInfo.getInstallPath());
|
||||
volumeHost.setSize(volInfo.getSize());
|
||||
volumeHost.setPhysicalSize(volInfo.getPhysicalSize());
|
||||
volumeHost.setLastUpdated(new Date());
|
||||
_volumeHostDao.update(volumeHost.getId(), volumeHost);
|
||||
|
||||
if (volume.getSize() == 0) {
|
||||
// Set volume size in volumes table
|
||||
volume.setSize(volInfo.getSize());
|
||||
_volumeDao.update(volumeHost.getVolumeId(), volume);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,14 +47,14 @@ public interface AccountManager extends AccountService {
|
|||
|
||||
boolean deleteAccount(AccountVO account, long callerUserId, Account caller);
|
||||
|
||||
boolean cleanupAccount(AccountVO account, long callerUserId, Account caller);
|
||||
boolean cleanupAccount(AccountVO account, long callerUserId, Account caller);
|
||||
|
||||
Long checkAccessAndSpecifyAuthority(Account caller, Long zoneId);
|
||||
|
||||
Account createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details);
|
||||
|
||||
UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone);
|
||||
|
||||
Long checkAccessAndSpecifyAuthority(Account caller, Long zoneId);
|
||||
|
||||
Account createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details, String uuid, int regionId);
|
||||
|
||||
UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone);
|
||||
|
||||
/**
|
||||
* Logs out a user
|
||||
* @param userId
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account")
|
||||
public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
|
||||
Map<String, String> details, String accountUUID, String userUUID, Integer regionId) {
|
||||
Map<String, String> details) {
|
||||
|
||||
if (accountName == null) {
|
||||
accountName = userName;
|
||||
|
|
@ -806,41 +806,16 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
}
|
||||
}
|
||||
|
||||
if(regionId == null){
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
// create account
|
||||
AccountVO account = createAccount(accountName, accountType, domainId, networkDomain, details, UUID.randomUUID().toString(), _regionMgr.getId());
|
||||
long accountId = account.getId();
|
||||
|
||||
// create the first user for the account
|
||||
UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone);
|
||||
|
||||
if (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
|
||||
// set registration token
|
||||
byte[] bytes = (domainId + accountName + userName + System.currentTimeMillis()).getBytes();
|
||||
String registrationToken = UUID.nameUUIDFromBytes(bytes).toString();
|
||||
user.setRegistrationToken(registrationToken);
|
||||
}
|
||||
txn.commit();
|
||||
//Propagate Add account to other Regions
|
||||
_regionMgr.propagateAddAccount(userName, password, firstName, lastName, email, timezone, accountName, accountType, domainId,
|
||||
networkDomain, details, account.getUuid(), user.getUuid());
|
||||
//check success
|
||||
return _userAccountDao.findById(user.getId());
|
||||
} else {
|
||||
// Account is propagated from another Region
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
// create account
|
||||
AccountVO account = createAccount(accountName, accountType, domainId, networkDomain, details, accountUUID, regionId);
|
||||
AccountVO account = createAccount(accountName, accountType, domainId, networkDomain, details);
|
||||
long accountId = account.getId();
|
||||
|
||||
// create the first user for the account
|
||||
UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone, userUUID, regionId);
|
||||
UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone);
|
||||
|
||||
if (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
|
||||
// set registration token
|
||||
|
|
@ -849,12 +824,13 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
user.setRegistrationToken(registrationToken);
|
||||
}
|
||||
txn.commit();
|
||||
//check success
|
||||
return _userAccountDao.findById(user.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID, Integer regionId) {
|
||||
public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId) {
|
||||
|
||||
// default domain to ROOT if not specified
|
||||
if (domainId == null) {
|
||||
|
|
@ -882,15 +858,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
if (!_userAccountDao.validateUsernameInDomain(userName, domainId)) {
|
||||
throw new CloudRuntimeException("The user " + userName + " already exists in domain " + domainId);
|
||||
}
|
||||
UserVO user = null;
|
||||
if(regionId == null){
|
||||
user = createUser(account.getId(), userName, password, firstName, lastName, email, timeZone);
|
||||
//Propagate Add user to peer Regions
|
||||
_regionMgr.propagateAddUser(userName, password, firstName, lastName, email, timeZone, accountName, domain.getUuid(), user.getUuid());
|
||||
} else {
|
||||
user = createUser(account.getId(), userName, password, firstName, lastName, email, timeZone, userUUID, regionId);
|
||||
}
|
||||
return user;
|
||||
|
||||
return createUser(account.getId(), userName, password, firstName, lastName, email, timeZone);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -975,7 +944,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
}
|
||||
}
|
||||
if (encodedPassword == null) {
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
}
|
||||
user.setPassword(encodedPassword);
|
||||
}
|
||||
|
|
@ -1297,7 +1266,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
String newAccountName = cmd.getNewName();
|
||||
String networkDomain = cmd.getNetworkDomain();
|
||||
Map<String, String> details = cmd.getDetails();
|
||||
|
||||
|
||||
boolean success = false;
|
||||
Account account = null;
|
||||
if (accountId != null) {
|
||||
|
|
@ -1677,7 +1646,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public AccountVO createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details, String uuid, int regionId) {
|
||||
public AccountVO createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details) {
|
||||
// Validate domain
|
||||
Domain domain = _domainMgr.getDomain(domainId);
|
||||
if (domain == null) {
|
||||
|
|
@ -1721,7 +1690,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
AccountVO account = _accountDao.persist(new AccountVO(accountName, domainId, networkDomain, accountType, uuid, regionId));
|
||||
AccountVO account = _accountDao.persist(new AccountVO(accountName, domainId, networkDomain, accountType, _accountDao.getRegionId()));
|
||||
|
||||
if (account == null) {
|
||||
throw new CloudRuntimeException("Failed to create account name " + accountName + " in domain id=" + domainId);
|
||||
|
|
@ -1749,7 +1718,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone);
|
||||
}
|
||||
|
||||
|
||||
String encodedPassword = null;
|
||||
for (UserAuthenticator authenticator : _userAuthenticators) {
|
||||
encodedPassword = authenticator.encode(password);
|
||||
|
|
@ -1758,33 +1727,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
}
|
||||
}
|
||||
if (encodedPassword == null) {
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
}
|
||||
|
||||
UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, UUID.randomUUID().toString(), _regionMgr.getId()));
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
//ToDo Add events??
|
||||
public UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String uuid, int regionId) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone);
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
}
|
||||
|
||||
String encodedPassword = null;
|
||||
for (Iterator<UserAuthenticator> en = _userAuthenticators.iterator(); en.hasNext();) {
|
||||
UserAuthenticator authenticator = en.next();
|
||||
encodedPassword = authenticator.encode(password);
|
||||
if (encodedPassword != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (encodedPassword == null) {
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
}
|
||||
|
||||
UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, uuid, regionId));
|
||||
UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, _userDao.getRegionId()));
|
||||
|
||||
return user;
|
||||
}
|
||||
|
|
@ -2014,7 +1960,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
|
||||
@Override @DB
|
||||
public String[] createApiKeyAndSecretKey(RegisterCmd cmd) {
|
||||
//Send keys to other Regions
|
||||
//Send keys to other Regions
|
||||
Long userId = cmd.getId();
|
||||
|
||||
User user = getUserIncludingRemoved(userId);
|
||||
|
|
@ -2243,7 +2189,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void buildACLViewSearchBuilder(SearchBuilder<? extends ControlledViewEntity> sb, Long domainId,
|
||||
boolean isRecursive, List<Long> permittedAccounts, ListProjectResourcesCriteria listProjectResourcesCriteria) {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import com.cloud.domain.DomainVO;
|
|||
public interface DomainManager extends DomainService {
|
||||
Set<Long> getDomainChildrenIds(String parentDomainPath);
|
||||
|
||||
Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, String domainUUID, Integer regionId);
|
||||
Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain);
|
||||
|
||||
Set<Long> getDomainParentIds(long domainId);
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_DOMAIN_CREATE, eventDescription = "creating Domain")
|
||||
public Domain createDomain(String name, Long parentId, String networkDomain, String domainUUID, Integer regionId) {
|
||||
public Domain createDomain(String name, Long parentId, String networkDomain) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
if (parentId == null) {
|
||||
|
|
@ -136,13 +136,13 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom
|
|||
|
||||
_accountMgr.checkAccess(caller, parentDomain);
|
||||
|
||||
return createDomain(name, parentId, caller.getId(), networkDomain, domainUUID, regionId);
|
||||
return createDomain(name, parentId, caller.getId(), networkDomain);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, String domainUUID, Integer regionId) {
|
||||
public Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain) {
|
||||
// Verify network domain
|
||||
if (networkDomain != null) {
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
|
|
@ -161,28 +161,14 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom
|
|||
throw new InvalidParameterValueException("Domain with name " + name + " already exists for the parent id=" + parentId);
|
||||
}
|
||||
|
||||
if(regionId == null){
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
DomainVO domain = _domainDao.create(new DomainVO(name, ownerId, parentId, networkDomain, _regionMgr.getId()));
|
||||
DomainVO domain = _domainDao.create(new DomainVO(name, ownerId, parentId, networkDomain, _regionMgr.getId()));
|
||||
_resourceCountDao.createResourceCounts(domain.getId(), ResourceLimit.ResourceOwnerType.Domain);
|
||||
txn.commit();
|
||||
//Propagate domain creation to peer Regions
|
||||
_regionMgr.propagateAddDomain(name, parentId, networkDomain, domain.getUuid());
|
||||
return domain;
|
||||
} else {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
DomainVO domain = _domainDao.create(new DomainVO(name, ownerId, parentId, networkDomain, domainUUID, regionId));
|
||||
_resourceCountDao.createResourceCounts(domain.getId(), ResourceLimit.ResourceOwnerType.Domain);
|
||||
|
||||
txn.commit();
|
||||
return domain;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -44,17 +44,17 @@ import com.cloud.utils.db.Transaction;
|
|||
public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements AccountDao {
|
||||
private static final Logger s_logger = Logger.getLogger(AccountDaoImpl.class);
|
||||
private final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.username, u.account_id, u.secret_key, u.state, " +
|
||||
"a.id, a.account_name, a.type, a.domain_id, a.state " +
|
||||
"FROM `cloud`.`user` u, `cloud`.`account` a " +
|
||||
"WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL";
|
||||
|
||||
"a.id, a.account_name, a.type, a.domain_id, a.state " +
|
||||
"FROM `cloud`.`user` u, `cloud`.`account` a " +
|
||||
"WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL";
|
||||
|
||||
protected final SearchBuilder<AccountVO> AllFieldsSearch;
|
||||
protected final SearchBuilder<AccountVO> AccountTypeSearch;
|
||||
protected final SearchBuilder<AccountVO> DomainAccountsSearch;
|
||||
protected final SearchBuilder<AccountVO> CleanupForRemovedAccountsSearch;
|
||||
protected final SearchBuilder<AccountVO> CleanupForDisabledAccountsSearch;
|
||||
protected final SearchBuilder<AccountVO> NonProjectAccountSearch;
|
||||
|
||||
|
||||
public AccountDaoImpl() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("accountName", AllFieldsSearch.entity().getAccountName(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -62,7 +62,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
|
||||
AccountTypeSearch = createSearchBuilder();
|
||||
AccountTypeSearch.and("domainId", AccountTypeSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
AccountTypeSearch.and("type", AccountTypeSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -72,19 +72,19 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
DomainAccountsSearch.and("domainId", DomainAccountsSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
DomainAccountsSearch.and("removed", DomainAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
DomainAccountsSearch.done();
|
||||
|
||||
|
||||
CleanupForRemovedAccountsSearch = createSearchBuilder();
|
||||
CleanupForRemovedAccountsSearch.and("cleanup", CleanupForRemovedAccountsSearch.entity().getNeedsCleanup(), SearchCriteria.Op.EQ);
|
||||
CleanupForRemovedAccountsSearch.and("removed", CleanupForRemovedAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NNULL);
|
||||
CleanupForRemovedAccountsSearch.and("domainid", CleanupForRemovedAccountsSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
CleanupForRemovedAccountsSearch.done();
|
||||
|
||||
|
||||
CleanupForDisabledAccountsSearch = createSearchBuilder();
|
||||
CleanupForDisabledAccountsSearch.and("cleanup", CleanupForDisabledAccountsSearch.entity().getNeedsCleanup(), SearchCriteria.Op.EQ);
|
||||
CleanupForDisabledAccountsSearch.and("removed", CleanupForDisabledAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
CleanupForDisabledAccountsSearch.and("state", CleanupForDisabledAccountsSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
CleanupForDisabledAccountsSearch.done();
|
||||
|
||||
|
||||
NonProjectAccountSearch = createSearchBuilder();
|
||||
NonProjectAccountSearch.and("accountName", NonProjectAccountSearch.entity().getAccountName(), SearchCriteria.Op.EQ);
|
||||
NonProjectAccountSearch.and("domainId", NonProjectAccountSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -92,28 +92,28 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
NonProjectAccountSearch.and("type", NonProjectAccountSearch.entity().getType(), SearchCriteria.Op.NEQ);
|
||||
NonProjectAccountSearch.done();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AccountVO> findCleanupsForRemovedAccounts(Long domainId) {
|
||||
SearchCriteria<AccountVO> sc = CleanupForRemovedAccountsSearch.create();
|
||||
sc.setParameters("cleanup", true);
|
||||
|
||||
if (domainId != null) {
|
||||
sc.setParameters("domainid", domainId);
|
||||
}
|
||||
|
||||
return searchIncludingRemoved(sc, null, null, false);
|
||||
SearchCriteria<AccountVO> sc = CleanupForRemovedAccountsSearch.create();
|
||||
sc.setParameters("cleanup", true);
|
||||
|
||||
if (domainId != null) {
|
||||
sc.setParameters("domainid", domainId);
|
||||
}
|
||||
|
||||
return searchIncludingRemoved(sc, null, null, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AccountVO> findCleanupsForDisabledAccounts() {
|
||||
SearchCriteria<AccountVO> sc = CleanupForDisabledAccountsSearch.create();
|
||||
sc.setParameters("cleanup", true);
|
||||
sc.setParameters("state", State.disabled);
|
||||
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pair<User, Account> findUserAccountByApiKey(String apiKey) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
|
@ -160,7 +160,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
sc.setParameters("state", State.enabled);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Account findEnabledNonProjectAccount(String accountName, Long domainId) {
|
||||
SearchCriteria<AccountVO> sc = NonProjectAccountSearch.create("accountName", accountName);
|
||||
|
|
@ -170,15 +170,15 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account findActiveAccount(String accountName, Long domainId) {
|
||||
@Override
|
||||
public Account findActiveAccount(String accountName, Long domainId) {
|
||||
SearchCriteria<AccountVO> sc = AllFieldsSearch.create("accountName", accountName);
|
||||
sc.setParameters("domainId", domainId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account findActiveNonProjectAccount(String accountName, Long domainId) {
|
||||
|
||||
@Override
|
||||
public Account findActiveNonProjectAccount(String accountName, Long domainId) {
|
||||
SearchCriteria<AccountVO> sc = NonProjectAccountSearch.create("accountName", accountName);
|
||||
sc.setParameters("domainId", domainId);
|
||||
sc.setParameters("type", Account.ACCOUNT_TYPE_PROJECT);
|
||||
|
|
@ -191,7 +191,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
sc.setParameters("domainId", domainId);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Account findNonProjectAccountIncludingRemoved(String accountName, Long domainId) {
|
||||
SearchCriteria<AccountVO> sc = NonProjectAccountSearch.create("accountName", accountName);
|
||||
|
|
@ -199,7 +199,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
sc.setParameters("type", Account.ACCOUNT_TYPE_PROJECT);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AccountVO> listAccounts(String accountName, Long domainId, Filter filter) {
|
||||
SearchCriteria<AccountVO> sc = AllFieldsSearch.create("accountName", accountName);
|
||||
|
|
@ -246,22 +246,22 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
return listIncludingRemovedBy(sc, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountVO> findActiveAccountsForDomain(Long domain) {
|
||||
@Override
|
||||
public List<AccountVO> findActiveAccountsForDomain(Long domain) {
|
||||
SearchCriteria<AccountVO> sc = DomainAccountsSearch.create();
|
||||
sc.setParameters("domainId", domain);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForCleanup(long accountId) {
|
||||
AccountVO account = findByIdIncludingRemoved(accountId);
|
||||
if (!account.getNeedsCleanup()) {
|
||||
account.setNeedsCleanup(true);
|
||||
if (!update(accountId, account)) {
|
||||
s_logger.warn("Failed to mark account id=" + accountId + " for cleanup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForCleanup(long accountId) {
|
||||
AccountVO account = findByIdIncludingRemoved(accountId);
|
||||
if (!account.getNeedsCleanup()) {
|
||||
account.setNeedsCleanup(true);
|
||||
if (!update(accountId, account)) {
|
||||
s_logger.warn("Failed to mark account id=" + accountId + " for cleanup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,17 +44,17 @@ public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long
|
|||
"WHERE us.account_id = a.id AND (a.removed IS NULL OR a.removed >= ?) " +
|
||||
"ORDER BY us.id";
|
||||
private static final String UPDATED_STATS_SEARCH = "SELECT id, current_bytes_received, current_bytes_sent, net_bytes_received, net_bytes_sent, agg_bytes_received, agg_bytes_sent from user_statistics " +
|
||||
"where (agg_bytes_received < net_bytes_received + current_bytes_received) OR (agg_bytes_sent < net_bytes_sent + current_bytes_sent)";
|
||||
"where (agg_bytes_received < net_bytes_received + current_bytes_received) OR (agg_bytes_sent < net_bytes_sent + current_bytes_sent)";
|
||||
private final SearchBuilder<UserStatisticsVO> AllFieldsSearch;
|
||||
private final SearchBuilder<UserStatisticsVO> AccountSearch;
|
||||
|
||||
|
||||
public UserStatisticsDaoImpl() {
|
||||
AccountSearch = createSearchBuilder();
|
||||
AccountSearch.and("account", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountSearch.done();
|
||||
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
|
||||
public UserStatisticsDaoImpl() {
|
||||
AccountSearch = createSearchBuilder();
|
||||
AccountSearch.and("account", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountSearch.done();
|
||||
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("dc", AllFieldsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -63,7 +63,7 @@ public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long
|
|||
AllFieldsSearch.and("deviceType", AllFieldsSearch.entity().getDeviceType(), SearchCriteria.Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserStatisticsVO findBy(long accountId, long dcId, long networkId, String publicIp, Long deviceId, String deviceType) {
|
||||
SearchCriteria<UserStatisticsVO> sc = AllFieldsSearch.create();
|
||||
|
|
@ -133,5 +133,5 @@ public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long
|
|||
}
|
||||
return userStats;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,6 @@ import com.cloud.utils.Journal;
|
|||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.PasswordGenerator;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.crypt.RSAHelper;
|
||||
|
|
@ -226,35 +225,13 @@ import com.cloud.utils.exception.ExecutionException;
|
|||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.*;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.*;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.cloud.vm.dao.InstanceGroupDao;
|
||||
import com.cloud.vm.dao.InstanceGroupVMMapDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmCloneSettingDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import com.cloud.vm.snapshot.VMSnapshotManager;
|
||||
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
|
||||
|
||||
|
|
@ -266,6 +243,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3
|
||||
// seconds
|
||||
|
||||
public enum UserVmCloneType {
|
||||
full,
|
||||
linked
|
||||
}
|
||||
|
||||
@Inject
|
||||
protected HostDao _hostDao = null;
|
||||
@Inject
|
||||
|
|
@ -283,6 +265,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
@Inject
|
||||
protected DomainDao _domainDao = null;
|
||||
@Inject
|
||||
protected UserVmCloneSettingDao _vmCloneSettingDao = null;
|
||||
@Inject
|
||||
protected UserVmDao _vmDao = null;
|
||||
@Inject
|
||||
protected UserVmJoinDao _vmJoinDao = null;
|
||||
|
|
@ -398,10 +382,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
UsageEventDao _usageEventDao;
|
||||
@Inject
|
||||
protected VMSnapshotDao _vmSnapshotDao;
|
||||
@Inject
|
||||
@Inject
|
||||
protected VMSnapshotManager _vmSnapshotMgr;
|
||||
|
||||
@Inject
|
||||
|
||||
@Inject
|
||||
List<DeployPlannerSelector> plannerSelectors;
|
||||
|
||||
protected ScheduledExecutorService _executor = null;
|
||||
|
|
@ -420,7 +404,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
|
||||
@Inject
|
||||
protected OrchestrationService _orchSrvc;
|
||||
|
||||
|
||||
@Inject VolumeManager volumeMgr;
|
||||
|
||||
@Override
|
||||
|
|
@ -724,7 +708,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void checkVMSnapshots(UserVmVO vm, Long volumeId, boolean attach) {
|
||||
// Check that if vm has any VM snapshot
|
||||
|
|
@ -737,7 +721,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private UserVm rebootVirtualMachine(long userId, long vmId)
|
||||
throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
|
@ -776,14 +760,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
throw new InvalidParameterValueException(
|
||||
"unable to find a virtual machine with id " + vmId);
|
||||
}
|
||||
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, vmInstance);
|
||||
|
||||
// Check that the specified service offering ID is valid
|
||||
_itMgr.checkIfCanUpgrade(vmInstance, svcOffId);
|
||||
|
||||
// remove diskAndMemory VM snapshots
|
||||
/* List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.findByVm(vmId);
|
||||
/* List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.findByVm(vmId);
|
||||
for (VMSnapshotVO vmSnapshotVO : vmSnapshots) {
|
||||
if(vmSnapshotVO.getType() == VMSnapshot.Type.DiskAndMemory){
|
||||
if(!_vmSnapshotMgr.deleteAllVMSnapshots(vmId, VMSnapshot.Type.DiskAndMemory)){
|
||||
|
|
@ -791,10 +775,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
s_logger.debug(errMsg);
|
||||
throw new CloudRuntimeException(errMsg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
_itMgr.upgradeVmDb(vmId, svcOffId);
|
||||
|
||||
return _vmDao.findById(vmInstance.getId());
|
||||
|
|
@ -817,7 +801,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
}
|
||||
NicProfile profile = new NicProfile(null, null);
|
||||
if(ipAddress != null) {
|
||||
profile = new NicProfile(ipAddress, null);
|
||||
profile = new NicProfile(ipAddress, null);
|
||||
}
|
||||
|
||||
// Perform permission check on VM
|
||||
|
|
@ -837,7 +821,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
throw new PermissionDeniedException("Unable to modify a vm using network with id " + network.getId() + ", permission denied");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ensure network belongs in zone
|
||||
if (network.getDataCenterId() != vmInstance.getDataCenterId()) {
|
||||
throw new CloudRuntimeException(vmInstance + " is in zone:" + vmInstance.getDataCenterId() + " but " + network + " is in zone:" + network.getDataCenterId());
|
||||
|
|
@ -853,7 +837,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
throw new CloudRuntimeException(network + " already has a vm with host name: '" + vmInstance.getHostName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NicProfile guestNic = null;
|
||||
|
||||
try {
|
||||
|
|
@ -914,14 +898,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
throw new PermissionDeniedException("Unable to modify a vm using network with id " + network.getId() + ", permission denied");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean nicremoved = false;
|
||||
|
||||
try {
|
||||
nicremoved = _itMgr.removeNicFromVm(vmInstance, nic);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
throw new CloudRuntimeException("Unable to remove " + network + " from " + vmInstance +": " + e);
|
||||
|
||||
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Concurrent operations on removing " + network + " from " + vmInstance + ": " + e);
|
||||
}
|
||||
|
|
@ -929,19 +913,19 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
if (!nicremoved) {
|
||||
throw new CloudRuntimeException("Unable to remove " + network + " from " + vmInstance );
|
||||
}
|
||||
|
||||
|
||||
s_logger.debug("Successful removal of " + network + " from " + vmInstance);
|
||||
return _vmDao.findById(vmInstance.getId());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserVm updateDefaultNicForVirtualMachine(UpdateDefaultNicForVMCmd cmd) throws InvalidParameterValueException, CloudRuntimeException {
|
||||
Long vmId = cmd.getVmId();
|
||||
Long nicId = cmd.getNicId();
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
|
||||
UserVmVO vmInstance = _vmDao.findById(vmId);
|
||||
if (vmInstance == null){
|
||||
throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId);
|
||||
|
|
@ -954,7 +938,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
if (network == null){
|
||||
throw new InvalidParameterValueException("unable to find a network with id " + nic.getNetworkId());
|
||||
}
|
||||
|
||||
|
||||
// Perform permission check on VM
|
||||
_accountMgr.checkAccess(caller, null, true, vmInstance);
|
||||
|
||||
|
|
@ -966,7 +950,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
|
||||
// no need to check permissions for network, we'll enumerate the ones they already have access to
|
||||
Network existingdefaultnet = _networkModel.getDefaultNetworkForVm(vmId);
|
||||
|
||||
|
||||
//check to see if nic is attached to VM
|
||||
if (nic.getInstanceId() != vmId) {
|
||||
throw new InvalidParameterValueException(nic + " is not a nic on " + vmInstance);
|
||||
|
|
@ -980,7 +964,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
if ((vmInstance.getState() != State.Running) && (vmInstance.getState() != State.Stopped)) {
|
||||
throw new CloudRuntimeException("refusing to set default " + vmInstance + " is not Running or Stopped");
|
||||
}
|
||||
|
||||
|
||||
NicProfile existing = null;
|
||||
List<NicProfile> nicProfiles = _networkMgr.getNicProfiles(vmInstance);
|
||||
for (NicProfile nicProfile : nicProfiles) {
|
||||
|
|
@ -1009,26 +993,26 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
|
||||
Network newdefault = null;
|
||||
newdefault = _networkModel.getDefaultNetworkForVm(vmId);
|
||||
|
||||
if (newdefault == null){
|
||||
nic.setDefaultNic(false);
|
||||
nic.setDeviceId(chosenID);
|
||||
existingVO.setDefaultNic(true);
|
||||
existingVO.setDeviceId(existingID);
|
||||
|
||||
nic = _nicDao.persist(nic);
|
||||
existingVO = _nicDao.persist(existingVO);
|
||||
|
||||
newdefault = _networkModel.getDefaultNetworkForVm(vmId);
|
||||
if (newdefault.getId() == existingdefaultnet.getId()) {
|
||||
throw new CloudRuntimeException("Setting a default nic failed, and we had no default nic, but we were able to set it back to the original");
|
||||
}
|
||||
throw new CloudRuntimeException("Failed to change default nic to " + nic + " and now we have no default");
|
||||
if (newdefault == null){
|
||||
nic.setDefaultNic(false);
|
||||
nic.setDeviceId(chosenID);
|
||||
existingVO.setDefaultNic(true);
|
||||
existingVO.setDeviceId(existingID);
|
||||
|
||||
nic = _nicDao.persist(nic);
|
||||
existingVO = _nicDao.persist(existingVO);
|
||||
|
||||
newdefault = _networkModel.getDefaultNetworkForVm(vmId);
|
||||
if (newdefault.getId() == existingdefaultnet.getId()) {
|
||||
throw new CloudRuntimeException("Setting a default nic failed, and we had no default nic, but we were able to set it back to the original");
|
||||
}
|
||||
throw new CloudRuntimeException("Failed to change default nic to " + nic + " and now we have no default");
|
||||
} else if (newdefault.getId() == nic.getNetworkId()) {
|
||||
s_logger.debug("successfully set default network to " + network + " for " + vmInstance);
|
||||
return _vmDao.findById(vmInstance.getId());
|
||||
}
|
||||
|
||||
|
||||
throw new CloudRuntimeException("something strange happened, new default network(" + newdefault.getId() + ") is not null, and is not equal to the network(" + nic.getNetworkId() + ") of the chosen nic");
|
||||
}
|
||||
|
||||
|
|
@ -1963,7 +1947,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
if (isSecurityGroupEnabled) {
|
||||
if (networkIdList.size() > 1) {
|
||||
throw new InvalidParameterValueException("Can't create a vm with multiple networks one of" +
|
||||
" which is Security Group enabled");
|
||||
" which is Security Group enabled");
|
||||
}
|
||||
|
||||
isSecurityGroupEnabledNetworkUsed = true;
|
||||
|
|
@ -1971,7 +1955,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
|
||||
if (!(network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Shared)) {
|
||||
throw new InvalidParameterValueException("Can specify only Shared Guest networks when" +
|
||||
" deploy vm in Advance Security Group enabled zone");
|
||||
" deploy vm in Advance Security Group enabled zone");
|
||||
}
|
||||
|
||||
// Perform account permission check
|
||||
|
|
@ -1984,8 +1968,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
|
||||
// if network is security group enabled, and no security group is specified, then add the default security group automatically
|
||||
if (isSecurityGroupEnabledNetworkUsed && !isVmWare && _networkModel.canAddDefaultSecurityGroup()) {
|
||||
|
||||
//add the default securityGroup only if no security group is specified
|
||||
|
||||
//add the default securityGroup only if no security group is specified
|
||||
if(securityGroupIdList == null || securityGroupIdList.isEmpty()){
|
||||
if (securityGroupIdList == null) {
|
||||
securityGroupIdList = new ArrayList<Long>();
|
||||
|
|
@ -2109,7 +2093,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
_networkModel.checkNetworkPermissions(owner, network);
|
||||
|
||||
// don't allow to use system networks
|
||||
|
|
@ -2139,7 +2123,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
@DB @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true)
|
||||
protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, String hostName, String displayName, Account owner, Long diskOfferingId,
|
||||
Long diskSize, List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, String userData, String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard)
|
||||
throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException {
|
||||
throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException {
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, owner);
|
||||
|
||||
|
|
@ -2193,7 +2177,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (template.getHypervisorType() != null && template.getHypervisorType() != HypervisorType.BareMetal) {
|
||||
// check if we have available pools for vm deployment
|
||||
long availablePools = _storagePoolDao.countPoolsByStatus(StoragePoolStatus.Up);
|
||||
|
|
@ -2246,7 +2230,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
}
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
|
||||
|
||||
Map<String, NicProfile> networkNicMap = new HashMap<String, NicProfile>();
|
||||
|
||||
short defaultNetworkNumber = 0;
|
||||
|
|
@ -2263,20 +2247,20 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
if (requestedIps != null && !requestedIps.isEmpty()) {
|
||||
requestedIpPair = requestedIps.get(network.getId());
|
||||
}
|
||||
|
||||
|
||||
if (requestedIpPair == null) {
|
||||
requestedIpPair = new IpAddresses(null, null);
|
||||
requestedIpPair = new IpAddresses(null, null);
|
||||
} else {
|
||||
_networkModel.checkRequestedIpAddresses(network.getId(), requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address());
|
||||
_networkModel.checkRequestedIpAddresses(network.getId(), requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address());
|
||||
}
|
||||
|
||||
|
||||
NicProfile profile = new NicProfile(requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address());
|
||||
|
||||
if (defaultNetworkNumber == 0) {
|
||||
defaultNetworkNumber++;
|
||||
// if user requested specific ip for default network, add it
|
||||
if (defaultIps.getIp4Address() != null || defaultIps.getIp6Address() != null) {
|
||||
_networkModel.checkRequestedIpAddresses(network.getId(), defaultIps.getIp4Address(), defaultIps.getIp6Address());
|
||||
_networkModel.checkRequestedIpAddresses(network.getId(), defaultIps.getIp4Address(), defaultIps.getIp6Address());
|
||||
profile = new NicProfile(defaultIps.getIp4Address(), defaultIps.getIp6Address());
|
||||
}
|
||||
|
||||
|
|
@ -2405,6 +2389,20 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
vm.setIsoId(template.getId());
|
||||
}
|
||||
|
||||
// If hypervisor is vSphere, check for clone type setting.
|
||||
if (hypervisorType.equals(HypervisorType.VMware)) {
|
||||
// retrieve clone flag.
|
||||
UserVmCloneType cloneType = UserVmCloneType.linked;
|
||||
String value = _configDao.getValue(Config.VmwareCreateFullClone.key());
|
||||
if (value != null) {
|
||||
if (Boolean.parseBoolean(value) == true)
|
||||
cloneType = UserVmCloneType.full;
|
||||
}
|
||||
UserVmCloneSettingVO vmCloneSettingVO = new UserVmCloneSettingVO(id, cloneType.toString());
|
||||
_vmCloneSettingDao.persist(vmCloneSettingVO);
|
||||
}
|
||||
|
||||
|
||||
_vmDao.persist(vm);
|
||||
_vmDao.saveDetails(vm);
|
||||
|
||||
|
|
@ -2429,7 +2427,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
VirtualMachineEntity vmEntity = _orchSrvc.createVirtualMachine(vm.getUuid(), new Long(owner.getAccountId()).toString(), new Long(template.getId()).toString(), hostName, displayName, hypervisor.name(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully allocated DB entry for " + vm);
|
||||
|
|
@ -2465,7 +2463,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
return vm;
|
||||
}
|
||||
|
||||
private void validateUserData(String userData) {
|
||||
private void validateUserData(String userData) {
|
||||
byte[] decodedUserData = null;
|
||||
if (userData != null) {
|
||||
if (!Base64.isBase64(userData)) {
|
||||
|
|
@ -2499,7 +2497,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
protected UserVm startVirtualMachine(DeployVMCmd cmd,
|
||||
Map<VirtualMachineProfile.Param, Object> additonalParams)
|
||||
throws ResourceUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException {
|
||||
ConcurrentOperationException {
|
||||
|
||||
long vmId = cmd.getEntityId();
|
||||
Long hostId = cmd.getHostId();
|
||||
|
|
@ -2896,18 +2894,18 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
}
|
||||
|
||||
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
|
||||
|
||||
String plannerName = null;
|
||||
for (DeployPlannerSelector dps : plannerSelectors) {
|
||||
plannerName = dps.selectPlanner(vm);
|
||||
if (plannerName != null) {
|
||||
|
||||
String plannerName = null;
|
||||
for (DeployPlannerSelector dps : plannerSelectors) {
|
||||
plannerName = dps.selectPlanner(vm);
|
||||
if (plannerName != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (plannerName == null) {
|
||||
}
|
||||
if (plannerName == null) {
|
||||
throw new CloudRuntimeException(String.format("cannot find DeployPlannerSelector for vm[uuid:%s, hypervisorType:%s]", vm.getUuid(), vm.getHypervisorType()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String reservationId = vmEntity.reserve(plannerName, plan, new ExcludeList(), new Long(callerUser.getId()).toString());
|
||||
vmEntity.deploy(reservationId, new Long(callerUser.getId()).toString());
|
||||
|
||||
|
|
@ -3069,7 +3067,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
int count = 0;
|
||||
for (String key : tags.keySet()) {
|
||||
for (String key : tags.keySet()) {
|
||||
sc.setParameters("key" + String.valueOf(count), key);
|
||||
sc.setParameters("value" + String.valueOf(count), tags.get(key));
|
||||
count++;
|
||||
|
|
@ -3189,7 +3187,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
public UserVm createVirtualMachine(DeployVMCmd cmd)
|
||||
throws InsufficientCapacityException, ResourceUnavailableException,
|
||||
ConcurrentOperationException, StorageUnavailableException,
|
||||
ResourceAllocationException {
|
||||
ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
@ -3557,12 +3555,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
List<Long> securityGroupIdList = cmd.getSecurityGroupIdList();
|
||||
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
if (networkIdList != null && !networkIdList.isEmpty()) {
|
||||
if (networkIdList != null && !networkIdList.isEmpty()) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Can't move vm with network Ids; this is a basic zone VM");
|
||||
}
|
||||
}
|
||||
// cleanup the old security groups
|
||||
_securityGroupMgr.removeInstanceFromGroups(cmd.getVmId());
|
||||
_securityGroupMgr.removeInstanceFromGroups(cmd.getVmId());
|
||||
// cleanup the network for the oldOwner
|
||||
_networkMgr.cleanupNics(vmOldProfile);
|
||||
_networkMgr.expungeNics(vmOldProfile);
|
||||
|
|
@ -3700,7 +3698,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags());
|
||||
}
|
||||
s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" +
|
||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||
newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
|
||||
null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null);
|
||||
|
|
@ -3909,7 +3907,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
|
|||
public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm,
|
||||
ReservationContext context, DeployDestination dest)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException {
|
||||
InsufficientCapacityException {
|
||||
UserVmVO vmVO = _vmDao.findById(vm.getId());
|
||||
if (vmVO.getState() == State.Running) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.UserVmCloneSettingVO;
|
||||
|
||||
public interface UserVmCloneSettingDao extends GenericDao<UserVmCloneSettingVO, Long> {
|
||||
|
||||
/*
|
||||
* Returns a User VM clone type record by vm id.
|
||||
*/
|
||||
UserVmCloneSettingVO findByVmId(long id);
|
||||
|
||||
/*
|
||||
* Returns a list of VMs by clone type.
|
||||
* cloneType can be full/linked.
|
||||
*/
|
||||
List<UserVmCloneSettingVO> listByCloneType(String cloneType);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.vm.UserVmCloneSettingVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
|
||||
|
||||
@Component
|
||||
@Local(value= { UserVmCloneSettingDao.class })
|
||||
@DB(txn = false)
|
||||
public class UserVmCloneSettingDaoImpl extends GenericDaoBase<UserVmCloneSettingVO, Long> implements UserVmCloneSettingDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UserVmCloneSettingDaoImpl.class);
|
||||
|
||||
protected SearchBuilder<UserVmCloneSettingVO> vmIdSearch;
|
||||
protected SearchBuilder<UserVmCloneSettingVO> cloneTypeSearch;
|
||||
|
||||
public UserVmCloneSettingDaoImpl() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Initialize the search builders.
|
||||
vmIdSearch = createSearchBuilder();
|
||||
vmIdSearch.and("vmId", vmIdSearch.entity().getCloneType(), Op.EQ);
|
||||
vmIdSearch.done();
|
||||
|
||||
cloneTypeSearch = createSearchBuilder();
|
||||
cloneTypeSearch.and("cloneType", cloneTypeSearch.entity().getCloneType(), Op.EQ);
|
||||
cloneTypeSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVmCloneSettingVO findByVmId(long vmId) {
|
||||
SearchCriteria<UserVmCloneSettingVO> sc = vmIdSearch.create();
|
||||
sc.setParameters("vmId", vmId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmCloneSettingVO> listByCloneType(String cloneType) {
|
||||
SearchCriteria<UserVmCloneSettingVO> sc = cloneTypeSearch.create();
|
||||
sc.setParameters("cloneType", cloneType);
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,12 +18,9 @@ package com.cloud.vm.dao;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.UserVmDetailVO;
|
||||
|
||||
@Component
|
||||
public interface UserVmDetailsDao extends GenericDao<UserVmDetailVO, Long> {
|
||||
Map<String, String> findDetails(long vmId);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,186 +31,46 @@ import com.cloud.user.Account;
|
|||
import com.cloud.user.UserAccount;
|
||||
|
||||
public interface RegionManager {
|
||||
|
||||
/**
|
||||
* Propagates Account details to peer Regions
|
||||
* @param userName
|
||||
* @param password
|
||||
* @param firstName
|
||||
* @param lastName
|
||||
* @param email
|
||||
* @param timezone
|
||||
* @param accountName
|
||||
* @param accountType
|
||||
* @param domainId
|
||||
* @param networkDomain
|
||||
* @param details
|
||||
* @param accountUUID
|
||||
* @param userUUID
|
||||
* @return
|
||||
*/
|
||||
public boolean propagateAddAccount(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);
|
||||
|
||||
/**
|
||||
* Returns the Id of local Region
|
||||
* @return
|
||||
*/
|
||||
public int getId();
|
||||
|
||||
/**
|
||||
* Propagates User details to peer Regions
|
||||
* @param userName
|
||||
* @param password
|
||||
* @param firstName
|
||||
* @param lastName
|
||||
* @param email
|
||||
* @param timeZone
|
||||
* @param accountName
|
||||
* @param domainUUId
|
||||
* @param userUUID
|
||||
*/
|
||||
public void propagateAddUser(String userName, String password,
|
||||
String firstName, String lastName, String email, String timeZone,
|
||||
String accountName, String domainUUId, String userUUID);
|
||||
|
||||
/**
|
||||
* Propagates Domain details to peer Regions
|
||||
* @param name
|
||||
* @param parentId
|
||||
* @param networkDomain
|
||||
* @param uuid
|
||||
*/
|
||||
public void propagateAddDomain(String name, Long parentId, String networkDomain, String uuid);
|
||||
|
||||
|
||||
/**
|
||||
* Adds a peer Region to the local Region
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Returns added Region object
|
||||
*/
|
||||
Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* Update details of the Region with specified Id
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
*
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Returns update Region object
|
||||
*/
|
||||
Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return True if region is successfully removed
|
||||
*/
|
||||
boolean removeRegion(int id);
|
||||
|
||||
/** List all Regions or by Id/Name
|
||||
* @param id
|
||||
* @param name
|
||||
* @return List of Regions
|
||||
*/
|
||||
List<RegionVO> listRegions(Integer id, String name);
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a user by userId and propagates the change to peer Regions
|
||||
*
|
||||
* @param accountId
|
||||
* - id of the account do delete
|
||||
*
|
||||
* @return true if delete was successful, false otherwise
|
||||
*/
|
||||
boolean deleteUserAccount(long accountId);
|
||||
|
||||
/**
|
||||
* Updates an account
|
||||
* isPopagate falg is set to true if sent from peer Region
|
||||
*
|
||||
* @param cmd
|
||||
* - the parameter containing accountId or account nameand domainId
|
||||
* @return updated account object
|
||||
*/
|
||||
Account updateAccount(UpdateAccountCmd cmd);
|
||||
|
||||
/**
|
||||
* Disables an account by accountName and domainId or accountId
|
||||
* @param accountName
|
||||
* @param domainId
|
||||
* @param id
|
||||
* @param lockRequested
|
||||
* @return
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
Account disableAccount(String accountName, Long domainId, Long id, Boolean lockRequested) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* Enables an account by accountId
|
||||
*
|
||||
* @param accountName
|
||||
* - the enableAccount command defining the accountId to be deleted.
|
||||
* @param domainId
|
||||
* TODO
|
||||
* @param accountId
|
||||
* @return account object
|
||||
*/
|
||||
Account enableAccount(String accountName, Long domainId, Long accountId);
|
||||
|
||||
/**
|
||||
* Deletes user by Id
|
||||
* @param deleteUserCmd
|
||||
* Returns the Id of local Region
|
||||
* @return
|
||||
*/
|
||||
boolean deleteUser(DeleteUserCmd deleteUserCmd);
|
||||
|
||||
public int getId();
|
||||
|
||||
/**
|
||||
* update an existing domain
|
||||
*
|
||||
* @param cmd
|
||||
* - the command containing domainId and new domainName
|
||||
* @return Domain object if the command succeeded
|
||||
* Adds a peer Region to the local Region
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Returns added Region object
|
||||
*/
|
||||
Domain updateDomain(UpdateDomainCmd updateDomainCmd);
|
||||
|
||||
/**
|
||||
* Deletes domain by Id
|
||||
* @param id
|
||||
* @param cleanup
|
||||
* @return true if delete was successful, false otherwise
|
||||
*/
|
||||
boolean deleteDomain(Long id, Boolean cleanup);
|
||||
|
||||
Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* Update a user by userId
|
||||
* Update details of the Region with specified Id
|
||||
* @param id
|
||||
* @param name
|
||||
* @param endPoint
|
||||
*
|
||||
* @param userId
|
||||
* @return UserAccount object
|
||||
* @param apiKey
|
||||
* @param secretKey
|
||||
* @return Returns update Region object
|
||||
*/
|
||||
UserAccount updateUser(UpdateUserCmd updateUserCmd);
|
||||
|
||||
Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey);
|
||||
|
||||
/**
|
||||
* Disables a user by userId
|
||||
*
|
||||
* @param userId
|
||||
* - the userId
|
||||
* @return UserAccount object
|
||||
*/
|
||||
UserAccount disableUser(Long id);
|
||||
|
||||
/**
|
||||
* Enables a user
|
||||
*
|
||||
* @param userId
|
||||
* - the userId
|
||||
* @return UserAccount object
|
||||
* @param id
|
||||
* @return True if region is successfully removed
|
||||
*/
|
||||
UserAccount enableUser(long userId);
|
||||
boolean removeRegion(int id);
|
||||
|
||||
/** List all Regions or by Id/Name
|
||||
* @param id
|
||||
* @param name
|
||||
* @return List of Regions
|
||||
*/
|
||||
List<RegionVO> listRegions(Integer id, String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ import com.cloud.uuididentity.dao.IdentityDao;
|
|||
@Local(value = { RegionManager.class })
|
||||
public class RegionManagerImpl extends ManagerBase implements RegionManager, Manager{
|
||||
public static final Logger s_logger = Logger.getLogger(RegionManagerImpl.class);
|
||||
|
||||
|
||||
@Inject
|
||||
RegionDao _regionDao;
|
||||
@Inject
|
||||
|
|
@ -78,17 +78,17 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man
|
|||
private IdentityDao _identityDao;
|
||||
@Inject
|
||||
private RegionSyncDao _regionSyncDao;
|
||||
|
||||
|
||||
private String _name;
|
||||
private int _id;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
_id = _regionDao.getRegionId();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
|
|
@ -104,776 +104,98 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man
|
|||
return _name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
/*
|
||||
* Propagates Account creation to peer Regions
|
||||
* Adds an entry in region_sync table on failure
|
||||
*/
|
||||
@Override
|
||||
public boolean propagateAddAccount(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 command = "createAccount";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.USERNAME, userName));
|
||||
params.add(new NameValuePair(ApiConstants.PASSWORD, password));
|
||||
params.add(new NameValuePair(ApiConstants.FIRSTNAME, firstName));
|
||||
params.add(new NameValuePair(ApiConstants.LASTNAME, lastName));
|
||||
params.add(new NameValuePair(ApiConstants.EMAIL, email));
|
||||
params.add(new NameValuePair(ApiConstants.TIMEZONE, timezone));
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT, accountName));
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT_TYPE, ""+accountType));
|
||||
//ToDo: use domain UUID
|
||||
params.add(new NameValuePair(ApiConstants.DOMAIN_ID, ((domainId != null) ? domainId.toString() : "")));
|
||||
params.add(new NameValuePair(ApiConstants.NETWORK_DOMAIN, networkDomain));
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT_DETAILS, (details != null) ? details.toString() : ""));
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT_ID, accountUUID));
|
||||
params.add(new NameValuePair(ApiConstants.USER_ID, userUUID));
|
||||
params.add(new NameValuePair(ApiConstants.REGION_ID, ""+getId()));
|
||||
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
s_logger.debug("Adding account :"+accountName+" to Region: "+region.getId());
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully added account :"+accountName+" to Region: "+region.getId());
|
||||
} else {
|
||||
// api call failed. Add entry in region_sync table
|
||||
addRegionSyncItem(region.getId(), command, params);
|
||||
s_logger.error("Error while Adding account :"+accountName+" to Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Propagates User creation to peer Regions
|
||||
* Adds an entry in region_sync table on failure
|
||||
*/
|
||||
@Override
|
||||
public void propagateAddUser(String userName, String password,
|
||||
String firstName, String lastName, String email, String timezone,
|
||||
String accountName, String domainUUId, String userUUID) {
|
||||
|
||||
String command = "createUser";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.USERNAME, userName));
|
||||
params.add(new NameValuePair(ApiConstants.PASSWORD, password));
|
||||
params.add(new NameValuePair(ApiConstants.FIRSTNAME, firstName));
|
||||
params.add(new NameValuePair(ApiConstants.LASTNAME, lastName));
|
||||
params.add(new NameValuePair(ApiConstants.EMAIL, email));
|
||||
params.add(new NameValuePair(ApiConstants.TIMEZONE, timezone));
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT, accountName));
|
||||
params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domainUUId));
|
||||
params.add(new NameValuePair(ApiConstants.USER_ID, userUUID));
|
||||
params.add(new NameValuePair(ApiConstants.REGION_ID, ""+getId()));
|
||||
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
s_logger.debug("Adding account :"+accountName+" to Region: "+region.getId());
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully added user :"+userName+" to Region: "+region.getId());
|
||||
} else {
|
||||
// api call failed. Add entry in region_sync table
|
||||
addRegionSyncItem(region.getId(), command, params);
|
||||
s_logger.error("Error while Adding user :"+userName+" to Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Propagates Domain creation details to peer Regions
|
||||
* Adds an entry in region_sync table on failure
|
||||
*/
|
||||
@Override
|
||||
public void propagateAddDomain(String name, Long parentId, String networkDomain, String uuid) {
|
||||
|
||||
String command = "createDomain";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.NAME, name));
|
||||
if(parentId != null){
|
||||
DomainVO domain = _domainDao.findById(parentId);
|
||||
if(domain != null){
|
||||
params.add(new NameValuePair(ApiConstants.PARENT_DOMAIN_ID, domain.getUuid()));
|
||||
}
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.NETWORK_DOMAIN, networkDomain));
|
||||
params.add(new NameValuePair(ApiConstants.DOMAIN_ID, uuid));
|
||||
params.add(new NameValuePair(ApiConstants.REGION_ID, ""+getId()));
|
||||
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
s_logger.debug("Adding domain :"+name+" to Region: "+region.getId());
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully added domain :"+name+" to Region: "+region.getId());
|
||||
} else {
|
||||
// api call failed. Add entry in region_sync table
|
||||
addRegionSyncItem(region.getId(), command, params);
|
||||
s_logger.error("Error while Adding domain :"+name+" to Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an entry to region_sync table
|
||||
* Entry contains region Id along with failed api
|
||||
* @param regionId
|
||||
* @param command
|
||||
* @param params
|
||||
*/
|
||||
private void addRegionSyncItem(int regionId, String command, List<NameValuePair> params){
|
||||
String api = RegionsApiUtil.buildParams(command, params);
|
||||
RegionSyncVO sync = new RegionSyncVO(regionId, api);
|
||||
if(_regionSyncDao.persist(sync) == null){
|
||||
s_logger.error("Failed to add Region Sync Item. RegionId: "+regionId + "API command: "+api);
|
||||
}
|
||||
}
|
||||
public int getId() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||
//Region Id should be unique
|
||||
if( _regionDao.findById(id) != null ){
|
||||
throw new InvalidParameterValueException("Region with id: "+id+" already exists");
|
||||
}
|
||||
//Region Name should be unique
|
||||
if( _regionDao.findByName(name) != null ){
|
||||
throw new InvalidParameterValueException("Region with name: "+name+" already exists");
|
||||
}
|
||||
RegionVO region = new RegionVO(id, name, endPoint, apiKey, secretKey);
|
||||
return _regionDao.persist(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@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");
|
||||
}
|
||||
|
||||
//Ensure region name is unique
|
||||
if(name != null){
|
||||
RegionVO region1 = _regionDao.findByName(name);
|
||||
if(region1 != null && id != region1.getId()){
|
||||
throw new InvalidParameterValueException("Region with name: "+name+" already exists");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean removeRegion(int id) {
|
||||
RegionVO region = _regionDao.findById(id);
|
||||
if(region == null){
|
||||
throw new InvalidParameterValueException("Failed to delete Region: " + id + ", Region not found");
|
||||
}
|
||||
return _regionDao.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<RegionVO> listRegions(Integer id, String name) {
|
||||
List<RegionVO> regions = new ArrayList<RegionVO>();
|
||||
if(id != null){
|
||||
RegionVO region = _regionDao.findById(id);
|
||||
if(region != null){
|
||||
regions.add(region);
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
if(name != null){
|
||||
RegionVO region = _regionDao.findByName(name);
|
||||
if(region != null){
|
||||
regions.add(region);
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
return _regionDao.listAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteUserAccount(long accountId) {
|
||||
AccountVO account = _accountDao.findById(accountId);
|
||||
if(account == null){
|
||||
throw new InvalidParameterValueException("The specified account does not exist in the system");
|
||||
}
|
||||
String accountUUID = account.getUuid();
|
||||
int regionId = account.getRegionId();
|
||||
|
||||
String command = "deleteAccount";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, accountUUID));
|
||||
|
||||
if(getId() == regionId){
|
||||
if(_accountMgr.deleteUserAccount(accountId)){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully deleted account :"+accountUUID+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while deleting account :"+accountUUID+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
//First delete in the Region where account is created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully deleted account :"+accountUUID+" in Region: "+region.getId());
|
||||
return true;
|
||||
} else {
|
||||
s_logger.error("Error while deleting account :"+accountUUID+" in Region: "+region.getId());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account updateAccount(UpdateAccountCmd cmd) {
|
||||
Long accountId = cmd.getId();
|
||||
Long domainId = cmd.getDomainId();
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
String accountName = cmd.getAccountName();
|
||||
String newAccountName = cmd.getNewName();
|
||||
String networkDomain = cmd.getNetworkDomain();
|
||||
//ToDo send details
|
||||
Map<String, String> details = cmd.getDetails();
|
||||
|
||||
Account account = null;
|
||||
if (accountId != null) {
|
||||
account = _accountDao.findById(accountId);
|
||||
} else {
|
||||
account = _accountDao.findEnabledAccount(accountName, domainId);
|
||||
@Override
|
||||
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||
//Region Id should be unique
|
||||
if( _regionDao.findById(id) != null ){
|
||||
throw new InvalidParameterValueException("Region with id: "+id+" already exists");
|
||||
}
|
||||
|
||||
// Check if account exists
|
||||
if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
s_logger.error("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
|
||||
throw new InvalidParameterValueException("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
|
||||
}
|
||||
|
||||
String command = "updateAccount";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.NEW_NAME, newAccountName));
|
||||
params.add(new NameValuePair(ApiConstants.ID, account.getUuid()));
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT, accountName));
|
||||
params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid()));
|
||||
params.add(new NameValuePair(ApiConstants.NETWORK_DOMAIN, networkDomain));
|
||||
params.add(new NameValuePair(ApiConstants.NEW_NAME, newAccountName));
|
||||
if(details != null){
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT_DETAILS, details.toString()));
|
||||
}
|
||||
int regionId = account.getRegionId();
|
||||
if(getId() == regionId){
|
||||
Account updatedAccount = _accountMgr.updateAccount(cmd);
|
||||
if(updatedAccount != null){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully updated account :"+account.getUuid()+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while updating account :"+account.getUuid()+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return updatedAccount;
|
||||
} else {
|
||||
//First update in the Region where account is created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
RegionAccount updatedAccount = RegionsApiUtil.makeAccountAPICall(region, command, params);
|
||||
if (updatedAccount != null) {
|
||||
Long id = _identityDao.getIdentityId("account", updatedAccount.getUuid());
|
||||
updatedAccount.setId(id);
|
||||
Long domainID = _identityDao.getIdentityId("domain", updatedAccount.getDomainUuid());
|
||||
updatedAccount.setDomainId(domainID);
|
||||
s_logger.debug("Successfully updated account :"+account.getUuid()+" in source Region: "+region.getId());
|
||||
return updatedAccount;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Error while updating account :"+account.getUuid()+" in source Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
//Region Name should be unique
|
||||
if( _regionDao.findByName(name) != null ){
|
||||
throw new InvalidParameterValueException("Region with name: "+name+" already exists");
|
||||
}
|
||||
RegionVO region = new RegionVO(id, name, endPoint, apiKey, secretKey);
|
||||
return _regionDao.persist(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account disableAccount(String accountName, Long domainId, Long accountId, Boolean lockRequested) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
Account account = null;
|
||||
if (accountId != null) {
|
||||
account = _accountDao.findById(accountId);
|
||||
} else {
|
||||
account = _accountDao.findActiveAccount(accountName, domainId);
|
||||
@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 (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
throw new InvalidParameterValueException("Unable to find active account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
|
||||
}
|
||||
|
||||
String accountUUID = account.getUuid();
|
||||
|
||||
String command = "disableAccount";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.LOCK, lockRequested.toString()));
|
||||
params.add(new NameValuePair(ApiConstants.ID, accountUUID));
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
if(domain != null){
|
||||
params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid()));
|
||||
}
|
||||
|
||||
int regionId = account.getRegionId();
|
||||
if(getId() == regionId){
|
||||
Account retAccount = null;
|
||||
if(lockRequested){
|
||||
retAccount = _accountMgr.lockAccount(accountName, domainId, accountId);
|
||||
} else {
|
||||
retAccount = _accountMgr.disableAccount(accountName, domainId, accountId);
|
||||
}
|
||||
if(retAccount != null){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully disabled account :"+accountUUID+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while disabling account :"+accountUUID+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return retAccount;
|
||||
} else {
|
||||
//First disable account in the Region where account is created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
Account retAccount = RegionsApiUtil.makeAccountAPICall(region, command, params);
|
||||
if (retAccount != null) {
|
||||
s_logger.debug("Successfully disabled account :"+accountUUID+" in source Region: "+region.getId());
|
||||
return retAccount;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Error while disabling account :"+accountUUID+" in source Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account enableAccount(String accountName, Long domainId, Long accountId) {
|
||||
// Check if account exists
|
||||
Account account = null;
|
||||
if (accountId != null) {
|
||||
account = _accountDao.findById(accountId);
|
||||
} else {
|
||||
account = _accountDao.findActiveAccount(accountName, domainId);
|
||||
//Ensure region name is unique
|
||||
if(name != null){
|
||||
RegionVO region1 = _regionDao.findByName(name);
|
||||
if(region1 != null && id != region1.getId()){
|
||||
throw new InvalidParameterValueException("Region with name: "+name+" already exists");
|
||||
}
|
||||
}
|
||||
|
||||
if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
throw new InvalidParameterValueException("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId);
|
||||
}
|
||||
|
||||
String accountUUID = account.getUuid();
|
||||
|
||||
String command = "enableAccount";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, accountUUID));
|
||||
params.add(new NameValuePair(ApiConstants.ACCOUNT, accountName));
|
||||
DomainVO domain = _domainDao.findById(domainId);
|
||||
if(domain != null){
|
||||
params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid()));
|
||||
}
|
||||
|
||||
int regionId = account.getRegionId();
|
||||
if(getId() == regionId){
|
||||
Account retAccount = _accountMgr.enableAccount(accountName, domainId, accountId);
|
||||
if(retAccount != null){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
if(name != null){
|
||||
region.setName(name);
|
||||
}
|
||||
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully enabled account :"+accountUUID+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while enabling account :"+accountUUID+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return retAccount;
|
||||
} else {
|
||||
//First disable account in the Region where account is created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
Account retAccount = RegionsApiUtil.makeAccountAPICall(region, command, params);
|
||||
if (retAccount != null) {
|
||||
s_logger.debug("Successfully enabled account :"+accountUUID+" in source Region: "+region.getId());
|
||||
return retAccount;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Error while enabling account :"+accountUUID+" in source Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(endPoint != null){
|
||||
region.setEndPoint(endPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteUser(DeleteUserCmd cmd) {
|
||||
long id = cmd.getId();
|
||||
if(apiKey != null){
|
||||
region.setApiKey(apiKey);
|
||||
}
|
||||
|
||||
UserVO user = _userDao.findById(id);
|
||||
if(secretKey != null){
|
||||
region.setSecretKey(secretKey);
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
throw new InvalidParameterValueException("The specified user doesn't exist in the system");
|
||||
}
|
||||
|
||||
String userUUID = user.getUuid();
|
||||
int regionId = user.getRegionId();
|
||||
|
||||
String command = "deleteUser";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, userUUID));
|
||||
|
||||
if(getId() == regionId){
|
||||
if(_accountMgr.deleteUser(cmd)){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully deleted user :"+userUUID+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while deleting account :"+userUUID+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
//First delete in the Region where account is created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully deleted user :"+userUUID+" in source Region: "+region.getId());
|
||||
return true;
|
||||
} else {
|
||||
s_logger.error("Error while deleting user :"+userUUID+" in source Region: "+region.getId());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_regionDao.update(id, region);
|
||||
return _regionDao.findById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Domain updateDomain(UpdateDomainCmd cmd) {
|
||||
long id = cmd.getId();
|
||||
DomainVO domain = _domainDao.findById(id);
|
||||
if(domain == null){
|
||||
throw new InvalidParameterValueException("The specified domain doesn't exist in the system");
|
||||
}
|
||||
|
||||
String domainUUID = domain.getUuid();
|
||||
|
||||
String command = "updateDomain";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, domainUUID));
|
||||
params.add(new NameValuePair(ApiConstants.NAME, cmd.getDomainName()));
|
||||
params.add(new NameValuePair(ApiConstants.NETWORK_DOMAIN, cmd.getNetworkDomain()));
|
||||
|
||||
int regionId = domain.getRegionId();
|
||||
if(getId() == regionId){
|
||||
Domain updatedDomain = _domainMgr.updateDomain(cmd);
|
||||
if(updatedDomain != null){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully updated updatedDomain :"+domainUUID+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while updating updatedDomain :"+domainUUID+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return updatedDomain;
|
||||
} else {
|
||||
//First update in the Region where domain was created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
RegionDomain updatedDomain = RegionsApiUtil.makeDomainAPICall(region, command, params);
|
||||
if (updatedDomain != null) {
|
||||
Long parentId = _identityDao.getIdentityId("domain", updatedDomain.getParentUuid());
|
||||
updatedDomain.setParent(parentId);
|
||||
s_logger.debug("Successfully updated user :"+domainUUID+" in source Region: "+region.getId());
|
||||
return (DomainVO)updatedDomain;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Error while updating user :"+domainUUID+" in source Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteDomain(Long id, Boolean cleanup) {
|
||||
DomainVO domain = _domainDao.findById(id);
|
||||
if(domain == null){
|
||||
throw new InvalidParameterValueException("The specified domain doesn't exist in the system");
|
||||
}
|
||||
|
||||
String domainUUID = domain.getUuid();
|
||||
|
||||
String command = "deleteDomain";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, domainUUID));
|
||||
params.add(new NameValuePair(ApiConstants.CLEANUP, cleanup.toString()));
|
||||
|
||||
int regionId = domain.getRegionId();
|
||||
if(getId() == regionId){
|
||||
if(_domainMgr.deleteDomain(id, cleanup)){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully deleted domain :"+domainUUID+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while deleting domain :"+domainUUID+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
//First delete in the Region where domain is created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully deleted domain :"+domainUUID+" in Region: "+region.getId());
|
||||
return true;
|
||||
} else {
|
||||
s_logger.error("Error while deleting domain :"+domainUUID+" in Region: "+region.getId());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean removeRegion(int id) {
|
||||
RegionVO region = _regionDao.findById(id);
|
||||
if(region == null){
|
||||
throw new InvalidParameterValueException("Failed to delete Region: " + id + ", Region not found");
|
||||
}
|
||||
return _regionDao.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount updateUser(UpdateUserCmd cmd) {
|
||||
long id = cmd.getId();
|
||||
|
||||
UserVO user = _userDao.findById(id);
|
||||
if (user == null) {
|
||||
throw new InvalidParameterValueException("The specified user doesn't exist in the system");
|
||||
}
|
||||
|
||||
String userUUID = user.getUuid();
|
||||
|
||||
String command = "updateUser";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, userUUID));
|
||||
params.add(new NameValuePair(ApiConstants.API_KEY, cmd.getApiKey()));
|
||||
params.add(new NameValuePair(ApiConstants.EMAIL, cmd.getEmail()));
|
||||
params.add(new NameValuePair(ApiConstants.FIRSTNAME, cmd.getFirstname()));
|
||||
params.add(new NameValuePair(ApiConstants.LASTNAME, cmd.getLastname()));
|
||||
params.add(new NameValuePair(ApiConstants.PASSWORD, cmd.getPassword()));
|
||||
params.add(new NameValuePair(ApiConstants.SECRET_KEY, cmd.getSecretKey()));
|
||||
params.add(new NameValuePair(ApiConstants.TIMEZONE, cmd.getTimezone()));
|
||||
params.add(new NameValuePair(ApiConstants.USERNAME, cmd.getUsername()));
|
||||
|
||||
int regionId = user.getRegionId();
|
||||
if(getId() == regionId){
|
||||
UserAccount updateUser = _accountMgr.updateUser(cmd);
|
||||
if(updateUser != null){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully updated user :"+userUUID+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while updating user :"+userUUID+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return updateUser;
|
||||
} else {
|
||||
//First update in the Region where user was created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
UserAccount updateUser = RegionsApiUtil.makeUserAccountAPICall(region, command, params);
|
||||
if (updateUser != null) {
|
||||
s_logger.debug("Successfully updated user :"+userUUID+" in source Region: "+region.getId());
|
||||
return updateUser;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Error while updating user :"+userUUID+" in source Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount disableUser(Long userId) {
|
||||
UserVO user = _userDao.findById(userId);
|
||||
if (user == null || user.getRemoved() != null) {
|
||||
throw new InvalidParameterValueException("Unable to find active user by id " + userId);
|
||||
}
|
||||
|
||||
int regionId = user.getRegionId();
|
||||
|
||||
String command = "disableUser";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, user.getUuid()));
|
||||
|
||||
if(getId() == regionId){
|
||||
UserAccount disabledUser = _accountMgr.disableUser(userId);
|
||||
if(disabledUser != null){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully disabled user :"+user.getUuid()+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while disabling user :"+user.getUuid()+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return disabledUser;
|
||||
} else {
|
||||
//First disable in the Region where user was created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
UserAccount disabledUser = RegionsApiUtil.makeUserAccountAPICall(region, command, params);
|
||||
if (disabledUser != null) {
|
||||
s_logger.debug("Successfully disabled user :"+user.getUuid()+" in source Region: "+region.getId());
|
||||
return disabledUser;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Error while disabling user :"+user.getUuid()+" in source Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount enableUser(long userId) {
|
||||
UserVO user = _userDao.findById(userId);
|
||||
if (user == null || user.getRemoved() != null) {
|
||||
throw new InvalidParameterValueException("Unable to find active user by id " + userId);
|
||||
}
|
||||
|
||||
int regionId = user.getRegionId();
|
||||
|
||||
String command = "enableUser";
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new NameValuePair(ApiConstants.ID, user.getUuid()));
|
||||
|
||||
if(getId() == regionId){
|
||||
UserAccount enabledUser = _accountMgr.enableUser(userId);
|
||||
if(enabledUser != null){
|
||||
List<RegionVO> regions = _regionDao.listAll();
|
||||
for (Region region : regions){
|
||||
if(region.getId() == getId()){
|
||||
continue;
|
||||
}
|
||||
params.add(new NameValuePair(ApiConstants.IS_PROPAGATE, "true"));
|
||||
if (RegionsApiUtil.makeAPICall(region, command, params)) {
|
||||
s_logger.debug("Successfully enabled user :"+user.getUuid()+" in Region: "+region.getId());
|
||||
} else {
|
||||
s_logger.error("Error while disabling user :"+user.getUuid()+" in Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return enabledUser;
|
||||
} else {
|
||||
//First enable in the Region where user was created
|
||||
Region region = _regionDao.findById(regionId);
|
||||
UserAccount enabledUser = RegionsApiUtil.makeUserAccountAPICall(region, command, params);
|
||||
if (enabledUser != null) {
|
||||
s_logger.debug("Successfully enabled user :"+user.getUuid()+" in source Region: "+region.getId());
|
||||
return enabledUser;
|
||||
} else {
|
||||
throw new CloudRuntimeException("Error while enabling user :"+user.getUuid()+" in source Region: "+region.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@Override
|
||||
public List<RegionVO> listRegions(Integer id, String name) {
|
||||
List<RegionVO> regions = new ArrayList<RegionVO>();
|
||||
if(id != null){
|
||||
RegionVO region = _regionDao.findById(id);
|
||||
if(region != null){
|
||||
regions.add(region);
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
if(name != null){
|
||||
RegionVO region = _regionDao.findByName(name);
|
||||
if(region != null){
|
||||
regions.add(region);
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
return _regionDao.listAll();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ import com.cloud.utils.component.ManagerBase;
|
|||
@Local(value = { RegionService.class })
|
||||
public class RegionServiceImpl extends ManagerBase implements RegionService, Manager {
|
||||
public static final Logger s_logger = Logger.getLogger(RegionServiceImpl.class);
|
||||
|
||||
|
||||
@Inject
|
||||
private RegionDao _regionDao;
|
||||
@Inject
|
||||
|
|
@ -72,15 +72,15 @@ public class RegionServiceImpl extends ManagerBase implements RegionService, Man
|
|||
private AccountManager _accountMgr;
|
||||
@Inject
|
||||
private DomainManager _domainMgr;
|
||||
|
||||
|
||||
private String _name;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
|
|
@ -99,203 +99,121 @@ public class RegionServiceImpl extends ManagerBase implements RegionService, Man
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||
//Check for valid Name
|
||||
//Check valid end_point url
|
||||
return _regionMgr.addRegion(id, name, endPoint, apiKey, secretKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||
//Check for valid Name
|
||||
//Check valid end_point url
|
||||
return _regionMgr.updateRegion(id, name, endPoint, apiKey, secretKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean removeRegion(int id) {
|
||||
return _regionMgr.removeRegion(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<? extends Region> listRegions(ListRegionsCmd cmd) {
|
||||
return _regionMgr.listRegions(cmd.getId(), cmd.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteUserAccount(DeleteAccountCmd cmd) {
|
||||
boolean result = false;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
result = _accountMgr.deleteUserAccount(cmd.getId());
|
||||
} else {
|
||||
result = _regionMgr.deleteUserAccount(cmd.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account updateAccount(UpdateAccountCmd cmd) {
|
||||
Account result = null;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
result = _accountMgr.updateAccount(cmd);
|
||||
} else {
|
||||
result = _regionMgr.updateAccount(cmd);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account disableAccount(DisableAccountCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
Account result = null;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
if(cmd.getLockRequested())
|
||||
result = _accountMgr.lockAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId());
|
||||
else
|
||||
result = _accountMgr.disableAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId());
|
||||
} else {
|
||||
result = _regionMgr.disableAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId(), cmd.getLockRequested());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account enableAccount(EnableAccountCmd cmd) {
|
||||
Account result = null;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
result = _accountMgr.enableAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId());
|
||||
} else {
|
||||
result = _regionMgr.enableAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteUser(DeleteUserCmd cmd) {
|
||||
boolean result = false;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
result = _accountMgr.deleteUser(cmd);
|
||||
} else {
|
||||
result = _regionMgr.deleteUser(cmd);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Domain updateDomain(UpdateDomainCmd cmd) {
|
||||
Domain domain = null;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
domain = _domainMgr.updateDomain(cmd);
|
||||
} else {
|
||||
domain = _regionMgr.updateDomain(cmd);
|
||||
}
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteDomain(DeleteDomainCmd cmd) {
|
||||
boolean result = false;
|
||||
if(checkIsPropagate(cmd.isPropagate())){
|
||||
result = _domainMgr.deleteDomain(cmd.getId(), cmd.getCleanup());
|
||||
} else {
|
||||
result = _regionMgr.deleteDomain(cmd.getId(), cmd.getCleanup());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount updateUser(UpdateUserCmd cmd){
|
||||
UserAccount user = null;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
user = _accountMgr.updateUser(cmd);
|
||||
} else {
|
||||
user = _regionMgr.updateUser(cmd);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount disableUser(DisableUserCmd cmd) {
|
||||
UserAccount user = null;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
user = _accountMgr.disableUser(cmd.getId());
|
||||
} else {
|
||||
user = _regionMgr.disableUser(cmd.getId());
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount enableUser(EnableUserCmd cmd) {
|
||||
UserAccount user = null;
|
||||
if(checkIsPropagate(cmd.getIsPropagate())){
|
||||
user = _accountMgr.enableUser(cmd.getId());
|
||||
} else {
|
||||
user = _regionMgr.enableUser(cmd.getId());
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
private boolean isRootAdmin(short accountType) {
|
||||
return (accountType == Account.ACCOUNT_TYPE_ADMIN);
|
||||
@Override
|
||||
public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||
//Check for valid Name
|
||||
//Check valid end_point url
|
||||
return _regionMgr.addRegion(id, name, endPoint, apiKey, secretKey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check isPopagate flag, Only ROOT Admin can use this param
|
||||
* @param isPopagate
|
||||
* @return
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) {
|
||||
//Check for valid Name
|
||||
//Check valid end_point url
|
||||
return _regionMgr.updateRegion(id, name, endPoint, apiKey, secretKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean removeRegion(int id) {
|
||||
return _regionMgr.removeRegion(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<? extends Region> listRegions(ListRegionsCmd cmd) {
|
||||
return _regionMgr.listRegions(cmd.getId(), cmd.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteUserAccount(DeleteAccountCmd cmd) {
|
||||
return _accountMgr.deleteUserAccount(cmd.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
private boolean checkIsPropagate(Boolean isPopagate){
|
||||
if(isPopagate == null || !isPopagate){
|
||||
return false;
|
||||
}
|
||||
// Only Admin can use isPopagate flag
|
||||
UserContext ctx = UserContext.current();
|
||||
Account caller = ctx.getCaller();
|
||||
if(!isRootAdmin(caller.getType())){
|
||||
throw new PermissionDeniedException("isPropagate param cannot be used by non ROOT Admin");
|
||||
}
|
||||
return true;
|
||||
@Override
|
||||
public Account updateAccount(UpdateAccountCmd cmd) {
|
||||
return _accountMgr.updateAccount(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account disableAccount(DisableAccountCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
Account result = null;
|
||||
if(cmd.getLockRequested())
|
||||
result = _accountMgr.lockAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId());
|
||||
else
|
||||
result = _accountMgr.disableAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Account enableAccount(EnableAccountCmd cmd) {
|
||||
return _accountMgr.enableAccount(cmd.getAccountName(), cmd.getDomainId(), cmd.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteUser(DeleteUserCmd cmd) {
|
||||
return _accountMgr.deleteUser(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Domain updateDomain(UpdateDomainCmd cmd) {
|
||||
return _domainMgr.updateDomain(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteDomain(DeleteDomainCmd cmd) {
|
||||
return _domainMgr.deleteDomain(cmd.getId(), cmd.getCleanup());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount updateUser(UpdateUserCmd cmd){
|
||||
return _accountMgr.updateUser(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount disableUser(DisableUserCmd cmd) {
|
||||
return _accountMgr.disableUser(cmd.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UserAccount enableUser(EnableUserCmd cmd) {
|
||||
return _accountMgr.enableUser(cmd.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,306 +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.region;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
import org.apache.commons.httpclient.NameValuePair;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.user.UserAccountVO;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
|
||||
/**
|
||||
* Utility class for making API calls between peer Regions
|
||||
*
|
||||
*/
|
||||
public class RegionsApiUtil {
|
||||
public static final Logger s_logger = Logger.getLogger(RegionsApiUtil.class);
|
||||
|
||||
/**
|
||||
* Makes an api call using region service end_point, api command and params
|
||||
* @param region
|
||||
* @param command
|
||||
* @param params
|
||||
* @return True, if api is successful
|
||||
*/
|
||||
protected static boolean makeAPICall(Region region, String command, List<NameValuePair> params){
|
||||
try {
|
||||
String apiParams = buildParams(command, params);
|
||||
String url = buildUrl(apiParams, region);
|
||||
HttpClient client = new HttpClient();
|
||||
HttpMethod method = new GetMethod(url);
|
||||
if( client.executeMethod(method) == 200){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (HttpException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an api call using region service end_point, api command and params
|
||||
* Returns Account object on success
|
||||
* @param region
|
||||
* @param command
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
protected static RegionAccount makeAccountAPICall(Region region, String command, List<NameValuePair> params){
|
||||
try {
|
||||
String url = buildUrl(buildParams(command, params), region);
|
||||
HttpClient client = new HttpClient();
|
||||
HttpMethod method = new GetMethod(url);
|
||||
if( client.executeMethod(method) == 200){
|
||||
InputStream is = method.getResponseBodyAsStream();
|
||||
//Translate response to Account object
|
||||
XStream xstream = new XStream(new DomDriver());
|
||||
xstream.alias("account", RegionAccount.class);
|
||||
xstream.alias("user", RegionUser.class);
|
||||
xstream.aliasField("id", RegionAccount.class, "uuid");
|
||||
xstream.aliasField("name", RegionAccount.class, "accountName");
|
||||
xstream.aliasField("accounttype", RegionAccount.class, "type");
|
||||
xstream.aliasField("domainid", RegionAccount.class, "domainUuid");
|
||||
xstream.aliasField("networkdomain", RegionAccount.class, "networkDomain");
|
||||
xstream.aliasField("id", RegionUser.class, "uuid");
|
||||
xstream.aliasField("accountId", RegionUser.class, "accountUuid");
|
||||
ObjectInputStream in = xstream.createObjectInputStream(is);
|
||||
return (RegionAccount)in.readObject();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (HttpException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
} catch (ClassNotFoundException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an api call using region service end_point, api command and params
|
||||
* Returns Domain object on success
|
||||
* @param region
|
||||
* @param command
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
protected static RegionDomain makeDomainAPICall(Region region, String command, List<NameValuePair> params){
|
||||
try {
|
||||
String url = buildUrl(buildParams(command, params), region);
|
||||
HttpClient client = new HttpClient();
|
||||
HttpMethod method = new GetMethod(url);
|
||||
if( client.executeMethod(method) == 200){
|
||||
InputStream is = method.getResponseBodyAsStream();
|
||||
XStream xstream = new XStream(new DomDriver());
|
||||
//Translate response to Domain object
|
||||
xstream.alias("domain", RegionDomain.class);
|
||||
xstream.aliasField("id", RegionDomain.class, "uuid");
|
||||
xstream.aliasField("parentdomainid", RegionDomain.class, "parentUuid");
|
||||
xstream.aliasField("networkdomain", DomainVO.class, "networkDomain");
|
||||
ObjectInputStream in = xstream.createObjectInputStream(is);
|
||||
return (RegionDomain)in.readObject();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (HttpException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
} catch (ClassNotFoundException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an api call using region service end_point, api command and params
|
||||
* Returns UserAccount object on success
|
||||
* @param region
|
||||
* @param command
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
protected static UserAccount makeUserAccountAPICall(Region region, String command, List<NameValuePair> params){
|
||||
try {
|
||||
String url = buildUrl(buildParams(command, params), region);
|
||||
HttpClient client = new HttpClient();
|
||||
HttpMethod method = new GetMethod(url);
|
||||
if( client.executeMethod(method) == 200){
|
||||
InputStream is = method.getResponseBodyAsStream();
|
||||
XStream xstream = new XStream(new DomDriver());
|
||||
xstream.alias("useraccount", UserAccountVO.class);
|
||||
xstream.aliasField("id", UserAccountVO.class, "uuid");
|
||||
ObjectInputStream in = xstream.createObjectInputStream(is);
|
||||
return (UserAccountVO)in.readObject();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (HttpException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
} catch (ClassNotFoundException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds parameters string with command and encoded param values
|
||||
* @param command
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
protected static String buildParams(String command, List<NameValuePair> params) {
|
||||
StringBuffer paramString = new StringBuffer("command="+command);
|
||||
Iterator<NameValuePair> iter = params.iterator();
|
||||
try {
|
||||
while(iter.hasNext()){
|
||||
NameValuePair param = iter.next();
|
||||
if(param.getValue() != null && !(param.getValue().isEmpty())){
|
||||
paramString.append("&"+param.getName()+"="+URLEncoder.encode(param.getValue(), "UTF-8"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return paramString.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build URL for api call using region end_point
|
||||
* Parameters are sorted and signed using secret_key
|
||||
* @param apiParams
|
||||
* @param region
|
||||
* @return
|
||||
*/
|
||||
private static String buildUrl(String apiParams, Region region) {
|
||||
|
||||
String apiKey = region.getApiKey();
|
||||
String secretKey = region.getSecretKey();
|
||||
|
||||
|
||||
if (apiKey == null || secretKey == null) {
|
||||
return region.getEndPoint() +"?"+ apiParams;
|
||||
}
|
||||
|
||||
String encodedApiKey;
|
||||
try {
|
||||
encodedApiKey = URLEncoder.encode(apiKey, "UTF-8");
|
||||
|
||||
List<String> sortedParams = new ArrayList<String>();
|
||||
sortedParams.add("apikey=" + encodedApiKey.toLowerCase());
|
||||
StringTokenizer st = new StringTokenizer(apiParams, "&");
|
||||
String url = null;
|
||||
boolean first = true;
|
||||
while (st.hasMoreTokens()) {
|
||||
String paramValue = st.nextToken();
|
||||
String param = paramValue.substring(0, paramValue.indexOf("="));
|
||||
String value = paramValue.substring(paramValue.indexOf("=") + 1, paramValue.length());
|
||||
if (first) {
|
||||
url = param + "=" + value;
|
||||
first = false;
|
||||
} else {
|
||||
url = url + "&" + param + "=" + value;
|
||||
}
|
||||
sortedParams.add(param.toLowerCase() + "=" + value.toLowerCase());
|
||||
}
|
||||
Collections.sort(sortedParams);
|
||||
|
||||
|
||||
//Construct the sorted URL and sign and URL encode the sorted URL with your secret key
|
||||
String sortedUrl = null;
|
||||
first = true;
|
||||
for (String param : sortedParams) {
|
||||
if (first) {
|
||||
sortedUrl = param;
|
||||
first = false;
|
||||
} else {
|
||||
sortedUrl = sortedUrl + "&" + param;
|
||||
}
|
||||
}
|
||||
String encodedSignature = signRequest(sortedUrl, secretKey);
|
||||
|
||||
String finalUrl = region.getEndPoint() +"?"+apiParams+ "&apiKey=" + apiKey + "&signature=" + encodedSignature;
|
||||
|
||||
return finalUrl;
|
||||
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
s_logger.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Signs a string with a secret key using SHA-1 2. Base64 encode the result 3. URL encode the final result
|
||||
*
|
||||
* @param request
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private static String signRequest(String request, String key) {
|
||||
try {
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "HmacSHA1");
|
||||
mac.init(keySpec);
|
||||
mac.update(request.getBytes());
|
||||
byte[] encryptedBytes = mac.doFinal();
|
||||
return URLEncoder.encode(Base64.encodeBase64String(encryptedBytes), "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
s_logger.error(ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -325,30 +325,28 @@ public class MockAccountManagerImpl extends ManagerBase implements Manager, Acco
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserAccount createUserAccount(String userName, String password,
|
||||
String firstName, String lastName, String email, String timezone,
|
||||
String accountName, short accountType, Long domainId,
|
||||
String networkDomain, Map<String, String> details,
|
||||
String accountUUID, String userUUID, Integer regionId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
public UserAccount createUserAccount(String userName, String password,
|
||||
String firstName, String lastName, String email, String timezone,
|
||||
String accountName, short accountType, Long domainId,
|
||||
String networkDomain, Map<String, String> details) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User createUser(String userName, String password, String firstName,
|
||||
String lastName, String email, String timeZone, String accountName,
|
||||
Long domainId, String userUUID, Integer regionId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public User createUser(String userName, String password, String firstName,
|
||||
String lastName, String email, String timeZone, String accountName,
|
||||
Long domainId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account createAccount(String accountName, short accountType,
|
||||
Long domainId, String networkDomain, Map details, String uuid,
|
||||
int regionId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Account createAccount(String accountName, short accountType,
|
||||
Long domainId, String networkDomain, Map details) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public RoleType getRoleType(Account account) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -137,24 +137,24 @@ public class MockDomainManagerImpl extends ManagerBase implements DomainManager,
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain createDomain(String name, Long parentId,
|
||||
String networkDomain, String domainUUID, Integer regionId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Domain createDomain(String name, Long parentId,
|
||||
String networkDomain) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain updateDomain(UpdateDomainCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Domain updateDomain(UpdateDomainCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain createDomain(String name, Long parentId, Long ownerId,
|
||||
String networkDomain, String domainUUID, Integer regionId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Domain createDomain(String name, Long parentId, Long ownerId,
|
||||
String networkDomain) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.vm.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.cloud.vm.UserVmCloneSettingVO;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "classpath:/CloneSettingDaoTestContext.xml")
|
||||
public class UserVmCloneSettingDaoImplTest extends TestCase {
|
||||
@Inject UserVmCloneSettingDaoImpl _vmcsdao;
|
||||
|
||||
public void makeEntry(Long vmId, String cloneType) {
|
||||
UserVmCloneSettingVO vo = new UserVmCloneSettingVO(vmId, cloneType);
|
||||
_vmcsdao.persist(vo);
|
||||
vo = _vmcsdao.findById(vmId);
|
||||
assert (vo.getCloneType().equalsIgnoreCase(cloneType)) : "Unexpected Clone Type retrieved from table! Retrieved: " + vo.getCloneType() + " while expected was: " + cloneType;
|
||||
|
||||
// Next test whether the record is retrieved by clone type.
|
||||
List<UserVmCloneSettingVO> voList = new ArrayList<UserVmCloneSettingVO>();
|
||||
voList = _vmcsdao.listByCloneType(cloneType);
|
||||
assert (voList != null && !voList.isEmpty()) : "Failed to retrieve any record of VMs by clone type!";
|
||||
|
||||
// If a vo list is indeed retrieved, also check whether the vm id retrieved matches what we put in there.
|
||||
assert (voList.get(0).getVmId() == vmId) : "Retrieved vmId " + voList.get(0).getVmId() + " does not match input vmId: " + vmId;
|
||||
}
|
||||
@Test
|
||||
public void testPersist() {
|
||||
|
||||
Long vmId = 2222l;
|
||||
String[] arr = {"full", "linked"};
|
||||
for (String cloneType : arr) {
|
||||
_vmcsdao.expunge(vmId);
|
||||
makeEntry(vmId, cloneType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
// 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
|
||||
// the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.storage.dao;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
|
||||
import com.cloud.utils.component.SpringComponentScanUtils;
|
||||
import com.cloud.vm.dao.UserVmCloneSettingDaoImpl;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackageClasses={
|
||||
UserVmCloneSettingDaoImpl.class},
|
||||
includeFilters={@Filter(value=UserVmCloneSettingDaoTestConfiguration.Library.class, type=FilterType.CUSTOM)},
|
||||
useDefaultFilters=false
|
||||
)
|
||||
public class UserVmCloneSettingDaoTestConfiguration {
|
||||
|
||||
|
||||
public static class Library implements TypeFilter {
|
||||
|
||||
@Override
|
||||
public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
|
||||
mdr.getClassMetadata().getClassName();
|
||||
ComponentScan cs = UserVmCloneSettingDaoTestConfiguration.class.getAnnotation(ComponentScan.class);
|
||||
return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -608,7 +608,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
|||
*/
|
||||
@Override
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId, NetworkType zoneType,
|
||||
String allocationState, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled) {
|
||||
String allocationState, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,32 +43,19 @@ public class RegionManagerTest extends TestCase {
|
|||
protected void setUp() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUniqueName() {
|
||||
RegionManagerImpl regionMgr = new RegionManagerImpl();
|
||||
RegionDao regionDao = Mockito.mock(RegionDao.class);
|
||||
RegionVO region = new RegionVO(2, "APAC", "", null, null);
|
||||
Mockito.when(regionDao.findByName(Mockito.anyString())).thenReturn(region);
|
||||
regionMgr._regionDao = regionDao;
|
||||
try {
|
||||
regionMgr.addRegion(2, "APAC", "", null, null);
|
||||
} catch (InvalidParameterValueException e){
|
||||
Assert.assertEquals("Region with name: APAC already exists", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserDelete() {
|
||||
RegionManagerImpl regionMgr = new RegionManagerImpl();
|
||||
AccountDao accountDao = Mockito.mock(AccountDao.class);
|
||||
Mockito.when(accountDao.findById(Mockito.anyLong())).thenReturn(null);
|
||||
regionMgr._accountDao = accountDao;
|
||||
try {
|
||||
regionMgr.deleteUserAccount(5);
|
||||
} catch (InvalidParameterValueException e){
|
||||
Assert.assertEquals("The specified account does not exist in the system", e.getMessage());
|
||||
}
|
||||
RegionManagerImpl regionMgr = new RegionManagerImpl();
|
||||
RegionDao regionDao = Mockito.mock(RegionDao.class);
|
||||
RegionVO region = new RegionVO(2, "APAC", "", null, null);
|
||||
Mockito.when(regionDao.findByName(Mockito.anyString())).thenReturn(region);
|
||||
regionMgr._regionDao = regionDao;
|
||||
try {
|
||||
regionMgr.addRegion(2, "APAC", "", null, null);
|
||||
} catch (InvalidParameterValueException e){
|
||||
Assert.assertEquals("Region with name: APAC already exists", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<!-- 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. -->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:annotation-config />
|
||||
|
||||
<!-- @DB support -->
|
||||
<aop:config proxy-target-class="true">
|
||||
<aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
|
||||
<aop:pointcut id="captureAnyMethod" expression="execution(* *(..))" />
|
||||
|
||||
<aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod" />
|
||||
</aop:aspect>
|
||||
|
||||
</aop:config>
|
||||
|
||||
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext"/>
|
||||
<bean id="CSTestConfiguration"
|
||||
class="com.cloud.vm.dao.UserVmCloneSettingDaoTestConfiguration" />
|
||||
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" >
|
||||
<property name="requiredParameterValue" value="false" />
|
||||
</bean>
|
||||
</beans>
|
||||
|
|
@ -260,15 +260,6 @@ CREATE TABLE `cloud`.`region` (
|
|||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`region_sync` (
|
||||
`id` bigint unsigned NOT NULL auto_increment,
|
||||
`region_id` int unsigned NOT NULL,
|
||||
`api` varchar(1024) NOT NULL,
|
||||
`created` datetime NOT NULL COMMENT 'date created',
|
||||
`processed` tinyint NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- INSERT INTO `cloud`.`region` values ('1','Local','http://localhost:8080/client/api','','');
|
||||
ALTER TABLE `cloud`.`account` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';
|
||||
ALTER TABLE `cloud`.`user` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';
|
||||
|
|
@ -490,6 +481,9 @@ ALTER TABLE `cloud`.`vlan` ADD COLUMN `ip6_gateway` varchar(255);
|
|||
ALTER TABLE `cloud`.`vlan` ADD COLUMN `ip6_cidr` varchar(255);
|
||||
ALTER TABLE `cloud`.`vlan` ADD COLUMN `ip6_range` varchar(255);
|
||||
|
||||
ALTER TABLE `cloud`.`data_center` ADD COLUMN `ip6_dns1` varchar(255);
|
||||
ALTER TABLE `cloud`.`data_center` ADD COLUMN `ip6_dns2` varchar(255);
|
||||
|
||||
-- DB views for list api
|
||||
|
||||
DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
|
||||
|
|
@ -688,6 +682,8 @@ CREATE VIEW `cloud`.`domain_router_view` AS
|
|||
data_center.name data_center_name,
|
||||
data_center.dns1 dns1,
|
||||
data_center.dns2 dns2,
|
||||
data_center.ip6_dns1 ip6_dns1,
|
||||
data_center.ip6_dns2 ip6_dns2,
|
||||
host.id host_id,
|
||||
host.uuid host_uuid,
|
||||
host.name host_name,
|
||||
|
|
@ -1614,6 +1610,8 @@ CREATE VIEW `cloud`.`data_center_view` AS
|
|||
data_center.description,
|
||||
data_center.dns1,
|
||||
data_center.dns2,
|
||||
data_center.ip6_dns1,
|
||||
data_center.ip6_dns2,
|
||||
data_center.internal_dns1,
|
||||
data_center.internal_dns2,
|
||||
data_center.guest_network_cidr,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
-- Schema upgrade from 4.1.0 to 4.2.0;
|
||||
--;
|
||||
|
||||
-- Disable foreign key checking
|
||||
SET foreign_key_checks = 0;
|
||||
|
||||
ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `max_hosts_per_cluster` int unsigned DEFAULT NULL COMMENT 'Max. hosts in cluster supported by hypervisor';
|
||||
|
|
@ -97,7 +98,6 @@ CREATE TABLE `vpc_service_map` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.instancename.flag', 'false', 'Append guest VM display Name (if set) to the internal name of the VM');
|
||||
|
||||
|
|
@ -108,3 +108,14 @@ INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest
|
|||
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 (64 bit)', 209);
|
||||
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 Server (64 bit)', 210);
|
||||
|
||||
CREATE TABLE `cloud`.`user_vm_clone_setting` (
|
||||
`vm_id` bigint unsigned NOT NULL COMMENT 'guest VM id',
|
||||
`clone_type` varchar(10) NOT NULL COMMENT 'Full or Linked Clone (applicable to VMs on ESX)',
|
||||
PRIMARY KEY (`vm_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'false', 'If set to true, creates VMs as full clones on ESX hypervisor');
|
||||
|
||||
-- Re-enable foreign key checking, at the end of the upgrade path
|
||||
SET foreign_key_checks = 1;
|
||||
|
|
|
|||
|
|
@ -6899,7 +6899,9 @@ label.error {
|
|||
|
||||
/*** Multi-edit*/
|
||||
.multi-wizard.zone-wizard .multi-edit {
|
||||
width: 100%;
|
||||
width: 732px;
|
||||
float: left;
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit table {
|
||||
|
|
@ -6907,22 +6909,45 @@ label.error {
|
|||
width: 98%;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit table th,
|
||||
.multi-wizard.zone-wizard .multi-edit table td {
|
||||
min-width: 97px;
|
||||
max-width: 97px;
|
||||
.multi-wizard.zone-wizard .multi-edit table td,
|
||||
.multi-wizard.zone-wizard .multi-edit table th {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit table th {
|
||||
padding-top: 11px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit table input {
|
||||
margin: 2px 0px 2px -5px;
|
||||
padding: 2px 0px;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit .data {
|
||||
width: 102%;
|
||||
float: left;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit .data-body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit .data-body .data-item {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit .data-body .data-item td {
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.multi-wizard.zone-wizard .multi-edit .data-body .data-item td span {
|
||||
font-size: 10px;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 91px;
|
||||
}
|
||||
|
||||
/*** Select container fields*/
|
||||
.multi-wizard.zone-wizard .select-container .field {
|
||||
width: 100%;
|
||||
|
|
@ -7286,6 +7311,7 @@ div.ui-dialog div.multi-edit-add-list div.view div.data-table table.body tbody t
|
|||
}
|
||||
|
||||
.multi-edit {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.multi-edit > form {
|
||||
|
|
@ -7464,7 +7490,6 @@ div.ui-dialog div.multi-edit-add-list div.view div.data-table table.body tbody t
|
|||
}
|
||||
|
||||
.multi-edit .data .data-body {
|
||||
width: 96%;
|
||||
margin: auto auto auto 11px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,13 @@
|
|||
data: items
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
error:function(json){
|
||||
args.response.error(parseXMLHttpResponse(json));
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -628,7 +628,13 @@
|
|||
$.extend(data, {
|
||||
networkdomain: args.data.networkdomain
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(args.data.cidr !="" ){
|
||||
$.extend(data, {
|
||||
guestvmcidr: args.data.cidr
|
||||
});
|
||||
}
|
||||
|
||||
//args.data.networkofferingid is null when networkofferingid field is hidden
|
||||
if(args.data.networkofferingid != null && args.data.networkofferingid != args.context.networks[0].networkofferingid) {
|
||||
|
|
@ -1001,7 +1007,12 @@
|
|||
gateway: { label: 'label.gateway' },
|
||||
|
||||
//netmask: { label: 'label.netmask' },
|
||||
cidr: { label: 'label.cidr' },
|
||||
cidr: { label: 'label.cidr', isEditable:true },
|
||||
|
||||
networkcidr:{label:'Network CIDR'},
|
||||
|
||||
reservediprange:{label:'Reserved IP Range'},
|
||||
|
||||
|
||||
networkdomaintext: {
|
||||
label: 'label.network.domain.text'
|
||||
|
|
|
|||
|
|
@ -222,8 +222,7 @@
|
|||
}
|
||||
|
||||
// Align width to main header
|
||||
var targetWidth = $multi.find('th.' + fieldName).width() + 5;
|
||||
$td.width(targetWidth);
|
||||
_medit.refreshItemWidths($multi);
|
||||
|
||||
if (data._hideFields &&
|
||||
$.inArray(fieldName, data._hideFields) > -1) {
|
||||
|
|
@ -523,10 +522,15 @@
|
|||
* Align width of each data row to main header
|
||||
*/
|
||||
refreshItemWidths: function($multi) {
|
||||
$multi.find('.data-body').width(
|
||||
$multi.find('form > table.multi-edit').width()
|
||||
);
|
||||
|
||||
$multi.find('.data tr').filter(function() {
|
||||
return !$(this).closest('.expandable-listing').size();
|
||||
}).each(function() {
|
||||
var $tr = $(this);
|
||||
|
||||
$tr.find('td').each(function() {
|
||||
var $td = $(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -1430,7 +1430,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
|
|||
timeSinceJob = now - lastSuccess;
|
||||
}
|
||||
|
||||
if ((timeSinceJob > 0) && (timeSinceJob > aggregationDurationMillis)) {
|
||||
if ((timeSinceJob > 0) && (timeSinceJob > (aggregationDurationMillis - 100))) {
|
||||
if (timeToJob > (aggregationDurationMillis/2)) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("it's been " + timeSinceJob + " ms since last usage job and " + timeToJob + " ms until next job, scheduling an immediate job to catch up (aggregation duration is " + m_aggregationDuration + " minutes)");
|
||||
|
|
|
|||
Loading…
Reference in New Issue