OSM MAAS Plugin

From UNamur InfoSec
Jump to navigation Jump to search

OSM MAAS Plugin

Setup development server

Step 1: Install OSM

  1. VM requirement to install OSM

    • MINIMUM: 2 CPUs, 6 GB RAM, 40GB disk and a single interface with Internet access
    • RECOMMENDED: 2 CPUs, 8 GB RAM, 40GB disk and a single interface with Internet access
    • Base image: Ubuntu18.04 (64-bit variant required)

    note: I have installed VM on a KVM host in the Ubuntu machine.

  2. Download and run the OSM installation script

    <source lang="bash">wget https://osm-download.etsi.org/ftp/osm-10.0-ten/install_osm.sh chmod +x install_osm.sh

    ./install_osm.sh</source>

Step 2

  1. Install dependency

    <source lang="bash">DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ DEBIAN_FRONTEND=noninteractive apt-get --yes install \ gcc python3 python3-dev python3-venv python3-pip \ python3-setuptools curl git genisoimage netbase</source>

    <source lang="bash">python3 -m pip install -U pip build</source>
  2. clone RO, and Common

    <source lang="bash">git clone https://osm.etsi.org/gerrit/osm/common.git

    git clone https://osm.etsi.org/gerrit/osm/RO</source>
  3. Install dependency

    <source lang="bash">python3 -m pip install -r RO/requirements.txt python3 -m pip install -r common/requirements.txt python3 -m pip install -e common # try with --user if get permission errors python3 -m pip install -e ./RO/NG-RO

    python3 -m pip install -e ./RO/RO-plugin</source>
  4. Start RO server (It need to connect to database server we expose in next step)

    <source lang="bash">python3 RO/NG-RO/osm_ng_ro/ro_main.py</source>

Step 3

  1. create k8s yaml file with these to expose the service port (expose_service.yaml)

    <source lang="bash">---

    1. kafka

    apiVersion: v1 kind: Service metadata:

     name: kafka-debug
     namespace: osm
    

    spec:

     externalTrafficPolicy: Cluster
     ports:
     - nodePort: 9092
       port: 9092
       protocol: TCP
       targetPort: 9092
     selector:
       app: kafka
     sessionAffinity: None
     type: NodePort
    

    status:

     loadBalancer: {}
    

    ---

    1. mysql

    apiVersion: v1 kind: Service metadata:

     name: mysql-debug
     namespace: osm
    

    spec:

     externalTrafficPolicy: Cluster
     ports:
     - nodePort: 3306
       port: 3306
       protocol: TCP
       targetPort: 3306
     selector:
       app: mysql
     sessionAffinity: None
     type: NodePort
    

    status:

     loadBalancer: {}
    

    ---

    1. mongo

    apiVersion: v1 kind: Service metadata:

     name: mongo-debug
     namespace: osm
    

    spec:

     externalTrafficPolicy: Cluster
     ports:
     - nodePort: 27017
       port: 27017
       protocol: TCP
       targetPort: 27017
     selector:
       app: mongo
     sessionAffinity: None
     type: NodePort
    

    status:

     loadBalancer: {}
    
    </source>
  2. apply service

    <source lang="bash">kubectl apply -n osm -f expose_service.yaml</source>
  3. Edit /etc/hosts file to add host name with the following value

    <source lang="bash">127.0.0.1 localhost kafka kafka-0.kafka.osm.svc.cluster.local keystone nbi mongo mysql ro</source>
  4. Remove RO from k8s

    <source lang="bash">kubectl -n osm scale deployment ro --replicas=0

    kubectl -n osm delete service/ro</source>
  5. Update LCM to point to new RO server

    <source lang="bash">kubectl -n osm patch deployment lcm --patch '{"spec": {"template": {"spec": {"containers": [{"name": "lcm", "env": [{"name": "OSMLCM_RO_HOST", "value": "172.17.0.1"}] }]}}}}'</source>

    noted: if the patch deployment fail, we can update the /etc/hosts file in the container

    <source lang="bash">kubectl -n osm exec -i -t lcm-69d8d4fb5c-l7mtl -- /bin/bash nano /etc/hosts

    172.17.0.1 ro</source>
  6. Read DB common key

    <source lang="bash">kubectl get secret lcm-secret -n osm --template=Template:.data.OSMLCM DATABASE COMMONKEY | base64 --decode</source>
  7. Update ro.cfg file to use the common and static dir, (Note: I need to run ‘kubectl get service -n osm’ to get the mongo-db-k8s service cluster IP address and put it in the cfg file, so I am not sure if edit hosts file and expose ports steps are necessary)

    <source lang="bash">[database]

    1. use env OSMRO_DATABASE_XXX to override

    driver: "mongo" # mongo or memory uri: "mongodb://mongo:27017" name: "osm"

    1. user: "user"
    2. password: "password"
    commonkey: "4Pu8JBKt7ULUQe6GetMlEcvsvMQTyJgu"</source>
  8. Start RO server (continue from step 1)

    <source lang="bash">python3 RO/NG-RO/osm_ng_ro/ro_main.py</source>

    note: if we get error msg about static directory, or mongo connection. we need to update ro.cfg file (change mongo to cluster ip and restart the server).

Step 4

  1. Create a ro_vim_maas module by copying from one of the vim. (Or clone our git repo.)

    <source lang="bash">cp -r RO/RO-VIM-aws ./RO-VIM-maas</source>
  2. Edit setup.py, requirement, vimconn_xxx.py file to change vim name, etc.

  3. Run the module in development mode

    <source lang="bash">python3 -m pip install -e ./RO-VIM-maas</source>
  4. Restart RO server