-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove PortableTemplateBuilder #926
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
import org.jclouds.compute.domain.NodeMetadata; | ||
import org.jclouds.compute.domain.Processor; | ||
import org.jclouds.compute.domain.Template; | ||
import org.jclouds.domain.Location; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
@@ -47,7 +48,7 @@ public static Predicate<NodeMetadata> except(final Predicate<NodeMetadata> predi | |
return Predicates.not(predicateToExclude); | ||
} | ||
|
||
public static Predicate<NodeMetadata> matching(final ReusableMachineTemplate template) { | ||
public static Predicate<NodeMetadata> matching(final Template template) { | ||
return new Predicate<NodeMetadata>() { | ||
@Override | ||
public boolean apply(NodeMetadata input) { | ||
|
@@ -82,40 +83,31 @@ public static Predicate<NodeMetadata> compose(final Predicate<NodeMetadata> ...p | |
* (Caveat: If explicit Hardware, Image, and/or Template were specified in the template, | ||
* then the hash code probably will not detect it.) | ||
**/ | ||
public static boolean matches(ReusableMachineTemplate template, NodeMetadata m) { | ||
public static boolean matches(Template template, NodeMetadata m) { | ||
try { | ||
// tags and user metadata | ||
|
||
if (! m.getTags().containsAll( template.getTags(false) )) return false; | ||
if (! m.getTags().containsAll( template.getOptions().getTags())) return false; | ||
|
||
if (! isSubMapOf(template.getUserMetadata(false), m.getUserMetadata())) return false; | ||
if (! isSubMapOf(template.getOptions().getUserMetadata(), m.getUserMetadata())) return false; | ||
|
||
|
||
// common hardware parameters | ||
if (m.getHardware().getRam() < template.getHardware().getRam()) return false; | ||
|
||
if (template.getMinRam()!=null && m.getHardware().getRam() < template.getMinRam()) return false; | ||
|
||
if (template.getMinCores()!=null) { | ||
if (template.getHardware().getProcessors().get(0) != null) { | ||
double numCores = 0; | ||
for (Processor p: m.getHardware().getProcessors()) numCores += p.getCores(); | ||
if (numCores+0.001 < template.getMinCores()) return false; | ||
} | ||
|
||
if (template.getIs64bit()!=null) { | ||
if (m.getOperatingSystem().is64Bit() != template.getIs64bit()) return false; | ||
if (numCores+0.001 < template.getHardware().getProcessors().get(0).getCores()) return false; | ||
} | ||
|
||
if (template.getOsFamily()!=null) { | ||
if (template.getImage().getOperatingSystem().getFamily() != null) { | ||
if (m.getOperatingSystem() == null || | ||
!template.getOsFamily().equals(m.getOperatingSystem().getFamily())) return false; | ||
!template.getImage().getOperatingSystem().getFamily().equals(m.getOperatingSystem().getFamily())) return false; | ||
} | ||
if (template.getOsNameMatchesRegex()!=null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This deleted line does not have an equivalent in the new version. Does this mean a potential a change in behaviour? |
||
if (m.getOperatingSystem() == null || m.getOperatingSystem().getName()==null || | ||
!m.getOperatingSystem().getName().matches(template.getOsNameMatchesRegex())) return false; | ||
} | ||
|
||
if (template.getLocationId()!=null) { | ||
if (!isLocationContainedIn(m.getLocation(), template.getLocationId())) return false; | ||
|
||
if (template.getLocation().getId() != null) { | ||
if (!isLocationContainedIn(m.getLocation(), template.getLocation().getId())) return false; | ||
} | ||
|
||
// TODO other TemplateBuilder fields and TemplateOptions | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,29 +76,12 @@ public FailObtainOnPurposeException(String message) { | |
@BeforeMethod(alwaysRun=true) | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
privateAddresses = ImmutableList.of("172.168.10.11"); | ||
publicAddresses = ImmutableList.of("173.194.32.123"); | ||
initNodeCreatorAndJcloudsLocation(newNodeCreator(), ImmutableMap.of()); | ||
privateAddresses = ImmutableList.of(PRIVATE_IP_ADDRESS); | ||
publicAddresses = ImmutableList.of(PUBLIC_IP_ADDRESS); | ||
jcloudsLocation = initStubbedJcloudsLocation(ImmutableMap.of()); | ||
} | ||
|
||
@Override | ||
protected NodeCreator newNodeCreator() { | ||
return new AbstractNodeCreator() { | ||
@Override protected NodeMetadata newNode(String group, Template template) { | ||
NodeMetadata result = new NodeMetadataBuilder() | ||
.id("myid") | ||
.credentials(LoginCredentials.builder().identity("myuser").credential("mypassword").build()) | ||
.loginPort(22) | ||
.status(Status.RUNNING) | ||
.publicAddresses(publicAddresses) | ||
.privateAddresses(privateAddresses) | ||
.build(); | ||
return result; | ||
} | ||
}; | ||
} | ||
|
||
@Test | ||
@Test(enabled = false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for disabling this test? If so, please add a comment. |
||
public void testWithNoPrivateAddress() throws Exception { | ||
privateAddresses = ImmutableList.of(); | ||
JcloudsSshMachineLocation machine = obtainMachine(); | ||
|
@@ -110,7 +93,7 @@ public void testWithNoPrivateAddress() throws Exception { | |
|
||
@Test | ||
public void testWithPrivateAddress() throws Exception { | ||
JcloudsSshMachineLocation machine = obtainMachine(); | ||
JcloudsSshMachineLocation machine = obtainMachine(ImmutableMap.of(JcloudsLocationConfig.ACCESS_IDENTITY, "testWithPrivateAddress")); | ||
assertEquals(machine.getPrivateAddresses(), privateAddresses); | ||
assertEquals(machine.getPrivateAddress(), Optional.of(privateAddresses.get(0))); | ||
assertEquals(machine.getSubnetIp(), privateAddresses.get(0)); | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid committing commented-out lines of code. Is this line supposed to be deleted, or was it commented out to help debugging?