Package org.jclouds.trmk.vcloud_0_8.domain

Examples of org.jclouds.trmk.vcloud_0_8.domain.IpAddress


   @Override
   public Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIp(VApp vApp, int port, Protocol protocol) {
      logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getHref(), protocol, port);
      InternetService is = null;
      PublicIpAddress ip = null;
      try {
         ip = client.activatePublicIpInVDC(vApp.getVDC().getHref());
      } catch (InsufficientResourcesException e) {
         logger.warn(">> no more ip addresses available, looking for one to re-use");
         Set<PublicIpAddress> publicIps = client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref());
         for (PublicIpAddress existingIp : publicIps) {
            Set<InternetService> services = client.getInternetServicesOnPublicIp(existingIp.getId());
            if (services.size() == 0) {
               ip = existingIp;
               break;
            }
         }
         if (ip == null)
            throw new InsufficientResourcesException(
                     "no more ip addresses available and existing ips all have services attached: " + publicIps, e
                              .getCause());
      }
      is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port,
               withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(), vApp
                        .getName())));
      Map<InternetService, PublicIpAddress> result = ImmutableMap.<InternetService, PublicIpAddress> of(is, ip);
      Entry<InternetService, PublicIpAddress> entry = Iterables.getOnlyElement(result.entrySet());
      return entry;
View Full Code Here


   public void endElement(String uri, String name, String qName) {
      depth--;
      if (equalsOrSuffix(qName, "PublicIpAddress")) {
         inPublicIpAddress = false;
         publicIpAddress = new PublicIpAddress(address, addressLocation);
         address = null;
         addressLocation = null;
      } else {
         String value = currentOrNull(currentText);
         if (value != null && !value.equals("")) {
View Full Code Here

      super(orgVDCMap, defaultOrg, defaultVDC);
   }

   protected URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource,
         org.jclouds.trmk.vcloud_0_8.domain.VDC vDCObject) {
      ReferenceType resourceEntity = vDCObject.getResourceEntities().get(resource);
      if (resourceEntity == null)
         throw new NoSuchElementException("entity " + resource + " in vdc " + vDC + ", org " + org + " not found in "
               + vDCObject.getResourceEntities().keySet());
      return resourceEntity.getHref();
   }
View Full Code Here

      super(orgVDCMap, defaultOrg, defaultVDC);
   }

   protected URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource,
         org.jclouds.trmk.vcloud_0_8.domain.VDC vDCObject) {
      ReferenceType resourceEntity = vDCObject.getAvailableNetworks().get(resource);
      if (resourceEntity == null)
         throw new NoSuchElementException("network " + resource + " in vdc " + vDC + ", org " + org + " not found in "
               + vDCObject.getAvailableNetworks().keySet());
      return resourceEntity.getHref();
   }
View Full Code Here

   }

   public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
      Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
      if (qName.equals("VApp")) {
         ReferenceType resource = newReferenceType(attributes);
         name = resource.getName();
         location = resource.getHref();
         String statusString = attributes.get("status");
         status = Status.fromValue(statusString);
         if (attributes.containsKey("size"))
            size = Long.valueOf(attributes.get("size"));
      } else if (qName.equals("Link")) { // type should never be missing
View Full Code Here

   }

   public void testTerremark() {
      InputStream is = getClass().getResourceAsStream("/task.xml");

      Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
      Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), null,
            TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
            dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1",
                  TerremarkVCloudMediaType.VAPP_XML,
                  URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null
View Full Code Here

   }

   public void testSelf() {
      InputStream is = getClass().getResourceAsStream("/task-self.xml");

      Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);

      Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), null,
            TaskStatus.QUEUED, null, null, null, null, null);
      assertEquals(result, expects);

   }
View Full Code Here

   }

   public void testError() {
      InputStream is = getClass().getResourceAsStream("/task-error.xml");

      Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);

      Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), null, TaskStatus.ERROR,
            dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"),
            dateService.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1",
                  TerremarkVCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), new ErrorImpl(
                  "Error processing job", 500, MinorCode.UNRECOGNIZED,
                  " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00", null));
View Full Code Here

   }

   public boolean apply(URI taskId) {
      logger.trace("looking for status on task %s", taskId);

      Task task = client.getTask(taskId);
      // perhaps task isn't available, yet
      if (task == null)
         return false;
      logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task.getStatus());
      if (task.getStatus() == TaskStatus.ERROR)
         throw new RuntimeException("error on task: " + task.getHref() + " error: " + task.getError());
      return task.getStatus() == TaskStatus.SUCCESS;
   }
View Full Code Here

   }

   public void testInstantiated() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/instantiatedvapp.xml");

      VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);

      VApp expects = new VAppImpl("centos53", URI
               .create("http://10.150.4.49/api/v0.8/vApp/10"), Status.RESOLVED, 123456789l, new ReferenceTypeImpl(null,
               "application/vnd.vmware.vcloud.vdc+xml", URI.create("http://10.150.4.49/api/v0.8/vdc/4")),
               ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet
                        .<ResourceAllocationSettingData> of());
      assertEquals(result, expects);
View Full Code Here

TOP

Related Classes of org.jclouds.trmk.vcloud_0_8.domain.IpAddress

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.