Share
Embed
Transcript
37 slides
-
@ben_nuttall Ben Nuttall • Software Engineer at BBC News Labs
• Former Community Manager at Raspberry Pi • Creator of gpiozero & piwheels • twitter.com/ben_nuttall • github.com/bennuttall -
@ben_nuttall GPIO Zero v1.6 • Python library • Simple interface
to GPIO devices • New v1.6 release featuring rotary encoder thanks to the talk from Tony Smith last month! • gpiozero.readthedocs.io -
@ben_nuttall Mythic Beasts • Competent & trustworthy UK based hosting
provider – Raspberry Pi OS downloads – Raspberry Pi apt archive • UK based, data centres in UK, EU & US • Range of support options -
@ben_nuttall Mythic Beasts Pi Cloud • Raspberry Pi 3/4 hosting
service • Netbooted (no SD cards) with network storage • IPv6-only connectivity • IPv4 proxy • IPv4 SSH access • Billed monthly or on-demand • Reinstall at any time -
@ben_nuttall piwheels • Automated compilation of Python packages for Raspberry
Pi hardware • Makes "pip install" fast • Raspberry Pi OS pre-configured to use piwheels.org • First announced at Raspberry Pint in 2017 • www.piwheels.org • github.com/piwheels/piwheels -
@ben_nuttall piwheels setup • 1 x Pi 4 (previously Pi
3) with 2TB storage - controller software and web server • 5 x Pi 3 (building packages for Stretch) • 3 x Pi 4 (building packages for Buster) • 1 x VM (previously Pi 3) running postgres database -
@ben_nuttall piwheels stats • 39 million downloads total • 1
day: – 130k downloads – 140GB bandwidth – 850k searches -
@ben_nuttall Python >>> url = API_URL + '/' + name
>>> r = requests.get(url, headers=headers) >>> r.json() -
@ben_nuttall Getting started 1. Create a Mythic Beasts account 2.
Create an API key 3. Install hostedpi 4. Configure API keys as environment variables 5. Test your API connection -
@ben_nuttall CLI - commands • hostedpi add-key • hostedpi cancel
• hostedpi copy-keys • hostedpi count-keys • hostedpi create • hostedpi images • hostedpi keys • hostedpi list • hostedpi off • hostedpi on • hostedpi power • hostedpi reboot • hostedpi remove-keys • hostedpi show • hostedpi ssh-command • hostedpi ssh-config • hostedpi ssh-import-id • hostedpi status • hostedpi test -
@ben_nuttall CLI - account commands • hostedpi test • hostedpi
images • hostedpi create • hostedpi list -
@ben_nuttall Test the API $ hostedpi test Connected to the
Mythic Beasts API -
@ben_nuttall Provision a new Pi $ hostedpi create mypi Pi
mypi provisioned successfully Name: mypi Provision status: provisioning Model: Raspberry Pi 3 Disk size: 10GB IPv6 address: 2a00:1098:8:5b::1 IPv6 network: 2a00:1098:8:5b00::/56 SSH port: 5091 Location: MER URLs: http://www.mypi.hostedpi.com https://www.mypi.hostedpi.com SSH commands: ssh -p 5091 [email protected] # IPv4 ssh root@[2a00:1098:8:5b::1] # IPv6 -
@ben_nuttall Pi 3 images $ hostedpi images 3 Ubuntu 16.04
(Xenial) : ubuntu-16.04 Ubuntu 18.04 (Bionic) : ubuntu-18.04 Raspbian Jessie : raspbian-jessie Raspbian Stretch : stretch Raspbian Buster : raspbian-buster -
@ben_nuttall Pi 4 images $ hostedpi images 4 Ubuntu 20.04
64 bit : ubuntu20.04.arm64 Raspbian Buster : raspbian-buster4 Raspberry Pi OS 64 bit : pios64b Ubuntu 18.04 (Bionic) : ubuntu-18.04-rpi4 -
@ben_nuttall Provision a new Pi - with options $ hostedpi
create mypi4 --model 4 --disk 60 --image ubuntu20.04.arm64 --ssh-key- path ~/.ssh/id_rsa.pub Pi mypi4 provisioned successfully Name: mypi4 Provision status: provisioning Model: Raspberry Pi 4 Disk size: 60GB IPv6 address: 2a00:1098:8:5b::1 IPv6 network: 2a00:1098:8:5b00::/56 SSH port: 5091 Location: MER URLs: http://www.mypi4.hostedpi.com https://www.mypi4.hostedpi.com SSH commands: ssh -p 5091 [email protected] # IPv4 ssh root@[2a00:1098:8:5b::1] # IPv6 -
@ben_nuttall CLI - Pi management commands • hostedpi cancel •
hostedpi off • hostedpi on • hostedpi power • hostedpi reboot • hostedpi show • hostedpi status -
@ben_nuttall CLI - Pi management commands $ hostedpi on mypi
mypi powered on $ hostedpi off mypi2 mypi2 powered off $ hostedpi reboot mypi3 mypi3 rebooted $ hostedpi power mypi4 mypi4: powered on $ hostedpi status mypi mypi: live $ hostedpi cancel mypi5 mypi5 cancelled -
@ben_nuttall CLI - Pi management commands $ hostedpi reboot mypi
mypi2 mypi3 mypi rebooted mypi2 rebooted mypi3 rebooted $ hostedpi off mypi{4,5,6} mypi4 powered off mypi5 powered off mypi6 powered off -
@ben_nuttall CLI - show Pi information $ hostedpi show mypi
Name: mypi Provision status: live Model: Raspberry Pi 3B Disk size: 10GB Power: off IPv6 address: 2a00:1098:8:5b::1 IPv6 network: 2a00:1098:8:5b00::/56 Initialised keys: yes SSH keys: 0 IPv4 SSH port: 5091 Location: MER URLs: http://www.mypi.hostedpi.com https://www.mypi.hostedpi.com SSH commands: ssh -p 5091 [email protected] # IPv4 ssh root@[2a00:1098:8:5b::1] # IPv6 -
@ben_nuttall CLI - Pi SSH key management commands • hostedpi
add-key • hostedpi copy-keys • hostedpi count-keys • hostedpi keys • hostedpi remove-keys • hostedpi ssh-import-id -
@ben_nuttall CLI - Pi SSH key management commands $ hostedpi
add-key ~/.ssh/id_rsa.pub mypi 1 key added to mypi $ hostedpi count-keys mypi mypi: 4 keys $ hostedpi copy-keys mypi mypi2 1 key added to mypi2 $ hostedpi ssh-import-id mypi --gh bennuttall 4 keys retrieved from GitHub 4 keys added to mypi $ hostedpi keys mypi ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSkT3A1j89RT... $ hostedpi remove-keys mypi 1 key removed from mypi -
@ben_nuttall SSH $ hostedpi ssh-command mypi ssh -p 5091 [email protected]
$ ssh -p 5091 [email protected] root@raspberrypi:~# -
@ben_nuttall Python recipe - gpiozero button from hostedpi import PiCloud
from gpiozero import Button, LED cloud = PiCloud() btn = Button(2) led = LED(3) def make_pi(): name = "helloworld" cloud.create_pi(name) led.on() btn.when_pressed = make_pi -
@ben_nuttall Python recipe - access a web page from hostedpi
import PiCloud import requests cloud = PiCloud() pi = cloud.pis['somepi'] r = requests.get(pi.url) with open('pi.html', 'w') as f: f.write(r.text) -
@ben_nuttall Project status / what next? • Continual feedback loop
with Mythic Beasts • This is a beta - API/CLI subject to change until v1.0 release • Test suite in progress • Integrate into piwheels - auto scale builders up/down and auto re-image -
@ben_nuttall Try it out! Give feedback! • Docs: – hostedpi.readthedocs.io
• GitHub: – github.com/piwheels/hostedpi • PyPI: – pypi.org/project/hostedpi