blob: 951a41815f80d6060b4cbc976ebeb43cb5541ee5 [file] [log] [blame]
/**
*
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.vcloud.terremark.compute;
import static org.testng.Assert.assertEquals;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.vcloud.domain.VCloudExpressVApp;
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
import org.testng.annotations.Test;
/**
* This test is disabled, as it doesn't work while there are too few public ip addresses.
*
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, sequential = true)
public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public TerremarkECloudComputeServiceLiveTest() {
provider = "trmk-ecloud";
}
@Override
public void setServiceDefaults() {
group = "te";
}
@Override
protected Template buildTemplate(TemplateBuilder templateBuilder) {
Template template = super.buildTemplate(templateBuilder);
Image image = template.getImage();
assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image;
assert image.getDefaultCredentials() != null && image.getDefaultCredentials().credential != null : image;
return template;
}
// currently, the wrong CIM OSType data is coming back.
@Override
protected void checkOsMatchesTemplate(NodeMetadata node) {
if (node.getOperatingSystem() != null)
assertEquals(node.getOperatingSystem().getFamily(), null);
}
@Override
public void testListImages() throws Exception {
for (Image image : client.listImages()) {
assert image.getProviderId() != null : image;
// image.getLocationId() can be null, if it is a location-free image
assertEquals(image.getType(), ComputeType.IMAGE);
if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS
&& image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) {
assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image;
assert image.getDefaultCredentials().credential != null : image;
}
}
}
@Override
public void testListNodes() throws Exception {
for (ComputeMetadata node : client.listNodes()) {
assert node.getProviderId() != null;
assert node.getLocation() != null;
assertEquals(node.getType(), ComputeType.NODE);
NodeMetadata allData = client.getNodeMetadata(node.getId());
System.out.println(allData.getHardware());
RestContext<TerremarkVCloudClient, TerremarkVCloudClient> tmContext = new ComputeServiceContextFactory()
.createContext(provider, identity, credential).getProviderSpecificContext();
VCloudExpressVApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName());
assertEquals(vApp.getName(), allData.getName());
}
}
@Override
public void testDestroyNodes() {
super.testDestroyNodes();
}
@Override
protected JschSshClientModule getSshModule() {
return new JschSshClientModule();
}
}