use of io.fabric8.kubernetes.api.model.PersistentVolume in project camel by apache.
the class KubernetesPersistentVolumesProducer method doListPersistentVolumesByLabels.
protected void doListPersistentVolumesByLabels(Exchange exchange, String operation) throws Exception {
PersistentVolumeList pvList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_LABELS, Map.class);
NonNamespaceOperation<PersistentVolume, PersistentVolumeList, DoneablePersistentVolume, Resource<PersistentVolume, DoneablePersistentVolume>> pvs;
pvs = getEndpoint().getKubernetesClient().persistentVolumes();
for (Map.Entry<String, String> entry : labels.entrySet()) {
pvs.withLabel(entry.getKey(), entry.getValue());
}
pvList = pvs.list();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(pvList.getItems());
}
use of io.fabric8.kubernetes.api.model.PersistentVolume in project camel by apache.
the class KubernetesPersistentVolumesProducer method doGetPersistentVolume.
protected void doGetPersistentVolume(Exchange exchange, String operation) throws Exception {
PersistentVolume pv = null;
String pvName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_NAME, String.class);
if (ObjectHelper.isEmpty(pvName)) {
LOG.error("Get a specific Persistent Volume require specify a Persistent Volume name");
throw new IllegalArgumentException("Get a specific Persistent Volume require specify a Persistent Volume name");
}
pv = getEndpoint().getKubernetesClient().persistentVolumes().withName(pvName).get();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(pv);
}
use of io.fabric8.kubernetes.api.model.PersistentVolume in project camel by apache.
the class KubernetesPersistentVolumesClaimsProducerTest method listByLabelsTest.
@Test
public void listByLabelsTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:listByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
Map<String, String> labels = new HashMap<String, String>();
labels.put("component", "elasticsearch");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS, labels);
}
});
List<PersistentVolume> result = ex.getOut().getBody(List.class);
}
use of io.fabric8.kubernetes.api.model.PersistentVolume in project camel by apache.
the class KubernetesPersistentVolumesProducerTest method listByLabelsTest.
@Test
public void listByLabelsTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:listByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
Map<String, String> labels = new HashMap<String, String>();
labels.put("component", "elasticsearch");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_LABELS, labels);
}
});
List<PersistentVolume> result = ex.getOut().getBody(List.class);
}
Aggregations