Skip to content

Commit

Permalink
Fixed instance hostname saving logic (related to #167)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Dec 9, 2016
1 parent 02b7d3c commit 627858a
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class ListInstancesOperation implements SupplyingOperation<Set<Instance>>

@Value("${perspective.openstack.console.type:off}")
private String consoleType;
@Value("${perspective.openstack.default.domain}")

@Value("${perspective.openstack.default.domain:}") //Default is empty string
private String defaultDomain;


Expand Down Expand Up @@ -200,9 +200,7 @@ private Instance createInstance(Cloud cloud, String region, Server server) {
Optional<Network> networkCandidate = project.getNetworks().stream()
.filter(n -> n.getName().equals(networkName))
.findFirst();
if (networkCandidate.isPresent()) {
networks.add(networkCandidate.get());
}
networkCandidate.ifPresent(networks::add);
});
instance.setNetworks(networks);
String fqdn = getFQDN(server.getName());
Expand All @@ -212,9 +210,7 @@ private Instance createInstance(Cloud cloud, String region, Server server) {
if (server.getImage() != null) {
String imageId = idGenerator.getImageId(cloud, server.getImage().getId());
Optional<Image> imageCandidate = imagesAware.getImage(imageId);
if (imageCandidate.isPresent()) {
instance.setImage(imageCandidate.get());
}
imageCandidate.ifPresent(instance::setImage);
}

return instance;
Expand All @@ -224,8 +220,8 @@ private String getFQDN(String instanceName) {
if (instanceName.contains(DOT)) {
return instanceName;
}
return defaultDomain != null ?
String.format("%s.%s", instanceName, defaultDomain) : instanceName;
return defaultDomain.isEmpty() ?
instanceName : String.format("%s.%s", instanceName, defaultDomain);
}

private void addConsoleUrl(Instance instance, Api api) {
Expand Down

0 comments on commit 627858a

Please sign in to comment.