Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Implement ServerWithNatRuleToNodeMetadata Function #428

Conversation

btrishkin
Copy link

No description provided.

Copy link
Member

@nacx nacx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @btrishkin!

Server server = serverWithExternalIp.server();
builder.ids(server.id());
builder.name(server.name());
builder.hostname(serverWithExternalIp.server().description());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the hostname? Don't put that here if not.

builder.ids(server.id());
builder.name(server.name());
builder.hostname(serverWithExternalIp.server().description());
if (server.datacenterId() != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under which circumstances can this be null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be null. Our xsd has it as a required attribute:
<xs:attribute name="datacenterId" type="xs:string" use="required"/>

}
if (privateAddress != null && serverWithExternalIp.externalIp() != null) {
builder.publicAddresses(ImmutableSet.of(serverWithExternalIp.externalIp()));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider not only the primary NIC here. Let's return all IP addresses of the server.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, why read the external IP only if there is a private IP?

Credentials credentials = credentialStore.get("node#" + server.id());
if (credentials instanceof LoginCredentials) {
builder.credentials(LoginCredentials.class.cast(credentials));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this. The credentials are already set by jclouds.

BaseImage getBaseImage(final String sourceImageId) {
BaseImage baseImage = api.getServerImageApi().getOsImage(sourceImageId);
return baseImage == null ? api.getServerImageApi().getCustomerImage(sourceImageId) : baseImage;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means two additional calls for each existing node, to get the image info. Instead of doing this, could you inject the image supplier to this class?
jclouds caches the results of the ComptueService.listImages call (as it is usually an expensive one). You could look for the image in the list of cached images and save these two calls for each node (that would be a significant amount of extra calls when calling listNodes in large environments).

@btrishkin
Copy link
Author

ServerWithNatRuleToNodeMetadata Function reimplemented without expensive image list API calls.
BaseImageToImage and BaseImageToHardware are not required for this function anymore, but we have plans to use them later

Copy link
Member

@nacx nacx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @btrishkin! Just one minor comment left. Apart from that, LGTM!


private final OperatingSystemToOsFamily operatingSystemToOsFamily;

public OperatingSystemToOperatingSystem(final OperatingSystemToOsFamily operatingSystemToOsFamily) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the @Inject annotation and remove the public modifier from the constructor to make it package private (background).

@btrishkin btrishkin force-pushed the server-with-nat-rule-to-node-metadata branch from 69cdeb3 to 39a47e7 Compare April 13, 2018 09:33
@btrishkin
Copy link
Author

@nacx small issue fixed and commits squashed.

@nacx
Copy link
Member

nacx commented Apr 17, 2018

Pushed to master and 2.1.x. Thanks @btrishkin!

@nacx nacx closed this Apr 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants