Package org.openstack.client.common

Examples of org.openstack.client.common.OpenstackImageClient


    }
  }

  public ImageStore getImageStore(OpenstackCloud cloud) throws OpsException {
    OpenstackCloudHelpers helpers = new OpenstackCloudHelpers();
    OpenstackImageClient openstackImageClient = helpers.buildOpenstackImageClient(cloud);

    return new GlanceImageStore(openstackImageClient);
  }
View Full Code Here


    this.openstackImageClient = openstackImageClient;
  }

  @Override
  public String uploadImage(OpsTarget target, Tags tags, File imageFile, long rawImageFileSize) throws OpsException {
    OpenstackImageClient client = getOpenstackImageClient();

    String diskFormat = null;
    if (tags != null) {
      assert false; // This logic looks suspicious...
      for (Tag tag : tags.getTags()) {
        ImageFormat imageFormat = ImageFormat.fromTags(tags);
        diskFormat = mapToGlanceDiskFormat(imageFormat);
      }
    }

    String glanceBaseUrl;
    String tokenId;

    try {
      Access access = client.getSession().getAuthenticationToken();
      tokenId = access.getToken().getId();
      glanceBaseUrl = client.root().getBaseUrl();
    } catch (OpenstackException e) {
      throw new OpsException("Error getting glance url", e);
    }

    // Upload to glance
View Full Code Here

    return openstackImageClient;
  }

  @Override
  public void updateImageTags(String imageId, Tags tags) throws OpsException {
    OpenstackImageClient glanceClient = getOpenstackImageClient();

    boolean replace = false;
    try {
      Map<String, Object> tagMap = Maps.newHashMap();
      for (Tag tag : tags.getTags()) {
        tagMap.put(tag.getKey(), tag.getValue());
      }
      glanceClient.root().images().image(imageId).updateMetadata(tagMap, replace);
    } catch (OpenstackException e) {
      throw new OpsException("Error updating image tags", e);
    }
  }
View Full Code Here

  @Override
  public List<CloudImage> findImages(List<Tag> tags) throws OpsException {
    List<CloudImage> matches = Lists.newArrayList();

    OpenstackImageClient glanceClient = getOpenstackImageClient();

    Iterable<Image> images;
    try {
      images = glanceClient.root().images().list(true);
    } catch (OpenstackException e) {
      throw new OpsException("Error listing images", e);
    }

    for (Image image : images) {
View Full Code Here

TOP

Related Classes of org.openstack.client.common.OpenstackImageClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.