Package org.jclouds.openstack.v2_0.domain

Examples of org.jclouds.openstack.v2_0.domain.Link


        String.format(OBJ_FIELD_REQ, MEDIA, "files"));
    assertEquals(1, keyPairsContainer.getFiles().size(), String.format(
        OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, keyPairsContainer
            .getFiles().size()));

    Link uploadLink = getUploadLinkForMedia(keyPairsContainer);
    // generate an empty iso
    byte[] iso = new byte[] {};
    context.getApi()
        .getUploadApi()
        .upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));

    Checks.checkMediaFor(VCloudDirectorMediaType.MEDIA, keyPairsContainer);
    setKeyPairOnkeyPairsContainer(keyPairsContainer, keyPairName, generateKeyPair(keyPairName));

    return keyPairsContainer;
View Full Code Here


    assertTrue(Iterables.all(links, Predicates.or(
        LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT),
        LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))),
        String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first"));

    Link uploadLink = Iterables.find(links,
        LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT));
    return uploadLink;
  }
View Full Code Here

        LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT));
    return uploadLink;
  }

  private Media addEmptyMediaInVDC(Vdc currentVDC, String keyPairName) {
    Link addMedia = find(
        currentVDC.getLinks(),
        and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)));

    Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA)
        .name(keyPairName).size(0).imageType(Media.ImageType.ISO)
        .description("iso generated as KeyPair bucket").build();

    Media emptyMedia = mediaApi.add(addMedia.getHref(), sourceMedia);
    Checks.checkMediaFor(MEDIA, emptyMedia);
    return emptyMedia;
  }
View Full Code Here

   protected Media lazyGetMedia(){
      if (media == null || mediaUrn == null) {
         Predicate<Link> addMediaLink = and(relEquals(Link.Rel.ADD), typeEquals(VCloudDirectorMediaType.MEDIA));
         if (contains(lazyGetVdc().getLinks(), addMediaLink)) {
            Link addMedia = find(lazyGetVdc().getLinks(), addMediaLink);
            byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

            Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name(name("media"))
                     .size(iso.length).imageType(Media.ImageType.ISO)
                     .description("Test media generated by VmApiLiveTest").build();
            media = context.getApi().getMediaApi().add(addMedia.getHref(), sourceMedia);

            Link uploadLink = getFirst(getFirst(media.getFiles(), null).getLinks(), null);
            context.getApi().getUploadApi().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));

            media = context.getApi().getMediaApi().get(media.getId());

            if (media.getTasks().size() == 1) {
               Task uploadTask = Iterables.getOnlyElement(media.getTasks());
View Full Code Here

   }

   @Test(description = "POST /vdc/{id}/media")
   public void testAddMedia() throws URISyntaxException {
      Vdc vdc = lazyGetVdc();
      Link addMedia = find(vdc.getLinks(), and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)));

      // TODO: generate an iso
      byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

      Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name("Test media " + random.nextInt())
               .size(iso.length).imageType(Media.ImageType.ISO).description("Test media generated by testAddMedia()")
               .build();
      media = mediaApi.add(addMedia.getHref(), sourceMedia);

      Checks.checkMediaFor(MEDIA, media);

      assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files"));
      assertEquals(1, media.getFiles().size(),
               String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size()));
      File uploadFile = getFirst(media.getFiles(), null);
      assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first"));
      assertEquals(uploadFile.getSize(), Long.valueOf(iso.length));
      assertEquals(uploadFile.getSize().longValue(), sourceMedia.getSize(),
               String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize()));

      Set<Link> links = uploadFile.getLinks();
      assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links"));
      assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size()));
      assertTrue(
               Iterables.all(
                        links,
                        Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT),
                                 LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))),
               String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first"));

      Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT));
      context.getApi().getUploadApi().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));

      media = mediaApi.get(media.getId());
      if (media.getTasks().size() == 1) {
         Task uploadTask = Iterables.getOnlyElement(media.getTasks());
         Checks.checkTask(uploadTask);
View Full Code Here

      api.getNetworkConfigSection(uri);
   }

   private VAppTemplate exampleTemplate() {
      Link aLink = Link.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"))
            .type("application/vnd.vmware.vcloud.vdc+xml").rel("up").build();
      Link bLink = Link.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"))
            .rel("remove").build();

      Owner owner = Owner.builder().type("application/vnd.vmware.vcloud.owner+xml").user(Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69")).name("x@jclouds.org").type("application/vnd.vmware.admin.user+xml").build()).build();

      LeaseSettingsSection leaseSettings = LeaseSettingsSection.builder().type("application/vnd.vmware.vcloud.leaseSettingsSection+xml")
View Full Code Here

      if (ovf.getVirtualSystem().getVirtualHardwareSections().size() > 1) {
         logger.warn("multiple hardware choices found. using first", ovf);
      }
      VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0);
      HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
      Link vdc = Iterables.find(checkNotNull(from, "from").getLinks(), LinkPredicates.typeEquals(VCloudDirectorMediaType.VDC));
      if (vdc != null) {
         builder.location(findLocationForResource.apply(vdc));
      } else {
         // otherwise, it could be in a public catalog, which is not assigned to a VDC
      }
View Full Code Here

      ImageBuilder builder = new ImageBuilder();
      builder.ids(from.getHref().toASCIIString());
      builder.uri(from.getHref());
      builder.name(from.getName());
      Link vdc = Iterables.find(checkNotNull(from, "from").getLinks(), LinkPredicates.typeEquals(VCloudDirectorMediaType.VDC));
      if (vdc != null) {
         builder.location(findLocationForResource.apply(vdc));
      } else {
         // otherwise, it could be in a public catalog, which is not assigned to a VDC
      }
View Full Code Here

   }

   @Test(description = "POST /vdc/{id}/media")
   public void testAddMedia() throws URISyntaxException {
      Vdc vdc = lazyGetVdc();
      Link addMedia = find(vdc.getLinks(), and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)));

      // TODO: generate an iso
      byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

      Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name("Test media " + random.nextInt())
               .size(iso.length).imageType(Media.ImageType.ISO).description("Test media generated by testAddMedia()")
               .build();
      media = mediaApi.add(addMedia.getHref(), sourceMedia);

      Checks.checkMediaFor(MEDIA, media);

      assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files"));
      assertEquals(1, media.getFiles().size(),
               String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size()));
      File uploadFile = getFirst(media.getFiles(), null);
      assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first"));
      assertEquals(uploadFile.getSize(), Long.valueOf(iso.length));
      assertEquals(uploadFile.getSize().longValue(), sourceMedia.getSize(),
               String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize()));

      Set<Link> links = uploadFile.getLinks();
      assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links"));
      assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size()));
      assertTrue(
               Iterables.all(
                        links,
                        Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT),
                                 LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))),
               String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first"));

      Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT));
      context.getApi().getUploadApi().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));

      media = mediaApi.get(media.getId());
      if (media.getTasks().size() == 1) {
         Task uploadTask = Iterables.getOnlyElement(media.getTasks());
         Checks.checkTask(uploadTask);
View Full Code Here

   protected Media lazyGetMedia(){
      if (media == null || mediaUrn == null) {
         Predicate<Link> addMediaLink = and(relEquals(Link.Rel.ADD), typeEquals(VCloudDirectorMediaType.MEDIA));
         if (contains(lazyGetVdc().getLinks(), addMediaLink)) {
            Link addMedia = find(lazyGetVdc().getLinks(), addMediaLink);
            byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

            Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name(name("media"))
                     .size(iso.length).imageType(Media.ImageType.ISO)
                     .description("Test media generated by VmApiLiveTest").build();
            media = context.getApi().getMediaApi().add(addMedia.getHref(), sourceMedia);

            Link uploadLink = getFirst(getFirst(media.getFiles(), null).getLinks(), null);
            context.getApi().getUploadApi().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));

            media = context.getApi().getMediaApi().get(media.getId());

            if (media.getTasks().size() == 1) {
               Task uploadTask = Iterables.getOnlyElement(media.getTasks());
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.v2_0.domain.Link

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.