使用OpenShift Java REST客户端获取持久卷列表

时间:2018-11-05 21:46:18

标签: openshift

我正在使用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中所有卷的列表?

1 个答案:

答案 0 :(得分:0)

    IClient client = new ClientBuilder(osUrl).withUserName(userName).withPassword(mySecretPw).build();

    List<IPersistentVolume> persistentVolumes = client.list(ResourceKind.PERSISTENT_VOLUME);