Commit 21d73fc1 authored by Mark Beierl's avatar Mark Beierl
Browse files

Finalizing Welcome Session


Signed-off-by: Mark Beierl's avatarMark Beierl <mark.beierl@canonical.com>
parent 174c51d0
Pipeline #7598 failed with stage
in 1 minute and 27 seconds
......@@ -9,8 +9,8 @@ fi
echo "========================================================================"
echo "Cleaning out any prior versions of the descriptors from OSM"
echo "========================================================================"
osm nsd-delete my_first_ns
osm vnfd-delete my_first_vnf
osm nsd-delete my_first_ns | grep -v "not found"
osm vnfd-delete my_first_vnf | grep -v "not found"
echo "========================================================================"
echo "Uploading packages"
......
#!/bin/bash
echo "========================================================================"
echo "Waiting for deployment to finish"
echo "========================================================================"
WAITING=1
while [ $WAITING -eq 1 ] ; do
osm ns-list | grep my_first_ns | grep READY
WAITING=$?
done
echo "========================================================================"
echo "Getting IP Address of VNF"
echo "========================================================================"
IP_ADDRESS=$(osm vnf-list | grep my_first_vnf | awk '{print $14}')
echo "Your VNF is reachable at ${IP_ADDRESS}"
echo "To log in, use"
echo " ssh ubuntu@${IP_ADDRESS}"
echo "========================================================================"
echo "Done"
echo "========================================================================"
#!/bin/bash
echo "========================================================================"
echo "Here are some of the actions you can run"
echo "========================================================================"
cat << EOF
osm ns-action my_first_ns --wait --vnf_name my_first_vnf --action_name reboot
osm ns-action my_first_ns --wait --vnf_name my_first_vnf --action_name cancel-reboot
osm ns-action my_first_ns --wait --vnf_name my_first_vnf --action_name add-package --params '{package: traceroute}'
osm ns-action my_first_ns --wait --vnf_name my_first_vnf --action_name remove-package --params '{package: traceroute}'
osm ns-action my_first_ns --wait --vnf_name my_first_vnf --action_name update-system
EOF
\ No newline at end of file
#!/bin/bash
cat << EOF
==============================================================================================
File: my_first_vnf/charms/my-first-charm/src/charm.py
Around line 87, change _announce to read as follows:
def _announce(self, event):
self.unit.status = MaintenanceStatus("Announce")
message = event.params["message"]
shell(f"wall \"{message}\"")
self.unit.status = self._get_current_status()
==============================================================================================
Launching VSCode, alt-tab to get back to this window :)
EOF
sleep 4
code -g ~/osm-packages/Hackfest_Demos/OSM-MR13/1.1-Welcome/my_first_vnf/charms/my-first-charm/src/charm.py:87
#!/bin/bash
echo "========================================================================"
echo "Performing software update"
echo "========================================================================"
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)
......@@ -11,3 +15,8 @@ osm ns-update ${NS_ID} \
vnfdId: \"$VNFD_ID\"}]}" \
--timeout 300 \
--wait
echo "========================================================================"
echo "Done"
echo "========================================================================"
#!/bin/bash
echo "========================================================================"
echo "Here are some of the actions you can run"
echo "Try out your new action. Make sure you are logged into the VNF VM"
echo "========================================================================"
cat << 'EOF'
TBD
osm ns-action --vnf_name my_first_vnf --action_name announce --params "{message: hi}" my_first_ns
EOF 
......@@ -4,7 +4,7 @@ echo "========================================================================"
echo "Deleting network service"
echo "========================================================================"
osm ns-delete basic-vnf
osm ns-delete my_first_ns
echo "========================================================================"
echo "Done"
......
#!/bin/bash
git clone --recurse-submodules -j8 https://osm.etsi.org/gitlab/vnf-onboarding/osm-packages.git
......@@ -15,16 +15,6 @@ add-package:
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:
......@@ -35,6 +25,9 @@ announce:
required:
- message
cancel-reboot:
description: "Cancels any pending reboot commands."
reboot:
description: "Reboots the server."
......@@ -48,16 +41,6 @@ remove-package:
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."
......@@ -8,7 +8,6 @@ import os
import shutil
import time
from jinja2 import Template
from ops.charm import CharmBase
from ops.framework import StoredState
from ops.main import main
......@@ -18,8 +17,6 @@ from ops.model import (
# BlockedStatus,
)
from utils import (
service_stop,
service_restart,
install_apt,
remove_apt,
shell,
......@@ -42,18 +39,16 @@ class OSMCharm(CharmBase, InstallProgress):
self.last_status_update = time.time()
# Basic hooks
self.framework.observe(self.on.install, self._on_install)
self.framework.observe(self.on.start, self._on_start)
self.framework.observe(self.on.stop, self._on_stop)
self.framework.observe(self.on.config_changed, self._on_config_changed)
self.framework.observe(self.on.update_status, self._on_update_status)
# Actions hooks
self.framework.observe(self.on["add-package"].action, self._add_package)
self.framework.observe(self.on["add-snap"].action, self._add_snap)
self.framework.observe(self.on["announce"].action, self._announce)
self.framework.observe(self.on["cancel-reboot"].action, self._cancel_reboot)
self.framework.observe(self.on["reboot"].action, self._reboot)
self.framework.observe(self.on["remove-package"].action, self._remove_package)
self.framework.observe(self.on["remove-snap"].action, self._remove_snap)
self.framework.observe(self.on["update-system"].action, self._update_system)
# Relations hooks
......@@ -67,10 +62,6 @@ class OSMCharm(CharmBase, InstallProgress):
self.unit.status = MaintenanceStatus(message)
# Basic hooks
def _on_install(self, _):
self._stored.installed = True
self.unit.status = self._get_current_status()
def _on_start(self, _):
self._stored.started = True
......@@ -93,16 +84,12 @@ class OSMCharm(CharmBase, InstallProgress):
update=True, progress=self)
self.unit.status = self._get_current_status()
def _add_snap(self, event):
self.unit.status = MaintenanceStatus("Installing snaps")
for snap in event.params["package"].split(','):
shell("snap install " + snap)
def _announce(self, event):
self.unit.status = self._get_current_status()
def _announce(self, event):
self.unit.status = MaintenanceStatus("Announce")
message = event.params["message"]
shell(f"su - ubuntu -c 'wall ${message}'")
def _cancel_reboot(self, _):
self.unit.status = MaintenanceStatus("Cancelling any pending reboot")
shell("shutdown -c")
self.unit.status = self._get_current_status()
def _reboot(self, _):
......@@ -116,12 +103,6 @@ class OSMCharm(CharmBase, InstallProgress):
update=True, progress=self)
self.unit.status = self._get_current_status()
def _remove_snap(self, event):
self.unit.status = MaintenanceStatus("Removing snaps")
for snap in event.params["package"].split(','):
shell("snap remove " + snap)
self.unit.status = self._get_current_status()
def _update_system(self, _):
self.unit.status = MaintenanceStatus("Updating system")
upgrade_apt(update=True, progress=self)
......@@ -133,7 +114,7 @@ class OSMCharm(CharmBase, InstallProgress):
def _get_current_status(self):
status_type = ActiveStatus
status_msg = ""
if self._stored.installed:
if self._stored.started:
status_msg = "Ready"
return status_type(status_msg)
......
......@@ -5,19 +5,6 @@ import subprocess
from typing import Dict, List, NoReturn
def service_active(service_name: str):
result = subprocess.run(
["systemctl", "is-active", service_name],
stdout=subprocess.PIPE,
encoding="utf-8",
)
return result.stdout == "active\n"
def all_values_set(dictionary: Dict[str, str]) -> bool:
return not any(v is None for v in dictionary.values())
def install_apt(packages: List, update: bool = False, progress=None) -> NoReturn:
cache = apt.cache.Cache()
if update:
......@@ -53,34 +40,3 @@ def upgrade_apt(update: bool = False, progress=None) -> NoReturn:
def shell(command: str) -> NoReturn:
subprocess.run(command, shell=True).check_returncode()
def copy_files(origin: Dict[str, str], destination: Dict[str, str]) -> NoReturn:
for config, origin_path in origin.items():
destination_path = destination[config]
shutil.copy(origin_path, destination_path)
# Service functions
def _systemctl(action: str, service_name: str) -> NoReturn:
subprocess.run(["systemctl", action, service_name]).check_returncode()
def service_start(service_name: str) -> NoReturn:
_systemctl("start", service_name)
def service_restart(service_name: str) -> NoReturn:
_systemctl("restart", service_name)
def service_stop(service_name: str) -> NoReturn:
_systemctl("stop", service_name)
def service_enable(service_name: str) -> NoReturn:
_systemctl("enable", service_name)
def systemctl_daemon_reload():
subprocess.run(["systemctl", "daemon-reload"]).check_returncode()
......@@ -23,26 +23,19 @@ vnfd:
juju:
charm: my-first-charm
proxy: false
initial-config-primitive:
- name: config
execution-environment-ref: native
seq: 1
config-primitive:
- name: add-package
execution-environment-ref: native
parameter:
- data-type: STRING
name: package
- name: add-snap
execution-environment-ref: native
parameter:
- data-type: STRING
name: package
- name: announce
execution-environment-ref: native
parameter:
- data-type: STRING
name: message
- name: cancel-reboot
execution-environment-ref: native
- name: reboot
execution-environment-ref: native
- name: remove-package
......@@ -50,11 +43,6 @@ vnfd:
parameter:
- data-type: STRING
name: package
- name: remove-snap
execution-environment-ref: native
parameter:
- data-type: STRING
name: package
- name: update-system
execution-environment-ref: native
......
......@@ -29,7 +29,7 @@ fi
# ETSI VIM ADMIN_DOMAIN=default, Partner Cloud=admin_domain
ADMIN_DOMAIN=admin_domain
APT_PROXY=http://172.21.18.3:3142
FLAVOR=m1.xlarge
FLAVOR=hackfest
KEY_NAME=hackfest
NETWORK=osm-ext
SUBNET=172.21.19
......
......@@ -5,7 +5,6 @@ echo $0 started at $(date)
for PARTICIPANT in `seq ${START} ${MAX}` ; do
IP=`expr ${PARTICIPANT} + 0`
scp -o StrictHostKeyChecking=no -i hackfest_rsa ./hackfest_rsa ubuntu@${SUBNET}.${IP}:.ssh/id_rsa &
scp -o StrictHostKeyChecking=no -i hackfest_rsa ./hackfest_rsa ./hackfest_rsa.pub ubuntu@${SUBNET}.${IP}:.ssh/ &
scp -o StrictHostKeyChecking=no -i hackfest_rsa vm-microk8s-setup.sh ubuntu@${SUBNET}.${IP}: &
done
......
......@@ -7,6 +7,8 @@ for PARTICIPANT in `seq ${START} ${MAX}` ; do
IP=`expr ${PARTICIPANT} + 0`
scp -o StrictHostKeyChecking=no -i hackfest_rsa vm-initial-setup.sh ubuntu@${SUBNET}.${IP}: &
scp -o StrictHostKeyChecking=no -i hackfest_rsa ./hackfest_rsa ubuntu@${SUBNET}.${IP}:.ssh/id_rsa &
scp -o StrictHostKeyChecking=no -i hackfest_rsa ./hackfest_rsa.pub ubuntu@${SUBNET}.${IP}:.ssh/id_rsa.pub &
scp -o StrictHostKeyChecking=no -i hackfest_rsa ./hackfest_rsa ./hackfest_rsa.pub ubuntu@${SUBNET}.${IP}:.ssh/ &
scp -o StrictHostKeyChecking=no -i hackfest_rsa vm-microk8s-setup.sh ubuntu@${SUBNET}.${IP}: &
done
......
......@@ -13,7 +13,7 @@ sudo apt full-upgrade -y
sudo apt install -y gnome-session xrdp
sudo snap install code --classic
sudo snap install firefox openstackclients
sudo snap install firefox openstackclients yq jq
# Update so buttons show up
gsettings set org.gnome.desktop.wm.preferences button-layout :minimize,maximize,close
......@@ -38,4 +38,7 @@ cat << EOF | sudo tee /etc/rc.local
echo iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE
EOF
sudo chmod +x /etc/rc.local
git clone --recurse-submodules -j8 https://osm.etsi.org/gitlab/vnf-onboarding/osm-packages.git
echo $0 $@ complete at $(date)
\ No newline at end of file
......@@ -39,7 +39,6 @@ juju config -m osm mon grafana-password=hackfest
POD=`sudo microk8s.kubectl -n osm get po | grep -v operator | grep grafana- | awk '{print $1}'`
sudo microk8s.kubectl exec -n osm -it $POD -- grafana-cli admin reset-admin-password hackfest
juju config -m osm prometheus web_config_password=hackfest
# Expose our services
sudo sed -i "s/127.0.0.1 /127.0.0.1 nbi.osm ui.osm grafana.osm prometheus.osm /" /etc/hosts
......
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