我正在使用OpenShift Java REST客户端(https://github.com/openshift/openshift-restclient-java),并且正在使用以下一些代码进行尝试:
IClient client = new ClientBuilder(osUrl)
.withUserName(userName)
.withPassword(mySecretPw)
.build();
System.out.println("=====API & Status==================================================================");
System.out.println(client.getOpenShiftAPIVersion() + ", " + client.getServerReadyStatus());
IPersistentVolume volume = (IPersistentVolume)client.getResourceFactory().stub(ResourceKind.PERSISTENT_VOLUME, "DEFAULT");
System.out.println("=====Version Etc:==================================================================");
System.out.println("Openshift API version : " + volume.getApiVersion() +", Volume name : " + volume.getName());
但这只是显示单个卷中的信息。当我使用OC命令行时,通过:
oc get pv
我大约有20卷。如何获得OpenShift中所有卷的列表?
答案 0 :(得分:0)
IClient client = new ClientBuilder(osUrl).withUserName(userName).withPassword(mySecretPw).build();
List<IPersistentVolume> persistentVolumes = client.list(ResourceKind.PERSISTENT_VOLUME);