mirror of https://github.com/apache/cloudstack.git
Add Region APIs
This commit is contained in:
parent
ccf15cb5f6
commit
6a1b0f3ecf
|
|
@ -357,6 +357,7 @@ 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 enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import com.cloud.network.security.SecurityGroupService;
|
|||
import com.cloud.network.vpn.RemoteAccessVpnService;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectService;
|
||||
import com.cloud.region.RegionService;
|
||||
import com.cloud.resource.ResourceService;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.storage.StorageService;
|
||||
|
|
@ -128,7 +129,8 @@ public abstract class BaseCmd {
|
|||
public static ResourceLimitService _resourceLimitService;
|
||||
public static IdentityService _identityService;
|
||||
public static StorageNetworkService _storageNetworkService;
|
||||
|
||||
public static RegionService _regionService;
|
||||
|
||||
static void setComponents(ResponseGenerator generator) {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||
_mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name);
|
||||
|
|
@ -155,6 +157,7 @@ public abstract class BaseCmd {
|
|||
_resourceLimitService = locator.getManager(ResourceLimitService.class);
|
||||
_identityService = locator.getManager(IdentityService.class);
|
||||
_storageNetworkService = locator.getManager(StorageNetworkService.class);
|
||||
_regionService = locator.getManager(RegionService.class);
|
||||
}
|
||||
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import com.cloud.api.response.ProjectAccountResponse;
|
|||
import com.cloud.api.response.ProjectInvitationResponse;
|
||||
import com.cloud.api.response.ProjectResponse;
|
||||
import com.cloud.api.response.ProviderResponse;
|
||||
import com.cloud.api.response.RegionResponse;
|
||||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.api.response.ResourceCountResponse;
|
||||
import com.cloud.api.response.ResourceLimitResponse;
|
||||
|
|
@ -83,6 +84,7 @@ import com.cloud.configuration.ResourceCount;
|
|||
import com.cloud.configuration.ResourceLimit;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.region.Region;
|
||||
import com.cloud.dc.StorageNetworkIpRange;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.domain.Domain;
|
||||
|
|
@ -273,6 +275,8 @@ public interface ResponseGenerator {
|
|||
LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String baseSearch, String dn);
|
||||
|
||||
StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(StorageNetworkIpRange result);
|
||||
|
||||
RegionResponse createRegionResponse(Region region);
|
||||
|
||||
/**
|
||||
* @param tableName TODO
|
||||
|
|
|
|||
|
|
@ -332,3 +332,9 @@ updateStorageNetworkIpRange=com.cloud.api.commands.UpdateStorageNetworkIpRangeCm
|
|||
addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
|
||||
listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
|
||||
deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
|
||||
|
||||
#### Region commands
|
||||
addRegion=com.cloud.api.commands.AddRegionCmd;1
|
||||
updateRegion=com.cloud.api.commands.UpdateRegionCmd;1
|
||||
removeRegion=com.cloud.api.commands.RemoveRegionCmd;1
|
||||
listRegions=com.cloud.api.commands.ListRegionsCmd;7
|
||||
|
|
@ -63,6 +63,9 @@ public class AccountVO implements Account, Identity {
|
|||
@Column(name="default_zone_id")
|
||||
private Long defaultZoneId = null;
|
||||
|
||||
@Column(name="region_id")
|
||||
private long regionId;
|
||||
|
||||
public AccountVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
|
@ -78,7 +81,6 @@ public class AccountVO implements Account, Identity {
|
|||
this.networkDomain = networkDomain;
|
||||
this.type = type;
|
||||
this.state = State.enabled;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public void setNeedsCleanup(boolean value) {
|
||||
|
|
@ -171,4 +173,12 @@ public class AccountVO implements Account, Identity {
|
|||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public long getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(long regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ public class UserVO implements User, Identity {
|
|||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="region_id")
|
||||
private long regionId;
|
||||
|
||||
public UserVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
|
@ -257,4 +260,12 @@ public class UserVO implements User, Identity {
|
|||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public long getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(long regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ import com.cloud.api.response.ProjectAccountResponse;
|
|||
import com.cloud.api.response.ProjectInvitationResponse;
|
||||
import com.cloud.api.response.ProjectResponse;
|
||||
import com.cloud.api.response.ProviderResponse;
|
||||
import com.cloud.api.response.RegionResponse;
|
||||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.api.response.ResourceCountResponse;
|
||||
import com.cloud.api.response.ResourceLimitResponse;
|
||||
|
|
@ -150,6 +151,7 @@ import com.cloud.org.Cluster;
|
|||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectAccount;
|
||||
import com.cloud.projects.ProjectInvitation;
|
||||
import com.cloud.region.Region;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.GuestOS;
|
||||
|
|
@ -3399,4 +3401,14 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
return ApiDispatcher.getIdentiyId(tableName, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionResponse createRegionResponse(Region region) {
|
||||
RegionResponse response = new RegionResponse();
|
||||
response.setId(region.getId());
|
||||
response.setName(region.getName());
|
||||
response.setEndPoint(region.getEndPoint());
|
||||
response.setObjectName("region");
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ import com.cloud.projects.ProjectManagerImpl;
|
|||
import com.cloud.projects.dao.ProjectAccountDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectDaoImpl;
|
||||
import com.cloud.projects.dao.ProjectInvitationDaoImpl;
|
||||
import com.cloud.region.RegionManagerImpl;
|
||||
import com.cloud.region.dao.RegionDaoImpl;
|
||||
import com.cloud.resource.ResourceManagerImpl;
|
||||
import com.cloud.resourcelimit.ResourceLimitManagerImpl;
|
||||
import com.cloud.service.dao.ServiceOfferingDaoImpl;
|
||||
|
|
@ -329,6 +331,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
addDao("NetworkServiceMapDao", NetworkServiceMapDaoImpl.class);
|
||||
addDao("StorageNetworkIpAddressDao", StorageNetworkIpAddressDaoImpl.class);
|
||||
addDao("StorageNetworkIpRangeDao", StorageNetworkIpRangeDaoImpl.class);
|
||||
addDao("RegionDao", RegionDaoImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -385,6 +388,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
addManager("StorageNetworkManager", StorageNetworkManagerImpl.class);
|
||||
addManager("ExternalLoadBalancerUsageManager", ExternalLoadBalancerUsageManagerImpl.class);
|
||||
addManager("HA Manager", HighAvailabilityManagerImpl.class);
|
||||
addManager("Region Manager", RegionManagerImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ public class DomainVO implements Domain, Identity {
|
|||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="region_id")
|
||||
private long regionId;
|
||||
|
||||
public DomainVO() {}
|
||||
|
||||
|
|
@ -200,5 +203,13 @@ public class DomainVO implements Domain, Identity {
|
|||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public long getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(long regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
|
|
@ -42,6 +43,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
|||
protected SearchBuilder<DomainVO> ImmediateChildDomainSearch;
|
||||
protected SearchBuilder<DomainVO> FindAllChildrenSearch;
|
||||
protected SearchBuilder<DomainVO> AllFieldsSearch;
|
||||
private final long _regionId = 1;
|
||||
|
||||
public DomainDaoImpl () {
|
||||
DomainNameLikeSearch = createSearchBuilder();
|
||||
|
|
@ -266,4 +268,11 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
|||
|
||||
return parentDomains;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public DomainVO persist(DomainVO domain) {
|
||||
domain.setRegionId(_regionId);
|
||||
return super.persist(domain);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,7 +199,9 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
private ProjectAccountDao _projectAccountDao;
|
||||
@Inject
|
||||
private IPAddressDao _ipAddressDao;
|
||||
|
||||
//@Inject
|
||||
//private RegionManager _regionMgr;
|
||||
|
||||
private Adapters<UserAuthenticator> _userAuthenticators;
|
||||
|
||||
private final ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AccountChecker"));
|
||||
|
|
@ -1575,7 +1577,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
|
||||
// Create default security group
|
||||
_networkGroupMgr.createDefaultSecurityGroup(accountId);
|
||||
|
||||
//_regionMgr.propogateAddResource();
|
||||
txn.commit();
|
||||
|
||||
return account;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
|
@ -48,6 +49,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
protected final SearchBuilder<AccountVO> CleanupForRemovedAccountsSearch;
|
||||
protected final SearchBuilder<AccountVO> CleanupForDisabledAccountsSearch;
|
||||
protected final SearchBuilder<AccountVO> NonProjectAccountSearch;
|
||||
private final long _regionId = 1;
|
||||
|
||||
protected AccountDaoImpl() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
|
|
@ -257,4 +259,11 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public AccountVO persist(AccountVO account) {
|
||||
account.setRegionId(_regionId);
|
||||
return super.persist(account);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
|
@ -35,6 +36,7 @@ public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements UserDao
|
|||
protected SearchBuilder<UserVO> AccountIdSearch;
|
||||
protected SearchBuilder<UserVO> SecretKeySearch;
|
||||
protected SearchBuilder<UserVO> RegistrationTokenSearch;
|
||||
private final long _regionId = 1;
|
||||
|
||||
protected UserDaoImpl () {
|
||||
UsernameSearch = createSearchBuilder();
|
||||
|
|
@ -123,4 +125,11 @@ public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements UserDao
|
|||
sc.setParameters("username", username);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public UserVO persist(UserVO user) {
|
||||
user.setRegionId(_regionId);
|
||||
return super.persist(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ DROP TABLE IF EXISTS `cloud`.`op_dc_storage_network_ip_address`;
|
|||
DROP TABLE IF EXISTS `cloud`.`cluster_vsm_map`;
|
||||
DROP TABLE IF EXISTS `cloud`.`virtual_supervisor_module`;
|
||||
DROP TABLE IF EXISTS `cloud`.`port_profile`;
|
||||
DROP TABLE IF EXISTS `cloud`.`region`;
|
||||
|
||||
CREATE TABLE `cloud`.`version` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
|
|
@ -874,6 +875,7 @@ CREATE TABLE `cloud`.`user` (
|
|||
`timezone` varchar(30) default NULL,
|
||||
`registration_token` varchar(255) default NULL,
|
||||
`is_registered` tinyint NOT NULL DEFAULT 0 COMMENT '1: yes, 0: no',
|
||||
`region_id` bigint unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `i_user__removed`(`removed`),
|
||||
INDEX `i_user__secret_key_removed`(`secret_key`, `removed`),
|
||||
|
|
@ -1219,6 +1221,7 @@ CREATE TABLE `cloud`.`domain` (
|
|||
`state` char(32) NOT NULL default 'Active' COMMENT 'state of the domain',
|
||||
`network_domain` varchar(255),
|
||||
`type` varchar(255) NOT NULL DEFAULT 'Normal' COMMENT 'type of the domain - can be Normal or Project',
|
||||
`region_id` bigint unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (parent, name, removed),
|
||||
INDEX `i_domain__path`(`path`),
|
||||
|
|
@ -1237,6 +1240,7 @@ CREATE TABLE `cloud`.`account` (
|
|||
`cleanup_needed` tinyint(1) NOT NULL default '0',
|
||||
`network_domain` varchar(255),
|
||||
`default_zone_id` bigint unsigned,
|
||||
`region_id` bigint unsigned,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX i_account__removed(`removed`),
|
||||
CONSTRAINT `fk_account__default_zone_id` FOREIGN KEY `fk_account__default_zone_id`(`default_zone_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
|
||||
|
|
@ -2132,4 +2136,15 @@ CREATE TABLE `cloud`.`netscaler_pod_ref` (
|
|||
CONSTRAINT `fk_ns_pod_ref__device_id` FOREIGN KEY (`external_load_balancer_device_id`) REFERENCES `external_load_balancer_devices`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `cloud`.`region` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE,
|
||||
`name` varchar(255),
|
||||
`end_point` varchar(255),
|
||||
`status` varchar(32) NOT NULL,
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue