Ejemplo n.º 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;
  }
Ejemplo n.º 2
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;
  }