diff --git a/apps/k8s-networking/BUILD b/apps/k8s-networking/BUILD index 2cf9004066..ff83b1c574 100644 --- a/apps/k8s-networking/BUILD +++ b/apps/k8s-networking/BUILD @@ -4,6 +4,11 @@ BUNDLES = [ "@commons_net//jar", "@k8s_client//jar", "@k8s_model//jar", + "@okhttp//jar", + "@okio//jar", + "@logging_interceptor//jar", + "@jackson_dataformat_yaml//jar", + "@snakeyaml//jar", ] onos_app( diff --git a/apps/k8s-networking/api/BUILD b/apps/k8s-networking/api/BUILD index 36d2da128f..1995985e43 100644 --- a/apps/k8s-networking/api/BUILD +++ b/apps/k8s-networking/api/BUILD @@ -1,4 +1,12 @@ -COMPILE_DEPS = CORE_DEPS +COMPILE_DEPS = CORE_DEPS + [ + "@k8s_client//jar", + "@k8s_model//jar", + "@okhttp//jar", + "@okio//jar", + "@logging_interceptor//jar", + "@jackson_dataformat_yaml//jar", + "@snakeyaml//jar", +] TEST_DEPS = TEST_ADAPTERS + [ "//core/api:onos-api-tests", diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsAdminService.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsAdminService.java new file mode 100644 index 0000000000..989eefa712 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsAdminService.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Endpoints; + +/** + * Service for administering the inventory of kubernetes endpoint. + */ +public interface K8sEndpointsAdminService extends K8sEndpointsService { + + /** + * Creates kubernetes endpoints with the given information. + * + * @param endpoints the new kubernetes endpoints + */ + void createEndpoints(Endpoints endpoints); + + /** + * Updates the kubernetes endpoints with the given information. + * + * @param endpoints the updated kubernetes endpoints + */ + void updateEndpoints(Endpoints endpoints); + + /** + * Removes the kubernetes endpoints. + * + * @param uid kubernetes endpoint UID + */ + void removeEndpoints(String uid); + + /** + * Clears the existing endpoints. + */ + void clear(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsEvent.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsEvent.java new file mode 100644 index 0000000000..acce2152d8 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsEvent.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Endpoints; +import org.onosproject.event.AbstractEvent; + +/** + * Describes kubernetes endpoints event. + */ +public class K8sEndpointsEvent extends AbstractEvent { + + /** + * Creates an event of a given type for the specified kubernetes endpoints. + * + * @param type kubernetes endpoints event type + * @param subject kubernetes endpoints + */ + public K8sEndpointsEvent(Type type, Endpoints subject) { + super(type, subject); + } + + /** + * Kubernetes endpoints events. + */ + public enum Type { + + /** + * Signifies that a new kubernetes endpoints is created. + */ + K8S_ENDPOINTS_CREATED, + + /** + * Signifies that the kubernetes endpoints is updated. + */ + K8S_ENDPOINTS_UPDATED, + + /** + * Signifies that the kubernetes endpoints is removed. + */ + K8S_ENDPOINTS_REMOVED, + } +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsListener.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsListener.java new file mode 100644 index 0000000000..873e264339 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsListener.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import org.onosproject.event.EventListener; + +/** + * Listener for kubernetes endpoints event. + */ +public interface K8sEndpointsListener extends EventListener { +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsService.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsService.java new file mode 100644 index 0000000000..8f90269ab6 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsService.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Endpoints; +import org.onosproject.event.ListenerService; + +import java.util.Set; + +/** + * Service for interacting with the inventory of kubernetes endpoints. + */ +public interface K8sEndpointsService + extends ListenerService { + + /** + * Returns the kubernetes endpoints with the supplied endpoints UID. + * + * @param uid endpoint UID + * @return kubernetes endpoints + */ + Endpoints endpoints(String uid); + + /** + * Returns all kubernetes endpoints registered. + * + * @return set of kubernetes endpoints + */ + Set endpointses(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsStore.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsStore.java new file mode 100644 index 0000000000..9bcb5c96cf --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsStore.java @@ -0,0 +1,70 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Endpoints; +import org.onosproject.store.Store; + +import java.util.Set; + +/** + * Manages inventory of kubernetes endpoints; not intended for direct use. + */ +public interface K8sEndpointsStore + extends Store { + + /** + * Creates the new kubernetes endpoints. + * + * @param endpoints kubernetes endpoints + */ + void createEndpoints(Endpoints endpoints); + + /** + * Updates the kubernetes endpoints. + * + * @param endpoints kubernetes endpoints + */ + void updateEndpoints(Endpoints endpoints); + + /** + * Removes the kubernetes endpoints with the given endpoints UID. + * + * @param uid kubernetes endpoints UID + * @return removed kubernetes endpoints; null if failed + */ + Endpoints removeEndpoints(String uid); + + /** + * Returns the kubernetes endpoints with the given endpoints UID. + * + * @param uid kubernetes endpoints UID + * @return kubernetes endpoints; null if not found + */ + Endpoints endpoints(String uid); + + /** + * Returns all kubernetes endpoints. + * + * @return set of kubernetes endpoints + */ + Set endpointses(); + + /** + * Removes all kubernetes endpoints. + */ + void clear(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsStoreDelegate.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsStoreDelegate.java new file mode 100644 index 0000000000..f0b6a99e6c --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sEndpointsStoreDelegate.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import org.onosproject.store.StoreDelegate; + +/** + * Kubernetes endpoints store delegate abstraction. + */ +public interface K8sEndpointsStoreDelegate extends StoreDelegate { +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodAdminService.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodAdminService.java new file mode 100644 index 0000000000..cb51a51a50 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodAdminService.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Pod; + +/** + * Service for administering the inventory of kubernetes service. + */ +public interface K8sPodAdminService extends K8sPodService { + + /** + * Creates a kubernetes service with the given information. + * + * @param pod the new kubernetes pod + */ + void createPod(Pod pod); + + /** + * Updates the kubernetes pod with the given information. + * + * @param pod the updated kubernetes pod + */ + void updatePod(Pod pod); + + /** + * Removes the kubernetes pod. + * + * @param uid kubernetes pod UID + */ + void removePod(String uid); + + /** + * Clears the existing pods. + */ + void clear(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodEvent.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodEvent.java new file mode 100644 index 0000000000..c58043174b --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodEvent.java @@ -0,0 +1,53 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Pod; +import org.onosproject.event.AbstractEvent; + +public class K8sPodEvent extends AbstractEvent { + + /** + * Creates an event of a given type for the specified kubernetes pod. + * + * @param type kubernetes pod event type + * @param subject kubernetes pod + */ + protected K8sPodEvent(Type type, Pod subject) { + super(type, subject); + } + + /** + * Kubernetes pod events. + */ + public enum Type { + + /** + * Signifies that a new kubernetes pod is created. + */ + K8S_POD_CREATED, + + /** + * Signifies that the kubernetes pod is updated. + */ + K8S_POD_UPDATED, + + /** + * Signifies that the kubernetes pod is removed. + */ + K8S_POD_REMOVED, + } +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodListener.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodListener.java new file mode 100644 index 0000000000..c76e578b89 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodListener.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import org.onosproject.event.EventListener; + +/** + * Listener for kubernetes pod event. + */ +public interface K8sPodListener extends EventListener { +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodService.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodService.java new file mode 100644 index 0000000000..bc1049e975 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodService.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Pod; +import org.onosproject.event.ListenerService; + +import java.util.Set; + +/** + * Service for interacting with the inventory of kubernetes service. + */ +public interface K8sPodService + extends ListenerService { + + /** + * Returns the kubernetes pod with the supplied pod UID. + * + * @param uid pod UID + * @return kubernetes pod + */ + Pod pod(String uid); + + /** + * Returns all kubernetes pods registered. + * + * @return set of kubernetes pods + */ + Set pods(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodStore.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodStore.java new file mode 100644 index 0000000000..d0a39910ca --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodStore.java @@ -0,0 +1,69 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Pod; +import org.onosproject.store.Store; + +import java.util.Set; + +/** + * Manages inventory of kubernetes pod; not intended for direct use. + */ +public interface K8sPodStore extends Store { + + /** + * Creates the new kubernetes pod. + * + * @param pod kubernetes pod + */ + void createPod(Pod pod); + + /** + * Updates the kubernetes pod. + * + * @param pod kubernetes pod + */ + void updatePod(Pod pod); + + /** + * Removes the kubernetes pod with the given pod UID. + * + * @param uid kubernetes pod UID + * @return removed kubernetes pod; null if failed + */ + Pod removePod(String uid); + + /** + * Returns the kubernetes pod with the given pod UID. + * + * @param uid kubernetes pod UID + * @return kubernetes pod; null if not found + */ + Pod pod(String uid); + + /** + * Returns all kubernetes pods. + * + * @return set of kubernetes pods + */ + Set pods(); + + /** + * Removes all kubernetes pods. + */ + void clear(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodStoreDelegate.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodStoreDelegate.java new file mode 100644 index 0000000000..a0693e1e6a --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sPodStoreDelegate.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import org.onosproject.store.StoreDelegate; + +/** + * Kubernetes pod store delegate abstraction. + */ +public interface K8sPodStoreDelegate extends StoreDelegate { +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceAdminService.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceAdminService.java new file mode 100644 index 0000000000..097b1ce808 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceAdminService.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Service; + +/** + * Service for administering the inventory of kubernetes service. + */ +public interface K8sServiceAdminService extends K8sServiceService { + + /** + * Creates a kubernetes service with the given information. + * + * @param service the new kubernetes service + */ + void createService(Service service); + + /** + * Updates the kubernetes service with the given information. + * + * @param service the updated kubernetes service + */ + void updateService(Service service); + + /** + * Removes the kubernetes service. + * + * @param uid kubernetes service UID + */ + void removeService(String uid); + + /** + * Clears the existing services. + */ + void clear(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceEvent.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceEvent.java new file mode 100644 index 0000000000..920ded3698 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceEvent.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Service; +import org.onosproject.event.AbstractEvent; + +/** + * Describes kubernetes service event. + */ +public class K8sServiceEvent extends AbstractEvent { + + /** + * Creates an event of a given type for the specified kubernetes service. + * + * @param type kubernetes service event type + * @param subject kubernetes service + */ + public K8sServiceEvent(Type type, Service subject) { + super(type, subject); + } + + /** + * Kubernetes service events. + */ + public enum Type { + + /** + * Signifies that a new kubernetes service is created. + */ + K8S_SERVICE_CREATED, + + /** + * Signifies that the kubernetes service is updated. + */ + K8S_SERVICE_UPDATED, + + /** + * Signifies that the kubernetes service is removed. + */ + K8S_SERVICE_REMOVED, + } +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceListener.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceListener.java new file mode 100644 index 0000000000..9beb1c47b4 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceListener.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import org.onosproject.event.EventListener; + +/** + * Listener for kubernetes service event. + */ +public interface K8sServiceListener extends EventListener { +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceService.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceService.java new file mode 100644 index 0000000000..115d979919 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceService.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Service; +import org.onosproject.event.ListenerService; + +import java.util.Set; + +/** + * Service for interacting with the inventory of kubernetes service. + */ +public interface K8sServiceService + extends ListenerService { + + /** + * Returns the kubernetes service with the supplied service UID. + * + * @param uid service UID + * @return kubernetes service + */ + Service service(String uid); + + /** + * Returns all kubernetes services registered. + * + * @return set of kubernetes services + */ + Set services(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceStore.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceStore.java new file mode 100644 index 0000000000..4fb5d6225d --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceStore.java @@ -0,0 +1,70 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import io.fabric8.kubernetes.api.model.Service; +import org.onosproject.store.Store; + +import java.util.Set; + +/** + * Manages inventory of kubernetes service; not intended for direct use. + */ +public interface K8sServiceStore + extends Store { + + /** + * Creates the new kubernetes service. + * + * @param service kubernetes service + */ + void createService(Service service); + + /** + * Updates the kubernetes service. + * + * @param service kubernetes service + */ + void updateService(Service service); + + /** + * Removes the kubernetes service with the given service UID. + * + * @param uid kubernetes service UID + * @return removed kubernetes service; null if failed + */ + Service removeService(String uid); + + /** + * Returns the kubernetes service with the given service UID. + * + * @param uid kubernetes service UID + * @return kubernetes service; null if not found + */ + Service service(String uid); + + /** + * Returns all kubernetes services. + * + * @return set of kubernetes services + */ + Set services(); + + /** + * Removes all kubernetes services. + */ + void clear(); +} diff --git a/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceStoreDelegate.java b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceStoreDelegate.java new file mode 100644 index 0000000000..01cd1cfef5 --- /dev/null +++ b/apps/k8s-networking/api/src/main/java/org/onosproject/k8snetworking/api/K8sServiceStoreDelegate.java @@ -0,0 +1,24 @@ +/* + * Copyright 2019-present Open Networking Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.k8snetworking.api; + +import org.onosproject.store.StoreDelegate; + +/** + * Kubernetes service store delegate abstraction. + */ +public interface K8sServiceStoreDelegate extends StoreDelegate { +}