3 This repository contains the [Juju] layer that represents a working example of a proxy charm.
5 # What is a proxy charm?
7 A proxy charm is a limited type of charm that does not interact with software running on the same host, such as controlling and configuring a remote device (a static VM image, a router/switch, etc.). It cannot take advantage of some of Juju's key features, such as [scaling], [relations], and [leadership].
9 Proxy charms are primarily a stop-gap, intended to prototype quickly, with the end goal being to develop it into a full-featured charm, which installs and executes code on the same machine as the charm is running.
14 # Clone this repository
15 git clone https://osm.etsi.org/gerrit/osm/juju-charms
18 # Setup environment variables
24 # Examine the built charm
25 cd ../../builds/pingpong
27 actions config.yaml icon.svg metadata.yaml tests
28 actions.yaml copyright layer.yaml reactive tox.ini
29 bin deps lib README.md wheelhouse
30 builds hooks Makefile requirements.txt
34 You can view a screencast of this: https://asciinema.org/a/96738
36 The `charm build` process combines this pingpong layer with each layer that it
37 has included in the `metadata.yaml` file, along with their various dependencies.
39 This built charm is what will then be used by the SO to communicate with the
44 The pingpong charm has several configuration properties that can be set via
53 The ssh-* keys are included by the `sshproxy` layer, and enable the charm to
54 connect to the VNF image.
56 The mode key must be one of two values: `ping` or `pong`. This informs the
57 charm as to which function it is serving.
60 For support, please send an email to the [OSM Tech] list.
63 [OSM Tech]: mailto:OSM_TECH@list.etsi.org
64 [Juju]: https://jujucharms.com/about
65 [configure]: https://jujucharms.com/docs/2.0/charms-config
66 [scaling]: https://jujucharms.com/docs/2.0/charms-scaling
67 [relations]: https://jujucharms.com/docs/2.0/charms-relations
68 [leadership]: https://jujucharms.com/docs/2.0/developer-leadership
69 [created your charm]: https://jujucharms.com/docs/2.0/developer-getting-started
80 After you've [created your charm], open `interfaces.yaml` and add
81 `layer:sshproxy` to the includes stanza, as shown below:
83 includes: ['layer:basic', 'layer:sshproxy']
88 This layer will set the following states:
90 - `sshproxy.configured` This state is set when SSH credentials have been supplied to the charm.
94 In `reactive/mycharm.py`, you can add logic to execute commands over SSH. This
95 example is run via a `start` action, and starts a service running on a remote
99 import charms.sshproxy
102 @when('sshproxy.configured')
103 @when('actions.start')
105 """ Execute's the command, via the start action` using the
106 configured SSH credentials
108 sshproxy.ssh("service myservice start")
113 This layer includes a built-in `run` action useful for debugging or running arbitrary commands:
116 $ juju run-action mycharm/0 run command=hostname
117 Action queued with id: 014b72f3-bc02-4ecb-8d38-72bce03bbb63
119 $ juju show-action-output 014b72f3-bc02-4ecb-8d38-72bce03bbb63
121 output: juju-66a5f3-11
124 completed: 2016-10-27 19:53:49 +0000 UTC
125 enqueued: 2016-10-27 19:53:44 +0000 UTC
126 started: 2016-10-27 19:53:48 +0000 UTC
129 ## Known Limitations and Issues
133 - Password and key-based authentications are supported, with the caveat that
134 both (password and private key) are stored plaintext within the Juju controller.
136 # Configuration and Usage
138 This layer adds the following configuration options:
144 Once [configure] those values at any time. Once they are set, the `sshproxy.configured` state flag will be toggled:
147 juju deploy mycharm ssh-hostname=10.10.10.10 ssh-username=ubuntu ssh-password=yourpassword
151 juju deploy mycharm ssh-hostname=10.10.10.10 ssh-username=ubuntu ssh-private-key="cat `~/.ssh/id_rsa`"
155 # Contact Information
156 Homepage: https://github.com/AdamIsrael/layer-sshproxy
158 [Juju]: https://jujucharms.com/about
159 [configure]: https://jujucharms.com/docs/2.0/charms-config
160 [scaling]: https://jujucharms.com/docs/2.0/charms-scaling
161 [relations]: https://jujucharms.com/docs/2.0/charms-relations
162 [leadership]: https://jujucharms.com/docs/2.0/developer-leadership
163 [created your charm]: https://jujucharms.com/docs/2.0/developer-getting-started