Package com.abiquo.server.core.cloud

Examples of com.abiquo.server.core.cloud.VirtualMachineDto


   public void testAttachDvd() {
      VirtualMachine vm = VirtualMachine.Builder.fromVirtualMachine(env.virtualMachine).dvd(true).build();
      vm.save();

      VirtualMachineDto updated = env.cloudApi.getVirtualMachine(env.virtualAppliance.unwrap(), vm.getId());

      assertNotNull(updated.getDvd());
   }
View Full Code Here


      binder.bindToRequest(HttpRequest.builder().method("m").endpoint("http://localhost").build(), new Object());
   }

   @Test(expectedExceptions = NullPointerException.class)
   public void testInvalidNullInput() throws SecurityException, NoSuchMethodException {
      VirtualMachineDto vm = CloudResources.virtualMachinePut();

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, Lists.<Object> newArrayList(vm, null))).method(HttpMethod.GET)
            .endpoint(URI.create("http://localhost")).build();
View Full Code Here

      binder.bindToRequest(request, null);
   }

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testInvalidTypeInput() throws SecurityException, NoSuchMethodException {
      VirtualMachineDto vm = CloudResources.virtualMachinePut();
      Object network = new Object();

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, ImmutableList.<Object> of(vm, network))).method(HttpMethod.GET)
View Full Code Here

      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
      binder.bindToRequest(request, network);
   }

   public void testBindNetworkConfigurationRef() throws SecurityException, NoSuchMethodException, IOException {
      VirtualMachineDto vm = CloudResources.virtualMachinePut();
      VLANNetworkDto network = NetworkResources.privateNetworkPut();

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, ImmutableList.<Object> of(vm, network))).method(HttpMethod.GET)
            .endpoint(URI.create("http://localhost")).build();

      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));

      String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId();

      GeneratedHttpRequest newRequest = binder.bindToRequest(request, network);
      assertPayloadEquals(newRequest.getPayload(), withHeader("<links><link href=\"" + configLink
            + "\" rel=\"network_configuration\"/></links>"), LinksDto.class);
   }
View Full Code Here

      virtualAppliance.setName("VA");
      return virtualAppliance;
   }

   public static VirtualMachineDto virtualMachinePost() {
      VirtualMachineDto virtualMachine = new VirtualMachineDto();
      virtualMachine.setName("VM");
      virtualMachine.setCpu(1);
      virtualMachine.setRam(1);
      virtualMachine.setHdInBytes(20l);
      return virtualMachine;
   }
View Full Code Here

            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/price"));
      return virtualAppliance;
   }

   public static VirtualMachineDto virtualMachinePut() {
      VirtualMachineDto virtualMachine = virtualMachinePost();
      virtualMachine.setId(1);
      virtualMachine.addLink(new RESTLink("deploy",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/deploy"));
      virtualMachine.addLink(new RESTLink("disks",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks"));
      virtualMachine.addLink(new RESTLink("edit",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1"));
      virtualMachine.addLink(new RESTLink("state",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state"));
      virtualMachine.addLink(new RESTLink("reset",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/reset"));
      virtualMachine.addLink(new RESTLink("tasks",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks"));
      virtualMachine.addLink(new RESTLink("undeploy",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/undeploy"));
      virtualMachine.addLink(new RESTLink("persistent",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/persistent"));
      virtualMachine.addLink(new RESTLink("virtualappliance",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1"));
      virtualMachine.addLink(new RESTLink("virtualmachinetemplate",
            "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1"));
      virtualMachine.addLink(new RESTLink("nics",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/nics"));
      virtualMachine.addLink(new RESTLink("volumes",
            "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes"));
      virtualMachine
            .addLink(new RESTLink("configurations",
                  "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations"));
      virtualMachine.setCpu(1);
      virtualMachine.setRam(1);
      virtualMachine.setHdInBytes(20l);
      return virtualMachine;
   }
View Full Code Here

            "this binder is only valid for VLANNetworkDto");
      GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
      checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point");

      VLANNetworkDto network = (VLANNetworkDto) input;
      VirtualMachineDto vm = (VirtualMachineDto) Iterables.find(gRequest.getInvocation().getArgs(),
            Predicates.instanceOf(VirtualMachineDto.class));

      RESTLink configLink = checkNotNull(vm.searchLink("configurations"), "missing required link");

      LinksDto dto = new LinksDto();
      dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" + network.getId()));

      return super.bindToRequest(request, dto);
View Full Code Here

   public void testSetGatewayNetwork() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(CloudApi.class, "setGatewayNetwork", VirtualMachineDto.class,
            VLANNetworkDto.class);

      VirtualMachineDto vm = CloudResources.virtualMachinePut();
      VLANNetworkDto network = NetworkResources.privateNetworkPut();

      GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of(vm, network)));

      String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId();

      assertRequestLineEquals(
            request,
            "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations HTTP/1.1");
      assertNonPayloadHeadersEqual(request, "");
View Full Code Here

                  .statusCode(202)
                  .payload(
                        payloadFromResourceWithContentType("/payloads/vm-accepted-request.xml",
                              normalize(VirtualMachineInstanceDto.MEDIA_TYPE))).build());

      VirtualMachineDto vm = new VirtualMachineDto();
      vm.addLink(new RESTLink("instance",
            "http://localhost/api/admin/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/instance"));
      VirtualMachineInstanceDto snapshotConfig = new VirtualMachineInstanceDto();
      snapshotConfig.setInstanceName("foo");

      AcceptedRequestDto<String> taskRef = api.snapshotVirtualMachine(vm, snapshotConfig);
View Full Code Here

            "this binder is only valid for VLANNetworkDto");
      GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
      checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point");

      VLANNetworkDto network = (VLANNetworkDto) input;
      VirtualMachineDto vm = (VirtualMachineDto) Iterables.find(gRequest.getInvocation().getArgs(),
            Predicates.instanceOf(VirtualMachineDto.class));

      RESTLink configLink = checkNotNull(vm.searchLink("configurations"), "missing required link");

      LinksDto dto = new LinksDto();
      dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" + network.getId()));

      return super.bindToRequest(request, dto);
View Full Code Here

TOP

Related Classes of com.abiquo.server.core.cloud.VirtualMachineDto

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.