@SuppressWarnings("unchecked") static <T> void addNamedAction(MutableMap.Builder<String, URI> lb, RendererHints.NamedAction na, T value, Object context, Entity contextEntity) { if (na instanceof RendererHints.NamedActionWithUrl) { try { String v = ((RendererHints.NamedActionWithUrl<T>) na).getUrlFromValue(value); if (Strings.isNonBlank(v)) { String action = na.getActionName().toLowerCase(); lb.putIfAbsent("action:"+action, URI.create(v)); } } catch (Exception e) { Exceptions.propagateIfFatal(e); log.warn("Unable to make action "+na+" from "+context+" on "+contextEntity+": "+e, e); } } } }
protected void runCreatesUser(boolean useJcloudsSshInit) throws Exception { brooklynProperties.put(BROOKLYN_PROPERTIES_PREFIX+JcloudsLocationConfig.USE_JCLOUDS_SSH_INIT.getName(), Boolean.toString(useJcloudsSshInit)); brooklynProperties.put(BROOKLYN_PROPERTIES_PREFIX+JcloudsLocationConfig.USER.getName(), "myname"); jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().getLocationManaged(SOTLAYER_LOCATION_SPEC); JcloudsSshMachineLocation machine = obtainMachine(MutableMap.<String,Object>builder() .putIfAbsent("inboundPorts", ImmutableList.of(22)) .build()); machine.execCommands("test commands", ImmutableList.of("echo test")); assertSshable(machine); assertEquals(machine.getUser(), "myname"); } }
@Test(groups = "Live", dataProvider="cloudAndImageNames") public void testCreatesWindowsVm(String locationSpec, String imageNameRegex, Map<String, ?> additionalConfig) throws Exception { jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().getLocationManaged(locationSpec); JcloudsWinRmMachineLocation machine = obtainWinrmMachine(MutableMap.<String,Object>builder() .putIfAbsent("inboundPorts", ImmutableList.of(5986, 5985, 3389)) .put(JcloudsLocation.IMAGE_NAME_REGEX.getName(), imageNameRegex) .put(JcloudsLocation.USE_JCLOUDS_SSH_INIT.getName(), false) .put(JcloudsLocation.OS_FAMILY_OVERRIDE.getName(), OsFamily.WINDOWS) .putAll(additionalConfig != null ? additionalConfig : ImmutableMap.<String, Object>of()) .build()); assertWinrmable(machine); }
private JcloudsSshMachineLocation createEc2Machine(Map<String,? extends Object> conf) throws Exception { return obtainMachine(MutableMap.<String,Object>builder() .putAll(conf) .putIfAbsent("imageId", AWS_EC2_CENTOS_IMAGE_ID) .putIfAbsent("hardwareId", AWS_EC2_MEDIUM_HARDWARE_ID) .putIfAbsent("inboundPorts", ImmutableList.of(22)) .build()); }
private JcloudsSshMachineLocation createEc2Machine(Map<String,? extends Object> conf) throws Exception { return obtainMachine(MutableMap.<String,Object>builder() .putAll(conf) .putIfAbsent("imageId", AWS_IMAGE_ID) .putIfAbsent("loginUser", "ec2-user") .putIfAbsent("hardwareId", AWS_EC2_SMALL_HARDWARE_ID) .putIfAbsent("inboundPorts", ImmutableList.of(22)) .build()); }
private JcloudsSshMachineLocation createRackspaceMachine(Map<String,? extends Object> conf) throws Exception { return obtainMachine(MutableMap.<String,Object>builder() .putAll(conf) .putIfAbsent("inboundPorts", ImmutableList.of(22)) .build()); }
private JcloudsSshMachineLocation createEc2Machine(Map<String,? extends Object> conf) throws Exception { return obtainMachine(MutableMap.<String,Object>builder() .putAll(conf) .putIfAbsent("imageId", AWS_EC2_CENTOS_IMAGE_ID) .putIfAbsent("hardwareId", AWS_EC2_SMALL_HARDWARE_ID) .putIfAbsent("inboundPorts", ImmutableList.of(22)) .build()); }