mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Bugfix to make deployDataCenter.py work.
This commit is contained in:
parent
bbd5d13213
commit
36c1538f06
@ -24,4 +24,6 @@ import com.cloud.storage.ScopeType;
|
||||
public interface ImageStoreProvider extends DataStoreProvider {
|
||||
|
||||
public boolean isScopeSupported(ScopeType scope);
|
||||
|
||||
public boolean needDownloadSysTemplate();
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
||||
|
||||
@Column(name="store_id")
|
||||
private long dataStoreId;
|
||||
|
||||
|
||||
@Column(name="store_role")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private DataStoreRole role;
|
||||
@ -74,7 +74,7 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
||||
|
||||
@Column(name="parent_snapshot_id")
|
||||
private long parentSnapshotId;
|
||||
|
||||
|
||||
@Column (name="job_id")
|
||||
private String jobId;
|
||||
|
||||
@ -236,6 +236,11 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
||||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
public void setState(ObjectInDataStoreStateMachine.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getObjectId() {
|
||||
return this.getSnapshotId();
|
||||
|
||||
@ -347,6 +347,11 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
|
||||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
public void setState(ObjectInDataStoreStateMachine.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getObjectId() {
|
||||
return this.getVolumeId();
|
||||
|
||||
@ -23,6 +23,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
@ -109,6 +110,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
ss.setSnapshotId(obj.getId());
|
||||
ss.setDataStoreId(dataStore.getId());
|
||||
ss.setRole(dataStore.getRole());
|
||||
ss.setState(ObjectInDataStoreStateMachine.State.Allocated);
|
||||
ss = snapshotDataStoreDao.persist(ss);
|
||||
}
|
||||
} else {
|
||||
@ -121,6 +123,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
if (dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
ts.setInstallPath("template/tmpl/" + templateDao.findById(obj.getId()).getAccountId() + "/" + obj.getId());
|
||||
}
|
||||
ts.setState(ObjectInDataStoreStateMachine.State.Allocated);
|
||||
ts = templateDataStoreDao.persist(ts);
|
||||
break;
|
||||
case SNAPSHOT:
|
||||
@ -131,6 +134,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
if (dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
ss.setInstallPath("/snapshots/" + snapshotDao.findById(obj.getId()).getAccountId() + "/" + obj.getId());
|
||||
}
|
||||
ss.setState(ObjectInDataStoreStateMachine.State.Allocated);
|
||||
ss = snapshotDataStoreDao.persist(ss);
|
||||
break;
|
||||
case VOLUME:
|
||||
@ -140,6 +144,7 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
||||
if (dataStore.getRole() == DataStoreRole.ImageCache) {
|
||||
vs.setInstallPath("/volumes/" + volumeDao.findById(obj.getId()).getAccountId() + "/" + obj.getId());
|
||||
}
|
||||
vs.setState(ObjectInDataStoreStateMachine.State.Allocated);
|
||||
vs = volumeDataStoreDao.persist(vs);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class ImageStoreHelper {
|
||||
store.setScope((ScopeType)params.get("scope"));
|
||||
store.setUuid((String)params.get("uuid"));
|
||||
store.setUrl((String)params.get("url"));
|
||||
store.setRole(DataStoreRole.getRole((String)params.get("role")));
|
||||
store.setRole((DataStoreRole)params.get("role"));
|
||||
store = imageStoreDao.persist(store);
|
||||
|
||||
// persist details
|
||||
|
||||
@ -46,6 +46,7 @@ import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.ResourceListener;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.utils.UriUtils;
|
||||
|
||||
@ -80,6 +81,7 @@ public class CloudStackImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
|
||||
Long dcId = (Long) dsInfos.get("zoneId");
|
||||
String url = (String) dsInfos.get("url");
|
||||
String providerName = (String)dsInfos.get("providerName");
|
||||
DataStoreRole role =(DataStoreRole) dsInfos.get("role");
|
||||
Map<String, String> details = (Map<String, String>)dsInfos.get("details");
|
||||
|
||||
s_logger.info("Trying to add a new host at " + url + " in data center " + dcId);
|
||||
@ -115,6 +117,8 @@ public class CloudStackImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
|
||||
imageStoreParameters.put("protocol", uri.getScheme().toLowerCase());
|
||||
imageStoreParameters.put("scope", ScopeType.ZONE); // default cloudstack provider only supports zone-wide image store
|
||||
imageStoreParameters.put("providerName", providerName);
|
||||
imageStoreParameters.put("role", role);
|
||||
|
||||
|
||||
ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters, details);
|
||||
return imageStoreMgr.getImageStore(ids.getId());
|
||||
|
||||
@ -94,5 +94,10 @@ public class CloudStackImageStoreProviderImpl implements ImageStoreProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needDownloadSysTemplate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@ import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.ResourceListener;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.s3.S3Manager;
|
||||
import com.cloud.utils.UriUtils;
|
||||
@ -85,6 +86,7 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
|
||||
String url = (String) dsInfos.get("url");
|
||||
String providerName = (String)dsInfos.get("providerName");
|
||||
ScopeType scope = (ScopeType)dsInfos.get("scope");
|
||||
DataStoreRole role =(DataStoreRole) dsInfos.get("role");
|
||||
Map<String, String> details = (Map<String, String>)dsInfos.get("details");
|
||||
|
||||
s_logger.info("Trying to add a S3 store in data center " + dcId);
|
||||
@ -113,6 +115,7 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
|
||||
imageStoreParameters.put("scope", ScopeType.REGION);
|
||||
}
|
||||
imageStoreParameters.put("providerName", providerName);
|
||||
imageStoreParameters.put("role", role);
|
||||
|
||||
ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters, details);
|
||||
return imageStoreMgr.getImageStore(ids.getId());
|
||||
|
||||
@ -94,5 +94,10 @@ public class S3ImageStoreProviderImpl implements ImageStoreProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needDownloadSysTemplate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -88,5 +88,10 @@ public class SampleImageStoreProviderImpl implements ImageStoreProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needDownloadSysTemplate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@ import com.cloud.resource.Discoverer;
|
||||
import com.cloud.resource.ResourceListener;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.utils.UriUtils;
|
||||
|
||||
@ -81,6 +82,8 @@ public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
|
||||
String url = (String) dsInfos.get("url");
|
||||
ScopeType scope = (ScopeType)dsInfos.get("scope");
|
||||
String providerName = (String)dsInfos.get("providerName");
|
||||
DataStoreRole role =(DataStoreRole) dsInfos.get("role");
|
||||
|
||||
Map<String, String> details = (Map<String, String>)dsInfos.get("details");
|
||||
|
||||
s_logger.info("Trying to add a swift store at " + url + " in data center " + dcId);
|
||||
@ -97,8 +100,9 @@ public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
|
||||
imageStoreParameters.put("scope", ScopeType.REGION);
|
||||
}
|
||||
imageStoreParameters.put("providerName", providerName);
|
||||
imageStoreParameters.put("role", role);
|
||||
|
||||
ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters);
|
||||
ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters, details);
|
||||
return imageStoreMgr.getImageStore(ids.getId());
|
||||
}
|
||||
|
||||
|
||||
@ -96,5 +96,10 @@ public class SwiftImageStoreProviderImpl implements ImageStoreProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needDownloadSysTemplate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1913,8 +1913,10 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
throw new CloudRuntimeException("Failed to add data store", e);
|
||||
}
|
||||
|
||||
// trigger system vm template download
|
||||
this._imageSrv.downloadBootstrapSysTemplate(store);
|
||||
if (((ImageStoreProvider) storeProvider).needDownloadSysTemplate()) {
|
||||
// trigger system vm template download
|
||||
this._imageSrv.downloadBootstrapSysTemplate(store);
|
||||
}
|
||||
|
||||
return (ImageStore) _dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Image);
|
||||
}
|
||||
|
||||
@ -74,6 +74,7 @@ import com.cloud.template.TemplateManager;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
@ -160,7 +161,9 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
|
||||
|
||||
_copyAuthPasswd = configs.get("secstorage.copy.password");
|
||||
|
||||
_agentMgr.registerForHostEvents(new DownloadListener(this), true, false, false);
|
||||
DownloadListener dl = new DownloadListener(this);
|
||||
ComponentContext.inject(dl);
|
||||
_agentMgr.registerForHostEvents(dl, true, false, false);
|
||||
|
||||
ReadyTemplateStatesSearch = _vmTemplateStoreDao.createSearchBuilder();
|
||||
ReadyTemplateStatesSearch.and("state", ReadyTemplateStatesSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
@ -229,6 +232,7 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
|
||||
}
|
||||
DownloadListener dl = new DownloadListener(ep, store, template, _timer, this, dcmd,
|
||||
callback);
|
||||
ComponentContext.inject(dl); // initialize those auto-wired field in download listener.
|
||||
if (downloadJobExists) {
|
||||
// due to handling existing download job issues, we still keep
|
||||
// downloadState in template_store_ref to avoid big change in
|
||||
@ -298,6 +302,7 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
|
||||
return;
|
||||
}
|
||||
DownloadListener dl = new DownloadListener(ep, store, volume, _timer, this, dcmd, callback);
|
||||
ComponentContext.inject(dl); // auto-wired those injected fields in DownloadListener
|
||||
|
||||
if (downloadJobExists) {
|
||||
dl.setCurrState(volumeHost.getDownloadState());
|
||||
|
||||
@ -1347,7 +1347,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
}
|
||||
}
|
||||
*/
|
||||
return host;
|
||||
return null; // no need to handle this event anymore since secondary storage is not in host table anymore.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -76,6 +76,7 @@ CREATE TABLE `cloud`.`image_store` (
|
||||
`url` varchar(255) COMMENT 'url for image data store',
|
||||
`data_center_id` bigint unsigned COMMENT 'datacenter id of data store',
|
||||
`scope` varchar(255) COMMENT 'scope of data store',
|
||||
`role` varchar(255) COMMENT 'role of data store',
|
||||
`uuid` varchar(255) COMMENT 'uuid of data store',
|
||||
`parent` varchar(255) COMMENT 'parent path for the storage server',
|
||||
`created` datetime COMMENT 'date the image store first signed on',
|
||||
@ -135,6 +136,8 @@ CREATE TABLE `cloud`.`template_store_ref` (
|
||||
`state` varchar(255) NOT NULL,
|
||||
`destroyed` tinyint(1) COMMENT 'indicates whether the template_store entry was destroyed by the user or not',
|
||||
`is_copy` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates whether this was copied ',
|
||||
`update_count` bigint unsigned,
|
||||
`updated` datetime,
|
||||
PRIMARY KEY (`id`),
|
||||
-- CONSTRAINT `fk_template_store_ref__store_id` FOREIGN KEY `fk_template_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
|
||||
INDEX `i_template_store_ref__store_id`(`store_id`),
|
||||
@ -160,11 +163,14 @@ CREATE TABLE `cloud`.`snapshot_store_ref` (
|
||||
`created` DATETIME NOT NULL,
|
||||
`last_updated` DATETIME,
|
||||
`job_id` varchar(255),
|
||||
`store_role` varchar(255),
|
||||
`size` bigint unsigned,
|
||||
`physical_size` bigint unsigned DEFAULT 0,
|
||||
`install_path` varchar(255),
|
||||
`state` varchar(255) NOT NULL,
|
||||
`destroyed` tinyint(1) COMMENT 'indicates whether the snapshot_store entry was destroyed by the user or not',
|
||||
`update_count` bigint unsigned,
|
||||
`updated` datetime,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_snapshot_store_ref__store_id` FOREIGN KEY `fk_snapshot_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
|
||||
INDEX `i_snapshot_store_ref__store_id`(`store_id`),
|
||||
@ -192,6 +198,8 @@ CREATE TABLE `cloud`.`volume_store_ref` (
|
||||
`state` varchar(255) NOT NULL,
|
||||
`format` varchar(32) NOT NULL COMMENT 'format for the volume',
|
||||
`destroyed` tinyint(1) COMMENT 'indicates whether the volume_host entry was destroyed by the user or not',
|
||||
`update_count` bigint unsigned,
|
||||
`updated` datetime,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_volume_store_ref__store_id` FOREIGN KEY `fk_volume_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
|
||||
INDEX `i_volume_store_ref__store_id`(`store_id`),
|
||||
|
||||
@ -70,6 +70,7 @@ class zone():
|
||||
self.physical_networks = []
|
||||
self.pods = []
|
||||
self.secondaryStorages = []
|
||||
|
||||
|
||||
class traffictype():
|
||||
def __init__(self, typ, labeldict=None):
|
||||
@ -178,6 +179,8 @@ class primaryStorage():
|
||||
class secondaryStorage():
|
||||
def __init__(self):
|
||||
self.url = None
|
||||
self.providerName = None
|
||||
self.details = None
|
||||
|
||||
class s3():
|
||||
def __init__(self):
|
||||
|
||||
@ -138,10 +138,12 @@ class deployDataCenters():
|
||||
if secondaryStorages is None:
|
||||
return
|
||||
for secondary in secondaryStorages:
|
||||
secondarycmd = addSecondaryStorage.addSecondaryStorageCmd()
|
||||
secondarycmd = addImageStore.addImageStoreCmd()
|
||||
secondarycmd.url = secondary.url
|
||||
secondarycmd.provider = secondary.providerName
|
||||
"""if secondary.provider == "CloudStack ImageStore Provider":"""
|
||||
secondarycmd.zoneid = zoneId
|
||||
self.apiClient.addSecondaryStorage(secondarycmd)
|
||||
self.apiClient.addImageStore(secondarycmd)
|
||||
|
||||
def createnetworks(self, networks, zoneId):
|
||||
if networks is None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user