예제 #1
0
  @Override
  public IVirtualMachine createVirtualMachine(String site, LaunchVmOptions launchVmOptions)
      throws AdapterException {
    // site 只为兼容vmware vcloud vapp逻辑结构,h3cloud不需要处理站点。

    H3CloudServer server = new H3CloudServer();

    if (launchVmOptions.getVmName() == null) {
      throw new AdapterException("vm's name cannot be null when creating h3cloud server.");
    }

    server.setName(launchVmOptions.getVmName());

    server.setDescription(launchVmOptions.getDescription());

    server.setImageUuid(launchVmOptions.getImageOptions().getImageId());

    server.setNetworkUuid(launchVmOptions.getNetworkConfigOptions().getNetworkConfigId());

    server.setFlavorUuid(launchVmOptions.getHardwareOptions().getId());

    if (launchVmOptions.getNetworkConfigOptions().getPrivateIpAddress() != null
        && !"".equals(launchVmOptions.getNetworkConfigOptions().getPrivateIpAddress())) {
      server.setPrivateIp(launchVmOptions.getNetworkConfigOptions().getPrivateIpAddress());
    }

    server = serverService.create(server);

    H3CloudVirtualMachine vm = new H3CloudVirtualMachine(method, server);
    return vm;
  }
예제 #2
0
  @Override
  public IVirtualMachine virtualMachineMove(String siteSource, String vmId, String siteDestination)
      throws AdapterException {
    H3CloudServer server = serverService.getH3CServerById(vmId);

    H3CloudVirtualMachine vm = new H3CloudVirtualMachine(method, server);
    vm.powerOn();
    return vm;
  }
예제 #3
0
 @Override
 public IVirtualMachine getVirtualMachineById(String vmId) throws AdapterException {
   H3CloudServer server = serverService.getH3CServerById(vmId);
   IVirtualMachine vm = null;
   if (server != null) {
     vm = new H3CloudVirtualMachine(method, server);
   }
   return vm;
 }
예제 #4
0
  // H3Cloud查询虚拟机,start = 0; size = 10
  @Override
  public IVirtualMachine[] getVirtualMachines() throws AdapterException {
    List<H3CloudServer> servers = serverService.getH3CServers();
    IVirtualMachine[] vms = null;

    if (!servers.isEmpty()) {
      vms = new IVirtualMachine[servers.size()];
      int i = 0;
      for (H3CloudServer server : servers) {
        IVirtualMachine vm = new H3CloudVirtualMachine(method, server);
        vms[i] = vm;
        i++;
      }
    }

    return vms;
  }
예제 #5
0
  @Override
  public IVirtualMachine createVirtualMachine(LaunchVmOptions launchVmOptions)
      throws AdapterException {
    H3CloudServer server = new H3CloudServer();

    if (launchVmOptions.getVmName() == null) {
      throw new AdapterException("vm's name cannot be null when creating h3cloud server.");
    }

    server.setName(launchVmOptions.getVmName());
    server.setDescription(launchVmOptions.getDescription());

    server.setImageUuid(launchVmOptions.getImageOptions().getImageId());

    server.setNetworkUuid(launchVmOptions.getNetworkConfigOptions().getNetworkConfigId());

    server.setFlavorUuid(launchVmOptions.getHardwareOptions().getId());

    server = serverService.create(server);

    H3CloudVirtualMachine vm = new H3CloudVirtualMachine(method, server);
    return vm;
  }