mirror of https://github.com/apache/jclouds.git
Issue 280: milestone where vcloud 0.9+ passes compute service tests (bluelock)
This commit is contained in:
parent
31fd2b5067
commit
d502774eda
|
@ -305,7 +305,9 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
|
||||
protected void checkOsMatchesTemplate(NodeMetadata node) {
|
||||
if (node.getOperatingSystem() != null)
|
||||
assertEquals(node.getOperatingSystem().getFamily(), template.getImage().getOperatingSystem().getFamily());
|
||||
assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String
|
||||
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node
|
||||
.getOperatingSystem());
|
||||
}
|
||||
|
||||
void assertLocationSameOrChild(Location test, Location expected) {
|
||||
|
@ -524,7 +526,7 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
System.out.printf("smallest %s%n", smallest);
|
||||
System.out.printf("fastest %s%n", fastest);
|
||||
System.out.printf("biggest %s%n", biggest);
|
||||
|
||||
|
||||
assertEquals(defaultSize, smallest);
|
||||
|
||||
assert smallest.getCores() <= fastest.getCores() : String.format("%d ! <= %d", smallest, fastest);
|
||||
|
|
|
@ -90,7 +90,15 @@ public interface VCloudMediaType {
|
|||
*/
|
||||
public final static MediaType CATALOGITEM_XML_TYPE = new MediaType("application",
|
||||
"vnd.vmware.vcloud.catalogItem+xml");
|
||||
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.networkConnectionSection+xml"
|
||||
*/
|
||||
public final static String NETWORKCONNECTIONSECTION_XML = "application/vnd.vmware.vcloud.networkConnectionSection+xml";
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.networkConnectionSection+xml"
|
||||
*/
|
||||
public final static MediaType NETWORKCONNECTIONSECTION_XML_TYPE = new MediaType("application",
|
||||
"vnd.vmware.vcloud.networkConnectionSection+xml");
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.virtualHardwareSection+xml"
|
||||
*/
|
||||
|
|
|
@ -48,7 +48,9 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
|||
properties.setProperty("jclouds.dns_name_length_min", "1");
|
||||
properties.setProperty("jclouds.dns_name_length_max", "80");
|
||||
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString());
|
||||
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 180l * 1000l + "");
|
||||
// TODO integrate this with the {@link ComputeTimeouts} instead of having a single timeout for
|
||||
// everything.
|
||||
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 600l * 1000l + "");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.compute;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ImplementedBy(VCloudComputeClientImpl.class)
|
||||
public interface VCloudComputeClient extends CommonVCloudComputeClient {
|
||||
/**
|
||||
* Runs through all commands necessary to startup a vApp, opening at least one ip address to the
|
||||
* public network. These are the steps:
|
||||
* <p/>
|
||||
* instantiate -> deploy -> powerOn
|
||||
* <p/>
|
||||
* This command blocks until the vApp is in state {@code VAppStatus#ON}
|
||||
*
|
||||
* @param VDC
|
||||
* id of the virtual datacenter {@code VCloudClient#getDefaultVDC}
|
||||
* @param templateId
|
||||
* id of the vAppTemplate you wish to instantiate
|
||||
* @param name
|
||||
* name of the vApp
|
||||
* @param cores
|
||||
* amount of virtual cpu cores
|
||||
* @param megs
|
||||
* amount of ram in megabytes
|
||||
* @param options
|
||||
* options for instantiating the vApp; null is ok
|
||||
* @param portsToOpen
|
||||
* opens the following ports on the public ip address
|
||||
* @return map contains at least the following properties
|
||||
* <ol>
|
||||
* <li>id - vApp id</li> <li>username - console login user</li> <li> password - console
|
||||
* login password</li>
|
||||
* </ol>
|
||||
*/
|
||||
Map<String, String> start(@Nullable URI VDC, URI templateId, String name, InstantiateVAppTemplateOptions options,
|
||||
int... portsToOpen);
|
||||
|
||||
}
|
|
@ -30,12 +30,9 @@ import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
|
|||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.domain.Size;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
|
||||
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
|
||||
import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier;
|
||||
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier;
|
||||
|
@ -74,7 +71,6 @@ public abstract class CommonVCloudComputeServiceContextModule extends BaseComput
|
|||
@Override
|
||||
protected void configure() {
|
||||
install(new ComputeServiceTimeoutsModule());
|
||||
bind(DestroyNodeStrategy.class).to(VCloudDestroyNodeStrategy.class);
|
||||
bind(RunNodesAndAddToSetStrategy.class).to(EncodeTagIntoNameRunNodesAndAddToSetStrategy.class);
|
||||
bindLoadBalancer();
|
||||
}
|
||||
|
|
|
@ -21,25 +21,24 @@ package org.jclouds.vcloud.compute.config;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.Size;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.compute.CommonVCloudComputeClient;
|
||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
||||
import org.jclouds.vcloud.compute.functions.ImagesInOrg;
|
||||
import org.jclouds.vcloud.compute.functions.SizesInOrg;
|
||||
import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl;
|
||||
import org.jclouds.vcloud.compute.strategy.GetLoginCredentialsFromGuestConfiguration;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudAddNodeWithTagStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy;
|
||||
|
@ -49,7 +48,6 @@ import org.jclouds.vcloud.domain.Org;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
@ -80,12 +78,8 @@ public class VCloudComputeServiceContextModule extends CommonVCloudComputeServic
|
|||
});
|
||||
bind(AddNodeWithTagStrategy.class).to(VCloudAddNodeWithTagStrategy.class);
|
||||
bind(ListNodesStrategy.class).to(VCloudListNodesStrategy.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
CommonVCloudComputeClient provideCommonVCloudComputeClient(VCloudComputeClient in) {
|
||||
return in;
|
||||
bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(GetLoginCredentialsFromGuestConfiguration.class);
|
||||
bind(DestroyNodeStrategy.class).to(VCloudDestroyNodeStrategy.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jclouds.compute.ComputeServiceContext;
|
|||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
|
@ -36,6 +37,7 @@ import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
|
|||
import org.jclouds.vcloud.compute.functions.ImagesInVCloudExpressOrg;
|
||||
import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressAddNodeWithTagStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressDestroyNodeStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressGetNodeMetadataStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressListNodesStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressRebootNodeStrategy;
|
||||
|
@ -70,6 +72,7 @@ public class VCloudExpressComputeServiceContextModule extends CommonVCloudComput
|
|||
});
|
||||
bind(AddNodeWithTagStrategy.class).to(VCloudExpressAddNodeWithTagStrategy.class);
|
||||
bind(ListNodesStrategy.class).to(VCloudExpressListNodesStrategy.class);
|
||||
bind(DestroyNodeStrategy.class).to(VCloudExpressDestroyNodeStrategy.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -58,13 +58,13 @@ public class GetExtraFromVApp implements Function<VApp, Map<String, String>> {
|
|||
try {
|
||||
// TODO make this work with composite vApps
|
||||
Vm vm = Iterables.get(vApp.getChildren(), 0);
|
||||
extra.put("memory/mb", find(vm.getHardware().getResourceAllocations(), resourceType(ResourceType.MEMORY))
|
||||
extra.put("memory/mb", find(vm.getVirtualHardwareSection().getResourceAllocations(), resourceType(ResourceType.MEMORY))
|
||||
.getVirtualQuantity()
|
||||
+ "");
|
||||
extra.put("processor/count", find(vm.getHardware().getResourceAllocations(),
|
||||
extra.put("processor/count", find(vm.getVirtualHardwareSection().getResourceAllocations(),
|
||||
resourceType(ResourceType.PROCESSOR)).getVirtualQuantity()
|
||||
+ "");
|
||||
for (ResourceAllocation disk : filter(vm.getHardware().getResourceAllocations(),
|
||||
for (ResourceAllocation disk : filter(vm.getVirtualHardwareSection().getResourceAllocations(),
|
||||
resourceType(ResourceType.DISK_DRIVE))) {
|
||||
if (disk instanceof VCloudHardDisk) {
|
||||
VCloudHardDisk vDisk = VCloudHardDisk.class.cast(disk);
|
||||
|
@ -73,7 +73,7 @@ public class GetExtraFromVApp implements Function<VApp, Map<String, String>> {
|
|||
extra.put(String.format("disk_drive/%s/kb", disk.getAddressOnParent()), disk.getVirtualQuantity() + "");
|
||||
}
|
||||
}
|
||||
for (ResourceAllocation net : filter(vm.getHardware().getResourceAllocations(),
|
||||
for (ResourceAllocation net : filter(vm.getVirtualHardwareSection().getResourceAllocations(),
|
||||
resourceType(ResourceType.ETHERNET_ADAPTER))) {
|
||||
if (net instanceof VCloudNetworkAdapter) {
|
||||
VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net);
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.compute.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.internal.util.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl<VAppTemplate, VApp> implements
|
||||
VCloudComputeClient {
|
||||
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
public VCloudComputeClientImpl(VCloudClient client, Predicate<URI> successTester,
|
||||
Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
super(client, successTester);
|
||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> start(@Nullable URI VDC, URI templateId, String name,
|
||||
InstantiateVAppTemplateOptions options, int... portsToOpen) {
|
||||
checkNotNull(options, "options");
|
||||
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options);
|
||||
|
||||
VApp vAppResponse = VCloudClient.class.cast(client).instantiateVAppTemplateInVDC(VDC, templateId, name, options);
|
||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
|
||||
|
||||
Task task = vAppResponse.getTasks().get(0);
|
||||
if (options.shouldBlock()) {
|
||||
if (!taskTester.apply(task.getHref())) {
|
||||
throw new RuntimeException(String.format("failed to %s %s: %s", "deploy and power on", vAppResponse
|
||||
.getName(), task));
|
||||
}
|
||||
logger.debug("<< ready vApp(%s)", vAppResponse.getName());
|
||||
}
|
||||
return parseAndValidateResponse(null, vAppResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteVApp(VApp vApp) {
|
||||
logger.debug(">> deleting vApp(%s)", vApp.getName());
|
||||
Task task = VCloudClient.class.cast(client).deleteVApp(vApp.getHref());
|
||||
if (!taskTester.apply(task.getHref())) {
|
||||
throw new RuntimeException(String.format("failed to %s %s: %s", "delete", vApp.getName(), task));
|
||||
}
|
||||
logger.debug("<< ready vApp(%s)", vApp.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> parseResponse(VAppTemplate template, VApp vAppResponse) {
|
||||
vAppResponse = VCloudClient.class.cast(client).getVApp(vAppResponse.getHref());
|
||||
Map<String, String> config = Maps.newLinkedHashMap();// Allows nulls
|
||||
config.put("id", vAppResponse.getHref().toASCIIString());
|
||||
config.put("username", "root");
|
||||
config.put("password", Iterables.get(vAppResponse.getChildren(), 0).getGuestCustomization().getAdminPassword());
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getPrivateAddresses(URI id) {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getPublicAddresses(URI id) {
|
||||
Set<String> ips = Sets.newLinkedHashSet();
|
||||
VApp vApp = refreshVApp(id);
|
||||
// TODO make this work with composite vApps
|
||||
Vm vm = Iterables.get(vApp.getChildren(), 0);
|
||||
for (ResourceAllocation net : filter(vm.getHardware().getResourceAllocations(),
|
||||
resourceType(ResourceType.ETHERNET_ADAPTER))) {
|
||||
if (net instanceof VCloudNetworkAdapter) {
|
||||
VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net);
|
||||
ips.add(vNet.getIpAddress());
|
||||
}
|
||||
}
|
||||
return ips;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Status getStatus(VApp vApp) {
|
||||
return vApp.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VApp refreshVApp(URI id) {
|
||||
return VCloudClient.class.cast(client).getVApp(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Task powerOff(VApp vApp) {
|
||||
return VCloudClient.class.cast(client).powerOffVAppOrVm(vApp.getHref());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Task reset(VApp vApp) {
|
||||
return VCloudClient.class.cast(client).resetVAppOrVm(vApp.getHref());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Task undeploy(VApp vApp) {
|
||||
return VCloudClient.class.cast(client).undeployAndSaveStateOfVAppOrVm(vApp.getHref());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.compute.strategy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class GetLoginCredentialsFromGuestConfiguration implements PopulateDefaultLoginCredentialsForImageStrategy {
|
||||
|
||||
@Override
|
||||
public Credentials execute(Object resourceToAuthenticate) {
|
||||
checkNotNull(resourceToAuthenticate);
|
||||
checkArgument(resourceToAuthenticate instanceof VAppTemplate, "Resource must be an VAppTemplate");
|
||||
return getCredentialsFrom(VAppTemplate.class.cast(resourceToAuthenticate));
|
||||
}
|
||||
}
|
|
@ -19,44 +19,47 @@
|
|||
|
||||
package org.jclouds.vcloud.compute.strategy;
|
||||
|
||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
protected final VCloudClient client;
|
||||
protected final VCloudComputeClient computeClient;
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
protected final GetNodeMetadataStrategy getNode;
|
||||
protected final Predicate<URI> successTester;
|
||||
|
||||
@Inject
|
||||
protected VCloudAddNodeWithTagStrategy(VCloudClient client, VCloudComputeClient computeClient,
|
||||
Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
protected VCloudAddNodeWithTagStrategy(Predicate<URI> successTester, VCloudClient client,
|
||||
GetNodeMetadataStrategy getNode) {
|
||||
this.client = client;
|
||||
this.computeClient = computeClient;
|
||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||
this.successTester = successTester;
|
||||
this.getNode = getNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,19 +68,23 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
|||
.memory(template.getSize().getRam()).disk(template.getSize().getDisk() * 1024 * 1024l);
|
||||
if (!template.getOptions().shouldBlockUntilRunning())
|
||||
options.block(false);
|
||||
Map<String, String> metaMap = computeClient.start(URI.create(template.getLocation().getId()), URI.create(template
|
||||
.getImage().getId()), name, options, template.getOptions().getInboundPorts());
|
||||
VApp vApp = client.getVApp(URI.create(metaMap.get("id")));
|
||||
return newCreateNodeResponse(tag, template, metaMap, vApp);
|
||||
}
|
||||
|
||||
protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map<String, String> metaMap, VApp vApp) {
|
||||
return new NodeMetadataImpl(vApp.getHref().toASCIIString(), vApp.getName(), vApp.getHref().toASCIIString(),
|
||||
template.getLocation(), vApp.getHref(), ImmutableMap.<String, String> of(), tag, template.getImage()
|
||||
.getId(), toComputeOs(vApp, template.getImage().getOperatingSystem()), vAppStatusToNodeState
|
||||
.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getHref()), computeClient
|
||||
.getPrivateAddresses(vApp.getHref()), ImmutableMap.<String, String> of(), new Credentials(
|
||||
metaMap.get("username"), metaMap.get("password")));
|
||||
}
|
||||
URI VDC = URI.create(template.getLocation().getId());
|
||||
URI templateId = URI.create(template.getImage().getId());
|
||||
|
||||
logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options);
|
||||
|
||||
VApp vAppResponse = client.instantiateVAppTemplateInVDC(VDC, templateId, name, options);
|
||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getName());
|
||||
|
||||
Task task = vAppResponse.getTasks().get(0);
|
||||
if (options.shouldBlock()) {
|
||||
if (!successTester.apply(task.getHref())) {
|
||||
throw new RuntimeException(String.format("failed to %s %s: %s", "deploy and power on", vAppResponse
|
||||
.getName(), task));
|
||||
}
|
||||
logger.debug("<< ready vApp(%s)", vAppResponse.getName());
|
||||
}
|
||||
return getNode.execute(vAppResponse.getHref().toASCIIString());
|
||||
}
|
||||
}
|
|
@ -23,33 +23,96 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.vcloud.compute.CommonVCloudComputeClient;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy {
|
||||
protected final CommonVCloudComputeClient computeClient;
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
protected final Predicate<URI> successTester;
|
||||
protected final VCloudClient client;
|
||||
protected final GetNodeMetadataStrategy getNode;
|
||||
|
||||
@Inject
|
||||
protected VCloudDestroyNodeStrategy(CommonVCloudComputeClient computeClient, GetNodeMetadataStrategy getNode) {
|
||||
this.computeClient = computeClient;
|
||||
protected VCloudDestroyNodeStrategy(Predicate<URI> successTester, VCloudClient client,
|
||||
GetNodeMetadataStrategy getNode) {
|
||||
this.successTester = successTester;
|
||||
this.client = client;
|
||||
this.getNode = getNode;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String id) {
|
||||
computeClient.stop(URI.create(checkNotNull(id, "node.id")));
|
||||
return getNode.execute(id);
|
||||
URI vappId = URI.create(checkNotNull(id, "node.id"));
|
||||
VApp vApp = client.getVApp(vappId);
|
||||
if (vApp == null)
|
||||
return null;
|
||||
vApp = powerOffVAppIfDeployed(vApp);
|
||||
vApp = undeployVAppIfDeployed(vApp);
|
||||
deleteVApp(vappId);
|
||||
try {
|
||||
return getNode.execute(id);
|
||||
} catch (AuthorizationException e) {
|
||||
logger.trace("authorization error getting %s after deletion: %s", id, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void deleteVApp(URI vappId) {
|
||||
logger.debug(">> deleting vApp(%s)", vappId);
|
||||
Task task = client.deleteVApp(vappId);
|
||||
if (!successTester.apply(task.getHref())) {
|
||||
throw new RuntimeException(String.format("failed to %s %s: %s", "delete", vappId, task));
|
||||
}
|
||||
logger.debug("<< deleted vApp(%s)", vappId);
|
||||
}
|
||||
|
||||
VApp undeployVAppIfDeployed(VApp vApp) {
|
||||
if (vApp.getStatus().compareTo(Status.RESOLVED) > 0) {
|
||||
logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
|
||||
Task task = client.undeployVAppOrVm(vApp.getHref());
|
||||
if (!successTester.apply(task.getHref())) {
|
||||
// TODO timeout
|
||||
throw new RuntimeException(String.format("failed to %s %s: %s", "undeploy", vApp.getName(), task));
|
||||
}
|
||||
vApp = client.getVApp(vApp.getHref());
|
||||
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
|
||||
}
|
||||
return vApp;
|
||||
}
|
||||
|
||||
VApp powerOffVAppIfDeployed(VApp vApp) {
|
||||
if (vApp.getStatus().compareTo(Status.OFF) > 0) {
|
||||
logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
|
||||
Task task = client.powerOffVAppOrVm(vApp.getHref());
|
||||
if (!successTester.apply(task.getHref())) {
|
||||
// TODO timeout
|
||||
throw new RuntimeException(String.format("failed to %s %s: %s", "powerOff", vApp.getName(), task));
|
||||
}
|
||||
vApp = client.getVApp(vApp.getHref());
|
||||
logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
|
||||
}
|
||||
return vApp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.compute.strategy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.vcloud.compute.CommonVCloudComputeClient;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VCloudExpressDestroyNodeStrategy implements DestroyNodeStrategy {
|
||||
protected final CommonVCloudComputeClient computeClient;
|
||||
protected final GetNodeMetadataStrategy getNode;
|
||||
|
||||
@Inject
|
||||
protected VCloudExpressDestroyNodeStrategy(CommonVCloudComputeClient computeClient, GetNodeMetadataStrategy getNode) {
|
||||
this.computeClient = computeClient;
|
||||
this.getNode = getNode;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String id) {
|
||||
computeClient.stop(URI.create(checkNotNull(id, "node.id")));
|
||||
return getNode.execute(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,9 @@ package org.jclouds.vcloud.compute.strategy;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName;
|
||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
|
||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getPrivateIpsFromVApp;
|
||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getPublicIpsFromVApp;
|
||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -41,7 +44,6 @@ import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
||||
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
|
||||
import org.jclouds.vcloud.compute.functions.GetExtraFromVApp;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
|
@ -59,21 +61,19 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
|||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
public Logger logger = Logger.NULL;
|
||||
protected final VCloudClient client;
|
||||
protected final VCloudComputeClient computeClient;
|
||||
protected final Supplier<Set<? extends Image>> images;
|
||||
protected final FindLocationForResource findLocationForResourceInVDC;
|
||||
protected final GetExtraFromVApp getExtra;
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
protected VCloudGetNodeMetadataStrategy(VCloudClient client, VCloudComputeClient computeClient,
|
||||
Map<Status, NodeState> vAppStatusToNodeState, GetExtraFromVApp getExtra,
|
||||
FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images) {
|
||||
protected VCloudGetNodeMetadataStrategy(VCloudClient client, Map<Status, NodeState> vAppStatusToNodeState,
|
||||
GetExtraFromVApp getExtra, FindLocationForResource findLocationForResourceInVDC,
|
||||
Supplier<Set<? extends Image>> images) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.images = checkNotNull(images, "images");
|
||||
this.getExtra = checkNotNull(getExtra, "getExtra");
|
||||
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
||||
this.computeClient = checkNotNull(computeClient, "computeClient");
|
||||
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,7 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
|||
String tag = parseTagFromName(from.getName());
|
||||
Location location = findLocationForResourceInVDC.apply(from.getVDC());
|
||||
return new NodeMetadataImpl(in, from.getName(), in, location, from.getHref(), ImmutableMap.<String, String> of(),
|
||||
tag, null, toComputeOs(from, null), vAppStatusToNodeState.get(from.getStatus()), computeClient
|
||||
.getPublicAddresses(id), computeClient.getPrivateAddresses(id), getExtra.apply(from), null);
|
||||
tag, null, toComputeOs(from, null), vAppStatusToNodeState.get(from.getStatus()),
|
||||
getPublicIpsFromVApp(from), getPrivateIpsFromVApp(from), getExtra.apply(from), getCredentialsFrom(from));
|
||||
}
|
||||
|
||||
}
|
|
@ -19,13 +19,25 @@
|
|||
|
||||
package org.jclouds.vcloud.compute.util;
|
||||
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.os.CIMOperatingSystem;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.internal.util.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,7 +51,7 @@ public class VCloudComputeUtils {
|
|||
|
||||
public static CIMOperatingSystem toComputeOs(VApp vApp) {
|
||||
// TODO we need to change the design so that it doesn't assume single-vms
|
||||
return toComputeOs(Iterables.get(vApp.getChildren(), 0));
|
||||
return vApp.getChildren().size() > 0 ? toComputeOs(Iterables.get(vApp.getChildren(), 0)) : null;
|
||||
}
|
||||
|
||||
public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) {
|
||||
|
@ -47,11 +59,60 @@ public class VCloudComputeUtils {
|
|||
}
|
||||
|
||||
public static CIMOperatingSystem toComputeOs(Vm vm) {
|
||||
return toComputeOs(vm.getOperatingSystem());
|
||||
return toComputeOs(vm.getOperatingSystemSection());
|
||||
}
|
||||
|
||||
public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystemSection os) {
|
||||
return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), null, null, os.getDescription());
|
||||
}
|
||||
|
||||
public static Credentials getCredentialsFrom(VApp vApp) {
|
||||
return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null;
|
||||
}
|
||||
|
||||
public static Credentials getCredentialsFrom(VAppTemplate vApp) {
|
||||
return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null;
|
||||
}
|
||||
|
||||
public static Credentials getCredentialsFrom(Vm vm) {
|
||||
String user = "root";
|
||||
if (vm.getOperatingSystemSection() != null && vm.getOperatingSystemSection().getDescription() != null
|
||||
&& vm.getOperatingSystemSection().getDescription().indexOf("Windows") >= 0)
|
||||
user = "Administrator";
|
||||
String password = null;
|
||||
if (vm.getGuestCustomizationSection() != null)
|
||||
password = vm.getGuestCustomizationSection().getAdminPassword();
|
||||
return new Credentials(user, password);
|
||||
}
|
||||
|
||||
public static Set<String> getPublicIpsFromVApp(VApp vApp) {
|
||||
Set<String> ips = Sets.newLinkedHashSet();
|
||||
// TODO make this work with composite vApps
|
||||
if (vApp.getChildren().size() == 0)
|
||||
return ips;
|
||||
Vm vm = Iterables.get(vApp.getChildren(), 0);
|
||||
// TODO: figure out how to differentiate public from private ip addresses
|
||||
// assumption is that we'll do this from the network object, which may have
|
||||
// enough data to tell whether or not it is a public network without string
|
||||
// parsing. At worst, we could have properties set per cloud provider to
|
||||
// declare the networks which are public, then check against these in
|
||||
// networkconnection.getNetwork
|
||||
if (vm.getNetworkConnectionSection() != null) {
|
||||
for (NetworkConnection connection : vm.getNetworkConnectionSection().getConnections())
|
||||
ips.add(connection.getIpAddress());
|
||||
} else {
|
||||
for (ResourceAllocation net : filter(vm.getVirtualHardwareSection().getResourceAllocations(),
|
||||
resourceType(ResourceType.ETHERNET_ADAPTER))) {
|
||||
if (net instanceof VCloudNetworkAdapter) {
|
||||
VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net);
|
||||
ips.add(vNet.getIpAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
return ips;
|
||||
}
|
||||
|
||||
public static Set<String> getPrivateIpsFromVApp(VApp vApp) {
|
||||
return Sets.newLinkedHashSet();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.net.URI;
|
|||
* The GuestCustomization of a Vm contains customization parameters for the guest
|
||||
* operating system of the virtual machine.
|
||||
*/
|
||||
public class GuestCustomization {
|
||||
public class GuestCustomizationSection {
|
||||
protected final String type;
|
||||
protected final URI href;
|
||||
protected final String info;
|
||||
|
@ -45,7 +45,7 @@ public class GuestCustomization {
|
|||
protected final String computerName;
|
||||
protected final ReferenceType edit;
|
||||
|
||||
public GuestCustomization(String type, URI href, String info, Boolean enabled, Boolean changeSid,
|
||||
public GuestCustomizationSection(String type, URI href, String info, Boolean enabled, Boolean changeSid,
|
||||
String virtualMachineId, Boolean joinDomainEnabled, Boolean useOrgSettings, String domainName,
|
||||
String domainUserName, String domainUserPassword, Boolean adminPasswordEnabled, Boolean adminPasswordAuto,
|
||||
String adminPassword, Boolean resetPasswordRequired, String customizationScript, String computerName,
|
||||
|
@ -254,7 +254,7 @@ public class GuestCustomization {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
GuestCustomization other = (GuestCustomization) obj;
|
||||
GuestCustomizationSection other = (GuestCustomizationSection) obj;
|
||||
if (adminPassword == null) {
|
||||
if (other.adminPassword != null)
|
||||
return false;
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.domain;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
|
||||
|
||||
/**
|
||||
* describes a single network connection.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkConnection {
|
||||
private final String network;
|
||||
private final int networkConnectionIndex;
|
||||
@Nullable
|
||||
private final String ipAddress;
|
||||
@Nullable
|
||||
private final String externalIpAddress;
|
||||
private final boolean connected;
|
||||
@Nullable
|
||||
private final String MACAddress;
|
||||
private final IpAddressAllocationMode ipAddressAllocationMode;
|
||||
|
||||
public NetworkConnection(String network, int networkConnectionIndex, @Nullable String ipAddress,
|
||||
@Nullable String externalIpAddress, boolean connected, @Nullable String MACAddress,
|
||||
IpAddressAllocationMode ipAddressAllocationMode) {
|
||||
this.network = network;
|
||||
this.networkConnectionIndex = networkConnectionIndex;
|
||||
this.ipAddress = ipAddress;
|
||||
this.externalIpAddress = externalIpAddress;
|
||||
this.connected = connected;
|
||||
this.MACAddress = MACAddress;
|
||||
this.ipAddressAllocationMode = ipAddressAllocationMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of the network to which this connection connects.
|
||||
*/
|
||||
public String getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The value in the rasd:AddressOnParent element of the device supporting this
|
||||
* connection.
|
||||
*/
|
||||
public int getNetworkConnectionIndex() {
|
||||
return networkConnectionIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IP address of this connection
|
||||
*/
|
||||
@Nullable
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If the network that the NIC is connected to has NAT or port mapping, the external
|
||||
* address is populated in this element.
|
||||
*/
|
||||
@Nullable
|
||||
public String getExternalIpAddress() {
|
||||
return externalIpAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If the vApp is deployed, specifies the current state of its connection. If the vApp is
|
||||
* undeployed, specifies whether this connection should be connected at deployment time.
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MAC address of this connection
|
||||
*/
|
||||
@Nullable
|
||||
public String getMACAddress() {
|
||||
return MACAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return specifies how an IP address is allocated to this connection
|
||||
*/
|
||||
public IpAddressAllocationMode getIpAddressAllocationMode() {
|
||||
return ipAddressAllocationMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((MACAddress == null) ? 0 : MACAddress.hashCode());
|
||||
result = prime * result + (connected ? 1231 : 1237);
|
||||
result = prime * result + ((externalIpAddress == null) ? 0 : externalIpAddress.hashCode());
|
||||
result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
|
||||
result = prime * result + ((ipAddressAllocationMode == null) ? 0 : ipAddressAllocationMode.hashCode());
|
||||
result = prime * result + ((network == null) ? 0 : network.hashCode());
|
||||
result = prime * result + networkConnectionIndex;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NetworkConnection other = (NetworkConnection) obj;
|
||||
if (MACAddress == null) {
|
||||
if (other.MACAddress != null)
|
||||
return false;
|
||||
} else if (!MACAddress.equals(other.MACAddress))
|
||||
return false;
|
||||
if (connected != other.connected)
|
||||
return false;
|
||||
if (externalIpAddress == null) {
|
||||
if (other.externalIpAddress != null)
|
||||
return false;
|
||||
} else if (!externalIpAddress.equals(other.externalIpAddress))
|
||||
return false;
|
||||
if (ipAddress == null) {
|
||||
if (other.ipAddress != null)
|
||||
return false;
|
||||
} else if (!ipAddress.equals(other.ipAddress))
|
||||
return false;
|
||||
if (ipAddressAllocationMode == null) {
|
||||
if (other.ipAddressAllocationMode != null)
|
||||
return false;
|
||||
} else if (!ipAddressAllocationMode.equals(other.ipAddressAllocationMode))
|
||||
return false;
|
||||
if (network == null) {
|
||||
if (other.network != null)
|
||||
return false;
|
||||
} else if (!network.equals(other.network))
|
||||
return false;
|
||||
if (networkConnectionIndex != other.networkConnectionIndex)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[network=" + network + ", connected=" + connected + ", ipAddress=" + ipAddress + ", externalIpAddress="
|
||||
+ externalIpAddress + ", networkConnectionIndex=" + networkConnectionIndex
|
||||
+ ", ipAddressAllocationMode=" + ipAddressAllocationMode + ", MACAddress=" + MACAddress + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* The NetworkConnectionSection element specifies how a Vm is connected to a vApp network. It
|
||||
* extends the ovf:NetworkConnection element.
|
||||
* <p/>
|
||||
* NOTE The OVF NetworkSection element and the vCloud API NetworkConnectionSection element specify
|
||||
* many of the same parameters for a network connection. If both are present in a Vm body, the
|
||||
* values specified in the NetworkConnectionSection override those specified in the NetworkSection.
|
||||
*/
|
||||
public class NetworkConnectionSection {
|
||||
protected final String type;
|
||||
protected final URI href;
|
||||
protected final String info;
|
||||
protected final Integer primaryNetworkConnectionIndex;
|
||||
protected final Set<NetworkConnection> connections = Sets.newLinkedHashSet();
|
||||
protected final ReferenceType edit;
|
||||
|
||||
public NetworkConnectionSection(String type, URI href, String info, Integer primaryNetworkConnectionIndex,
|
||||
Iterable<NetworkConnection> connections, ReferenceType edit) {
|
||||
this.type = type;
|
||||
this.href = href;
|
||||
this.info = info;
|
||||
this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex;
|
||||
Iterables.addAll(this.connections, checkNotNull(connections, "connections"));
|
||||
this.edit = edit;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return media type of this section
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return URL to access this section
|
||||
*/
|
||||
public URI getHref() {
|
||||
return href;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The value of the rasd:AddressOnParent element of the device (NIC) supporting the
|
||||
* primary network connection to the containing virtual machine.
|
||||
*/
|
||||
public Integer getPrimaryNetworkConnectionIndex() {
|
||||
return primaryNetworkConnectionIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Set<? extends NetworkConnection> getConnections() {
|
||||
return connections;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ReferenceType getEdit() {
|
||||
return edit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((connections == null) ? 0 : connections.hashCode());
|
||||
result = prime * result + ((edit == null) ? 0 : edit.hashCode());
|
||||
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
||||
result = prime * result + ((info == null) ? 0 : info.hashCode());
|
||||
result = prime * result
|
||||
+ ((primaryNetworkConnectionIndex == null) ? 0 : primaryNetworkConnectionIndex.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NetworkConnectionSection other = (NetworkConnectionSection) obj;
|
||||
if (connections == null) {
|
||||
if (other.connections != null)
|
||||
return false;
|
||||
} else if (!connections.equals(other.connections))
|
||||
return false;
|
||||
if (edit == null) {
|
||||
if (other.edit != null)
|
||||
return false;
|
||||
} else if (!edit.equals(other.edit))
|
||||
return false;
|
||||
if (href == null) {
|
||||
if (other.href != null)
|
||||
return false;
|
||||
} else if (!href.equals(other.href))
|
||||
return false;
|
||||
if (info == null) {
|
||||
if (other.info != null)
|
||||
return false;
|
||||
} else if (!info.equals(other.info))
|
||||
return false;
|
||||
if (primaryNetworkConnectionIndex == null) {
|
||||
if (other.primaryNetworkConnectionIndex != null)
|
||||
return false;
|
||||
} else if (!primaryNetworkConnectionIndex.equals(other.primaryNetworkConnectionIndex))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[href=" + href + ", connections=" + connections + ", primaryNetworkConnectionIndex="
|
||||
+ primaryNetworkConnectionIndex + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -24,8 +24,8 @@ import java.util.List;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.internal.VmImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
|
@ -76,7 +76,7 @@ public interface Vm extends ReferenceType {
|
|||
* @since vcloud api 1.0
|
||||
*/
|
||||
@Nullable
|
||||
VCloudVirtualHardware getHardware();
|
||||
VCloudVirtualHardwareSection getVirtualHardwareSection();
|
||||
|
||||
/**
|
||||
* @return operating system on this VM, or null, if part of a vApp template
|
||||
|
@ -84,7 +84,15 @@ public interface Vm extends ReferenceType {
|
|||
* @since vcloud api 1.0
|
||||
*/
|
||||
@Nullable
|
||||
VCloudOperatingSystem getOperatingSystem();
|
||||
VCloudOperatingSystemSection getOperatingSystemSection();
|
||||
|
||||
/**
|
||||
* @return network connections for this VM, or null if it doesn't exist
|
||||
*
|
||||
* @since vcloud api 1.0
|
||||
*/
|
||||
@Nullable
|
||||
NetworkConnectionSection getNetworkConnectionSection();
|
||||
|
||||
/**
|
||||
* @return guest customization section for this VM, or null if it doesn't exist
|
||||
|
@ -92,7 +100,7 @@ public interface Vm extends ReferenceType {
|
|||
* @since vcloud api 1.0
|
||||
*/
|
||||
@Nullable
|
||||
GuestCustomization getGuestCustomization();
|
||||
GuestCustomizationSection getGuestCustomizationSection();
|
||||
|
||||
/**
|
||||
* read-only identifier created on import
|
||||
|
|
|
@ -26,13 +26,14 @@ import java.util.List;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.GuestCustomization;
|
||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -52,16 +53,18 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
private final String description;
|
||||
private final List<Task> tasks = Lists.newArrayList();
|
||||
@Nullable
|
||||
private final VCloudVirtualHardware hardware;
|
||||
private final VCloudVirtualHardwareSection hardware;
|
||||
private final String vAppScopedLocalId;
|
||||
private final VCloudOperatingSystem os;
|
||||
private final VCloudOperatingSystemSection os;
|
||||
@Nullable
|
||||
private final GuestCustomization guestCustomization;
|
||||
private final GuestCustomizationSection guestCustomization;
|
||||
@Nullable
|
||||
private final NetworkConnectionSection networkConnectionSection;
|
||||
|
||||
public VmImpl(String name, String type, URI id, @Nullable Status status, ReferenceType vApp,
|
||||
@Nullable String description, Iterable<Task> tasks, @Nullable VCloudVirtualHardware hardware,
|
||||
@Nullable VCloudOperatingSystem os, @Nullable GuestCustomization guestCustomization,
|
||||
@Nullable String vAppScopedLocalId) {
|
||||
@Nullable String description, Iterable<Task> tasks, @Nullable VCloudVirtualHardwareSection hardware,
|
||||
@Nullable VCloudOperatingSystemSection os, @Nullable NetworkConnectionSection networkConnectionSection,
|
||||
@Nullable GuestCustomizationSection guestCustomization, @Nullable String vAppScopedLocalId) {
|
||||
super(name, type, id);
|
||||
this.status = status;
|
||||
this.vApp = vApp;// TODO: once <1.0 is killed check not null
|
||||
|
@ -69,6 +72,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
|
||||
this.hardware = hardware;
|
||||
this.os = os;
|
||||
this.networkConnectionSection = networkConnectionSection;
|
||||
this.guestCustomization = guestCustomization;
|
||||
this.vAppScopedLocalId = vAppScopedLocalId;
|
||||
}
|
||||
|
@ -110,7 +114,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public VCloudVirtualHardware getHardware() {
|
||||
public VCloudVirtualHardwareSection getVirtualHardwareSection() {
|
||||
return hardware;
|
||||
}
|
||||
|
||||
|
@ -118,7 +122,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public VCloudOperatingSystem getOperatingSystem() {
|
||||
public VCloudOperatingSystemSection getOperatingSystemSection() {
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -126,7 +130,15 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public GuestCustomization getGuestCustomization() {
|
||||
public NetworkConnectionSection getNetworkConnectionSection() {
|
||||
return networkConnectionSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public GuestCustomizationSection getGuestCustomizationSection() {
|
||||
return guestCustomization;
|
||||
}
|
||||
|
||||
|
@ -145,6 +157,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((guestCustomization == null) ? 0 : guestCustomization.hashCode());
|
||||
result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
|
||||
result = prime * result + ((networkConnectionSection == null) ? 0 : networkConnectionSection.hashCode());
|
||||
result = prime * result + ((os == null) ? 0 : os.hashCode());
|
||||
result = prime * result + ((vApp == null) ? 0 : vApp.hashCode());
|
||||
result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.hashCode());
|
||||
|
@ -175,6 +188,11 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
return false;
|
||||
} else if (!hardware.equals(other.hardware))
|
||||
return false;
|
||||
if (networkConnectionSection == null) {
|
||||
if (other.networkConnectionSection != null)
|
||||
return false;
|
||||
} else if (!networkConnectionSection.equals(other.networkConnectionSection))
|
||||
return false;
|
||||
if (os == null) {
|
||||
if (other.os != null)
|
||||
return false;
|
||||
|
@ -197,7 +215,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
|
|||
public String toString() {
|
||||
return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description
|
||||
+ ", status=" + status + ", tasks=" + tasks + ", vApp=" + vApp + ", hardware=" + hardware + ", os=" + os
|
||||
+ ", vAppScopedLocalId=" + vAppScopedLocalId + "]";
|
||||
+ ", network=" + networkConnectionSection + ", vAppScopedLocalId=" + vAppScopedLocalId + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.domain.network;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The IpAddressAllocationMode element specifies how an IP address is allocated to this connection.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public enum IpAddressAllocationMode {
|
||||
/**
|
||||
* no IP addressing mode specified
|
||||
*
|
||||
* @since vcloud api 1.0
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* static IP address assigned manually
|
||||
*
|
||||
* @since vcloud api 1.0
|
||||
*/
|
||||
MANUAL,
|
||||
/**
|
||||
* static IP address allocated from a pool
|
||||
*
|
||||
* @since vcloud api 1.0
|
||||
*/
|
||||
POOL,
|
||||
/**
|
||||
* IP address assigned by DHCP
|
||||
*
|
||||
* @since vcloud api 1.0
|
||||
*/
|
||||
DHCP;
|
||||
|
||||
}
|
|
@ -63,9 +63,10 @@ public class NetworkConfig {
|
|||
}
|
||||
|
||||
/**
|
||||
* A name for the network. If the {@link org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection} includes a {@link NetworkSection.Network} network
|
||||
* element, the name you specify for the vApp network must match the name specified in that
|
||||
* element’s name attribute.
|
||||
* A name for the network. If the
|
||||
* {@link org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection} includes a
|
||||
* {@link NetworkSection.Network} network element, the name you specify for the vApp network must
|
||||
* match the name specified in that element’s name attribute.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
@ -89,6 +90,7 @@ public class NetworkConfig {
|
|||
return fenceMode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
|
|
@ -30,14 +30,14 @@ import org.jclouds.vcloud.domain.ReferenceType;
|
|||
/**
|
||||
* A description of the operating system supported by a virtual machine.
|
||||
*/
|
||||
public class VCloudOperatingSystem extends OperatingSystemSection {
|
||||
public class VCloudOperatingSystemSection extends OperatingSystemSection {
|
||||
protected final String type;
|
||||
protected final URI href;
|
||||
@Nullable
|
||||
protected final String vmwOsType;
|
||||
protected final ReferenceType edit;
|
||||
|
||||
public VCloudOperatingSystem(@Nullable Integer id, @Nullable String info, @Nullable String description, String type,
|
||||
public VCloudOperatingSystemSection(@Nullable Integer id, @Nullable String info, @Nullable String description, String type,
|
||||
URI href, @Nullable String vmwOsType, ReferenceType edit) {
|
||||
super(id, info, description);
|
||||
this.type = type;
|
||||
|
@ -95,7 +95,7 @@ public class VCloudOperatingSystem extends OperatingSystemSection {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VCloudOperatingSystem other = (VCloudOperatingSystem) obj;
|
||||
VCloudOperatingSystemSection other = (VCloudOperatingSystemSection) obj;
|
||||
if (edit == null) {
|
||||
if (other.edit != null)
|
||||
return false;
|
|
@ -25,11 +25,11 @@ import java.net.URI;
|
|||
/**
|
||||
* A description of the virtual hardware supported by a virtual machine.
|
||||
*/
|
||||
public class VCloudVirtualHardware extends VirtualHardwareSection {
|
||||
public class VCloudVirtualHardwareSection extends VirtualHardwareSection {
|
||||
protected final String type;
|
||||
protected final URI href;
|
||||
|
||||
public VCloudVirtualHardware(String type, URI href, String info, System virtualSystem,
|
||||
public VCloudVirtualHardwareSection(String type, URI href, String info, System virtualSystem,
|
||||
Iterable<? extends ResourceAllocation> resourceAllocations) {
|
||||
super(info, virtualSystem, resourceAllocations);
|
||||
this.type = type;
|
||||
|
@ -61,7 +61,7 @@ public class VCloudVirtualHardware extends VirtualHardwareSection {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VCloudVirtualHardware other = (VCloudVirtualHardware) obj;
|
||||
VCloudVirtualHardwareSection other = (VCloudVirtualHardwareSection) obj;
|
||||
if (href == null) {
|
||||
if (other.href != null)
|
||||
return false;
|
|
@ -25,14 +25,14 @@ import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.GuestCustomization;
|
||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class GuestCustomizationHandler extends ParseSax.HandlerWithResult<GuestCustomization> {
|
||||
public class GuestCustomizationSectionHandler extends ParseSax.HandlerWithResult<GuestCustomizationSection> {
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
private ReferenceType guest;
|
||||
private ReferenceType edit;
|
||||
|
@ -54,8 +54,8 @@ public class GuestCustomizationHandler extends ParseSax.HandlerWithResult<GuestC
|
|||
protected String customizationScript;
|
||||
protected String computerName;
|
||||
|
||||
public GuestCustomization getResult() {
|
||||
GuestCustomization system = new GuestCustomization(guest.getType(), guest.getHref(), info, enabled,
|
||||
public GuestCustomizationSection getResult() {
|
||||
GuestCustomizationSection system = new GuestCustomizationSection(guest.getType(), guest.getHref(), info, enabled,
|
||||
changeSid, virtualMachineId, joinDomainEnabled, useOrgSettings, domainName, domainUserName,
|
||||
domainUserPassword, adminPasswordEnabled, adminPasswordAuto, adminPassword, resetPasswordRequired,
|
||||
customizationScript, computerName, edit);
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.xml;
|
||||
|
||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkConnectionHandler extends ParseSax.HandlerWithResult<NetworkConnection> {
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected String network;
|
||||
protected int networkConnectionIndex;
|
||||
protected String ipAddress;
|
||||
protected String externalIpAddress;
|
||||
protected boolean connected;
|
||||
protected String MACAddress;
|
||||
protected IpAddressAllocationMode ipAddressAllocationMode;
|
||||
|
||||
public NetworkConnection getResult() {
|
||||
NetworkConnection connection = new NetworkConnection(network, networkConnectionIndex, ipAddress,
|
||||
externalIpAddress, connected, MACAddress, ipAddressAllocationMode);
|
||||
this.network = null;
|
||||
this.networkConnectionIndex = -1;
|
||||
this.ipAddress = null;
|
||||
this.externalIpAddress = null;
|
||||
this.connected = false;
|
||||
this.MACAddress = null;
|
||||
this.ipAddressAllocationMode = null;
|
||||
return connection;
|
||||
}
|
||||
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (qName.endsWith("NetworkConnection")) {
|
||||
network = attributes.get("network");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) {
|
||||
if (qName.endsWith("NetworkConnectionIndex")) {
|
||||
this.networkConnectionIndex = Integer.parseInt(currentOrNull());
|
||||
} else if (qName.endsWith("IpAddress")) {
|
||||
this.ipAddress = currentOrNull();
|
||||
} else if (qName.endsWith("ExternalIpAddress")) {
|
||||
this.externalIpAddress = currentOrNull();
|
||||
} else if (qName.endsWith("IsConnected")) {
|
||||
this.connected = Boolean.parseBoolean(currentOrNull());
|
||||
} else if (qName.endsWith("MACAddress")) {
|
||||
this.MACAddress = currentOrNull();
|
||||
} else if (qName.endsWith("IpAddressAllocationMode")) {
|
||||
this.ipAddressAllocationMode = IpAddressAllocationMode.valueOf(currentOrNull());
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.xml;
|
||||
|
||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
||||
import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkConnectionSectionHandler extends ParseSax.HandlerWithResult<NetworkConnectionSection> {
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
|
||||
private final NetworkConnectionHandler networkConnectionHandler;
|
||||
|
||||
@Inject
|
||||
public NetworkConnectionSectionHandler(NetworkConnectionHandler networkConnectionHandler) {
|
||||
this.networkConnectionHandler = networkConnectionHandler;
|
||||
}
|
||||
|
||||
protected String info;
|
||||
protected Set<NetworkConnection> connections = Sets.newLinkedHashSet();
|
||||
protected ReferenceType section;
|
||||
protected ReferenceType edit;
|
||||
protected Integer primaryNetworkConnectionIndex;
|
||||
protected boolean inConnections;
|
||||
|
||||
public NetworkConnectionSection getResult() {
|
||||
return new NetworkConnectionSection(section.getType(), section.getHref(), info, primaryNetworkConnectionIndex,
|
||||
connections, edit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (qName.endsWith("NetworkConnection")) {
|
||||
inConnections = true;
|
||||
}
|
||||
if (inConnections) {
|
||||
networkConnectionHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (qName.endsWith("NetworkConnectionSection")) {
|
||||
section = newReferenceType(attributes);
|
||||
} else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) {
|
||||
edit = newReferenceType(attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) {
|
||||
if (qName.endsWith("NetworkConnection")) {
|
||||
inConnections = false;
|
||||
connections.add(networkConnectionHandler.getResult());
|
||||
}
|
||||
if (inConnections) {
|
||||
networkConnectionHandler.endElement(uri, localName, qName);
|
||||
} else if (qName.endsWith("Info")) {
|
||||
this.info = currentOrNull();
|
||||
} else if (qName.endsWith("PrimaryNetworkConnectionIndex")) {
|
||||
this.primaryNetworkConnectionIndex = new Integer(currentOrNull());
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inConnections)
|
||||
networkConnectionHandler.characters(ch, start, length);
|
||||
else
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
}
|
||||
}
|
|
@ -28,14 +28,14 @@ import javax.inject.Inject;
|
|||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCloudVirtualHardware> {
|
||||
public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCloudVirtualHardwareSection> {
|
||||
|
||||
private final VirtualHardwareSectionHandler hardwareHandler;
|
||||
|
||||
|
@ -46,9 +46,9 @@ public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCl
|
|||
this.hardwareHandler = hardwareHandler;
|
||||
}
|
||||
|
||||
public VCloudVirtualHardware getResult() {
|
||||
public VCloudVirtualHardwareSection getResult() {
|
||||
VirtualHardwareSection hardware = hardwareHandler.getResult();
|
||||
return new VCloudVirtualHardware(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware
|
||||
return new VCloudVirtualHardwareSection(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware
|
||||
.getSystem(), hardware.getResourceAllocations());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,15 @@ import java.util.Map;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.GuestCustomization;
|
||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.internal.VmImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@ -50,14 +51,18 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
|||
protected final TaskHandler taskHandler;
|
||||
protected final VCloudVirtualHardwareHandler virtualHardwareHandler;
|
||||
protected final VCloudOperatingSystemHandler operatingSystemHandler;
|
||||
protected final GuestCustomizationHandler guestCustomizationHandler;
|
||||
protected final GuestCustomizationSectionHandler guestCustomizationHandler;
|
||||
protected final NetworkConnectionSectionHandler networkConnectionSectionHandler;
|
||||
|
||||
@Inject
|
||||
public VmHandler(TaskHandler taskHandler, VCloudVirtualHardwareHandler virtualHardwareHandler,
|
||||
VCloudOperatingSystemHandler operatingSystemHandler, GuestCustomizationHandler guestCustomizationHandler) {
|
||||
VCloudOperatingSystemHandler operatingSystemHandler,
|
||||
NetworkConnectionSectionHandler networkConnectionSectionHandler,
|
||||
GuestCustomizationSectionHandler guestCustomizationHandler) {
|
||||
this.taskHandler = taskHandler;
|
||||
this.virtualHardwareHandler = virtualHardwareHandler;
|
||||
this.operatingSystemHandler = operatingSystemHandler;
|
||||
this.networkConnectionSectionHandler = networkConnectionSectionHandler;
|
||||
this.guestCustomizationHandler = guestCustomizationHandler;
|
||||
}
|
||||
|
||||
|
@ -68,19 +73,21 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
|||
protected ReferenceType vdc;
|
||||
protected String description;
|
||||
protected List<Task> tasks = Lists.newArrayList();
|
||||
protected VCloudVirtualHardware hardware;
|
||||
protected VCloudOperatingSystem os;
|
||||
protected GuestCustomization guestCustomization;
|
||||
protected VCloudVirtualHardwareSection hardware;
|
||||
protected VCloudOperatingSystemSection os;
|
||||
protected NetworkConnectionSection networkConnectionSection;
|
||||
protected GuestCustomizationSection guestCustomization;
|
||||
protected String vAppScopedLocalId;
|
||||
|
||||
private boolean inTasks;
|
||||
private boolean inHardware;
|
||||
private boolean inOs;
|
||||
private boolean inNetworkConnectionSection;
|
||||
private boolean inGuestCustomization;
|
||||
|
||||
public Vm getResult() {
|
||||
return new VmImpl(vm.getName(), vm.getType(), vm.getHref(), status, vdc, description, tasks, hardware, os,
|
||||
guestCustomization, vAppScopedLocalId);
|
||||
networkConnectionSection, guestCustomization, vAppScopedLocalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,6 +99,8 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
|||
inOs = true;
|
||||
} else if (qName.endsWith("GuestCustomizationSection")) {
|
||||
inGuestCustomization = true;
|
||||
} else if (qName.endsWith("NetworkConnectionSection")) {
|
||||
inNetworkConnectionSection = true;
|
||||
} else if (qName.endsWith("Tasks")) {
|
||||
inTasks = true;
|
||||
}
|
||||
|
@ -99,6 +108,8 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
|||
virtualHardwareHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (inOs) {
|
||||
operatingSystemHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (inNetworkConnectionSection) {
|
||||
networkConnectionSectionHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (inGuestCustomization) {
|
||||
guestCustomizationHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (inTasks) {
|
||||
|
@ -120,6 +131,9 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
|||
} else if (qName.endsWith("OperatingSystemSection")) {
|
||||
inOs = false;
|
||||
os = operatingSystemHandler.getResult();
|
||||
} else if (qName.endsWith("NetworkConnectionSection")) {
|
||||
inNetworkConnectionSection = false;
|
||||
networkConnectionSection = networkConnectionSectionHandler.getResult();
|
||||
} else if (qName.endsWith("GuestCustomizationSection")) {
|
||||
inGuestCustomization = false;
|
||||
guestCustomization = guestCustomizationHandler.getResult();
|
||||
|
@ -133,6 +147,8 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
|||
operatingSystemHandler.endElement(uri, name, qName);
|
||||
} else if (inGuestCustomization) {
|
||||
guestCustomizationHandler.endElement(uri, name, qName);
|
||||
} else if (inNetworkConnectionSection) {
|
||||
networkConnectionSectionHandler.endElement(uri, name, qName);
|
||||
} else if (inTasks) {
|
||||
taskHandler.endElement(uri, name, qName);
|
||||
} else if (qName.equals("Description")) {
|
||||
|
@ -144,15 +160,18 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
|||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inTasks)
|
||||
taskHandler.characters(ch, start, length);
|
||||
if (inHardware)
|
||||
virtualHardwareHandler.characters(ch, start, length);
|
||||
if (inOs)
|
||||
else if (inOs)
|
||||
operatingSystemHandler.characters(ch, start, length);
|
||||
if (inGuestCustomization)
|
||||
else if (inGuestCustomization)
|
||||
guestCustomizationHandler.characters(ch, start, length);
|
||||
currentText.append(ch, start, length);
|
||||
else if (inNetworkConnectionSection)
|
||||
networkConnectionSectionHandler.characters(ch, start, length);
|
||||
else if (inTasks)
|
||||
taskHandler.characters(ch, start, length);
|
||||
else
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
|
|
|
@ -25,14 +25,14 @@ import java.util.Map;
|
|||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCloudOperatingSystem> {
|
||||
public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCloudOperatingSystemSection> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected ReferenceType os;
|
||||
|
@ -42,8 +42,8 @@ public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCl
|
|||
protected String description;
|
||||
protected ReferenceType edit;
|
||||
|
||||
public VCloudOperatingSystem getResult() {
|
||||
VCloudOperatingSystem system = new VCloudOperatingSystem(id, info, description, os.getType(), os.getHref(),
|
||||
public VCloudOperatingSystemSection getResult() {
|
||||
VCloudOperatingSystemSection system = new VCloudOperatingSystemSection(id, info, description, os.getType(), os.getHref(),
|
||||
vmwOsType, edit);
|
||||
os = null;
|
||||
id = null;
|
||||
|
|
|
@ -1,169 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudClient}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", enabled = true, sequential = true, testName = "vcloud.VCloudClientLiveTest")
|
||||
public class VCloudComputeClientLiveTest {
|
||||
protected String provider;
|
||||
protected VCloudComputeClient computeClient;
|
||||
protected VCloudClient client;
|
||||
|
||||
protected URI id;
|
||||
protected String publicAddress;
|
||||
protected String templateName;
|
||||
|
||||
public static class Expectation {
|
||||
final long hardDisk;
|
||||
final String os;
|
||||
|
||||
public Expectation(long hardDisk, String os) {
|
||||
this.hardDisk = hardDisk;
|
||||
this.os = os;
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<OsFamily, Expectation> expectationMap;
|
||||
|
||||
protected Predicate<IPSocket> addressTester;
|
||||
private String identity;
|
||||
private String credential;
|
||||
|
||||
@Test(enabled = true)
|
||||
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
OsFamily toTest = OsFamily.CENTOS;
|
||||
|
||||
String serverName = getCompatibleServerName(toTest);
|
||||
int processorCount = 1;
|
||||
int memory = 512;
|
||||
|
||||
VAppTemplate template = client.findVAppTemplateInOrgCatalogNamed(null, null, templateName);
|
||||
InstantiateVAppTemplateOptions options = processorCount(1).memory(512).disk(10 * 1025 * 1024);
|
||||
|
||||
id = URI.create(computeClient.start(null, template.getHref(), templateName, options).get("id"));
|
||||
Expectation expectation = expectationMap.get(toTest);
|
||||
|
||||
VApp vApp = client.getVApp(id);
|
||||
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk);
|
||||
assertEquals(vApp.getStatus(), Status.ON);
|
||||
}
|
||||
|
||||
private String getCompatibleServerName(OsFamily toTest) {
|
||||
String serverName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, toTest.toString()).substring(0,
|
||||
toTest.toString().length() <= 15 ? toTest.toString().length() : 14);
|
||||
return serverName;
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testPowerOn", enabled = true)
|
||||
public void testGetPublicAddresses() {
|
||||
publicAddress = Iterables.getLast(computeClient.getPublicAddresses(id));
|
||||
assert !addressTester.apply(new IPSocket(publicAddress, 22));
|
||||
}
|
||||
|
||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
|
||||
int memory, long hardDisk) {
|
||||
assertEquals(vApp.getName(), serverName);
|
||||
// assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||
// assertEquals(Iterables
|
||||
// .getOnlyElement(filter(vApp.getResourceAllocations(),
|
||||
// resourceType(ResourceType.PROCESSOR)))
|
||||
// .getVirtualQuantity(), processorCount);
|
||||
// assertEquals(Iterables.getOnlyElement(
|
||||
// filter(vApp.getResourceAllocations(),
|
||||
// resourceType(ResourceType.SCSI_CONTROLLER))).getVirtualQuantity(),
|
||||
// 1);
|
||||
// assertEquals(Iterables.getOnlyElement(filter(vApp.getResourceAllocations(),
|
||||
// resourceType(ResourceType.MEMORY)))
|
||||
// .getVirtualQuantity(), memory);
|
||||
// assertEquals(Iterables.getOnlyElement(
|
||||
// filter(vApp.getResourceAllocations(),
|
||||
// resourceType(ResourceType.DISK_DRIVE))).getVirtualQuantity(),
|
||||
// hardDisk);
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
if (id != null)
|
||||
computeClient.stop(id);
|
||||
}
|
||||
|
||||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("vcloud.identity"), "vcloud.identity");
|
||||
credential = checkNotNull(System.getProperty("vcloud.credential"), "vcloud.credential");
|
||||
}
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
setupCredentials();
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true");
|
||||
Injector injector = new RestContextFactory().createContextBuilder("vcloud", identity, credential,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), properties).buildInjector();
|
||||
|
||||
computeClient = injector.getInstance(VCloudComputeClient.class);
|
||||
client = injector.getInstance(VCloudClient.class);
|
||||
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<IPSocket>>() {
|
||||
}));
|
||||
expectationMap = ImmutableMap.<OsFamily, Expectation> builder().put(OsFamily.CENTOS,
|
||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
|
||||
provider = "vcloudtest";
|
||||
templateName = "Ubuntu JeOS 9.10 (32-bit)";
|
||||
}
|
||||
|
||||
}
|
|
@ -27,7 +27,7 @@ import java.net.UnknownHostException;
|
|||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.GuestCustomization;
|
||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -37,19 +37,19 @@ import org.testng.annotations.Test;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.GuestCustomizationSectionHandlerTest")
|
||||
public class GuestCustomizationHandlerTest extends BaseHandlerTest {
|
||||
public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {
|
||||
|
||||
public void testDefault() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/guestCustomization.xml");
|
||||
|
||||
GuestCustomization result = factory.create(injector.getInstance(GuestCustomizationHandler.class)).parse(is);
|
||||
GuestCustomizationSection result = factory.create(injector.getInstance(GuestCustomizationSectionHandler.class)).parse(is);
|
||||
|
||||
checkGuestCustomization(result);
|
||||
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public static void checkGuestCustomization(GuestCustomization result) {
|
||||
public static void checkGuestCustomization(GuestCustomizationSection result) {
|
||||
assertEquals(result.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
|
||||
assertEquals(result.getHref(), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"));
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.xml;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NetworkConnectionSectionHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.NetworkConnectionSectionHandlerTest")
|
||||
public class NetworkConnectionHandlerTest extends BaseHandlerTest {
|
||||
|
||||
public void testDefault() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/networkconnection.xml");
|
||||
|
||||
NetworkConnection result = factory.create(injector.getInstance(NetworkConnectionHandler.class)).parse(is);
|
||||
|
||||
checkNetworkConnection(result);
|
||||
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public static void checkNetworkConnection(NetworkConnection result) {
|
||||
assertEquals(result.getNetwork(), "internet01");
|
||||
assertEquals(result.getNetworkConnectionIndex(), 0);
|
||||
assertEquals(result.getIpAddress(), "174.47.101.164");
|
||||
assertEquals(result.getExternalIpAddress(), null);
|
||||
assertEquals(result.isConnected(), true);
|
||||
assertEquals(result.getMACAddress(), "00:50:56:01:01:f2");
|
||||
assertEquals(result.getIpAddressAllocationMode(), IpAddressAllocationMode.POOL);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 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.xml;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NetworkConnectionSectionHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.NetworkConnectionSectionHandlerTest")
|
||||
public class NetworkConnectionSectionHandlerTest {
|
||||
public void testVCloud1_0() {
|
||||
InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
|
||||
.parse(is);
|
||||
checkNetworkConnectionSection(result);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
static void checkNetworkConnectionSection(NetworkConnectionSection result) {
|
||||
assertEquals(result.getHref(), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/"));
|
||||
assertEquals(result.getType(), VCloudMediaType.NETWORKCONNECTIONSECTION_XML);
|
||||
assertEquals(result.getInfo(), "Specifies the available VM network connections");
|
||||
assertEquals(result.getPrimaryNetworkConnectionIndex(), new Integer(0));
|
||||
assertEquals(result.getEdit(), new ReferenceTypeImpl(null, VCloudMediaType.NETWORKCONNECTIONSECTION_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/")));
|
||||
NetworkConnectionHandlerTest.checkNetworkConnection(Iterables.getOnlyElement(result.getConnections()));
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.GuestCustomization;
|
||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
|
@ -78,7 +78,7 @@ public class VAppTemplateHandlerTest {
|
|||
assertEquals(vm.getTasks(), ImmutableList.of());
|
||||
assertEquals(vm.getVAppScopedLocalId(), "02_ubuntu_template");
|
||||
|
||||
GuestCustomization guestC = vm.getGuestCustomization();
|
||||
GuestCustomizationSection guestC = vm.getGuestCustomizationSection();
|
||||
|
||||
assertEquals(guestC.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
|
||||
assertEquals(
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.jclouds.vcloud.VCloudMediaType;
|
|||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandlerTest;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareHandlerTest;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemSectionHandlerTest;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareSectionHandlerTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -64,9 +64,10 @@ public class VmHandlerTest {
|
|||
assertEquals(result.getDescription(), null);
|
||||
assertEquals(result.getTasks(), ImmutableList.of());
|
||||
assertEquals(result.getVAppScopedLocalId(), "10_rhel_template");
|
||||
VCloudVirtualHardwareHandlerTest.checkHardware(result.getHardware());
|
||||
VCloudOperatingSystemHandlerTest.checkOs(result.getOperatingSystem());
|
||||
GuestCustomizationHandlerTest.checkGuestCustomization(result.getGuestCustomization());
|
||||
VCloudVirtualHardwareSectionHandlerTest.checkHardware(result.getVirtualHardwareSection());
|
||||
VCloudOperatingSystemSectionHandlerTest.checkOs(result.getOperatingSystemSection());
|
||||
NetworkConnectionSectionHandlerTest.checkNetworkConnectionSection(result.getNetworkConnectionSection());
|
||||
GuestCustomizationSectionHandlerTest.checkGuestCustomization(result.getGuestCustomizationSection());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.net.UnknownHostException;
|
|||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -37,19 +37,19 @@ import org.testng.annotations.Test;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.VCloudOperatingSystemHandlerTest")
|
||||
public class VCloudOperatingSystemHandlerTest extends BaseHandlerTest {
|
||||
public class VCloudOperatingSystemSectionHandlerTest extends BaseHandlerTest {
|
||||
|
||||
public void testDefault() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/os.xml");
|
||||
|
||||
VCloudOperatingSystem result = factory.create(injector.getInstance(VCloudOperatingSystemHandler.class)).parse(is);
|
||||
VCloudOperatingSystemSection result = factory.create(injector.getInstance(VCloudOperatingSystemHandler.class)).parse(is);
|
||||
|
||||
checkOs(result);
|
||||
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public static void checkOs(VCloudOperatingSystem result) {
|
||||
public static void checkOs(VCloudOperatingSystemSection result) {
|
||||
assertEquals(result.getHref(), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"));
|
||||
assertEquals(result.getDescription(), "Red Hat Enterprise Linux 5 (64-bit)");
|
|
@ -33,7 +33,7 @@ import org.jclouds.vcloud.domain.ovf.ResourceType;
|
|||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
||||
import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -46,19 +46,19 @@ import com.google.common.collect.Iterables;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.VCloudVirtualHardwareHandlerTest")
|
||||
public class VCloudVirtualHardwareHandlerTest extends BaseHandlerTest {
|
||||
public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest {
|
||||
|
||||
public void testDefault() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml");
|
||||
|
||||
VCloudVirtualHardware result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class)).parse(is);
|
||||
VCloudVirtualHardwareSection result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class)).parse(is);
|
||||
|
||||
checkHardware(result);
|
||||
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public static void checkHardware(VCloudVirtualHardware result) {
|
||||
public static void checkHardware(VCloudVirtualHardwareSection result) {
|
||||
System system = new System(0, "Virtual Hardware Family", "RHEL5", ImmutableSet.of("vmx-07"));
|
||||
|
||||
assertEquals(result.getHref(), URI
|
|
@ -0,0 +1,7 @@
|
|||
<NetworkConnection network="internet01">
|
||||
<NetworkConnectionIndex>0</NetworkConnectionIndex>
|
||||
<IpAddress>174.47.101.164</IpAddress>
|
||||
<IsConnected>true</IsConnected>
|
||||
<MACAddress>00:50:56:01:01:f2</MACAddress>
|
||||
<IpAddressAllocationMode>POOL</IpAddressAllocationMode>
|
||||
</NetworkConnection>
|
|
@ -0,0 +1,18 @@
|
|||
<NetworkConnectionSection
|
||||
type="application/vnd.vmware.vcloud.networkConnectionSection+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/"
|
||||
ovf:required="false">
|
||||
<ovf:Info>Specifies the available VM network connections</ovf:Info>
|
||||
<PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
|
||||
<NetworkConnection network="internet01">
|
||||
<NetworkConnectionIndex>0</NetworkConnectionIndex>
|
||||
<IpAddress>174.47.101.164</IpAddress>
|
||||
<IsConnected>true</IsConnected>
|
||||
<MACAddress>00:50:56:01:01:f2</MACAddress>
|
||||
<IpAddressAllocationMode>POOL</IpAddressAllocationMode>
|
||||
</NetworkConnection>
|
||||
<Link rel="edit"
|
||||
type="application/vnd.vmware.vcloud.networkConnectionSection+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/" />
|
||||
</NetworkConnectionSection>
|
||||
|
|
@ -45,7 +45,7 @@ import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
|||
import org.jclouds.vcloud.VCloudExpressClient;
|
||||
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
|
||||
import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressDestroyNodeStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressListNodesStrategy;
|
||||
import org.jclouds.vcloud.compute.strategy.VCloudExpressRebootNodeStrategy;
|
||||
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient;
|
||||
|
@ -101,7 +101,7 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudExpressCom
|
|||
// NOTE
|
||||
bind(GetNodeMetadataStrategy.class).to(TerremarkVCloudGetNodeMetadataStrategy.class);
|
||||
bind(RebootNodeStrategy.class).to(VCloudExpressRebootNodeStrategy.class);
|
||||
bind(DestroyNodeStrategy.class).to(VCloudDestroyNodeStrategy.class);
|
||||
bind(DestroyNodeStrategy.class).to(VCloudExpressDestroyNodeStrategy.class);
|
||||
bindLoadBalancer();
|
||||
// MORE specifics...
|
||||
bind(new TypeLiteral<Function<NodeMetadata, OrgAndName>>() {
|
||||
|
|
Loading…
Reference in New Issue