本文整理了Java中io.cattle.platform.core.model.Instance.getImageId()
方法的一些代码示例,展示了Instance.getImageId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getImageId()
方法的具体详情如下:
包路径:io.cattle.platform.core.model.Instance
类名称:Instance
方法名:getImageId
[英]Getter for cattle.instance.image_id
.
[中]cattle.instance.image_id
的Getter。
代码示例来源: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 Map<String, Object> populateInstance(IdFormatter idFormatter, Instance instance, Network network) {
Map<String, Object> data = new HashMap<String, Object>();
data.put("ami-id", formatId(idFormatter, Image.class, instance.getImageId()));
data.put("ami-manifest-path", "(unknown)");
data.put("instance-action", "none");
data.put("instance-id", "i-" + formatId(idFormatter, instance));
data.put("instance-type", getInstanceType(instance));
data.put("kernel-id", formatId(idFormatter, instance));
setNestedValue(data, getZone(idFormatter, instance), "placement", "availability-zone");
// TODO don't really know what values are valid here
data.put("profile", "default-paravirtual");
data.put("ami-launch-index", instance.getCreateIndex());
// TODO don't have a concept of reservations
data.put("reservation-id", formatId(idFormatter, instance));
return data;
}
代码示例来源:origin: rancher/cattle
@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
Instance instance = (Instance)state.getResource();
if (!InstanceConstants.CONTAINER_LIKE.contains(instance.getKind())) {
return null;
}
Image image = objectManager.loadResource(Image.class, instance.getImageId());
if (image == null) {
return null;
}
DockerBuild build = DataAccessor.field(instance, DockerInstanceConstants.FIELD_BUILD,
jsonMapper, DockerBuild.class);
if (build == null) {
return null;
}
String imageUuid = DataAccessor.fieldString(instance, InstanceConstants.FIELD_IMAGE_UUID);
if (imageUuid != null) {
String tag = StringUtils.removeStart(imageUuid, "docker:");
build.setTag(tag);
}
objectManager.setFields(image, DockerInstanceConstants.FIELD_BUILD, build);
return null;
}
}
代码示例来源:origin: rancher/cattle
@Override
public Object create(String type, ApiRequest request, ResourceManager next) {
Instance container = request.proxyRequestObject(Instance.class);
if (REQUIRE_INSTANCE_IMAGE.get()) {
Long imageId = container.getImageId();
String imageUuid = DataUtils.getFieldFromRequest(request, InstanceConstants.FIELD_IMAGE_UUID, String.class);
if (imageId == null && imageUuid == null) {
throw new ValidationErrorException(ValidationErrorCodes.MISSING_REQUIRED, InstanceConstants.FIELD_IMAGE_UUID,
"image is required, but not specified");
}
}
Long imageId = container.getImageId();
Image image = getObjectManager().loadResource(Image.class, imageId);
if (image != null && image.getInstanceKind() != null) {
if (!image.getInstanceKind().equals(type)) {
throw new ClientVisibleException(ResponseCodes.UNPROCESSABLE_ENTITY, "InvalidImageInstanceKind");
}
}
return super.create(type, request, next);
}
代码示例来源:origin: rancher/cattle
Image image = objectManager.loadResource(Image.class, instance.getImageId());
if (image == null) {
dockerStorageDao.createImageForInstance(instance);
代码示例来源:origin: stackoverflow.com
/**
* Returns a list with the public IPs of all the active instances, which are
* returned by the {@link #getActiveInstances()} method.
*
* @return a list with the public IPs of all the active instances.
* @see #getActiveInstances()
* */
public List<String> getPublicIPs(){
List<String> publicIpsList = new LinkedList<String>();
//if there are no active instances, we return immediately to avoid extra
//computations.
if(!areAnyActive())
return publicIpsList;
DescribeInstancesRequest request = new DescribeInstancesRequest();
request.setInstanceIds(instanceIds);
DescribeInstancesResult result = ec2.describeInstances(request);
List<Reservation> reservations = result.getReservations();
List<Instance> instances;
for(Reservation res : reservations){
instances = res.getInstances();
for(Instance ins : instances){
LOG.info("PublicIP from " + ins.getImageId() + " is " + ins.getPublicIpAddress());
publicIpsList.add(ins.getPublicIpAddress());
}
}
return publicIpsList;
}
代码示例来源:origin: rancher/cattle
@Override
public Image createImageForInstance(Instance instance) {
String uuid = (String) DataAccessor.fields(instance).withKey(InstanceConstants.FIELD_IMAGE_UUID).get();
Image image = storageService.registerRemoteImage(uuid);
if (image != null) {
objectManager.setFields(instance, INSTANCE.IMAGE_ID, image.getId());
long currentAccount = instance.getAccountId();
Long id = instance.getRegistryCredentialId();
image = objectManager.loadResource(Image.class, instance.getImageId());
if (id == null) {
for (ImageCredentialLookup imageLookup: imageCredentialLookups){
Credential cred = imageLookup.getDefaultCredential(uuid, currentAccount);
if (cred == null){
continue;
}
if (cred.getId() != null){
objectManager.setFields(instance, INSTANCE.REGISTRY_CREDENTIAL_ID, cred.getId());
break;
}
}
}
if (instance.getRegistryCredentialId() != null) {
objectManager.setFields(image, IMAGE.REGISTRY_CREDENTIAL_ID, instance.getRegistryCredentialId());
}
}
return image;
}
代码示例来源:origin: rancher/cattle
setCompute(from.getCompute());
setMemoryMb(from.getMemoryMb());
setImageId(from.getImageId());
setHostname(from.getHostname());
setZoneId(from.getZoneId());
内容来源于网络,如有侵权,请联系作者删除!