public void testCreateNodeWithGroupEncodedIntoNameThenStoreCredentials() { String group = "foo"; String name = "container" + new Random().nextInt(); Template template = templateBuilder.imageId(defaultImage.id()).build(); DockerTemplateOptions options = template.getOptions().as(DockerTemplateOptions.class); options.env(ImmutableList.of("ROOT_PASSWORD=password")); guest = adapter.createNodeWithGroupEncodedIntoName(group, name, template); assertEquals(guest.getNodeId(), guest.getNode().id()); }
@AfterClass(alwaysRun = true) protected void tearDown() { if (guest != null) { adapter.destroyNode(guest.getNode().id() + ""); } super.tearDown(); }
// TODO: finish me! @Test(enabled = false) public void testCreateNodeUsingVCloud1_0ApiAgainstVCloudDirector1_5WhenVAppTemplateHasNetworkNamedNone() throws Exception { String group = "group"; String name = "group-abcd"; String instantiateXML = XMLBuilder.create("InstantiateVAppTemplateParams") .a("xmlns", ns) .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1") .a("deploy", "false") .a("name", name) .a("powerOn", "false") .e("Description") .up() .e("InstantiationParams") .e("NetworkConfigSection") .e("ovf:Info") .t("Configuration parameters for logical networks") .up() .e("NetworkConfig") .a("networkName", "orgNet-jclouds-External") // NOTE not "None" .e("Configuration") .e("ParentNetwork") .a("href", ENDPOINT + "/v1.0/network/" + networkId) .up() .e("FenceMode") .t("bridged") .up() .up() .up() .up() .up() .e("Source") .a("href", ENDPOINT + "/v1.0/vAppTemplate/" + templateId) .up() .e("AllEULAsAccepted") .t("true") .up() .asString(outputProperties); HttpRequest version1_0InstantiateWithNetworkNamedSameAsOrgNetwork = HttpRequest.builder() .method("POST") .endpoint(ENDPOINT + "/v1.0/vdc/" + vdcId + "/action/instantiateVAppTemplate") .addHeader(HttpHeaders.ACCEPT, "application/vnd.vmware.vcloud.vApp+xml") .addHeader("x-vcloud-authorization", sessionToken) .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken) .payload( payloadFromStringWithContentType( instantiateXML, "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")) .build(); ComputeService compute = requestsSendResponses( ImmutableMap.<HttpRequest, HttpResponse>builder() .put(versionsRequest, versionsResponseFromVCD1_5) .put( version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) .put( version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) .put( version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) .put( version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) .put( version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) .put( version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent) .put( version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM) .put( version1_0InstantiateWithNetworkNamedSameAsOrgNetwork, successfulVersion1_0InstantiatedVApp) .build()); InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn starter = compute .getContext() .utils() .injector() .getInstance( InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class); NodeAndInitialCredentials<VApp> appAndCreds = starter.createNodeWithGroupEncodedIntoName(group, name, compute.templateBuilder().build()); assertEquals(appAndCreds.getNode().getName(), name); assertEquals( appAndCreds.getCredentials(), LoginCredentials.builder().user("root").password("fromVApp").build()); }