mirror of https://github.com/apache/jclouds.git
adjusted behavior relating to name/hostname
This commit is contained in:
parent
dc494414ba
commit
d0a2f54cb3
|
@ -94,7 +94,13 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
|||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||
builder.ids(from.getId() + "");
|
||||
builder.name(from.getName());
|
||||
builder.hostname(from.getHostname());
|
||||
// TODO: in cloudstack 2.2.12, when "name" was set fine on the backend,
|
||||
// but wrong API response was returned to the user
|
||||
// http://bugs.cloud.com/show_bug.cgi?id=11664
|
||||
//
|
||||
// we set displayName to the same value as name, but this could be wrong
|
||||
// on hosts not started with jclouds
|
||||
builder.hostname(from.getDisplayName());
|
||||
builder.location(findLocationForVirtualMachine.apply(from));
|
||||
builder.group(parseGroupFromName(from.getDisplayName()));
|
||||
Image image = findImageForVirtualMachine.apply(from);
|
||||
|
@ -120,14 +126,14 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
|||
}
|
||||
try {
|
||||
|
||||
builder.publicAddresses(transform(filter(getIPForwardingRulesByVirtualMachine.getUnchecked(from.getId()),
|
||||
builder.publicAddresses(transform(
|
||||
filter(getIPForwardingRulesByVirtualMachine.getUnchecked(from.getId()),
|
||||
new Predicate<IPForwardingRule>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable IPForwardingRule rule) {
|
||||
return !"Deleting".equals(rule.getState());
|
||||
}
|
||||
}),
|
||||
new Function<IPForwardingRule, String>() {
|
||||
}), new Function<IPForwardingRule, String>() {
|
||||
@Override
|
||||
public String apply(@Nullable IPForwardingRule rule) {
|
||||
return rule.getIPAddress();
|
||||
|
|
|
@ -121,8 +121,7 @@ public class CloudStackComputeServiceAdapter implements
|
|||
|
||||
CloudStackTemplateOptions templateOptions = template.getOptions().as(CloudStackTemplateOptions.class);
|
||||
|
||||
// not all hypervisors support setting name
|
||||
DeployVirtualMachineOptions options = displayName(name);
|
||||
DeployVirtualMachineOptions options = displayName(name).name(name);
|
||||
if (templateOptions.getSecurityGroupIds().size() > 0) {
|
||||
options.securityGroupIds(templateOptions.getSecurityGroupIds());
|
||||
} else if (templateOptions.getNetworkIds().size() > 0) {
|
||||
|
|
|
@ -72,7 +72,8 @@ public class CreatePortForwardingRulesForIP {
|
|||
}
|
||||
|
||||
public Set<IPForwardingRule> apply(PublicIPAddress ip, String protocol, Iterable<Integer> ports) {
|
||||
checkState(ip.getVirtualMachineId() != -1, "ip should be static NATed to a virtual machine");
|
||||
checkState(ip.getVirtualMachineId() != -1,
|
||||
"ip %s should be static NATed to a virtual machine before applying rules", ip);
|
||||
if (Iterables.size(ports) == 0)
|
||||
return ImmutableSet.<IPForwardingRule> of();
|
||||
Builder<AsyncCreateResponse> responses = ImmutableSet.<AsyncCreateResponse> builder();
|
||||
|
|
|
@ -62,6 +62,9 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* sets the displayName - just for display purposes. We don't pass this
|
||||
* parameter to the backend.
|
||||
*
|
||||
* @param displayName
|
||||
* an optional user generated name for the virtual machine
|
||||
*/
|
||||
|
@ -98,6 +101,10 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* sets the hostName, it will be propagated down to the backend and set on
|
||||
* the user vm. If this parameter is not passed it, it will be defaulted to
|
||||
* our usual "i-x-y'
|
||||
*
|
||||
* @param name
|
||||
* host name for the virtual machine
|
||||
*/
|
||||
|
@ -122,14 +129,9 @@ public class DeployVirtualMachineOptions extends AccountInDomainOptions {
|
|||
public DeployVirtualMachineOptions ipsToNetworks(Map<String, Long> ipsToNetworks) {
|
||||
int count = 0;
|
||||
for (String ip : ipsToNetworks.keySet()) {
|
||||
this.queryParameters.replaceValues(
|
||||
String.format("ipnetworklist[%d].ip", count),
|
||||
ImmutableSet.of(ip)
|
||||
);
|
||||
this.queryParameters.replaceValues(
|
||||
String.format("ipnetworklist[%d].networkid", count),
|
||||
ImmutableSet.of("" + ipsToNetworks.get(ip))
|
||||
);
|
||||
this.queryParameters.replaceValues(String.format("ipnetworklist[%d].ip", count), ImmutableSet.of(ip));
|
||||
this.queryParameters.replaceValues(String.format("ipnetworklist[%d].networkid", count),
|
||||
ImmutableSet.of("" + ipsToNetworks.get(ip)));
|
||||
count += 1;
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -82,7 +82,7 @@ public class VirtualMachineToNodeMetadataTest {
|
|||
assertEquals(
|
||||
node.toString(),
|
||||
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3")
|
||||
.location(ZoneToLocationTest.one).state(NodeState.PENDING)
|
||||
.location(ZoneToLocationTest.one).state(NodeState.PENDING).hostname("i-3-54-VM")
|
||||
.privateAddresses(ImmutableSet.of("10.1.1.18")).publicAddresses(ImmutableSet.of("1.1.1.1"))
|
||||
.hardware(ServiceOfferingToHardwareTest.one).imageId(TemplateToImageTest.one.getId())
|
||||
.operatingSystem(TemplateToImageTest.one.getOperatingSystem()).build().toString());
|
||||
|
@ -120,7 +120,7 @@ public class VirtualMachineToNodeMetadataTest {
|
|||
assertEquals(
|
||||
node.toString(),
|
||||
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3")
|
||||
.location(ZoneToLocationTest.one).state(NodeState.PENDING)
|
||||
.location(ZoneToLocationTest.one).state(NodeState.PENDING).hostname("i-3-54-VM")
|
||||
.privateAddresses(ImmutableSet.of("10.1.1.18")).hardware(ServiceOfferingToHardwareTest.one)
|
||||
.imageId(TemplateToImageTest.one.getId())
|
||||
.operatingSystem(TemplateToImageTest.one.getOperatingSystem()).build().toString());
|
||||
|
|
Loading…
Reference in New Issue