@Override @Deprecated public Maybe<Location> resolve(String spec, Boolean manage, Map locationFlags) { if (manage!=null) { locationFlags = MutableMap.copyOf(locationFlags); locationFlags.put(LocalLocationManager.CREATE_UNMANAGED, !manage); } Maybe<LocationSpec<? extends Location>> lSpec = getLocationSpec(spec, locationFlags); if (lSpec.isAbsent()) return (Maybe)lSpec; return Maybe.of((Location)mgmt.getLocationManager().createLocation(lSpec.get())); }
@Test(groups = "Integration") public void testGetJavaVersion() throws Exception { SshMachineLocation sshLocation = app.getManagementContext().getLocationManager().createLocation( LocationSpec.create(SshMachineLocation.class).configure("address", "localhost")); JavaSoftwareProcessSshDriver driver = new ConcreteJavaSoftwareProcessSshDriver(app, sshLocation); Optional<String> version = driver.getInstalledJavaVersion(); assertNotNull(version); assertTrue(version.isPresent()); LOG.info("{}.testGetJavaVersion found: {} on localhost", getClass(), version.get()); }
@BeforeMethod(alwaysRun=true) @Override public void setUp() throws Exception { super.setUp(); loc1 = mgmt.getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class)); }
@Override public Void apply(ManagementContext mgmt) { TestApplication app = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class)); SshMachineLocation loc = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); SshMachineLocation loc2 = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); app.addLocations(ImmutableList.of(loc)); appToKeep.set(app); locToKeep.set(loc); locToDelete.set(loc2); return null; }});
@Test public void testConfigBagContainsMatchesForFlagName() throws Exception { // Prefers flag-name, over config-key's name LocationInternal loc = managementContext.getLocationManager().createLocation(LocationSpec.create(MyLocation.class) .configure("myconfigflagname", "myval")); assertEquals(loc.config().getBag().getAllConfig(), ImmutableMap.of("mylocation.myconfigwithflagname", "myval", "myconfigflagname", "myval")); assertEquals(loc.config().getLocalBag().getAllConfig(), ImmutableMap.of("mylocation.myconfigwithflagname", "myval", "myconfigflagname", "myval")); Assert.assertEquals(loc.getAllConfig(true), ImmutableMap.of("mylocation.myconfigwithflagname", "myval", "myconfigflagname", "myval")); Assert.assertEquals(loc.getAllConfig(false), ImmutableMap.of("mylocation.myconfigwithflagname", "myval", "myconfigflagname", "myval")); }
@Test(groups="WIP") public void testChildConfigBagInheritsFlagNameFromParentSetsOwnConfigKey() throws Exception { LocationInternal loc = managementContext.getLocationManager().createLocation(LocationSpec.create(MyLocation.class) .configure("mychildconfigflagname", "myval")); LocationInternal child = managementContext.getLocationManager().createLocation(LocationSpec.create(MyChildLocation.class) .parent(loc)); assertEquals(child.config().getBag().getAllConfig(), ImmutableMap.of("mychildlocation.myconfigwithflagname", "myval")); assertEquals(child.config().getLocalBag().getAllConfig(), ImmutableMap.of()); Assert.assertEquals(child.getAllConfig(true), ImmutableMap.of("mychildlocation.myconfigwithflagname", "myval")); Assert.assertEquals(child.getAllConfig(false), ImmutableMap.of()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private ConcreteLocation createConcrete(Class<?> extensionType, Object extension) { // this cast is needed to make IntelliJ happy return (ConcreteLocation) mgmt.getLocationManager().createLocation(LocationSpec.create(ConcreteLocation.class).extension((Class)extensionType, extension)); }
@Test public void testChildConfigBagInheritsUnmatchedAtParent() throws Exception { LocationInternal loc = managementContext.getLocationManager().createLocation(LocationSpec.create(MyLocation.class) .configure("mychildlocation.myconfig", "myval1") .configure("notThere", "notThereVal")); LocationInternal child = managementContext.getLocationManager().createLocation(LocationSpec.create(MyChildLocation.class) .parent(loc)); assertEquals(child.config().getBag().getAllConfig(), ImmutableMap.of("mychildlocation.myconfig", "myval1", "notThere", "notThereVal")); assertEquals(child.config().getLocalBag().getAllConfig(), ImmutableMap.of()); Assert.assertEquals(child.getAllConfig(true), ImmutableMap.of("mychildlocation.myconfig", "myval1", "notThere", "notThereVal")); Assert.assertEquals(child.getAllConfig(false), ImmutableMap.of()); }
@Test public void testCustomizerIgnoresNonSshMachines() throws Exception { WinRmMachineLocation machine = mgmt.getLocationManager().createLocation(LocationSpec.create(WinRmMachineLocation.class) .configure("address", "4.3.2.1")); // Confirm not called (as that would cause error); and visual inspection that logs a nice message. customizer.customize(machine); }
@Test public void testBrooklynAccessibleAddressFindsPreexistingMapping() throws Exception { final int privatePort = 8080; final String publicNatIp = "1.2.3.4"; final int publicNatPort = 12000; SshMachineLocation machine = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(SshMachineLocation.TCP_PORT_MAPPINGS, ImmutableMap.of(privatePort, publicNatIp+":"+publicNatPort))); entity = app.createAndManageChild(EntitySpec.create(TestEntity.class) .configure(BrooklynAccessUtils.PORT_FORWARDING_MANAGER, pfm) .location(machine)); assertEquals(BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, privatePort), HostAndPort.fromParts(publicNatIp, publicNatPort)); }
@BeforeMethod(alwaysRun=true) public void setup() throws Exception { app = TestApplication.Factory.newManagedInstanceForTests(); mgmt = app.getManagementContext(); LocalhostMachineProvisioningLocation localhost = mgmt.getLocationManager().createLocation( LocationSpec.create(LocalhostMachineProvisioningLocation.class)); host = localhost.obtain(); app.start(Arrays.asList(host)); }
@BeforeMethod(alwaysRun=true) @Override public void setUp() throws Exception { super.setUp(); RecordingSshTool.clear(); machine = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure("address", "1.2.3.4") .configure(SshMachineLocation.SSH_TOOL_CLASS, RecordingSshTool.class.getName())); }
@BeforeMethod(alwaysRun=true) public void setUp() throws Exception { app = TestApplication.Factory.newManagedInstanceForTests(); managementContext = app.getManagementContext(); loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class) .configure("name", "london")); }
@Override public LocalhostMachineProvisioningLocation newLocalhostProvisioningLocation(Map<?,?> flags) { return getManagementContext().getLocationManager().createLocation( LocationSpec.create(LocalhostMachineProvisioningLocation.class).configure(flags)); }
private Location newSshMachineLocation(String name, String address, Location parent) { return mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .parent(parent) .displayName(name) .configure("address", address)); }
@Test public void testDeletesOrphanedSubGraph() throws Exception { Location loc1 = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); Location loc2 = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(ConfigKeys.newConfigKey(Object.class, "myconfig"), loc1)); assertTransformDeletes(new Deletions().locations(loc1.getId(), loc2.getId())); }
@BeforeMethod(alwaysRun=true) @Override public void setUp() throws Exception { super.setUp(); entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); machine = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure("address", "127.0.0.1")); portForwardManager = (PortForwardManager) mgmt.getLocationRegistry().getLocationManaged(PortForwardManagerLocationResolver.PFM_GLOBAL_SPEC); }
@Test public void testKeepsLocationsReferencedByEnricherInFlag() throws Exception { Location loc = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)); origApp.enrichers().add(EnricherSpec.create(MyEnricher.class) .configure("myobj", loc)); assertTransformIsNoop(); }
protected void assertSshable(Map<?,?> machineConfig) { SshMachineLocation machineWithThatConfig = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure(machineConfig)); try { assertSshable(machineWithThatConfig); } finally { Streams.closeQuietly(machineWithThatConfig); } }
@Override public SimulatedLocation newSubLocation(Map<?,?> newFlags) { // TODO shouldn't have to copy config bag as it should be inherited (but currently it is not used inherited everywhere; just most places) return getManagementContext().getLocationManager().createLocation(LocationSpec.create(getClass()) .parent(this) .configure(config().getLocalBag().getAllConfig()) // FIXME Should this just be inherited? .configure(newFlags)); }