use of com.fathomdb.cli.output.ClientAction in project platformlayer by platformlayer.
the class SshItem method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey key = path.resolve(getContext());
UntypedItem untypedItem = client.getItemUntyped(key, Format.XML);
InetAddress sshAddress = findSshAddress(client, untypedItem);
ClientAction action = null;
if (sshAddress != null) {
String user = "root";
ProjectId project = key.getProject();
if (project == null) {
project = client.getProject();
}
if (project == null) {
throw new CliException("Cannot determine project");
}
String projectKey = project.getKey();
String serviceKey = "service-" + key.getServiceType().getKey();
File sshKey = IoUtils.resolve("~/.credentials/ssh/" + projectKey + "/" + serviceKey);
// Hmmm... user? key?
action = new ClientAction(ClientAction.ClientActionType.SSH, user + "@" + sshAddress.getHostAddress(), sshKey.getAbsolutePath());
}
return action;
}
use of com.fathomdb.cli.output.ClientAction in project platformlayer by platformlayer.
the class OpenItem method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
PlatformLayerKey key = path.resolve(getContext());
UntypedItem untypedItem = client.getItemUntyped(key, getFormat());
List<EndpointInfo> endpointList = EndpointInfo.getEndpoints(untypedItem.getTags());
Set<EndpointInfo> endpoints = Sets.newHashSet(endpointList);
EndpointInfo bestEndpoint = null;
for (EndpointInfo candidate : endpoints) {
if (bestEndpoint == null) {
bestEndpoint = candidate;
} else {
throw new IllegalArgumentException("Cannot choose between: " + bestEndpoint + " and " + candidate);
}
}
ClientAction action = null;
if (bestEndpoint != null) {
// TODO: How do we want to do this? A new tag??
String id = key.getServiceType().getKey() + ":" + key.getItemType().getKey();
if (id.equals("jenkins:jenkinsService")) {
action = new ClientAction(ClientAction.ClientActionType.BROWSER, "http://" + bestEndpoint.publicIp + ":" + bestEndpoint.publicIp);
}
}
return action;
}
Aggregations