mirror of https://github.com/apache/jclouds.git
Null guards
This commit is contained in:
parent
bf40d2ed2b
commit
e3dc3fb976
|
@ -156,6 +156,7 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
||||||
// the VM
|
// the VM
|
||||||
VirtualMachineInstance instanceDetails = api.getVirtualMachineApi(azureGroup).getInstanceDetails(
|
VirtualMachineInstance instanceDetails = api.getVirtualMachineApi(azureGroup).getInstanceDetails(
|
||||||
virtualMachine.name());
|
virtualMachine.name());
|
||||||
|
if (instanceDetails != null && instanceDetails.powerState() != null) {
|
||||||
builder.status(POWERSTATE_TO_NODESTATUS.apply(instanceDetails.powerState()));
|
builder.status(POWERSTATE_TO_NODESTATUS.apply(instanceDetails.powerState()));
|
||||||
builder.backendStatus(Joiner.on(',').join(
|
builder.backendStatus(Joiner.on(',').join(
|
||||||
transform(instanceDetails.statuses(), new Function<VirtualMachineStatus, String>() {
|
transform(instanceDetails.statuses(), new Function<VirtualMachineStatus, String>() {
|
||||||
|
@ -164,6 +165,10 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
||||||
return input.code();
|
return input.code();
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
} else {
|
||||||
|
builder.status(NodeMetadata.Status.PENDING);
|
||||||
|
builder.backendStatus(provisioningState.name());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
builder.status(PROVISIONINGSTATE_TO_NODESTATUS.apply(provisioningState));
|
builder.status(PROVISIONINGSTATE_TO_NODESTATUS.apply(provisioningState));
|
||||||
builder.backendStatus(provisioningState.name());
|
builder.backendStatus(provisioningState.name());
|
||||||
|
@ -207,10 +212,15 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
||||||
List<String> privateIpAddresses = Lists.newArrayList();
|
List<String> privateIpAddresses = Lists.newArrayList();
|
||||||
for (IdReference networkInterfaceCardIdReference : idReferences) {
|
for (IdReference networkInterfaceCardIdReference : idReferences) {
|
||||||
NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
|
NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
|
||||||
|
if (networkInterfaceCard != null && networkInterfaceCard.properties() != null
|
||||||
|
&& networkInterfaceCard.properties().ipConfigurations() != null) {
|
||||||
for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
|
for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
|
||||||
|
if (ipConfiguration.properties().privateIPAddress() != null) {
|
||||||
privateIpAddresses.add(ipConfiguration.properties().privateIPAddress());
|
privateIpAddresses.add(ipConfiguration.properties().privateIPAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return privateIpAddresses;
|
return privateIpAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +236,8 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
||||||
List<String> publicIpAddresses = Lists.newArrayList();
|
List<String> publicIpAddresses = Lists.newArrayList();
|
||||||
for (IdReference networkInterfaceCardIdReference : idReferences) {
|
for (IdReference networkInterfaceCardIdReference : idReferences) {
|
||||||
NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
|
NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
|
||||||
|
if (networkInterfaceCard != null && networkInterfaceCard.properties() != null
|
||||||
|
&& networkInterfaceCard.properties().ipConfigurations() != null) {
|
||||||
String resourceGroup = Iterables.get(Splitter.on("/").split(networkInterfaceCardIdReference.id()), 4);
|
String resourceGroup = Iterables.get(Splitter.on("/").split(networkInterfaceCardIdReference.id()), 4);
|
||||||
for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
|
for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
|
||||||
if (ipConfiguration.properties().publicIPAddress() != null) {
|
if (ipConfiguration.properties().publicIPAddress() != null) {
|
||||||
|
@ -235,6 +247,7 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return publicIpAddresses;
|
return publicIpAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue