Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Overview
This repository contains the [Juju] layer that represents a working example of a proxy charm.
# What is a proxy charm?
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].
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.
# Usage
```bash
# Clone this repository
git clone https://osm.etsi.org/gerrit/osm/juju-charms
cd juju-charms
# Setup environment variables
source juju-env.sh
cd layers/pingpong
charm build
# Examine the built charm
cd ../../builds/pingpong
ls
actions config.yaml icon.svg metadata.yaml tests
actions.yaml copyright layer.yaml reactive tox.ini
bin deps lib README.md wheelhouse
builds hooks Makefile requirements.txt
```
You can view a screencast of this: https://asciinema.org/a/96738
The `charm build` process combines this pingpong layer with each layer that it
has included in the `metadata.yaml` file, along with their various dependencies.
This built charm is what will then be used by the SO to communicate with the
VNF.
# Configuration
The pingpong charm has several configuration properties that can be set via
the SO:
- ssh-hostname
- ssh-username
- ssh-password
- ssh-private-key
- mode
The ssh-* keys are included by the `sshproxy` layer, and enable the charm to
connect to the VNF image.
The mode key must be one of two values: `ping` or `pong`. This informs the
charm as to which function it is serving.
# Contact Information
For support, please send an email to the [OSM Tech] list.
[OSM Tech]: mailto:OSM_TECH@list.etsi.org
[Juju]: https://jujucharms.com/about
[configure]: https://jujucharms.com/docs/2.0/charms-config
[scaling]: https://jujucharms.com/docs/2.0/charms-scaling
[relations]: https://jujucharms.com/docs/2.0/charms-relations
[leadership]: https://jujucharms.com/docs/2.0/developer-leadership
[created your charm]: https://jujucharms.com/docs/2.0/developer-getting-started
-----
# Integration
After you've [created your charm], open `interfaces.yaml` and add
`layer:sshproxy` to the includes stanza, as shown below:
```
includes: ['layer:basic', 'layer:sshproxy']
```
## Reactive states
This layer will set the following states:
- `sshproxy.configured` This state is set when SSH credentials have been supplied to the charm.
## Example
In `reactive/mycharm.py`, you can add logic to execute commands over SSH. This
example is run via a `start` action, and starts a service running on a remote
host.
```
...
import charms.sshproxy
@when('sshproxy.configured')
@when('actions.start')
def start():
""" Execute's the command, via the start action` using the
configured SSH credentials
"""
sshproxy.ssh("service myservice start")
```
## Actions
This layer includes a built-in `run` action useful for debugging or running arbitrary commands:
```
$ juju run-action mycharm/0 run command=hostname
Action queued with id: 014b72f3-bc02-4ecb-8d38-72bce03bbb63
$ juju show-action-output 014b72f3-bc02-4ecb-8d38-72bce03bbb63
results:
output: juju-66a5f3-11
status: completed
timing:
completed: 2016-10-27 19:53:49 +0000 UTC
enqueued: 2016-10-27 19:53:44 +0000 UTC
started: 2016-10-27 19:53:48 +0000 UTC
```
## Known Limitations and Issues
### Security issues
- Password and key-based authentications are supported, with the caveat that
both (password and private key) are stored plaintext within the Juju controller.
# Configuration and Usage
This layer adds the following configuration options:
- ssh-hostname
- ssh-username
- ssh-password
- ssh-private-key
Once [configure] those values at any time. Once they are set, the `sshproxy.configured` state flag will be toggled:
```
juju deploy mycharm ssh-hostname=10.10.10.10 ssh-username=ubuntu ssh-password=yourpassword
```
or
```
juju deploy mycharm ssh-hostname=10.10.10.10 ssh-username=ubuntu ssh-private-key="cat `~/.ssh/id_rsa`"
```
# Contact Information
Homepage: https://github.com/AdamIsrael/layer-sshproxy
[Juju]: https://jujucharms.com/about
[configure]: https://jujucharms.com/docs/2.0/charms-config
[scaling]: https://jujucharms.com/docs/2.0/charms-scaling
[relations]: https://jujucharms.com/docs/2.0/charms-relations
[leadership]: https://jujucharms.com/docs/2.0/developer-leadership
[created your charm]: https://jujucharms.com/docs/2.0/developer-getting-started