• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Image类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openstack4j.model.image.Image的典型用法代码示例。如果您正苦于以下问题:Java Image类的具体用法?Java Image怎么用?Java Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Image类属于org.openstack4j.model.image包,在下文中一共展示了Image类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: downloadImage

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static boolean downloadImage(String imageId, String downloadLocation, String name) throws Exception{
    OSClient os=Osp4jSession.getOspSession();
    ImageService imgService= os.images();
    imageId=takeFromMemory(GlanceKey.IMAGE_ID, imageId);
    Image image=imgService.get(imageId);
    if(image!=null){
        System.out.println("image info: "+image.toString());
        InputStream is =imgService.getAsStream(imageId);
        if(is!=null){
            try{
                return writer_v1(downloadLocation, name, is);
            }catch(Exception e){
                e.printStackTrace();
                System.err.println("Exception : "+e.getMessage());
                return false;
            }
        }else{
            System.err.println("Download error.. inputstream is null");
            return false;
        }
    }else{
        System.err.println("Image with ID "+imageId+" not found!");
        return false;
    }
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:26,代码来源:CommonAPI.java


示例2: imageCreate

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static Image imageCreate(String imagePath, String name) throws IOException {
  OSClient os=Osp4jSession.getOspSession();
  Image image = os.images().reserve(Builders.image().name(name).build());
  File file = new File(imagePath);
  final Payload<File> payload = Payloads.create(file);
  image = image.toBuilder().containerFormat(ContainerFormat.BARE).diskFormat(DiskFormat.QCOW2).build();
  try{
      image= os.images().upload(image.getId(), payload, image);   
  }catch(MessageBodyProviderNotFoundException e){
      image=os.images().get(image.getId());
      if(image.getStatus().equals(Image.Status.ACTIVE) && file.length()==image.getSize()){
          //success
      }else{
          System.out.println("Upload failed!");
          return image;
      }
  }
  System.out.println("Upload success!");
  CommonAPI.addToMemory(GlanceKey.IMAGE_ID, image.getId());
  return image;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:22,代码来源:GlanceAPI.java


示例3: reserveGlanceImage

import org.openstack4j.model.image.Image; //导入依赖的package包/类
@Test
public void reserveGlanceImage() throws Exception {
    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());

    GlanceEndpoint endpoint = Mockito.mock(GlanceEndpoint.class);
    when(endpoint.getOperation()).thenReturn(GlanceConstants.RESERVE);

    Message msg = new DefaultMessage(camelContext);
    msg.setBody(dummyImage);

    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);

    Producer producer = new GlanceProducer(endpoint, client);
    producer.process(exchange);
    ArgumentCaptor<Image> captor = ArgumentCaptor.forClass(Image.class);
    verify(imageService).reserve(captor.capture());
    assertEquals(dummyImage, captor.getValue());

    Image result = msg.getBody(Image.class);
    assertNotNull(result.getId());
    assertEqualsImages(dummyImage, result);
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:25,代码来源:OpenstackIntegrationTest.java


示例4: deleteAllImages

import org.openstack4j.model.image.Image; //导入依赖的package包/类
/**
 * @author viborole
 */
public static void deleteAllImages() throws Exception {
    List<? extends Image> images = GlanceAPI.imageList();
    System.out.println("Total number of Images found "+images.size());
    System.out.println("Deleting Non-Public Images only..");
    for(Image image: images){
        if(!image.isPublic())
            GlanceAPI.delete(image.getId());
    }
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:13,代码来源:TenantAPI.java


示例5: monitorImageUpload

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static boolean monitorImageUpload(final String imageId) throws Exception {
    boolean isActive = false;
    final Image Img = Osp4jSession.getOspSession().images().get(imageId);
    while (!isActive) {
        isActive = isImageActive(Osp4jSession.getOspSession(), imageId);
    }
    return isActive;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:9,代码来源:GlanceAPI.java


示例6: isImageActive

import org.openstack4j.model.image.Image; //导入依赖的package包/类
private static boolean isImageActive(OSClient os, final String imageId) throws Exception {
    final Image Img = os.images().get(imageId);
    Image.Status status = Img.getStatus();
    System.out.println("current Image status: "+status.toString());
    if ((Image.Status.ACTIVE.equals(status))) {
        return true;
    } else {
        Thread.sleep(10000);
    }
    return false;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:12,代码来源:GlanceAPI.java


示例7: printImagesDetails

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static void printImagesDetails(List<? extends Image> images){
    TableBuilder tb=getImageTableBuilder();
    for (final Image image : images ) {
        addImageRow(tb,image);
    }
    System.out.println(tb.toString());
    System.out.println("TOTAL RECORDS: "+tb.totalrecords());
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:9,代码来源:GlanceAPI.java


示例8: addImageRow

import org.openstack4j.model.image.Image; //导入依赖的package包/类
private static void addImageRow(TableBuilder tb,Image image){
    String id = image.getId();
    String name = image.getName();
    String status = image.getStatus()!=null?image.getStatus().toString():"NA";
    String readableFileSize = readableFileSize(image.getSize()!=null?image.getSize():0l);
    String containerFormat = image.getContainerFormat()!=null?image.getContainerFormat().toString():"NA";
    String isPublic = String.valueOf(image.isPublic());
    tb.addRow(id,name,status,readableFileSize,containerFormat,isPublic);
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:10,代码来源:GlanceAPI.java


示例9: getListOfImages

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public List<SelectItem> getListOfImages() {
    // Get all images from Glance the current account making the request has access to
    List<? extends Image> images = osClient.images().list();

    List<SelectItem> imageList = new ArrayList<SelectItem>();
    for (Image image: images) {
        imageList.add (new SelectItem(image.getName(), image.getId()));
    }
    return imageList;
}
 
开发者ID:foundation-runtime,项目名称:jenkins-openstack-deployment-plugin,代码行数:11,代码来源:OpenStack4jClient.java


示例10: run

import org.openstack4j.model.image.Image; //导入依赖的package包/类
@Override
protected void run(JavaSamplerContext context) throws Exception {
	String uploadImage = context.getParameter(ExampleParameter.GLANCE_UPLOAD_IMAGE.name());
	int readTimeout = context.getIntParameter(ExampleParameter.GLANCE_READ_TIMEOUT.name());

	String imageName = OpenstackUtil.generateName();

	log.debug("uploading image " + uploadImage);
	Payload<File> payload = Payloads.create(new File(uploadImage));
	Image image = os.images().create(
			Builders.image().name(imageName).isPublic(true).containerFormat(ContainerFormat.BARE)
					.diskFormat(DiskFormat.QCOW2).build(), payload);

	int waited = 0;
	String imageId = image.getId();
	image = null;
	while (waited < readTimeout) {
		image = os.images().get(imageId);
		if (image != null)
			break;
		log.debug("waiting for image " + uploadImage);
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {
			break;
		}
	}

	log.debug("deleting image " + imageName);
	logIfError(os.images().delete(imageId));

	if (image == null)
		throw new OpenstackException("image " + uploadImage + " read failed");
}
 
开发者ID:savoirfairelinux,项目名称:jmeter-openstack,代码行数:35,代码来源:GlanceSampler.java


示例11: deleteGlanceImages

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static void deleteGlanceImages(OSClient os) {
	Map<String, String> filter = new HashMap<String, String>();

	filter.put("name", "^" + OpenstackUtil.NAME_PREFIX + "*");
	for (Image images : os.images().list(filter))
		logIfError(os.images().delete(images.getId()));
}
 
开发者ID:savoirfairelinux,项目名称:jmeter-openstack,代码行数:8,代码来源:OpenstackTearDownUtil.java


示例12: verifyImage

import org.openstack4j.model.image.Image; //导入依赖的package包/类
private void verifyImage(OSClient osClient, String name) {
    List<? extends Image> images = osClient.images().listAll();
    for (Image image : images) {
        LOGGER.debug("Found image: {}", image.getName());
        if (name.equalsIgnoreCase(image.getName())) {
            return;
        }
    }
    throw new CloudConnectorException(String.format("OpenStack image: %s not found", name));
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:11,代码来源:OpenStackSetup.java


示例13: assertEqualsImages

import org.openstack4j.model.image.Image; //导入依赖的package包/类
private void assertEqualsImages(Image original, Image newImage) {
    assertEquals(original.getContainerFormat(), newImage.getContainerFormat());
    assertEquals(original.getDiskFormat(), newImage.getDiskFormat());
    assertEquals(original.getChecksum(), newImage.getChecksum());
    assertEquals(original.getMinDisk(), newImage.getMinDisk());
    assertEquals(original.getMinRam(), newImage.getMinRam());
    assertEquals(original.getOwner(), newImage.getOwner());
    assertEquals(original.getName(), newImage.getName());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:10,代码来源:OpenstackIntegrationTest.java


示例14: list

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public List<? extends Image> list() {
	return client().images().list();
}
 
开发者ID:evoila,项目名称:cfsummiteu2017,代码行数:4,代码来源:GlanceFluent.java


示例15: get

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public Image get(String imageId) {
	return client().images().get(imageId);
}
 
开发者ID:evoila,项目名称:cfsummiteu2017,代码行数:4,代码来源:GlanceFluent.java


示例16: getImageDetail

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static Image getImageDetail(String imageId) throws Exception{
    imageId=CommonAPI.takeFromMemory(GlanceKey.IMAGE_ID,imageId);
    OSClient os=Osp4jSession.getOspSession();
    return os.images().get(imageId);
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:6,代码来源:GlanceAPI.java


示例17: imageList

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static List<? extends Image> imageList() throws Exception{
    OSClient os=Osp4jSession.getOspSession();
    final List<? extends Image> images = os.images().list();
    return images;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:6,代码来源:GlanceAPI.java


示例18: printImageDetails

import org.openstack4j.model.image.Image; //导入依赖的package包/类
public static void printImageDetails(Image image){
    TableBuilder tb = getImageTableBuilder();
    addImageRow(tb,image);
    System.out.println(tb.toString());
    System.out.println("TOTAL RECORDS: "+tb.totalrecords());
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:7,代码来源:GlanceAPI.java


示例19: listImages

import org.openstack4j.model.image.Image; //导入依赖的package包/类
@Override
public List<? extends org.openstack4j.model.image.Image> listImages() {
    return api.images().listAll();
}
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:5,代码来源:ApiProviderImpl.java


示例20: getImageById

import org.openstack4j.model.image.Image; //导入依赖的package包/类
@Override
public Optional<Image> getImageById(String imageId) {
    return Optional.ofNullable(api.images().get(imageId));
}
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:5,代码来源:ApiProviderImpl.java



注:本文中的org.openstack4j.model.image.Image类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlockReaderTestUtil类代码示例发布时间:2022-05-23
下一篇:
Java AFamilyDescriptor类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap