Commit 174c51d0 authored by Mark Beierl's avatar Mark Beierl
Browse files

Sample package



Content for the welcome session
Signed-off-by: Mark Beierl's avatarMark Beierl <mark.beierl@canonical.com>
parent 4a772376
Pipeline #7590 failed with stage
in 1 minute and 31 seconds
#!/bin/bash
if [ ! -d hackfest_basic_ns ] ; then
if [ ! -d my_first_ns ] ; then
echo "It does not look like we are in the osm-packages directory, exiting"
exit 1
fi
......@@ -9,20 +9,14 @@ fi
echo "========================================================================"
echo "Cleaning out any prior versions of the descriptors from OSM"
echo "========================================================================"
osm nsd-delete hackfest_basic-ns
osm vnfd-delete hackfest_basic-vnf
echo "========================================================================"
echo "Building packages"
echo "========================================================================"
osm package-build hackfest_basic_vnf
osm package-build hackfest_basic_ns
osm nsd-delete my_first_ns
osm vnfd-delete my_first_vnf
echo "========================================================================"
echo "Uploading packages"
echo "========================================================================"
osm upload-package hackfest_basic_vnf.tar.gz
osm upload-package hackfest_basic_ns.tar.gz
osm upload-package my_first_vnf
osm upload-package my_first_ns
echo "========================================================================"
echo "Done"
echo "========================================================================"
......
#!/bin/bash
VIMID=`osm vim-list | grep osm_ | awk '{ print $4 }'`
echo "========================================================================"
echo "Launching network service with VIMID ${VIMID}"
echo "Launching network service"
echo "========================================================================"
osm ns-create --ns_name basic-vnf \
--nsd_name hackfest_basic-ns \
--vim_account ${VIMID} \
osm ns-create --ns_name my_first_ns \
--nsd_name my_first_ns \
--vim_account openstack \
--ssh_keys ~/.ssh/id_rsa.pub \
--config \
'{vld: [ {name: mgmtnet, vim-network-name: osm-ext} ] }'
'{vld: [ {name: mgmtnet, vim-network-name: management} ] }'
echo "========================================================================"
echo "Done"
echo "========================================================================"
......
#!/bin/bash
echo "========================================================================"
echo "Here are some of the actions you can run"
echo "========================================================================"
cat << 'EOF'
TBD
EOF 
#!/bin/bash
echo "========================================================================"
echo "Uploading new package content"
echo "========================================================================"
osm package-build my_first_vnf
osm vnfpkg-update my_first_vnf --content=my_first_vnf.tar.gz
echo "========================================================================"
echo "Done"
echo "========================================================================"
#!/bin/bash
NS_ID=$(osm ns-list | grep my_first_ns | awk '{print $4}')
VNF_ID=$(osm vnf-list | grep my_first_vnf | awk '{print $2}')
VNFD_ID=$(osm vnf-show $VNF_ID --literal | yq .vnfd-id)
osm ns-update ${NS_ID} \
--updatetype CHANGE_VNFPKG \
--config "{changeVnfPackageData: [
{vnfInstanceId: \"${VNF_ID}\",
vnfdId: \"$VNFD_ID\"}]}" \
--timeout 300 \
--wait
nsd:
nsd:
- description: A very simple network service that deploys 1 VM
designer: Canonical
df:
- id: default-df
vnf-profile:
- id: my_first_vnf
virtual-link-connectivity:
- constituent-cpd-id:
- constituent-base-element-id: my_first_vnf
constituent-cpd-id: vnf-mgmt-ext
virtual-link-profile-id: mgmtnet
vnfd-id: my_first_vnf
id: my_first_ns
name: my_first_ns
version: 1.0
virtual-link-desc:
- id: mgmtnet
mgmt-network: true
vnfd-id:
- my_first_vnf
type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
# virtual-pc
## Description
## Usage
### Prepare the environment
```bash
sudo snap install juju --classic --channel 2.8/stable
sudo snap install lxd
lxd.init
juju bootstrap lxd
juju add-model test-virtual-pc
```
### Deploy (from the Store)
```bash
juju deploy cs:~charmed-osm/virtual-pc --channel edge
```
### Deploy (locally)
Build the charm:
```bash
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
pip install charmcraft
./venv/bin/charmcraft build
```
Deploy:
```bash
juju deploy ./virtual-pc.charm
```
## Developing
Create and activate a virtualenv with the development requirements:
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
## Testing
The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just `run_tests`:
./run_tests
# Copyright ETSI OSM Contributors
# See LICENSE file for licensing details.
#
# This is only an example, and you should edit to suit your needs.
# If you don't need actions, you can remove the file entirely.
# It ties in to the example _on_fortune_action handler in src/charm.py
add-package:
description: "Adds software packages from apt."
params:
package:
description: "Names of packages to add, comma delimited."
type: string
default: ""
required:
- package
add-snap:
description: "Adds software packages from snap store."
params:
package:
description: "Names of packages to add, comma delimited."
type: string
default: ""
required:
- package
announce:
description: "Sends a message to logged in users"
params:
message:
description: "Message to send"
type: string
default: ""
required:
- message
reboot:
description: "Reboots the server."
remove-package:
description: "Removes software packages from system."
params:
package:
description: "Names of packages to remove, comma delimited."
type: string
default: ""
required:
- package
remove-snap:
description: "Adds software packages from snap store."
params:
package:
description: "Names of packages to add, comma delimited."
type: string
default: ""
required:
- package
update-system:
description: "Updates all software to latest version."
type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
#!/bin/sh
JUJU_DISPATCH_PATH="${JUJU_DISPATCH_PATH:-$0}" PYTHONPATH=lib:venv ./src/charm.py
name: my-first-charm
summary: A simple example proxy charm
description: |
This is is an example charm used in OSM Hackfests
series:
- focal
-r requirements.txt
flake8
charmcraft
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment