@Test public void testNodesParseLoginPort() throws Exception { assertEquals(parser.apply(NodesFromYamlTest.TEST3), expectedNodeMetadataFromResource(2, resource, provider, 2022)); }
@Override public NodeMetadata apply(Node from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId()); builder.name(from.getName()); builder.loginPort(from.getLoginPort()); builder.hostname(from.getHostname()); builder.location(findLocationWithId(from.getLocationId())); builder.group(from.getGroup()); builder.tags(from.getTags()); builder.userMetadata(from.getMetadata()); builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family( OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription()) .version(from.getOsVersion()).build()); builder.status(Status.RUNNING); builder.publicAddresses(ImmutableSet.<String> of(from.getHostname())); if (from.getUsername() != null) { Builder credBuilder = LoginCredentials.builder().user(from.getUsername()); if (from.getCredentialUrl() != null) { try { credBuilder.credential(Strings2.toStringAndClose(slurp.apply(from.getCredentialUrl()))); } catch (IOException e) { logger.error(e, "URI could not be read: %s", from.getCredentialUrl()); } } else if (from.getCredential() != null) { credBuilder.credential(from.getCredential()); } if (from.getSudoPassword() != null) { credBuilder.password(from.getSudoPassword()); credBuilder.authenticateSudo(true); } LoginCredentials creds = credBuilder.build(); builder.credentials(creds); credentialStore.put("node#" + from.getId(), creds); } return builder.build(); }
NodeToNodeMetadata implements Function<Node, NodeMetadata> { @Override public NodeMetadata apply(Node from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId()); builder.name(from.getName()); builder.loginPort(from.getLoginPort()); builder.hostname(from.getHostname()); builder.location(findLocationWithId(from.getLocationId())); builder.group(from.getGroup()); builder.tags(from.getTags()); builder.userMetadata(from.getMetadata()); builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family( OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription()) .version(from.getOsVersion()).build()); builder.status(Status.RUNNING); builder.publicAddresses(ImmutableSet.<String> of(from.getHostname())); if (from.getUsername() != null) { Builder credBuilder = LoginCredentials.builder().user(from.getUsername()); if (from.getCredentialUrl() != null) { try { credBuilder.credential(Strings2.toStringAndClose(slurp.apply(from.getCredentialUrl()))); } catch (IOException e) { logger.error(e, "URI could not be read: %s", from.getCredentialUrl()); } } else if (from.getCredential() != null) { credBuilder.credential(from.getCredential()); } if (from.getSudoPassword() != null) { credBuilder.password(from.getSudoPassword()); credBuilder.authenticateSudo(true); } LoginCredentials creds = credBuilder.build(); builder.credentials(creds); credentialStore.put("node#" + from.getId(), creds); } return builder.build(); } }
NodeToNodeMetadata implements Function<Node, NodeMetadata> { @Override public NodeMetadata apply(Node from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId()); builder.name(from.getName()); builder.loginPort(from.getLoginPort()); builder.hostname(from.getHostname()); builder.location(findLocationWithId(from.getLocationId())); builder.group(from.getGroup()); builder.tags(from.getTags()); builder.userMetadata(from.getMetadata()); builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family( OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription()) .version(from.getOsVersion()).build()); builder.status(Status.RUNNING); builder.publicAddresses(ImmutableSet.<String> of(from.getHostname())); if (from.getUsername() != null) { Builder credBuilder = LoginCredentials.builder().user(from.getUsername()); if (from.getCredentialUrl() != null) { try { credBuilder.credential(Strings2.toStringAndClose(slurp.apply(from.getCredentialUrl()))); } catch (IOException e) { logger.error(e, "URI could not be read: %s", from.getCredentialUrl()); } } else if (from.getCredential() != null) { credBuilder.credential(from.getCredential()); } if (from.getSudoPassword() != null) { credBuilder.password(from.getSudoPassword()); credBuilder.authenticateSudo(true); } LoginCredentials creds = credBuilder.build(); builder.credentials(creds); credentialStore.put("node#" + from.getId(), creds); } return builder.build(); } @Inject  NodeToNodeMetadata(Supplier<Location> location, @Memoized Supplier<Set<? extends Location>> locations,
            Function<URI, InputStream> slurp, Map<String, Credentials> credentialStore); }
NodeToNodeMetadata implements Function<Node, NodeMetadata> { @Override public NodeMetadata apply(Node from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId()); builder.name(from.getName()); builder.loginPort(from.getLoginPort()); builder.hostname(from.getHostname()); builder.location(findLocationWithId(from.getLocationId())); builder.group(from.getGroup()); builder.tags(from.getTags()); builder.userMetadata(from.getMetadata()); builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family( OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription()) .version(from.getOsVersion()).build()); builder.status(Status.RUNNING); builder.publicAddresses(ImmutableSet.<String> of(from.getHostname())); if (from.getUsername() != null) { Builder credBuilder = LoginCredentials.builder().user(from.getUsername()); if (from.getCredentialUrl() != null) { try { credBuilder.credential(Strings2.toStringAndClose(slurp.apply(from.getCredentialUrl()))); } catch (IOException e) { logger.error(e, "URI could not be read: %s", from.getCredentialUrl()); } } else if (from.getCredential() != null) { credBuilder.credential(from.getCredential()); } if (from.getSudoPassword() != null) { credBuilder.password(from.getSudoPassword()); credBuilder.authenticateSudo(true); } LoginCredentials creds = credBuilder.build(); builder.credentials(creds); credentialStore.put("node#" + from.getId(), creds); } return builder.build(); } @Inject  NodeToNodeMetadata(Supplier<Location> location, @Memoized Supplier<Set<? extends Location>> locations,
            Function<URI, InputStream> slurp, Map<String, Credentials> credentialStore); @Override NodeMetadata apply(Node from); }
NodeToNodeMetadata implements Function<Node, NodeMetadata> { @Override public NodeMetadata apply(Node from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId()); builder.name(from.getName()); builder.loginPort(from.getLoginPort()); builder.hostname(from.getHostname()); builder.location(findLocationWithId(from.getLocationId())); builder.group(from.getGroup()); builder.tags(from.getTags()); builder.userMetadata(from.getMetadata()); builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family( OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription()) .version(from.getOsVersion()).build()); builder.status(Status.RUNNING); builder.publicAddresses(ImmutableSet.<String> of(from.getHostname())); if (from.getUsername() != null) { Builder credBuilder = LoginCredentials.builder().user(from.getUsername()); if (from.getCredentialUrl() != null) { try { credBuilder.credential(Strings2.toStringAndClose(slurp.apply(from.getCredentialUrl()))); } catch (IOException e) { logger.error(e, "URI could not be read: %s", from.getCredentialUrl()); } } else if (from.getCredential() != null) { credBuilder.credential(from.getCredential()); } if (from.getSudoPassword() != null) { credBuilder.password(from.getSudoPassword()); credBuilder.authenticateSudo(true); } LoginCredentials creds = credBuilder.build(); builder.credentials(creds); credentialStore.put("node#" + from.getId(), creds); } return builder.build(); } @Inject  NodeToNodeMetadata(Supplier<Location> location, @Memoized Supplier<Set<? extends Location>> locations,
            Function<URI, InputStream> slurp, Map<String, Credentials> credentialStore); @Override NodeMetadata apply(Node from);  }