Skip to content
Snippets Groups Projects
Commit 3fcb3c51 authored by torrespel's avatar torrespel
Browse files

Provider CLI example

parent 244e857c
No related branches found
No related tags found
No related merge requests found
Showing
with 492 additions and 58 deletions
.idea
.git
# Byte-compiled / optimized / DLL files
__pycache__/
./libraries/__pycache__/*.py[cod]
*.py[cod]
*$py.class
*.DS_Store
*.key
*.csr
*.pem
*./valid_ca/*
demo_values.json
capif_provider_details.json
\ No newline at end of file
Pipfile 0 → 100644
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pymongo = "==3.12.0"
inject = "==4.3.1"
[dev-packages]
[requires]
python_version = "3.8"
# provider-cli # CAPIF_Provider_ONE
This is the implementation of a Provider (AEF) for the Opennebula service
## Prerequisites
In order to use the Provider you must use the public CAPIF or create a [CAPIF](https://github.com/EVOLVED-5G/CAPIF_API_Services) instance.
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps. ## Important
This code is intended for testing in a local docker environment. If it is going to be deployed in an environment such as kubernetes, it is necessary to make modifications to the following file:
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! ```
./capif_ops/config_files/service_api_description_one.json
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files ```
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: ```
"ipv4Addr": <url of the service>
```
## Set Up
This repo is designed to be executed from docker, to create the images and raise the instance it is only necessary to execute the following command:
``` ```
cd existing_repo ./run.sh
git remote add origin https://labs.etsi.org/rep/ocf/example-clients/provider-cli.git
git branch -M main
git push -uf origin main
``` ```
## Integrate with your tools - Before executing the run.sh command, note that it supports one parameter, this parameter is the CAPIF hostname, by default this field is 'capifcore'. Modify it if necessary or add the hostname when executing the run.sh command
- [ ] [Set up project integrations](https://labs.etsi.org/rep/ocf/example-clients/provider-cli/-/settings/integrations) ```
./run.sh <other_hostname>
## Collaborate with your team ```
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) - It is important to have the following environment variables in the docker-compose file:
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) ```
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) - REGISTER_HOSTNAME = register
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) - CAPIF_PORT=8080
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - REGISTER_PORT=8084
## Test and Deploy extra_hosts:
- host.docker.internal:host-gateway
- capifcore:host-gateway
- register:host-gateway
Use the built-in continuous integration in GitLab. ```
By default, these are the ports and names that the CAPIF script uses when launching the different services. If during the deployment of CAPIF you modify these parameters, you must modify them so that they correspond to the new ones.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) If the hostname environment variables are modified, the extra host must also be modified so that the hostnames correspond and be able to reach the services deployed in docker.
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
*** Now it is only necessary to enter inside the container by executing this command
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README ```
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. ./terminal_to_py_aef.sh
## Name ```
Choose a self-explaining name for your project.
## Description Once inside the container you can run the provider command GUI by running
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges ```
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. ./python main.py
## Visuals ```
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation ## Interacting with the GUI
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. The provider is prepared to make the necessary previous provisions automatically.
The different .json files that must be saved in CAPIF are also added. To make the necessary provisions you just have to execute the following commands within the GUI
## Usage ```
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. register_provider
## Support ```
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap ```
If you have ideas for releases in the future, it is a good idea to list them in the README. publish_service
## Contributing ```
State if you are open to contributions and what your requirements are for accepting them. *If the first command returns a 401, it means that the token to interact the first time with CAPIF has expired, run the following command
```
provider_get_auth
```
## Run ONE Service
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. This service has Apified some of the functions of ONE. To start the service run the following command:
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. ```
python service/service_oauth.py
```
- It is necessary to modify the URL and the ONE credentials to be used in the python service itself
## Authors and acknowledgment The endpoints that are implemented are the following
Show your appreciation to those who have contributed to the project.
## License ```
For open source projects, say how it is licensed. /hello [POST]
Request Body:
{
"name": "ocf_user"
}
## Project status ```
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
apiVersion: v2
name: capif-provider-one
description: A Helm chart for capif-provider-one in Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "latest"
# Helm of capif-provider-one
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=for-the-badge)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=for-the-badge)
![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=for-the-badge)
## Description
A Helm chart for capif-provider-one in Kubernetes
## Usage
## Values
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| environment | string | `"openshift"` | The Environment variable. It accepts: 'kuberentes-athens', 'kuberentes-uma', 'openshift' |
| ingress_ip | object | `{"athens":"10.161.1.126","uma":"10.11.23.49"}` | If env: 'kuberentes-athens' or env: 'kuberentes-uma', use the Ip address dude for the kubernetes to your Ingress Controller ej: kubectl -n NAMESPACE_CAPIF get ing s |
| kubernetesClusterDomain | string | `"cluster.local"` | |
| oneProviderGui.oneProviderGui.env.capifHostname | string | `"my-capif.apps.ocp-epg.hi.inet"` | |
| oneProviderGui.oneProviderGui.env.capifPort | string | `"80"` | |
| oneProviderGui.oneProviderGui.env.easyRsaPort | string | `"8083"` | |
| oneProviderGui.oneProviderGui.env.requestsCaBundle | string | `"/usr/src/app/ca.crt"` | |
| oneProviderGui.oneProviderGui.env.sslCertFile | string | `"/usr/src/app/ca.crt"` | |
| oneProviderGui.oneProviderGui.image.repository | string | `"709233559969.dkr.ecr.eu-central-1.amazonaws.com/evolved5g:capif-one-provider-gui"` | |
| oneProviderGui.oneProviderGui.image.tag | string | `""` | |
| oneProviderGui.ports[0].name | string | `"capif-provider-one"` | |
| oneProviderGui.ports[0].port | int | `8085` | |
| oneProviderGui.ports[0].targetPort | int | `8085` | |
| oneProviderGui.type | string | `"ClusterIP"` | |
# Helm of capif-provider-one
![Version: {{ .Version }}](https://img.shields.io/badge/Version-{{ .Version | replace "-" "--" }}-informational?style=for-the-badge)
{{ if .Type }}![Type: {{ .Type }}](https://img.shields.io/badge/Type-{{ .Type }}-informational?style=for-the-badge) {{ end }}
{{ if .AppVersion }}![AppVersion: {{ .AppVersion }}](https://img.shields.io/badge/AppVersion-{{ .AppVersion | replace "-" "--" }}-informational?style=for-the-badge) {{ end }}
## Description
{{ template "chart.description" . }}
## Usage
{{ template "chart.valuesSection" . }}
{{ template "chart.homepageLine" . }}
{{ template "chart.sourcesSection" . }}
{{ template "chart.maintainersSection" . }}
{{/*
Expand the name of the chart.
*/}}
{{- define "capif-provider-one.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "capif-provider-one.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "capif-provider-one.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "capif-provider-one.labels" -}}
helm.sh/chart: {{ include "capif-provider-one.chart" . }}
{{ include "capif-provider-one.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "capif-provider-one.selectorLabels" -}}
app.kubernetes.io/name: {{ include "capif-provider-one.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "capif-provider-one.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "capif-provider-one.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "capif-provider-one.fullname" . }}-provider
labels:
io.kompose.service: capif-provider-one
{{- include "capif-provider-one.labels" . | nindent 4 }}
annotations:
kompose.cmd: kompose -f docker-compose.yml convert
kompose.version: 1.28.0 (c4137012e)
spec:
replicas: {{ .Values.oneProviderGui.replicas }}
selector:
matchLabels:
io.kompose.service: capif-provider-one
{{- include "capif-provider-one.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
io.kompose.service: capif-provider-one
{{- include "capif-provider-one.selectorLabels" . | nindent 8 }}
annotations:
kompose.cmd: kompose -f docker-compose.yml convert
kompose.version: 1.28.0 (c4137012e)
spec:
imagePullSecrets:
- name: regcred
{{- if eq .Values.environment "kubernetes-athens" }}
hostAliases:
- ip: "{{ .Values.ingress_ip.athens }}"
hostnames:
- "{{ .Values.oneProviderGui.oneProviderGui.env.capifHostname }}"
{{- end }}
{{- if eq .Values.environment "kubernetes-uma" }}
hostAliases:
- ip: "{{ .Values.ingress_ip.uma }}"
hostnames:
- "{{ .Values.oneProviderGui.oneProviderGui.env.capifHostname }}"
{{- end }}
containers:
- env:
- name: CAPIF_HOSTNAME
value: {{ quote .Values.oneProviderGui.oneProviderGui.env.capifHostname }}
- name: CAPIF_PORT
value: {{ quote .Values.oneProviderGui.oneProviderGui.env.capifPort }}
- name: EASY_RSA_PORT
value: {{ quote .Values.oneProviderGui.oneProviderGui.env.easyRsaPort }}
- name: REQUESTS_CA_BUNDLE
value: {{ quote .Values.oneProviderGui.oneProviderGui.env.requestsCaBundle }}
- name: SSL_CERT_FILE
value: {{ quote .Values.oneProviderGui.oneProviderGui.env.sslCertFile }}
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
image: {{ .Values.oneProviderGui.oneProviderGui.image.repository }}-{{ .Values.oneProviderGui.oneProviderGui.image.tag
| default .Chart.AppVersion }}
imagePullPolicy: Always
name: one-provider-gui
ports:
- containerPort: 8085
resources: {}
restartPolicy: Always
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: capif-provider-one
labels:
io.kompose.service: capif-provider-one
{{- include "capif-provider-one.labels" . | nindent 4 }}
annotations:
kompose.cmd: kompose -f docker-compose.yml convert
kompose.version: 1.28.0 (c4137012e)
spec:
type: {{ .Values.oneProviderGui.type }}
selector:
io.kompose.service: capif-provider-one
{{- include "capif-provider-one.selectorLabels" . | nindent 4 }}
ports:
{{- .Values.oneProviderGui.ports | toYaml | nindent 2 -}}
\ No newline at end of file
# -- The Environment variable. It accepts: 'kuberentes-athens', 'kuberentes-uma', 'openshift'
environment: "openshift"
# -- If env: 'kuberentes-athens' or env: 'kuberentes-uma', use the Ip address dude for the kubernetes to your Ingress Controller ej: kubectl -n NAMESPACE_CAPIF get ing s
ingress_ip:
athens: "10.161.1.126"
uma: "10.11.23.49"
oneProviderGui:
oneProviderGui:
env:
capifHostname: my-capif.apps.ocp-epg.hi.inet
capifPort: "80"
easyRsaPort: "8083"
requestsCaBundle: /usr/src/app/ca.crt
sslCertFile: /usr/src/app/ca.crt
image:
repository: 709233559969.dkr.ecr.eu-central-1.amazonaws.com/evolved5g:capif-one-provider-gui
tag: ""
ports:
- name: "capif-provider-one"
port: 8085
targetPort: 8085
type: ClusterIP
kubernetesClusterDomain: cluster.local
\ No newline at end of file
#!/bin/bash
docker-compose down --rmi all --remove-orphans
version: '3'
services:
one_provider_gui:
image: dockerhub.hi.inet/evolved-5g/capif/one_provider_gui:latest
hostname: exposer
container_name: one_provider_gui
build:
context: ./one_provider_gui
volumes:
- ./one_provider_gui:/usr/src/app
environment:
- CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
- CAPIF_PORT=8080
- REGISTER_HOSTNAME=register
- REGISTER_PORT=8084
extra_hosts:
- host.docker.internal:host-gateway
- capifcore:host-gateway
- register:host-gateway
networks:
default:
external:
name: capif-network
FROM python:3.8
ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y jq && apt-get clean
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ADD requirements.txt /usr/src/app/
RUN pip install -r requirements.txt
ADD . /usr/src/app/
RUN mkdir -p ./capif_ops/certs
EXPOSE 8085
CMD ["sh", "prepare.sh"]
\ No newline at end of file
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pymongo = "==3.12.0"
inject = "==4.3.1"
[dev-packages]
[requires]
python_version = "3.8"
{
"apiProvFuncs": [
{
"regInfo": {
"apiProvPubKey": ""
},
"apiProvFuncRole": "AEF"
},
{
"regInfo": {
"apiProvPubKey": ""
},
"apiProvFuncRole": "APF"
},
{
"regInfo": {
"apiProvPubKey": ""
},
"apiProvFuncRole": "AMF"
}
],
"suppFeat": "fff",
"failReason": "string"
}
[credentials]
exposer_username = ocf_user
exposer_password = user_pass
exposer_description = Exposer (APF, AMF, AEF)
exposer_email = ocf@gg.com
exposer_enterprise = ETSI
exposer_country = Spain
exposer_purpose = Use OCF
exposer_phone = +123456789
exposer_web = https://ocf.etsi.org/
capif_callback_ip = host.docker.internal
capif_callback_port = 8087
\ No newline at end of file
{
"events": ["API_INVOKER_ONBOARDED",
"API_INVOKER_OFFBOARDED",
"ACCESS_CONTROL_POLICY_UPDATE",
"ACCESS_CONTROL_POLICY_UNAVAILABLE",
"API_INVOKER_UPDATED"],
"notificationDestination": "http://192.168.100.26:2222",
"supportedFeatures": "fffffff",
"securityInfo": [
{
"authenticationInfo": "authenticationInfo",
"authorizationInfo": "authorizationInfo",
"interfaceDetails": {
"ipv4Addr": "10.95.47.147",
"securityMethods": ["PSK"],
"port": 2222
},
"prefSecurityMethods": ["PSK", "PKI", "OAUTH"]
},
{
"authenticationInfo": "authenticationInfo",
"authorizationInfo": "authorizationInfo",
"prefSecurityMethods": ["PSK", "PKI", "OAUTH"],
"aefId": "aefId"
}
],
"websockNotifConfig": {
"requestWebsocketUri": true,
"websocketUri": "websocketUri"
},
"requestTestNotification": true
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment