Java-клиент Openshift v3 выбрасывает ноль
Вот мой код клиента OpenShift Java:
public class JavaClient {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
IClient client = new ClientBuilder("https://api.starter-xx-xxx-1.openshift.com").withUserName("aaa@bbb.com").withPassword("password").build();
client.getAuthorizationContext().setToken("oqW-8xm8in6QcEaQXt........");
System.out.println("=======================================================================");
System.out.println(client.getOpenShiftAPIVersion() + ", " + client.getServerReadyStatus());
System.out.println("\n========================Openshift Project====================================");
IProject project = (IProject)client.getResourceFactory().stub(ResourceKind.PROJECT, "josephproject-openshift");
System.out.println("Openshift API version : " + project.getApiVersion() +", Project namespace : " + project.getNamespace() + ", Project name : " + project.getName());
System.out.println("\n========================Openshift Pods==============================");
IPod podWildfly = (IPod)client.getResourceFactory().stub(ResourceKind.POD, project.getName(), project.getNamespace());
System.out.println("Pod version : " + podWildfly.getApiVersion() + ",\n Pod Kind : " + podWildfly.getKind() + ",\n Pod Host : " + podWildfly.getHost()+ ", Pod Name \n : " + podWildfly.getName()
+ "\n, Pod state : " + podWildfly.getStatus() + "\n" + podWildfly.toJson());
Этот источник выполнен хорошо, без исключений, но на несколько ответов невозможно ответить. Ниже приведены ответы от моих проектов openshift v3
=======================================================================
v1, ok
========================Openshift Project====================================
Openshift API version : v1, Project namespace : josephproject-openshift, Project name : josephproject-openshift
========================Openshift Pods==============================
Pod version : v1,
Pod kind : Pod,
Pod Host : ,
Pod Name : josephproject-openshift,
Pod status :
{
"apiVersion" : "v1",
"kind" : "Pod",
"metadata" : {
"name" : "josephproject-openshift",
"namespace" : "josephproject-openshift"
},
"status" : {}
}
Как вы видите, ответ узла Pod, состояние Pod не получено от моего модуля OpenShift. И больше значений, которые здесь не описаны, также отсутствуют. Я пропустил процедуру кодирования моего OpenShift Java SDK?
1 ответ
Решение
Следующие коды выполнены успешно.
IClient client = new ClientBuilder("https://api.starter-us-east-1.openshift.com")
.withUserName("aaa@bbb.com")
.withPassword("password")
.build();
client.getAuthorizationContext().setToken("oqW-8xm8in6QcEaQXtM2ZEQ");
System.out.println("=======================================================================");
System.out.println(client.getOpenShiftAPIVersion() + ", " + client.getServerReadyStatus());
System.out.println("\n========================Openshift Project====================================");
IProject project = (IProject)client.getResourceFactory().stub(ResourceKind.PROJECT, "josephproject-openshift");
System.out.println("Openshift API version : " + project.getApiVersion()
+", Project namespace : " + project.getNamespace() + ", Project name : " + project.getName());
System.out.println("\n========================Openshift Pods==============================");
List<IPod> pods = client.list(ResourceKind.POD, "josephproject-openshift");
//IPod pod = (IPod) pods.stream().filter(p->p.getName().startsWith("docker-registry")).findFirst().orElse(null);
for(IPod pod : pods) {
System.out.println(pod.getName());
System.out.println("Pod Host : " + pod.getHost() + ", Pod Namespace : " + pod.getNamespace()
+ " ,Pod Creation Time :" + pod.getCreationTimeStamp());
System.out.println("Pod Status : " + pod.getStatus() + "\n" + pod.toJson());
}