Package org.jclouds.abiquo.domain.cloud

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


      EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name).build();
      assertEvents(options);
   }

   public void testListEventsFilteredByVM() {
      VirtualMachine vm = createVirtualMachine();
      vm.delete();

      EventOptions options = EventOptions.builder().dateFrom(new Date()).actionPerformed(EventType.VM_DELETE).build();
      assertEvents(options);
   }
View Full Code Here


      return volume;
   }

   private VirtualMachine createVirtualMachine() {
      VirtualMachine virtualMachine = VirtualMachine
            .builder(env.context.getApiContext(), env.virtualAppliance, env.template).cpu(2).ram(128)
            .nameLabel(PREFIX + "events").build();

      virtualMachine.save();
      assertNotNull(virtualMachine.getId());

      return virtualMachine;
   }
View Full Code Here

            Integer.valueOf(template.getImage().getId()));

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

      VirtualMachine vm = VirtualMachine.builder(context, template.getVirtualAppliance(), 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.
      Optional<PublicIp> publicIp = tryFind(template.getVirtualDatacenter().listPurchasedPublicIps(),
            IpPredicates.<PublicIp> notUsed());
      if (publicIp.isPresent()) {
         logger.debug(">> Found available public ip %s", publicIp.get().getIp());
         vm.setNics(Lists.<Ip<?, ?>> newArrayList(publicIp.get()));
      } else {
         logger.debug(">> No available public ip found. Using a private ip");
      }

      // This is an async operation, but jclouds already waits until the node is
      // RUNNING, so there is no need to block here
      vm.deploy();

      return new NodeAndInitialCredentials<VirtualMachine>(vm, vm.getId().toString(), null);
   }
View Full Code Here

   }

   @Override
   public void destroyNode(final String id) {
      VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
      VirtualMachine vm = getNode(id);
      vm.undeploy(true);
      monitor.awaitCompletionUndeploy(timeouts.nodeTerminated, TimeUnit.MILLISECONDS, vm);
      vm.delete();
   }
View Full Code Here

   }

   @Override
   public void rebootNode(final String id) {
      VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
      VirtualMachine vm = getNode(id);
      vm.reboot();
      monitor.awaitState(timeouts.nodeRunning, TimeUnit.MILLISECONDS, VirtualMachineState.ON, vm);
   }
View Full Code Here

   }

   @Override
   public void resumeNode(final String id) {
      VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
      VirtualMachine vm = getNode(id);
      vm.changeState(VirtualMachineState.ON);
      monitor.awaitState(timeouts.nodeRunning, TimeUnit.MILLISECONDS, VirtualMachineState.ON, vm);
   }
View Full Code Here

   }

   @Override
   public void suspendNode(final String id) {
      VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor();
      VirtualMachine vm = getNode(id);
      vm.changeState(VirtualMachineState.PAUSED);
      monitor.awaitState(timeouts.nodeSuspended, TimeUnit.MILLISECONDS, VirtualMachineState.PAUSED, vm);
   }
View Full Code Here

            virtualDatacenterToLocation());
   }

   public void testVirtualMachineToNodeMetadata() {
      VirtualAppliance vapp = EasyMock.createMock(VirtualAppliance.class);
      VirtualMachine mockVm = mockVirtualMachine(vapp);

      NodeMetadata node = function.apply(mockVm);

      verify(mockVm);
View Full Code Here

      return EasyMock.createMock(VirtualMachineTemplate.class);
   }

   @SuppressWarnings("unchecked")
   private VirtualMachine mockVirtualMachine(final VirtualAppliance vapp) {
      VirtualMachine mockVm = EasyMock.createMock(VirtualMachine.class);

      Ip<?, ?> mockPrivNic = wrap(EasyMock.createMock(ApiContext.class), PrivateIp.class, privNic);
      Ip<?, ?> mockPubNic = wrap(EasyMock.createMock(ApiContext.class), PublicIp.class, pubNic);
      Ip<?, ?> mockExtNic = wrap(EasyMock.createMock(ApiContext.class), ExternalIp.class, extNic);

      expect(mockVm.getId()).andReturn(vm.getId());
      expect(mockVm.getURI()).andReturn(URI.create(vm.getEditLink().getHref()));
      expect(mockVm.getNameLabel()).andReturn(vm.getNodeName());
      expect(mockVm.getTemplate()).andReturn(mockTemplate());
      expect(mockVm.getState()).andReturn(vm.getState());
      expect(mockVm.listAttachedNics()).andReturn(ImmutableList.<Ip<?, ?>> of(mockPubNic, mockPrivNic, mockExtNic));
      expect(mockVm.getVirtualAppliance()).andReturn(vapp);
      expect(vapp.getName()).andReturn("VAPP");
      expect(mockVm.getVirtualDatacenter()).andReturn(mockVirtualDatacenter());
      expect(mockVm.getRam()).andReturn(vm.getRam());
      expect(mockVm.getCpu()).andReturn(vm.getCpu());

      replay(mockVm);
      replay(vapp);

      return mockVm;
View Full Code Here

            Integer.valueOf(template.getImage().getId()));

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

      VirtualMachine vm = VirtualMachine.builder(context, template.getVirtualAppliance(), 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();

      configureNetworking(vm, template, datacenter, options);

      // This is an async operation, but jclouds already waits until the node is
      // RUNNING, so there is no need to block here
      vm.deploy();

      return new NodeAndInitialCredentials<VirtualMachine>(vm, vm.getId().toString(), null);
   }
View Full Code Here

TOP

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

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.