Package org.jclouds.abiquo.domain.cloud

Examples of org.jclouds.abiquo.domain.cloud.VirtualDatacenter


      // Load the template
      VirtualMachineTemplate virtualMachineTemplate = enterprise.getTemplateInRepository(datacenter,
            Integer.valueOf(template.getImage().getId()));

      // Get the zone where the template will be deployed
      VirtualDatacenter vdc = cloudService.getVirtualDatacenter(Integer.valueOf(template.getHardware().getLocation()
            .getId()));

      // Load the virtual appliance or create it if it does not exist
      VirtualAppliance vapp = vdc.findVirtualAppliance(VirtualAppliancePredicates.name(tag));
      if (vapp == null) {
         vapp = VirtualAppliance.builder(context, vdc).name(tag).build();
         vapp.save();
      }

      Integer overrideCores = options.getOverrideCores();
      Integer overrideRam = options.getOverrideRam();

      VirtualMachine vm = VirtualMachine.builder(context, vapp, virtualMachineTemplate) //
            .nameLabel(name) //
            .cpu(overrideCores != null ? overrideCores : totalCores(template.getHardware())) //
            .ram(overrideRam != null ? overrideRam : template.getHardware().getRam()) //
            .password(options.getVncPassword()) // Can be null
            .build();

      vm.save();

      // Once the virtual machine is created, override the default network
      // settings if needed
      // If no public ip is available in the virtual datacenter, the virtual
      // machine will be assigned by default an ip address in the default
      // private VLAN for the virtual datacenter
      PublicIp publicIp = vdc.findPurchasedPublicIp(IpPredicates.<PublicIp> notUsed());
      if (publicIp != null) {
         List<PublicIp> ips = Lists.newArrayList();
         ips.add(publicIp);
         vm.setNics(ips);
      }
View Full Code Here


      VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto);

      VirtualDatacenterDto vdcDto = new VirtualDatacenterDto();
      vdcDto.setId(6);
      vdcDto.setHypervisorType(HypervisorType.VMX_04);
      VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto);

      Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc));

      verify(vdcToLocation);

      assertEquals(hardware.getProviderId(), template.getId().toString());
      assertEquals(hardware.getId(), template.getId() + "/" + vdc.getId());
      assertEquals(hardware.getName(), template.getName());
      assertEquals(hardware.getUri(), URI.create("http://foo/bar"));

      assertEquals(hardware.getRam(), template.getRamRequired().intValue());
      assertEquals(hardware.getProcessors().size(), 1);
View Full Code Here

      VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto);

      VirtualDatacenterDto vdcDto = new VirtualDatacenterDto();
      vdcDto.setId(6);
      vdcDto.setHypervisorType(HypervisorType.VMX_04);
      VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto);

      Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc));

      verify(vdcToLocation);
View Full Code Here

      Function<VirtualDatacenter, Location> vdcToLocation = mockVirtualDatacenterToLocation();
      VirtualMachineTemplateInVirtualDatacenterToHardware function = new VirtualMachineTemplateInVirtualDatacenterToHardware(
            vdcToLocation);

      VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, new VirtualMachineTemplateDto());
      VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, new VirtualDatacenterDto());

      function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc));
   }
View Full Code Here

   }

   @Override
   public Hardware apply(final VirtualMachineTemplateInVirtualDatacenter templateInVirtualDatacenter) {
      VirtualMachineTemplate template = templateInVirtualDatacenter.getTemplate();
      VirtualDatacenter virtualDatacenter = templateInVirtualDatacenter.getZone();

      HardwareBuilder builder = new HardwareBuilder();
      builder.providerId(template.getId().toString());
      builder.id(template.getId().toString() + "/" + virtualDatacenter.getId());
      builder.uri(template.getURI());

      builder.name(template.getName());
      builder.processor(new Processor(template.getCpuRequired(), DEFAULT_CORE_SPEED));
      builder.ram(template.getRamRequired());

      // Location information
      builder.location(virtualDatacenterToLocation.apply(virtualDatacenter));
      builder.hypervisor(virtualDatacenter.getHypervisorType().name());
      builder.supportsImage(ImagePredicates.idEquals(template.getId().toString()));

      VolumeBuilder volumeBuilder = new VolumeBuilder();
      volumeBuilder.bootDevice(true);
      volumeBuilder.size(toGb(template.getHdRequired()));
View Full Code Here

   public Map<?, ListenableFuture<Void>> execute(final String group, int count, Template template,
         Set<NodeMetadata> goodNodes, Map<NodeMetadata, Exception> badNodes,
         Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
      // Get the zone where the template will be deployed
      Integer locationId = Integer.valueOf(template.getHardware().getLocation().getId());
      VirtualDatacenter vdc = cloudService.getVirtualDatacenter(locationId);

      // Check if it already exists a group with the given name
      Iterable<VirtualAppliance> existingGroups = vdc.listVirtualAppliances();
      Optional<VirtualAppliance> vapp = tryFind(existingGroups, new Predicate<VirtualAppliance>() {
         @Override
         public boolean apply(VirtualAppliance input) {
            return input.getName().equals(group);
         }
View Full Code Here

   public void testVirtualDatacenterToLocation() {
      Function<Datacenter, Location> dcToLocation = mockDatacenterToLocation();
      Supplier<Map<Integer, Datacenter>> regionMap = mockRegionMap();
      VirtualDatacenterToLocation function = new VirtualDatacenterToLocation(dcToLocation, regionMap);

      VirtualDatacenter vdc = mockVirtualDatacenter();

      Location location = function.apply(vdc);

      verify(regionMap);
      verify(dcToLocation);
View Full Code Here

      ApiContext<AbiquoApi> context = EasyMock.createMock(ApiContext.class);
      Datacenter datacenter = EasyMock.createMock(Datacenter.class);
      Enterprise enterprise = EasyMock.createMock(Enterprise.class);
      PrivateNetwork network = EasyMock.createMock(PrivateNetwork.class);

      VirtualDatacenter vdc = VirtualDatacenter.builder(context, datacenter, enterprise) //
            .network(network) //
            .name("mock").build();
      vdc.unwrap().setId(5);

      return vdc;
   }
View Full Code Here

      replay(stateToNodeState);
      return stateToNodeState;
   }

   private VirtualDatacenter mockVirtualDatacenter() {
      VirtualDatacenter vdc = EasyMock.createMock(VirtualDatacenter.class);
      expect(vdc.getHypervisorType()).andReturn(HypervisorType.VMX_04);
      expect(vdc.getDatacenter()).andReturn(null);
      replay(vdc);
      return vdc;
   }
View Full Code Here

      // TODO: Node credentials still not present in Abiquo template metadata
      // Will be added in Abiquo 2.4:
      // http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647

      // Location details
      VirtualDatacenter vdc = vm.getVirtualDatacenter();
      builder.location(virtualDatacenterToLocation.apply(vdc));

      // Image details
      VirtualMachineTemplate template = vm.getTemplate();
      Image image = virtualMachineTemplateToImage.apply(template);
View Full Code Here

TOP

Related Classes of org.jclouds.abiquo.domain.cloud.VirtualDatacenter

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.