io.cattle.platform.core.model.Volume.getDeviceNumber()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(94)

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

Volume.getDeviceNumber介绍

[英]Getter for cattle.volume.device_number.
[中][$0$]的Getter。

代码示例

代码示例来源:origin: rancher/cattle

protected void populateVolume(Map<String, Object> instanceMetadata, Instance instance, Volume volume) {
  if (volume == null) {
    return;
  }
  Integer deviceNumber = volume.getDeviceNumber();
  if (deviceNumber == null) {
    return;
  }
  char index = (char) ('a' + deviceNumber.intValue());
  if (deviceNumber == 0) {
    setNestedValue(instanceMetadata, String.format("/dev/sd%s", index), "block-device-mapping", "ami");
    setNestedValue(instanceMetadata, String.format("/dev/sd%s1", index), "block-device-mapping", "root");
  } else {
    setNestedValue(instanceMetadata, "sd" + index, "block-device-mapping", "ebs" + (deviceNumber + 1));
  }
  // TODO do something about swap and ephemeral
}

代码示例来源:origin: rancher/cattle

protected Volume getRoot(Instance instance, List<Volume> volumes) {
  if (instance.getImageId() == null) {
    return null;
  }
  for (Volume volume : volumes) {
    if (volume.getDeviceNumber() != null && volume.getDeviceNumber().intValue() == 0) {
      return volume;
    }
  }
  return objectManager.create(Volume.class, VOLUME.ACCOUNT_ID, instance.getAccountId(), VOLUME.INSTANCE_ID, instance.getId(), VOLUME.IMAGE_ID, instance
      .getImageId(), VOLUME.DEVICE_NUMBER, 0, VOLUME.ATTACHED_STATE, CommonStatesConstants.ACTIVE);
}

代码示例来源:origin: rancher/cattle

protected void storage(Instance instance, Map<String, Object> data) {
  List<Volume> volumes = getObjectManager().children(instance, Volume.class);
  for (Volume volume : volumes) {
    if (volume.getDeviceNumber() == 0) {
      remove(volume, data);
    } else {
      execute("volume.detach", volume, null);
    }
  }
  Map<Object, Object> criteria = new HashMap<Object, Object>();
  criteria.put(MOUNT.REMOVED, new Condition(ConditionType.NULL));
  criteria.put(MOUNT.STATE, new Condition(ConditionType.NOTIN, MountDeactivate.MOUNT_STATES));
  criteria.put(MOUNT.INSTANCE_ID, instance.getId());
  List<Mount> mounts = getObjectManager().find(Mount.class, criteria);
  for (Mount mount : mounts) {
    objectProcessManager.scheduleStandardProcess(StandardProcess.DEACTIVATE, mount, data);
  }
}

代码示例来源:origin: rancher/cattle

@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  Volume volume = (Volume) state.getResource();
  String driver = DataAccessor.fieldString(volume, VolumeConstants.FIELD_VOLUME_DRIVER);
  Long driverId = volume.getStorageDriverId();
  Integer deviceNum = volume.getDeviceNumber();
  StorageDriver storageDriver = objectManager.loadResource(StorageDriver.class, driverId);
  if (storageDriver == null && StringUtils.isNotBlank(driver)) {
    storageDriver = objectManager.findAny(StorageDriver.class,
        STORAGE_DRIVER.ACCOUNT_ID, volume.getAccountId(),
        STORAGE_DRIVER.REMOVED, null,
        STORAGE_DRIVER.NAME, driver);
  }
  if (storageDriver != null) {
    driver = storageDriver.getName();
    driverId = storageDriver.getId();
    deviceNum = -1;
  }
  HandlerResult result = new HandlerResult(VolumeConstants.FIELD_VOLUME_DRIVER, driver,
      VOLUME.DEVICE_NUMBER, deviceNum,
      VOLUME.STORAGE_DRIVER_ID, driverId);
  Long hostId = volume.getHostId();
  if (storageDriver != null && hostId != null) {
    if (storagePoolDao.associateVolumeToPool(volume.getId(), storageDriver.getId(), hostId) != null) {
      result.withShouldContinue(false)
      .withChainProcessName(objectProcessManager.getStandardProcessName(StandardProcess.DEACTIVATE, volume));
    }
  }
  return result;
}

代码示例来源:origin: rancher/cattle

setPhysicalSizeMb(from.getPhysicalSizeMb());
setVirtualSizeMb(from.getVirtualSizeMb());
setDeviceNumber(from.getDeviceNumber());
setFormat(from.getFormat());
setAllocationState(from.getAllocationState());

相关文章