K8S based XOS Service for EPC
Change-Id: I65bdabc3d63240bbdd21cb9e8674ff6723dd994f
diff --git a/Dockerfile.synchronizer b/Dockerfile.synchronizer
new file mode 100644
index 0000000..159b97e
--- /dev/null
+++ b/Dockerfile.synchronizer
@@ -0,0 +1,55 @@
+# Copyright 2017-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.
+
+# docker build -t xosproject/vepcservice-synchronizer:candidate -f Dockerfile.synchronizer .
+
+# xosproject/vepcservice-synchronizer
+
+FROM xosproject/xos-synchronizer-base:2.0.0
+
+COPY xos/synchronizer /opt/xos/synchronizers/vepcservice
+COPY VERSION /opt/xos/synchronizers/vepccervice/
+
+WORKDIR "/opt/xos/synchronizers/vepcservice"
+
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=vepcservice-synchronizer
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_component_chameleon_version=unknown
+ARG org_opencord_component_chameleon_vcs_url=unknown
+ARG org_opencord_component_chameleon_vcs_ref=unknown
+ARG org_opencord_component_xos_version=unknown
+ARG org_opencord_component_xos_vcs_url=unknown
+ARG org_opencord_component_xos_vcs_ref=unknown
+
+LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
+ org.label-schema.name=$org_label_schema_name \
+ org.label-schema.version=$org_label_schema_version \
+ org.label-schema.vcs-url=$org_label_schema_vcs_url \
+ org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+ org.label-schema.build-date=$org_label_schema_build_date \
+ org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
+ org.opencord.component.chameleon.version=$org_opencord_component_chameleon_version \
+ org.opencord.component.chameleon.vcs-url=$org_opencord_component_chameleon_vcs_url \
+ org.opencord.component.chameleon.vcs-ref=$org_opencord_component_chameleon_vcs_ref \
+ org.opencord.component.xos.version=$org_opencord_component_xos_version \
+ org.opencord.component.xos.vcs-url=$org_opencord_component_xos_vcs_url \
+ org.opencord.component.xos.vcs-ref=$org_opencord_component_xos_vcs_ref
+
+CMD ["/usr/bin/python", "/opt/xos/synchronizers/vepcservice/vepcservice-synchronizer.py"]
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..d9d9d30
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2016 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.
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..e752649
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.0.1.dev0
diff --git a/docs/vepc-service.md b/docs/vepc-service.md
new file mode 100644
index 0000000..503fa1d
--- /dev/null
+++ b/docs/vepc-service.md
@@ -0,0 +1 @@
+#TODO
\ No newline at end of file
diff --git a/xos/examples/VEpcServiceInstance.yaml b/xos/examples/VEpcServiceInstance.yaml
new file mode 100644
index 0000000..a43bc70
--- /dev/null
+++ b/xos/examples/VEpcServiceInstance.yaml
@@ -0,0 +1,725 @@
+---
+# Copyright 2017-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.
+
+# NOTE: ABOUT LICENSE: From Gopi - The K8S YAML resource section in this file are copied from
+# Intel's resources that were provided to ONF. We need to clarify what licensing terms are imposed
+# for these K8S resources
+
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Make a Virtual EPC service
+
+imports:
+ - custom_types/vepcservice.yaml
+ - custom_types/vepcserviceinstance.yaml
+ - custom_types/kubernetesresourceinstance.yaml
+ - custom_types/kubernetesservice.yaml
+ - custom_types/vepcresourceinstancelink.yaml
+
+
+topology_template:
+ node_templates:
+ service#vepcervice:
+ type: tosca.nodes.VEpcService
+ properties:
+ name: vepcservice
+ must-exist: true
+
+ service#kubernetes:
+ type: tosca.nodes.KubernetesService
+ properties:
+ name: kubernetes
+ must-exist: true
+
+ vepcserviceinstance:
+ type: tosca.nodes.VEpcServiceInstance
+ properties:
+ name: "EPC for Compute"
+ requirements:
+ - owner:
+ node: service#vepcservice
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_ngic_configmap:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "NGIC Config Map"
+ resource_definition: |
+ apiVersion: v1
+ data:
+ adc_rules.cfg: |
+ #Format -
+ #[ IP | IP Prefix | domain ] DROP? Sponsor-ID Service-ID Rate-Group? [Tariff-Group Tariff-Time]?
+ # Note: it is possible that ADC rules have conflicts & in that case rules are applied by line number...
+ # Rules defined first have a higher priority, unless DROP is specified (i.e. multiple rules for the same IP
+ # When specifying DROP with an IP address, use a prefix of 32 to prevent DNS results from overwriting rule
+
+ 13.1.1.111 Example Internet Zero-Rate
+ 13.1.1.112/24 Example Management Zero-Rate
+ 13.1.1.113 Example Provisioning Zero-Rate
+ www.example.gov Example Internet Zero-Rate
+ www.drop_example.com DROP Example CIPA
+ cp_config.cfg: |
+ SGW_S11_IP=$(hostname)
+ SGW_S1U_IP=$(netstat -ie | grep -A1 s1u-net | tail -1 | awk '{print $2}' | tr -d addr:)
+ MGMT_INFO="-s ${SGW_S11_IP} -m ${MME_S11_IP} -w ${SGW_S1U_IP}"
+ APN_INFO="-i ${IP_POOL_IP} -p ${IP_POOL_MASK} -a ${APN}"
+ TEID_INFO="-t ${S11_TEID_POOL_START} -e ${S11_TEID_POOL_STOP} -u ${S1U_TEID_POOL_START} -o ${S1U_TEID_POOL_STOP}"
+ APP_ARGS="${MGMT_INFO} ${APN_INFO} ${TEID_INFO}"
+
+ CORES="-c $(taskset -p $$ | awk '{print $NF}')"
+ MEMORY="-n4 --no-huge -m 4096 --file-prefix cp"
+ DEVICES="--no-pci"
+ EAL_ARGS="${CORES} ${MEMORY} ${DEVICES}"
+ dp_config.cfg: |
+ CORES="-c $(taskset -p $$ | awk '{print $NF}')"
+ MEMORY="-n4 --no-huge -m 8192 --file-prefix cp"
+
+ SGW_S1U_IP=$(netstat -ie | grep -A1 s1u-net | tail -1 | awk '{print $2}' | tr -d addr:)
+ SGW_SGI_IP=$(netstat -ie | grep -A1 sgi-net | tail -1 | awk '{print $2}' | tr -d addr:)
+ S1U_MAC=$( netstat -ie | grep -B1 $SGW_S1U_IP | head -n1 | awk '{print $5}' )
+ SGI_MAC=$( netstat -ie | grep -B1 $SGW_SGI_IP | head -n1 | awk '{print $5}' )
+ DEVICES="--no-pci --vdev eth_af_packet0,iface=s1u-net --vdev eth_af_packet1,iface=sgi-net"
+
+ EAL_ARGS="${CORES} ${MEMORY} ${DEVICES}"
+
+ S1U="--s1u_ip ${SGW_S1U_IP} --s1u_mac ${S1U_MAC}"
+ SGI="--sgi_ip ${SGW_SGI_IP} --sgi_mac ${SGI_MAC} --sgi_gw_ip ${RTR_SGI_IP} --sgi_mask ${SGI_MASK}"
+ WORKERS="--num_workers 1"
+ MISC="--log 1"
+
+ APP_ARGS="${S1U} ${SGI} ${WORKERS} ${MISC}"
+ interface.cfg: "; Copyright (c) 2017 Intel Corporation\n;\n; Licensed under the
+ Apache License, Version 2.0 (the \"License\");\n; you may not use this file except
+ in compliance with the License.\n; You may obtain a copy of the License at\n;\n;
+ \ http://www.apache.org/licenses/LICENSE-2.0\n;\n; Unless required by applicable
+ law or agreed to in writing, software\n; distributed under the License is distributed
+ on an \"AS IS\" BASIS,\n; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ express or implied.\n; See the License for the specific language governing permissions
+ and\n; limitations under the License.\n\n[0]\ndp_comm_ip = 127.0.0.1\ndp_comm_port
+ = 20\ncp_comm_ip = 127.0.0.1\ncp_comm_port = 21\n"
+ static_pcc.cfg: |+
+ [GLOBAL]
+ NUM_PACKET_FILTERS = 1
+
+ ;default filter - must be first for now (until DP doesn't install any filters)
+ [PACKET_FILTER_0]
+ RATING_GROUP = 9
+ ;Max Bit Rate (MBR) unit= bps
+ MBR = 512000
+
+ [PACKET_FILTER_1]
+ RATING_GROUP = 5
+ MBR = 1000000
+ DIRECTION = bidirectional
+ PRECEDENCE = 255
+ IPV4_REMOTE = 13.1.0.0
+ IPV4_REMOTE_MASK = 255.255.0.0
+ PROTOCOL = 17
+ REMOTE_LOW_LIMIT_PORT = 5060
+ REMOTE_HIGH_LIMIT_PORT = 5060
+
+ [PACKET_FILTER_2]
+ RATING_GROUP = 1
+ MBR = 2000000
+ DIRECTION = bidirectional
+ PRECEDENCE = 255
+ IPV4_REMOTE = 13.1.0.0
+ IPV4_REMOTE_MASK = 255.255.0.0
+ PROTOCOL = 17
+ LOCAL_LOW_LIMIT_PORT = 17000
+ LOCAL_HIGH_LIMIT_PORT = 17010
+
+ [PACKET_FILTER_3]
+ RATING_GROUP = 7
+ MBR = 4000000
+ DIRECTION = bidirectional
+ PRECEDENCE = 255
+ IPV4_REMOTE = 13.1.0.0
+ IPV4_REMOTE_MASK = 255.255.0.0
+ PROTOCOL = 17
+ LOCAL_LOW_LIMIT_PORT = 8000
+ LOCAL_HIGH_LIMIT_PORT = 8080
+
+ kind: ConfigMap
+ metadata:
+ name: ngic-config
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_mme_service:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "MME Service"
+ resource_definition: |
+ apiVersion: v1
+ kind: Service
+ metadata:
+ name: mme
+ spec:
+ selector:
+ app: mme
+ clusterIP: None
+ ports:
+ - name: s11
+ port: 2123
+ protocol: UDP
+ - name: s1ap
+ port: 36412
+ protocol: TCP
+ - name: s6a
+ port: 3868
+ protocol: TCP
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_mme_statefulset:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "MME StatefulSet"
+ resource_definition: |
+ apiVersion: apps/v1
+ kind: StatefulSet
+ metadata:
+ name: mme
+ labels:
+ app: mme
+ spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: mme
+ serviceName: "mme"
+ template:
+ metadata:
+ labels:
+ app: mme
+ spec:
+ terminationGracePeriodSeconds: 1
+ initContainers:
+ - name: init-mme
+ image: "ngick8stesting/c3po-mmeinit"
+ command: [ "sh", "-c"]
+ securityContext:
+ capabilities:
+ add:
+ - NET_ADMIN
+ args:
+ - iptables -A OUTPUT -p sctp --sport 36412 --chunk-types any ABORT -j DROP;
+ until nslookup hss-0.hss.default.svc.cluster.local;
+ do echo waiting for hss; sleep 2; done;
+ containers:
+ - name: mme
+ image: "ngick8stesting/c3po-mme:5e2eaf6"
+ imagePullPolicy: Always
+ env:
+ - name: SGW_S11_IP
+ value: ngic-0.ngic.default.svc.cluster.local
+ - name: MME_ETH0_IP
+ valueFrom:
+ fieldRef:
+ fieldPath: status.podIP
+ - name: ENB_S1AP_IP
+ value: 10.1.11.3
+ - name: CONNECT_PEER
+ value: hss-0.hss.default.svc.cluster.local
+ - name: VAR_HSS_REALM
+ value: hss.default.svc.cluster.local
+ - name: HSS_S6A_IP
+ value: hss-0.hss.default.svc.cluster.local
+ - name: HSS_PORT
+ value: "3868"
+
+ stdin: true
+ tty: true
+ #command: [ "sleep", "3600"]
+ #volumeMounts:
+ #- name: config-volume
+ # mountPath: /opt/ngic/config
+ #- name: scripts-volume
+ # mountPath: /opt/ngic/scripts
+ #- name: hugepage
+ # mountPath: /dev/hugepages
+ resources:
+ limits:
+ cpu: 3
+ memory: 1Gi
+ #volumes:
+ # - name: config-volume
+ # configMap:
+ # name: ngic-config
+ # - name: scripts-volume
+ # secret:
+ # secretName: ngic-scripts
+ # defaultMode: 511
+ # - name: hugepage
+ # emptyDir:
+ # medium: HugePages
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_hss_service:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "HSS Service"
+ resource_definition: |
+ apiVersion: v1
+ kind: Service
+ metadata:
+ name: hss
+ spec:
+ selector:
+ app: hss
+ clusterIP: None
+ ports:
+ - name: s6a
+ port: 3868
+ protocol: TCP
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_hss_statefulset:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "HSS StatefulSet"
+ resource_definition: |
+ apiVersion: apps/v1
+ kind: StatefulSet
+ metadata:
+ name: hss
+ labels:
+ app: hss
+ spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: hss
+ serviceName: "hss"
+ template:
+ metadata:
+ labels:
+ app: hss
+ spec:
+ terminationGracePeriodSeconds: 1
+ initContainers:
+ - name: init-db
+ image: "ngick8stesting/c3po-cassandra:5e2eaf6"
+ command: [ "bash", "-xc"]
+ args:
+ - until nslookup cassandra; do echo waiting for cassandra; sleep 2; done;
+ cqlsh --file /scripts/oai_db.cql cassandra;
+ /scripts/data_provisioning_users.sh 208014567891200 1122334455 apn1 465B5CE8B199B49FAA5F0A2EE238A6BC 100 cassandra mme-0.mme.default.svc.cluster.local mme.default.svc.cluster.local;
+ /scripts/data_provisioning_mme.sh 1 19136246000 mme-0.mme.default.svc.cluster.local mme.default.svc.cluster.local 1 cassandra;
+ /scripts/data_provisioning_mme.sh 1 19136246000 smsrouter.test3gpp.net test3gpp.net 0 cassandra;
+ containers:
+ - name: hss
+ image: "ngick8stesting/c3po-hss:5e2eaf6"
+ imagePullPolicy: Always
+ env:
+ - name: CASSANDRA_ADDR
+ value: cassandra
+ - name: MME_ADDR
+ value: mme-0.mme.default.svc.cluster.local
+ #command: [ "sleep", "3600"]
+ resources:
+ limits:
+ cpu: 3
+ memory: 1Gi
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_hssdb_service:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "HSS Cassandra Service"
+ resource_definition: |
+ apiVersion: v1
+ kind: Service
+ metadata:
+ labels:
+ app: cassandra
+ name: cassandra
+ spec:
+ clusterIP: None
+ ports:
+ - port: 9042
+ selector:
+ app: cassandra
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_hssdb_statefulset:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "HSS Cassandra StatefulSet"
+ resource_definition: |
+ apiVersion: "apps/v1"
+ kind: StatefulSet
+ metadata:
+ name: cassandra
+ labels:
+ app: cassandra
+ spec:
+ serviceName: cassandra
+ replicas: 1 # 3
+ selector:
+ matchLabels:
+ app: cassandra
+ template:
+ metadata:
+ labels:
+ app: cassandra
+ spec:
+ terminationGracePeriodSeconds: 1
+ containers:
+ - name: cassandra
+ image: ngick8stesting/c3po-cassandra:5e2eaf6
+ imagePullPolicy: Always
+ ports:
+ - containerPort: 7000
+ name: intra-node
+ - containerPort: 7001
+ name: tls-intra-node
+ - containerPort: 7199
+ name: jmx
+ - containerPort: 9042
+ name: cql
+ resources:
+ limits:
+ cpu: "3"
+ memory: 4Gi
+ # Probably Cassandra:3.x?
+ #securityContext:
+ # capabilities:
+ # add:
+ # - IPC_LOCK
+ # Later
+ #lifecycle:
+ # preStop:
+ # exec:
+ # command:
+ # - /bin/sh
+ # - -c
+ # - nodetool drain
+ env:
+ # Performance optimizations
+ - name: MAX_HEAP_SIZE
+ value: 512M
+ - name: HEAP_NEWSIZE
+ value: 100M
+ - name: CASSANDRA_SEEDS
+ value: "cassandra-0.cassandra.default.svc.cluster.local"
+ - name: CASSANDRA_CLUSTER_NAME
+ value: "HSS Cluster"
+ - name: CASSANDRA_RPC_ADDRESS
+ valueFrom:
+ fieldRef:
+ fieldPath: status.podIP
+ - name: CASSANDRA_ENDPOINT_SNITCH
+ value: "GossipingPropertyFileSnitch"
+ readinessProbe:
+ exec:
+ command: ["/bin/bash", "-c", "nodetool status -r | awk -v h=$(hostname) '$2==h {exit ($1==\"UN\" ? 0 : -1)}'"]
+ initialDelaySeconds: 15
+ timeoutSeconds: 5
+ # volumeMounts:
+ # - name: cassandra-data
+ # mountPath: /var/lib/cassandra
+ # volumeClaimTemplates:
+ # - metadata:
+ # name: cassandra-data
+ # spec:
+ # accessModes: [ "ReadWriteOnce" ]
+ # resources:
+ # requests:
+ # storage: 1Gi
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_spgwcu_service:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "SPGW Control and User Service"
+ resource_definition: |
+ apiVersion: v1
+ kind: Service
+ metadata:
+ name: ngic
+ spec:
+ selector:
+ app: ngic
+ clusterIP: None
+ ports:
+ - name: s11
+ port: 2123
+ protocol: UDP
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ kubernetesresourceinstance_spgwcu_statefulset:
+ type: tosca.nodes.KubernetesResourceInstance
+ properties:
+ name: "SPGW Control and User StatefulSet"
+ resource_definition: |
+ apiVersion: apps/v1
+ kind: StatefulSet
+ metadata:
+ name: ngic
+ labels:
+ app: ngic
+ spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: ngic
+ serviceName: "ngic"
+ template:
+ metadata:
+ labels:
+ app: ngic
+ annotations:
+ kubernetes.v1.cni.cncf.io/networks: '[
+ { "name": "s1u-net", "interfaceRequest": "s1u-net" },
+ { "name": "sgi-net", "interfaceRequest": "sgi-net" }
+ ]'
+ spec:
+ initContainers:
+ - name: init-iptables
+ image: "ngick8stesting/c3po-mmeinit"
+ command: [ "sh", "-c"]
+ securityContext:
+ capabilities:
+ add:
+ - NET_ADMIN
+ args:
+ - iptables -I OUTPUT -p icmp --icmp-type destination-unreachable -j DROP;
+ terminationGracePeriodSeconds: 1
+ containers:
+ - name: ngic-cp
+ image: "ngick8stesting/ngic-cp:d9b315c"
+ stdin: true
+ command: [ "bash", "-cx", ". /opt/ngic/config/cp_config.cfg; ./ngic_controlplane $EAL_ARGS -- $APP_ARGS"]
+ #command: ["sleep", "3600"]
+ tty: true
+ env:
+ - name: MME_S11_IP
+ value: mme-0.mme.default.svc.cluster.local
+ #- name: SGW_S1U_IP # for now,this will be in our own pod
+ # value: "5.5.5.5"
+ - name: APN
+ value: apn1
+ - name: IP_POOL_IP
+ value: "16.0.0.0"
+ - name: IP_POOL_MASK
+ value: "255.240.0.0"
+ - name: S11_TEID_POOL_START
+ value: "00100000"
+ - name: S11_TEID_POOL_STOP
+ value: "001fffff"
+ - name: S1U_TEID_POOL_START
+ value: "00100000"
+ - name: S1U_TEID_POOL_STOP
+ value: "001fffff"
+ volumeMounts:
+ - name: config-volume
+ mountPath: /opt/ngic/config
+ #- name: hugepage
+ # mountPath: /dev/hugepages
+ resources:
+ limits:
+ #hugepages-2Mi: 4Gi
+ cpu: 3
+ memory: 4Gi
+ - name: ngic-dp
+ image: "ngiccorddemo/ngic-dp:k8s-bm"
+ stdin: true
+ tty: true
+ env:
+ - name: RTR_SGI_IP
+ value: "13.1.1.110"
+ - name: SGI_MASK
+ value: "255.255.255.0"
+ command: [ "bash", "-cx", ". /opt/ngic/config/dp_config.cfg ; ./ngic_dataplane $EAL_ARGS -- $APP_ARGS"]
+ #command: ["sleep", "3600"]
+ volumeMounts:
+ - name: config-volume
+ mountPath: /opt/ngic/config
+ #- name: hugepage
+ # mountPath: /dev/hugepages
+ resources:
+ limits:
+ #hugepages-1Gi: 8Gi
+ cpu: 8
+ memory: 8Gi #200Mi
+ intel.com/sriov: '2'
+ securityContext:
+ privileged: true
+ capabilities:
+ add:
+ - NET_ADMIN
+ - IPC_LOCK
+ volumes:
+ - name: config-volume
+ configMap:
+ name: ngic-config
+ #- name: hugepage
+ # emptyDir:
+ # medium: HugePages
+
+ requirements:
+ - owner:
+ node: service#kubernetes
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_ngic_configmap:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "NGIC ConfigMap Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_ngic_configmap
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_mme_service:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "MME Service Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_mme_service
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_mme_statefulset:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "MME StatefulSet Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_mme_statefulset
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_hss_service:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "HSS Service Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_hss_service
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_hss_statefulset:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "HSS StatefulSet Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_hss_statefulset
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_hssdb_service:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "HSS Cassandra Service Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_hssdb_service
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_hssdb_statefulset:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "HSS Cassandra StatefulSet Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_hssdb_statefulset
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_spgwcu_service:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "SPGW Contol and User Service Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_spgwcu_service
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
+
+ vepcresourceinstancelink_spgwcu_statefulset:
+ type: tosca.nodes.VEpcResourceInstanceLink
+ properties:
+ name: "HS SPGW Control and User StatefulSet Resource Link"
+
+ requirements:
+ - resource_instance:
+ node: kubernetesresourceinstance_spgwcu_statefulset
+ relationship: tosca.relationships.BelongsToOne
+ - vepc_service_instance:
+ node: vepcserviceinstance
+ relationship: tosca.relationships.BelongsToOne
diff --git a/xos/examples/show-instances.py b/xos/examples/show-instances.py
new file mode 100755
index 0000000..2369d42
--- /dev/null
+++ b/xos/examples/show-instances.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+
+# Copyright 2017-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.
+
+# show-instances.py
+# Show the VEpcServiceInstances and their ip addresses in a human-readable table.
+# Syntax: show-instances.py <base_url> <username> <password>
+#
+# Example: show-instances.py http://192.168.42.253:30006 admin@opencord.org letmein
+
+import sys
+import time
+import requests
+from requests.auth import HTTPBasicAuth
+
+DELAY=1
+
+def main():
+ # if len(sys.argv)<4:
+ # print "Syntax: xos-instances.py <base_url> <username> <password>"
+ # sys.exit(-1)
+
+ # base_url = sys.argv[1]
+ # username = sys.argv[2]
+ # password = sys.argv[3]
+
+ # auth = HTTPBasicAuth(username, password)
+
+ # r = requests.get(base_url + "/xosapi/v1/vepcservice/vepcserviceinstances", auth=auth)
+
+ # if r.status_code != 200:
+ # print "Received error response", r.status_code
+ # print r.text
+ # sys.exit(-1)
+
+
+ # print "%-4s %-40s %-4s %-4s" % ("id", "Name", "Comp", "IP")
+ # for item in r.json()["items"]:
+ # name = item.get("name")
+ # compute_id = item["compute_instance_id"]
+ # if compute_id:
+ # r_compute = requests.get(base_url + "/xosapi/v1/kubernetes/kubernetesserviceinstances/%s" % compute_id, auth=auth)
+ # if r_compute.status_code != 200:
+ # print "Received error response when fetching compute instance", r_compute.status_code
+ # print r_compute.text
+ # sys.exit(-1)
+ # pod_ip = r_compute.json().get("pod_ip", "")
+ # else:
+ # pod_ip = ""
+ # print "%4s %-40s %4s %s" % (item["id"], name, compute_id, pod_ip)
+ pass
+
+
+if __name__=="__main__":
+ main()
diff --git a/xos/synchronizer/event_steps/vepcevent.py b/xos/synchronizer/event_steps/vepcevent.py
new file mode 100644
index 0000000..cece5fe
--- /dev/null
+++ b/xos/synchronizer/event_steps/vepcevent.py
@@ -0,0 +1,45 @@
+
+# Copyright 2017-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.
+
+
+import json
+import os
+import sys
+from synchronizers.new_base.eventstep import EventStep
+from synchronizers.new_base.modelaccessor import *
+from xosconfig import Config
+from multistructlog import create_logger
+
+log = create_logger(Config().get('logging'))
+
+class VEpcEventStep(EventStep):
+ topics = ["VEpcEvent"]
+ technology = "kafka"
+
+ def __init__(self, *args, **kwargs):
+ super(VEpcEventStep, self).__init__(*args, **kwargs)
+
+ def process_event(self, event):
+ value = json.loads(event.value)
+ service_instance_name = value["service_instance"]
+ #tenant_message = value["tenant_message"]
+
+ objs = VEpcServiceInstance.objects.filter(name=service_instance_name)
+ if not objs:
+ raise Exception("failed to find %s" % service_instance_name)
+
+ for obj in objs:
+ #obj.tenant_message = tenant_message
+ obj.save(always_update_timestamp = True)
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/synchronizer/model_policies/model_policy_vepcserviceinstance.py b/xos/synchronizer/model_policies/model_policy_vepcserviceinstance.py
new file mode 100644
index 0000000..bcf6d53
--- /dev/null
+++ b/xos/synchronizer/model_policies/model_policy_vepcserviceinstance.py
@@ -0,0 +1,143 @@
+
+# Copyright 2017-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.
+
+import base64
+import jinja2
+import json
+from synchronizers.new_base.modelaccessor import *
+from synchronizers.new_base.policy import Policy
+
+from xosconfig import Config
+from multistructlog import create_logger
+
+log = create_logger(Config().get('logging'))
+
+class VEpcServiceInstancePolicy(Policy):
+ model_name = "VEpcServiceInstance"
+
+ def handle_create(self, service_instance):
+ return self.handle_update(service_instance)
+
+ # def render_index(self, service_instance):
+ # service = service_instance.owner.leaf_model
+
+ # fields = {}
+ # fields['tenant_message'] = service_instance.tenant_message
+ # fields['service_message'] = service.service_message
+
+ # if service_instance.foreground_color:
+ # fields["foreground_color"] = service_instance.foreground_color.html_code
+
+ # if service_instance.background_color:
+ # fields["background_color"] = service_instance.background_color.html_code
+
+ # images=[]
+ # for image in service_instance.embedded_images.all():
+ # images.append({"name": image.name,
+ # "url": image.url})
+ # fields["images"] = images
+
+ # template_fn = os.path.join(os.path.abspath(os.path.dirname(os.path.realpath(__file__))), "index.html.j2")
+ # template = jinja2.Template(open(template_fn).read())
+
+ # return template.render(fields)
+
+ def handle_update(self, service_instance):
+ # if not service_instance.compute_instance:
+
+ # # TODO: Break dependency
+ # compute_service = KubernetesService.objects.first()
+ # compute_service_instance_class = Service.objects.get(id=compute_service.id).get_service_instance_class()
+
+ # vepcservice = service_instance.owner.leaf_model
+
+ # # TODO: What if there is the wrong number of slices?
+ # slice = vepcservice.slices.first()
+
+
+ # # TODO: What if there is no default image?
+ # # image = slice.default_image
+
+ # images = service_instance.images.all()
+
+ # # TODO: Gopi: Create the XOS Image object for each container
+ # # TODO: Gopi: Might have to extend the K8S synch to support multiple containers in a K8S pod
+ # # TODO: Gopi: Will have to extend the K8S sync to support StatefulSets
+
+ # docker_images = []
+ # for image in images:
+ # # TODO: Gopi: WORK ON THIS LOOP. THE Names need to be explicit now
+ # # TODO: slice = vepcservice.slices.get(name="mysite_vepcservice_mme")
+ # docker_image = "%s:%s" % (image.image_name, image.image_tag)
+ # compute_service_instance = compute_service_instance_class(slice=slice, owner=compute_service, image=docker_image, name=image.component_name) # Might need this at some point if I use configmap/secret: no_sync=True
+ # compute_service_instance.save()
+
+ # # # Create a configmap and attach it to the compute instance
+ # # data = {"index.html": self.render_index(service_instance)}
+ # # cfmap = KubernetesConfigMap(name="vepcserviceinstance-map-%s" % service_instance.id,
+ # # trust_domain=slice.trust_domain,
+ # # data=json.dumps(data))
+ # # cfmap.save()
+ # # cfmap_mnt = KubernetesConfigVolumeMount(config=cfmap,
+ # # service_instance=compute_service_instance,
+ # # mount_path="/usr/local/apache2/htdocs")
+ # # cfmap_mnt.save()
+
+ # # # Create a secret and attach it to the compute instance
+ # # data = {"service_secret.txt": base64.b64encode(str(vepcservice.service_secret)),
+ # # "tenant_secret.txt": base64.b64encode(str(service_instance.tenant_secret))}
+ # # secret = KubernetesSecret(name="vepcserviceinstance-secret-%s" % service_instance.id,
+ # # trust_domain=slice.trust_domain,
+ # # data=json.dumps(data))
+ # # secret.save()
+ # # secret_mnt = KubernetesSecretVolumeMount(secret=secret, service_instance=compute_service_instance, mount_path="/usr/local/apache2/secrets")
+ # # secret_mnt.save()
+
+ # # compute_service_instance.no_sync = False
+ # # compute_service_instance.save(update_fields=["no_sync"])
+
+ # # TODO: Gopi/Scott revisit this to make it more robust to declare
+ # # the K8S service instances dynamically
+ # service_instance.compute_instance_mme = compute_service_instance_mme
+ # service_instance.save(update_fields=["compute_instance_mme"])
+ # service_instance.compute_instance_hss = compute_service_instance_hss
+ # service_instance.save(update_fields=["compute_instance_hss"])
+ # service_instance.compute_instance_hssdb = compute_service_instance_hssdb
+ # service_instance.save(update_fields=["compute_instance_hssdb"])
+ # service_instance.compute_instance_spgw = compute_service_instance_spgw
+ # service_instance.save(update_fields=["compute_instance_spgw"])
+ # else:
+ # # TODO: Gopi: Need to handle the scenario of multiple compute instances representing the K8S Pods
+ # compute_instance = service_instance.compute_instance
+ # mnt = compute_instance.leaf_model.kubernetes_config_volume_mounts.first()
+ # config = mnt.config
+ # new_data = json.dumps({"index.html": self.render_index(service_instance)})
+ # if (new_data != config.data):
+ # config.data = new_data
+ # config.save(always_update_timestamp=True)
+ # # Force the Kubernetes syncstep
+ # compute_instance.save(always_update_timestamp=True)
+ pass
+
+ def handle_delete(self, service_instance):
+ # TODO: Gopi: Need to handle the scenario of multiple compute instances representing the K8S Pods
+ # log.info("handle_delete")
+ # if service_instance.compute_instance:
+ # log.info("has a compute_instance")
+ # service_instance.compute_instance.delete()
+ # service_instance.compute_instance = None
+ # # TODO: I'm not sure we can save things that are being deleted...
+ # service_instance.save(update_fields=["compute_instance"])
+ pass
diff --git a/xos/synchronizer/models/vepcservice.xproto b/xos/synchronizer/models/vepcservice.xproto
new file mode 100644
index 0000000..223ee0c
--- /dev/null
+++ b/xos/synchronizer/models/vepcservice.xproto
@@ -0,0 +1,16 @@
+option app_label = "vepcservice";
+option name = "vepcservice";
+
+message VEpcService (Service){
+ option verbose_name = "Virtual EPC Service";
+}
+
+message VEpcServiceInstance (ServiceInstance){
+ option verbose_name = "Virtual EPC Instance";
+}
+
+message VEpcResourceInstanceLink(XOSBase) {
+ required string name = 1 [help_text = "Resource link name", db_index=True, tosca_key=True];
+ required manytoone resource_instance->KubernetesResourceInstance:vepc_resource_instance_links = 2 [help_text = "Kubernetes resource file content", db_index=True, null=False, blank=False];
+ required manytoone vepc_service_instance->VEpcServiceInstance:vepc_resource_instance_links = 3 [help_text = "Virtual EPC Service Instance", db_index=True, null=False, blank=False];
+}
\ No newline at end of file
diff --git a/xos/synchronizer/steps/sync_vepcserviceinstance.py b/xos/synchronizer/steps/sync_vepcserviceinstance.py
new file mode 100644
index 0000000..91d3c54
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vepcserviceinstance.py
@@ -0,0 +1,48 @@
+
+# Copyright 2017-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.
+
+
+import os
+import sys
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.modelaccessor import *
+from xosconfig import Config
+from multistructlog import create_logger
+
+log = create_logger(Config().get('logging'))
+
+class SyncVEpcServiceInstance(SyncStep):
+
+ provides = [VEpcServiceInstance]
+
+ observes = VEpcServiceInstance
+
+ requested_interval = 0
+
+ # template_name = "vepcserviceinstance_playbook.yaml"
+
+ # service_key_name = "/opt/xos/synchronizers/vepcservicenew/vepcservice_private_key"
+
+ def __init__(self, *args, **kwargs):
+ super(SyncVEpcServiceInstance, self).__init__(*args, **kwargs)
+
+ def sync_record(self, o):
+ # There's nothing to do at this time. Configuration of VEpcServiceInstance is handled by Kubernetes
+ # through config maps, and that all happens in the model policy.
+ #
+ # TODO(smbaker): Consider deleting this sync step
+ # Note from Gopi: This method exists as the code is copied from Simple Example Service. Please
+ # discuss with smbaker if this function is necessary.
+ pass
diff --git a/xos/synchronizer/tests/test_config.yaml b/xos/synchronizer/tests/test_config.yaml
new file mode 100644
index 0000000..acd2ba7
--- /dev/null
+++ b/xos/synchronizer/tests/test_config.yaml
@@ -0,0 +1,29 @@
+# Copyright 2017-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.
+
+
+name: test-model-policies
+accessor:
+ username: xosadmin@opencord.org
+ password: "sample"
+ kind: "testframework"
+logging:
+ version: 1
+ handlers:
+ console:
+ class: logging.StreamHandler
+ loggers:
+ 'multistructlog':
+ handlers:
+ - console
diff --git a/xos/synchronizer/tests/test_model_policy_vepcserviceinstance.py b/xos/synchronizer/tests/test_model_policy_vepcserviceinstance.py
new file mode 100644
index 0000000..c6d301b
--- /dev/null
+++ b/xos/synchronizer/tests/test_model_policy_vepcserviceinstance.py
@@ -0,0 +1,54 @@
+
+# Copyright 2017-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.
+
+# Tests for VEpcServiceInstance model policies
+
+import base64
+import json
+import os
+import sys
+import unittest
+from mock import patch, PropertyMock, ANY, MagicMock
+from unit_test_common import setup_sync_unit_test
+
+
+class TestVEpcServiceInstancePolicy(unittest.TestCase):
+
+ def setUp(self):
+ self.unittest_setup = setup_sync_unit_test(os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
+ globals(),
+ [("vepcservice", "vepcservice.xproto"),
+ ("kubernetes-service", "kubernetes.xproto")] )
+
+ self.MockObjectList = self.unittest_setup["MockObjectList"]
+
+ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(os.path.realpath(__file__))), "../model_policies"))
+
+ from model_policy_vepcserviceinstance import VEpcServiceInstancePolicy
+ self.policy_class = VEpcServiceInstancePolicy
+
+ self.service = VEpcService()
+ self.k8s_service = KubernetesService(id=1111)
+ self.k8s_service.get_service_instance_class=MagicMock(return_value=KubernetesServiceInstance)
+ self.trust_domain = TrustDomain(owner=self.k8s_service, name="test-trust")
+ self.image = Image(name="test-image", tag="1.2", kind="container")
+ self.slice = Slice(trust_domain=self.trust_domain, service=self.service, default_image = self.image)
+ self.service.slices = self.MockObjectList([self.slice])
+
+ def tearDown(self):
+ sys.path = self.unittest_setup["sys_path_save"]
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/xos/synchronizer/tests/unit_test_common.py b/xos/synchronizer/tests/unit_test_common.py
new file mode 100644
index 0000000..68f6743
--- /dev/null
+++ b/xos/synchronizer/tests/unit_test_common.py
@@ -0,0 +1,84 @@
+
+# Copyright 2017-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.
+
+import os
+import sys
+
+def setup_sync_unit_test(test_path, globals_dict, models, config_fn="test_config.yaml"):
+ """ Perform the common steps associated with setting up a synchronizer unit test.
+ 1) Add synchronizers/new_base to sys.path
+ 2) Import xosconfig.Config and set it up to test_config.yaml in the current dir
+ 3) Build the mock modelaccessor and import it
+ 4) Import all model accessor classes into global space
+
+ Arguments:
+ test_path - path to the test case that is being run
+ globals_dict - a dictionary to add global models to
+ models - a list of pairs (service_name, xproto_name,
+ config_fn - filename of config file)
+
+ Returns:
+ Dictionary containing the following:
+ sys_path_save: the original sys.path
+ model_accessor: model accessor class
+ Config: the Config object
+ xos_dir: xos directory
+ services_dir: services directory
+ """
+ def get_models_fn(services_dir, service_name, xproto_name):
+ name = os.path.join(service_name, "xos", xproto_name)
+ if os.path.exists(os.path.join(services_dir, name)):
+ return name
+ else:
+ name = os.path.join(service_name, "xos", "synchronizer", "models", xproto_name)
+ if os.path.exists(os.path.join(services_dir, name)):
+ return name
+ raise Exception("Unable to find service=%s xproto=%s" % (service_name, xproto_name))
+
+ sys_path_save = sys.path
+
+ xos_dir = os.path.join(test_path, "../../..")
+ if not os.path.exists(os.path.join(test_path, "new_base")):
+ xos_dir = os.path.join(test_path, "../../../../../../orchestration/xos/xos")
+ services_dir = os.path.join(xos_dir, "../../xos_services")
+ sys.path.append(xos_dir)
+ sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
+
+ # Setting up the config module
+ from xosconfig import Config
+ config = os.path.join(test_path, config_fn)
+ Config.clear()
+ Config.init(config, "synchronizer-config-schema.yaml")
+
+ xprotos = []
+ for (service_name, xproto_name) in models:
+ xprotos.append(get_models_fn(services_dir, service_name, xproto_name))
+
+ from synchronizers.new_base.mock_modelaccessor_build import build_mock_modelaccessor
+ build_mock_modelaccessor(xos_dir, services_dir, xprotos)
+ import synchronizers.new_base.modelaccessor
+ from synchronizers.new_base.modelaccessor import model_accessor
+ from mock_modelaccessor import MockObjectList
+
+ # import all class names to globals
+ for (k, v) in model_accessor.all_model_classes.items():
+ globals_dict[k] = v
+
+ return {"sys_path_save": sys_path_save,
+ "model_accessor": model_accessor,
+ "Config": Config,
+ "xos_dir": xos_dir,
+ "services_dir": services_dir,
+ "MockObjectList": MockObjectList}
diff --git a/xos/synchronizer/vepcservice-synchronizer.py b/xos/synchronizer/vepcservice-synchronizer.py
new file mode 100644
index 0000000..590c1e2
--- /dev/null
+++ b/xos/synchronizer/vepcservice-synchronizer.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+# Copyright 2017-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.
+
+# Runs the standard XOS synchronizer
+
+import importlib
+import os
+import sys
+from xosconfig import Config
+
+config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/vepcservice_config.yaml')
+Config.init(config_file, 'synchronizer-config-schema.yaml')
+
+synchronizer_path = os.path.join(os.path.dirname(
+ os.path.realpath(__file__)), "../../synchronizers/new_base")
+sys.path.append(synchronizer_path)
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
+
diff --git a/xos/synchronizer/vepcservice_config.yaml b/xos/synchronizer/vepcservice_config.yaml
new file mode 100644
index 0000000..7d4d0aa
--- /dev/null
+++ b/xos/synchronizer/vepcservice_config.yaml
@@ -0,0 +1,33 @@
+
+# Copyright 2017-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.
+
+
+name: vepcservice
+accessor:
+ username: xosadmin@opencord.org
+ password: "@/opt/xos/services/vepcservice/credentials/xosadmin@opencord.org"
+required_models:
+ - VEpcService
+ - VEpcServiceInstance
+ - VEpcResourceInstanceLink
+ - ServiceDependency
+ - KubernetesService
+ - kubernetesResourceInstance
+dependency_graph: "/opt/xos/synchronizers/vepcservice/model-deps"
+steps_dir: "/opt/xos/synchronizers/vepcservice/steps"
+event_steps_dir: "/opt/xos/synchronizers/vepcservice/event_steps"
+sys_dir: "/opt/xos/synchronizers/vepcservice/sys"
+model_policies_dir: "/opt/xos/synchronizers/vepcservice/model_policies"
+models_dir: "/opt/xos/synchronizers/vepcservice/models"
diff --git a/xos/unittest.cfg b/xos/unittest.cfg
new file mode 100644
index 0000000..9a7a380
--- /dev/null
+++ b/xos/unittest.cfg
@@ -0,0 +1,13 @@
+[unittest]
+plugins=nose2.plugins.junitxml
+code-directories=synchronizer
+ model_policies
+ steps
+ pull_steps
+
+[coverage]
+always-on = True
+coverage = synchronizer
+coverage-report = term
+coverage-report = html
+coverage-report = xml