org.jclouds.cloudsigma2.domain.ServerInfo serverToCreate = new org.jclouds.cloudsigma2.domain.ServerInfo.Builder() .name(a.getName()) .memory(BigInteger.valueOf(vm.getMinRam()).multiply(BigInteger.valueOf(1024 * 1024))) .vncPassword("cloudml") .cpu(vm.getMinCores() * 2600) .nics(ImmutableList.of(nic)) .meta(m) .drives(ImmutableList.of(drive)) .build();
input = new ServerInfo.Builder() .cpu(1000) .cpusInsteadOfCores(false) .drives(ImmutableList.of( new ServerDrive.Builder() .deviceChannel("0:0") .build() )) .enableNuma(false) .hvRelaxed(false) .hvTsc(false) .memory(new BigInteger("268435456")) .meta(meta) .name("test_acc_full_server") .nics(ImmutableList.of( new NIC.Builder() .firewallPolicy(null) .build() )) .owner(owner) .requirements(new ArrayList<String>()) .resourceUri(new URI("/api/2.0/servers/a19a425f-9e92-42f6-89fb-6361203071bb/")) .runtime(null) .smp(1) .status(ServerStatus.STOPPED) .tags(ImmutableList.of(new Tag.Builder().name("tag_uuid_1").build(), new Tag.Builder().name("tag_uuid_2").build())) .uuid("a19a425f-9e92-42f6-89fb-6361203071bb")
logger.debug(">> creating server..."); serverInfo = api.createServer(new ServerInfo.Builder() .name(name) .cpu((int) hardware.getProcessors().get(0).getSpeed()) .memory(BigInteger.valueOf(hardware.getRam()).multiply(BigInteger.valueOf(1024 * 1024))) .drives(ImmutableList.of(drive.toServerDrive(1, "0:1", options.getDeviceEmulationType()))) .nics(nics) .meta(metadata) .tags(tagIds) .vncPassword(Optional.fromNullable(options.getVncPassword()).or(defaultVncPassword)).build());
logger.debug(">> creating server..."); serverInfo = api.createServer(new ServerInfo.Builder() .name(name) .cpu((int) hardware.getProcessors().get(0).getSpeed()) .memory(BigInteger.valueOf(hardware.getRam()).multiply(BigInteger.valueOf(1024 * 1024))) .drives(ImmutableList.of(drive.toServerDrive(1, "0:1", options.getDeviceEmulationType()))) .nics(nics) .meta(metadata) .tags(tagIds) .vncPassword(Optional.fromNullable(options.getVncPassword()).or(defaultVncPassword)).build());
.getDefaultEndpoint().get())), ImmutableSet.<String>of()); input = new ServerInfo.Builder() .uuid("a19a425f-9e92-42f6-89fb-6361203071bb") .name("jclouds-cloudsigma-test_acc_full_server") .cpu(1000) .memory(new BigInteger("268435456")) .status(ServerStatus.STOPPED) .drives(ImmutableList.of( new Drive.Builder() .uuid("ae78e68c-9daa-4471-8878-0bb87fa80260") .resourceUri(new URI("/api/2.0/drives/22826af4-d6c8-4d39-bd41-9cea86df2976/")) .build().toServerDrive(1, "0:0", DeviceEmulationType.VIRTIO))) .nics(ImmutableList.of(new NIC.Builder() .ipV4Configuration(new IPConfiguration.Builder() .ip(new IP.Builder().uuid("1.2.3.4").build()) .build()) .build())) .meta(ImmutableMap.of("foo", "bar", "image_id", "image")) .tags(ImmutableList.of(new Tag.Builder().uuid("foo").name("foo").build(), new Tag.Builder().uuid("jclouds-cloudsigma2-s").name("jclouds-cloudsigma2-s").build(), new Tag.Builder().uuid("jclouds-cloudsigma2").name("jclouds-cloudsigma2").build() )) .build();
new ServerInfo.Builder() .cpu(100) .memory(new BigInteger("536870912")) .name("test_server_0") .vncPassword("testserver") .build(), new ServerInfo.Builder() .cpu(100) .memory(new BigInteger("536870912")) .name("test_server_1") .vncPassword("testserver") .build(), new ServerInfo.Builder() .cpu(100) .memory(new BigInteger("536870912")) .name("test_server_2") .vncPassword("testserver") .build()));
@Test public void testCreateServers() throws Exception { List<ServerInfo> newServerList = ImmutableList.of( new ServerInfo.Builder() .name("New Server") .memory(new BigInteger("5368709120")) .cpu(3000) .vncPassword("new_password") .build(), new ServerInfo.Builder() .name("Test Server") .memory(new BigInteger("5368709120")) .cpu(3000) .vncPassword("test_password") .build()); createdServers = api.createServers(newServerList); assertEquals(newServerList.size(), createdServers.size()); for (int i = 0; i < newServerList.size(); i++) { checkServer(newServerList.get(i), createdServers.get(i)); } }
@Test public void testEditServer() throws Exception { String uuid = "a19a425f-9e92-42f6-89fb-6361203071bb"; CloudSigma2Api api = requestSendsResponse( putBuilder() .endpoint(endpoint + "servers/" + uuid + "/") .payload(payloadFromResourceWithContentType("/servers-create-request.json", MediaType.APPLICATION_JSON)) .build(), responseBuilder() .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON)) .build()); ServerInfo result = api.editServer(uuid, new ServerInfo.Builder() .name("testServerAcc") .cpu(100) .memory(new BigInteger("536870912")) .vncPassword("testserver") .build()); assertNotNull(result); }
public static Builder fromServerInfo(ServerInfo serverInfo) { return new Builder() .uuid(serverInfo.getUuid()) .name(serverInfo.getName()) .resourceUri(serverInfo.getResourceUri()) .owner(serverInfo.getOwner()) .status(serverInfo.getStatus()) .runtime(serverInfo.getRuntime()) .cpusInsteadOfCores(serverInfo.isCpusInsteadOfCores()) .drives(serverInfo.getDrives()) .enableNuma(serverInfo.isNumaEnabled()) .hvRelaxed(serverInfo.isHvRelaxed()) .hvTsc(serverInfo.isHvTsc()) .memory(serverInfo.getMemory()) .meta(serverInfo.getMeta()) .nics(serverInfo.getNics()) .requirements(serverInfo.getRequirements()) .tags(serverInfo.getTags()) .vncPassword(serverInfo.getVncPassword()) .smp(serverInfo.getSmp()); }
@Test public void testCreateServer() throws Exception { CloudSigma2Api api = requestSendsResponse( postBuilder() .endpoint(endpoint + "servers/") .payload(payloadFromResourceWithContentType("/servers-create-request.json" , MediaType.APPLICATION_JSON)) .build(), responseBuilder() .payload(payloadFromResourceWithContentType("/servers-single.json", MediaType.APPLICATION_JSON)) .build()); ServerInfo result = api.createServer(new ServerInfo.Builder() .cpu(100) .memory(new BigInteger("536870912")) .name("testServerAcc") .vncPassword("testserver") .build()); assertNotNull(result); }
public static Builder fromServerInfo(ServerInfo serverInfo) { return new Builder() .uuid(serverInfo.getUuid()) .name(serverInfo.getName()) .resourceUri(serverInfo.getResourceUri()) .owner(serverInfo.getOwner()) .status(serverInfo.getStatus()) .runtime(serverInfo.getRuntime()) .cpusInsteadOfCores(serverInfo.isCpusInsteadOfCores()) .drives(serverInfo.getDrives()) .enableNuma(serverInfo.isNumaEnabled()) .hvRelaxed(serverInfo.isHvRelaxed()) .hvTsc(serverInfo.isHvTsc()) .memory(serverInfo.getMemory()) .meta(serverInfo.getMeta()) .nics(serverInfo.getNics()) .requirements(serverInfo.getRequirements()) .tags(serverInfo.getTags()) .vncPassword(serverInfo.getVncPassword()) .smp(serverInfo.getSmp()); }
public static Builder fromServerInfo(ServerInfo serverInfo) { return new Builder() .uuid(serverInfo.getUuid()) .name(serverInfo.getName()) .resourceUri(serverInfo.getResourceUri()) .owner(serverInfo.getOwner()) .status(serverInfo.getStatus()) .runtime(serverInfo.getRuntime()) .cpusInsteadOfCores(serverInfo.isCpusInsteadOfCores()) .drives(serverInfo.getDrives()) .enableNuma(serverInfo.isNumaEnabled()) .hvRelaxed(serverInfo.isHvRelaxed()) .hvTsc(serverInfo.isHvTsc()) .memory(serverInfo.getMemory()) .meta(serverInfo.getMeta()) .nics(serverInfo.getNics()) .requirements(serverInfo.getRequirements()) .tags(serverInfo.getTags()) .vncPassword(serverInfo.getVncPassword()) .smp(serverInfo.getSmp()); }
public void testServerStatus() { CloudSigma2Api api = EasyMock.createMock(CloudSigma2Api.class); expect(api.getServerInfo("one")).andReturn(new ServerInfo.Builder().status(STOPPED).build()); expect(api.getServerInfo("two")).andReturn(new ServerInfo.Builder().status(STOPPING).build()); replay(api); ServerStatusPredicate predicate = new ServerStatusPredicate(api, STOPPED); assertTrue(predicate.apply("one")); assertFalse(predicate.apply("two")); verify(api); }
@Test(dependsOnMethods = {"testCreateServer"}) public void testEditServer() throws Exception { ServerInfo serverInfo = new ServerInfo.Builder() .name("Edited Server") .memory(new BigInteger("5368709120")) .cpu(2000) .vncPassword("edited_password") .build(); checkServer(serverInfo, api.editServer(createdServer.getUuid(), serverInfo)); }
@Test public void testCreateServer() throws Exception { ServerInfo serverInfo = new ServerInfo.Builder() .name("New Server") .memory(new BigInteger("5368709120")) .cpu(3000) .vncPassword("new_password") .drives(ImmutableList.of(api.listDrives().concat().get(0).toServerDrive(1, "0:1", DeviceEmulationType.IDE))) .build(); createdServer = api.createServer(serverInfo); checkServer(serverInfo, createdServer); }