Skip to content

Commit 946c0de

Browse files
committed
Byon dsl config - fix tests failures
1 parent 58847c1 commit 946c0de

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WinRmMachineLocationExternalConfigYamlTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void testWindowsMachinesNoExternalIPProvider() throws Exception {
120120
waitForApplicationTasks(app);
121121
Asserts.shouldHaveFailedPreviously();
122122
} catch (Exception e) {
123-
Asserts.expectedFailureOfType(e, NullPointerException.class);
123+
Asserts.expectedFailureContains(e, "Must specify exactly one of 'ssh' or 'winrm' for machine");
124124
}
125125
}
126126

core/src/main/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocation.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.Map;
3030
import java.util.Set;
3131

32+
import com.google.common.base.Preconditions;
3233
import com.google.common.net.HostAndPort;
3334
import org.apache.brooklyn.api.location.Location;
3435
import org.apache.brooklyn.api.location.LocationSpec;
@@ -384,7 +385,10 @@ protected void updateMachineConfig(T machine, Map<?, ?> flags) {
384385
// For backwards compatibility, where peristed state did not have this.
385386
origConfigs = Maps.newLinkedHashMap();
386387
}
387-
parseMachineConfig((AbstractLocation) machine);
388+
if (((AbstractLocation) machine).config().getBag().getAllConfig().get("provider") != null &&
389+
((AbstractLocation) machine).config().getBag().getAllConfig().get("provider").equals("byon")) {
390+
parseMachineConfig((AbstractLocation) machine);
391+
}
388392
Map<String, Object> strFlags = ConfigBag.newInstance(flags).getAllConfig();
389393
Map<String, Object> origConfig = ((ConfigurationSupportInternal)machine.config()).getLocalBag().getAllConfig();
390394
origConfigs.put(machine, origConfig);
@@ -399,12 +403,14 @@ private void parseMachineConfig(AbstractLocation machine) {
399403
String winrm = machine.config().get(ConfigKeys.newStringConfigKey("winrm"));
400404
machine.config().removeKey(ConfigKeys.newStringConfigKey("winrm"));
401405

402-
Map<Integer, String> tcpPortMappings = (Map<Integer, String>) machine.config().get(ConfigKeys.newConfigKey(Map.class, "tcpPortMappings"));
403-
404-
if (ssh == null && winrm == null) {
405-
throw new IllegalArgumentException("Must specify exactly one of 'ssh' or 'winrm' for machine: "+machine);
406+
if (ssh ==null && winrm == null && machine.config().get(ConfigKeys.newStringConfigKey("address")) != null) {
407+
return;
406408
}
407409

410+
Preconditions.checkArgument(ssh != null || winrm != null, "Must specify exactly one of 'ssh' or 'winrm' for machine: " + machine);
411+
412+
Map<Integer, String> tcpPortMappings = (Map<Integer, String>) machine.config().get(ConfigKeys.newConfigKey(Map.class, "tcpPortMappings"));
413+
408414
UserAndHostAndPort userAndHostAndPort;
409415
String host;
410416
int port;

0 commit comments

Comments
 (0)