org.apache.cloudstack.engine.subsystem.api.storage.DataStore.getTO()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.apache.cloudstack.engine.subsystem.api.storage.DataStore.getTO()方法的一些代码示例,展示了DataStore.getTO()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataStore.getTO()方法的具体详情如下:
包路径:org.apache.cloudstack.engine.subsystem.api.storage.DataStore
类名称:DataStore
方法名:getTO

DataStore.getTO介绍

暂无

代码示例

代码示例来源:origin: apache/cloudstack

@Override
public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format, DataObject dataObject) {
  SwiftTO swiftTO = (SwiftTO)store.getTO();
  String tempKey = UUID.randomUUID().toString();
  boolean result = SwiftUtil.setTempKey(swiftTO, tempKey);
  if (!result) {
    String errMsg = "Unable to set Temp-Key: " + tempKey;
    s_logger.error(errMsg);
    throw new CloudRuntimeException(errMsg);
  }
  String containerName = SwiftUtil.getContainerName(dataObject.getType().toString(), dataObject.getId());
  String objectName = installPath.split("\\/")[1];
  // Get extract url expiration interval set in global configuration (in seconds)
  int urlExpirationInterval = Integer.parseInt(_configDao.getValue(Config.ExtractURLExpirationInterval.toString()));
  URL swiftUrl = SwiftUtil.generateTempUrl(swiftTO, containerName, objectName, tempKey, urlExpirationInterval);
  if (swiftUrl != null) {
    s_logger.debug("Swift temp-url: " + swiftUrl.toString());
    return swiftUrl.toString();
  }
  throw new CloudRuntimeException("Unable to create extraction URL");
}

代码示例来源:origin: apache/cloudstack

private Map<Long, TemplateProp> listVolume(DataStore store) {
  ListVolumeCommand cmd = new ListVolumeCommand(store.getTO(), store.getUri());
  EndPoint ep = _epSelector.select(store);
  Answer answer = null;
  if (ep == null) {
    String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
    s_logger.error(errMsg);
    answer = new Answer(cmd, false, errMsg);
  } else {
    answer = ep.sendMessage(cmd);
  }
  if (answer != null && answer.getResult()) {
    ListVolumeAnswer tanswer = (ListVolumeAnswer)answer;
    return tanswer.getTemplateInfo();
  } else {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("Can not list volumes for image store " + store.getId());
    }
  }
  return null;
}

代码示例来源:origin: apache/cloudstack

@Override
public String getChecksum(DataStore store, String templatePath, String algorithm) {
  EndPoint ep = _epSelector.select(store);
  ComputeChecksumCommand cmd = new ComputeChecksumCommand(store.getTO(), templatePath, algorithm);
  Answer answer = null;
  if (ep == null) {
    String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
    s_logger.error(errMsg);
    answer = new Answer(cmd, false, errMsg);
  } else {
    answer = ep.sendMessage(cmd);
  }
  if (answer != null && answer.getResult()) {
    return answer.getDetails();
  }
  return null;
}

代码示例来源:origin: apache/cloudstack

private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
  Integer nfsVersion = imageStoreDetailsUtil.getNfsVersion(ssStore.getId());
  ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getTO(), nfsVersion);
  EndPoint ep = _epSelector.select(ssStore);
  Answer answer = null;
  if (ep == null) {
    String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
    s_logger.error(errMsg);
    answer = new Answer(cmd, false, errMsg);
  } else {
    answer = ep.sendMessage(cmd);
  }
  if (answer != null && answer.getResult()) {
    ListTemplateAnswer tanswer = (ListTemplateAnswer)answer;
    return tanswer.getTemplateInfo();
  } else {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("can not list template for secondary storage host " + ssStore.getId());
    }
  }
  return null;
}

代码示例来源:origin: apache/cloudstack

@Override
public TemplateInfo prepareIso(long isoId, long dcId, Long hostId, Long poolId) {
  TemplateInfo tmplt;
  boolean bypassed = false;
  if (_tmplFactory.isTemplateMarkedForDirectDownload(isoId)) {
    tmplt = _tmplFactory.getReadyBypassedTemplateOnPrimaryStore(isoId, poolId, hostId);
    bypassed = true;
  } else {
    tmplt = _tmplFactory.getTemplate(isoId, DataStoreRole.Image, dcId);
  }
  if (tmplt == null || tmplt.getFormat() != ImageFormat.ISO) {
    s_logger.warn("ISO: " + isoId + " does not exist in vm_template table");
    return null;
  }
  if (!bypassed && tmplt.getDataStore() != null && !(tmplt.getDataStore().getTO() instanceof NfsTO)) {
    // if it is s3, need to download into cache storage first
    Scope destScope = new ZoneScope(dcId);
    TemplateInfo cacheData = (TemplateInfo)cacheMgr.createCacheObject(tmplt, destScope);
    if (cacheData == null) {
      s_logger.error("Failed in copy iso from S3 to cache storage");
      return null;
    }
    return cacheData;
  } else {
    return tmplt;
  }
}

代码示例来源:origin: apache/cloudstack

private void addConfigDriveDisk(final VirtualMachineProfile profile, final DataStore dataStore) {
  boolean isoAvailable = false;
  final String isoPath = ConfigDrive.createConfigDrivePath(profile.getInstanceName());
  for (DiskTO dataTo : profile.getDisks()) {
    if (dataTo.getPath().equals(isoPath)) {
      isoAvailable = true;
      break;
    }
  }
  if (!isoAvailable) {
    TemplateObjectTO dataTO = new TemplateObjectTO();
    dataTO.setDataStore(dataStore.getTO());
    dataTO.setUuid(profile.getUuid());
    dataTO.setPath(isoPath);
    dataTO.setFormat(Storage.ImageFormat.ISO);
    profile.addDisk(new DiskTO(dataTO, CONFIGDRIVEDISKSEQ.longValue(), isoPath, Volume.Type.ISO));
  } else {
    LOG.warn("Config drive iso already is in VM profile.");
  }
}

代码示例来源:origin: apache/cloudstack

public SnapshotObjectTO(SnapshotInfo snapshot) {
  this.path = snapshot.getPath();
  this.setId(snapshot.getId());
  VolumeInfo vol = snapshot.getBaseVolume();
  if (vol != null) {
    this.volume = (VolumeObjectTO)vol.getTO();
    this.setVmName(vol.getAttachedVmName());
  }
  SnapshotInfo parentSnapshot = snapshot.getParent();
  ArrayList<String> parentsArry = new ArrayList<String>();
  if (parentSnapshot != null) {
    this.parentSnapshotPath = parentSnapshot.getPath();
    while(parentSnapshot != null) {
      parentsArry.add(parentSnapshot.getPath());
      parentSnapshot = parentSnapshot.getParent();
    }
    parents =  parentsArry.toArray(new String[parentsArry.size()]);
    ArrayUtils.reverse(parents);
  }
  this.dataStore = snapshot.getDataStore().getTO();
  this.setName(snapshot.getName());
  this.hypervisorType = snapshot.getHypervisorType();
  this.quiescevm = false;
}

代码示例来源:origin: apache/cloudstack

GetStorageStatsCommand command = new GetStorageStatsCommand(store.getTO(), nfsVersion);
EndPoint ssAhost = _epSelector.select(store);
if (ssAhost == null) {

代码示例来源:origin: apache/cloudstack

private boolean deleteConfigDriveIso(final VirtualMachine vm) throws ResourceUnavailableException {
  DataStore dataStore = _dataStoreMgr.getImageStore(vm.getDataCenterId());
  Long agentId = findAgentIdForImageStore(dataStore);
  if (VirtualMachineManager.VmConfigDriveOnPrimaryPool.value()) {
    List<VolumeVO> volumes = _volumeDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
    if (volumes != null && volumes.size() > 0) {
      dataStore = _dataStoreMgr.getDataStore(volumes.get(0).getPoolId(), DataStoreRole.Primary);
    }
    agentId = (vm.getHostId() != null) ? vm.getHostId() : vm.getLastHostId();
  }
  if (agentId == null || dataStore == null) {
    throw new ResourceUnavailableException("Config drive iso creation failed, agent or datastore not available",
        ConfigDriveNetworkElement.class, 0L);
  }
  LOG.debug("Deleting config drive ISO for vm: " + vm.getInstanceName());
  final String isoPath = ConfigDrive.createConfigDrivePath(vm.getInstanceName());
  final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, null, dataStore.getTO(), false);
  final Answer answer = agentManager.easySend(agentId, configDriveIsoCommand);
  if (!answer.getResult()) {
    LOG.error("Failed to remove config drive for instance: " + vm.getInstanceName());
    return false;
  }
  return true;
}

代码示例来源:origin: apache/cloudstack

private boolean createConfigDriveIso(VirtualMachineProfile profile, DeployDestination dest) throws ResourceUnavailableException {
  final DataStore dataStore = findDataStore(profile, dest);
  final Long agentId = findAgentId(profile, dest, dataStore);
  if (agentId == null || dataStore == null) {
    throw new ResourceUnavailableException("Config drive iso creation failed, agent or datastore not available",
        ConfigDriveNetworkElement.class, 0L);
  }
  LOG.debug("Creating config drive ISO for vm: " + profile.getInstanceName());
  final String isoFileName = ConfigDrive.configIsoFileName(profile.getInstanceName());
  final String isoPath = ConfigDrive.createConfigDrivePath(profile.getInstanceName());
  final String isoData = ConfigDriveBuilder.buildConfigDrive(profile.getVmData(), isoFileName, profile.getConfigDriveLabel());
  final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, isoData, dataStore.getTO(), true);
  final Answer answer = agentManager.easySend(agentId, configDriveIsoCommand);
  if (!answer.getResult()) {
    throw new ResourceUnavailableException(String.format("Config drive iso creation failed, details: %s",
        answer.getDetails()), ConfigDriveNetworkElement.class, 0L);
  }
  addConfigDriveDisk(profile, dataStore);
  return true;
}

代码示例来源:origin: apache/cloudstack

for (DataStore ssHost : ssHosts) {
  String snapshotDir = TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + accountId + "/" + volumeId;
  DeleteSnapshotsDirCommand cmd = new DeleteSnapshotsDirCommand(ssHost.getTO(), snapshotDir);
  EndPoint ep = _epSelector.select(ssHost);
  Answer answer = null;

代码示例来源:origin: apache/cloudstack

DataStoreTO storTO = store.getTO();
DataObject srcData = snapObj;
try {

代码示例来源:origin: apache/cloudstack

public TemplateObjectTO(TemplateInfo template) {
  this.path = template.getInstallPath();
  this.uuid = template.getUuid();
  this.id = template.getId();
  this.origUrl = template.getUrl();
  this.displayText = template.getDisplayText();
  this.checksum = template.getChecksum();
  this.hvm = template.isRequiresHvm();
  this.accountId = template.getAccountId();
  this.name = template.getUniqueName();
  this.format = template.getFormat();
  this.uniqueName = template.getUniqueName();
  this.size = template.getSize();
  if (template.getDataStore() != null) {
    this.imageDataStore = template.getDataStore().getTO();
  }
  this.hypervisorType = template.getHypervisorType();
}

代码示例来源:origin: apache/cloudstack

tmplTO.setDataStore(store.getTO());
tmplTO.setPath(tInfo.getInstallPath());
tmplTO.setId(tInfo.getId());

代码示例来源:origin: apache/cloudstack

tmplTO.setDataStore(store.getTO());
tmplTO.setPath(tInfo.getInstallPath());
tmplTO.setId(tInfo.getId());

代码示例来源:origin: apache/cloudstack

@Override
public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
  Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
  VirtualMachineTemplate tmpl = _templateDao.findById(data.getId());
  DataStore cacheStore = cacheManager.getCacheStorage(dataStore.getScope());
  DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(data.getTO()), maxTemplateSizeInBytes);
  dcmd.setCacheStore(cacheStore.getTO());
  dcmd.setProxy(getHttpProxy());
  EndPoint ep = _epSelector.select(data);
  if (ep == null) {
    String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
    s_logger.error(errMsg);
    throw new CloudRuntimeException(errMsg);
  }
  CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
  AsyncCallbackDispatcher<SwiftImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher.create(this);
  caller.setContext(context);
  if (data.getType() == DataObjectType.TEMPLATE) {
    caller.setCallback(caller.getTarget().createTemplateAsyncCallback(null, null));
  } else if (data.getType() == DataObjectType.VOLUME) {
    caller.setCallback(caller.getTarget().createVolumeAsyncCallback(null, null));
  }
  ep.sendMessageAsync(dcmd, caller);
}

代码示例来源:origin: apache/cloudstack

public VolumeObjectTO(VolumeInfo volume) {
  uuid = volume.getUuid();
  path = volume.getPath();
  accountId = volume.getAccountId();
  if (volume.getDataStore() != null) {
    dataStore = volume.getDataStore().getTO();
  } else {
    dataStore = null;
  }
  vmName = volume.getAttachedVmName();
  size = volume.getSize();
  setVolumeId(volume.getId());
  chainInfo = volume.getChainInfo();
  volumeType = volume.getVolumeType();
  name = volume.getName();
  setId(volume.getId());
  format = volume.getFormat();
  provisioningType = volume.getProvisioningType();
  bytesReadRate = volume.getBytesReadRate();
  bytesWriteRate = volume.getBytesWriteRate();
  iopsReadRate = volume.getIopsReadRate();
  iopsWriteRate = volume.getIopsWriteRate();
  cacheMode = volume.getCacheMode();
  hypervisorType = volume.getHypervisorType();
  setDeviceId(volume.getDeviceId());
}

代码示例来源:origin: apache/cloudstack

TemplateConstants.DEFAULT_TMPLT_ROOT_DIR + "/" + TemplateConstants.DEFAULT_TMPLT_FIRST_LEVEL_DIR +
    templateDao.findById(obj.getId()).getAccountId() + "/" + obj.getId();
if (dataStore.getTO() instanceof S3TO) {
  TemplateInfo tmpl = (TemplateInfo)obj;
  installPath += "/" + tmpl.getUniqueName(); // for S3, we

相关文章