Ping/pong charm

This is the Juju charm layer to build the pingpong charm

Change-Id: I732746a53ce6db0faa3e7e528cb60a60e0296afe
Signed-off-by: Adam Israel <adam.israel@canonical.com>
diff --git a/layers/pingpong/README.md b/layers/pingpong/README.md
new file mode 100644
index 0000000..3bec243
--- /dev/null
+++ b/layers/pingpong/README.md
@@ -0,0 +1,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
diff --git a/layers/pingpong/actions.yaml b/layers/pingpong/actions.yaml
new file mode 100644
index 0000000..f283ed0
--- /dev/null
+++ b/layers/pingpong/actions.yaml
@@ -0,0 +1,32 @@
+set-server:
+    description: "Set the target IP address and port"
+    params:
+        server-ip:
+            description: "IP on which the target service is listening."
+            type: string
+            default: ""
+        server-port:
+            description: "Port on which the target service is listening."
+            type: integer
+            default: 5555
+    required:
+        - server-ip
+set-rate:
+    description: "Set the rate of packet generation."
+    params:
+        rate:
+            description: "Packet rate."
+            type: integer
+            default: 5
+get-stats:
+    description: "Get the stats."
+get-state:
+    description: "Get the admin state of the target service."
+get-rate:
+    description: "Get the rate set on the target service."
+get-server:
+    description: "Get the target server and IP set"
+start-ping:
+    description: "Start the traffic generator."
+stop-ping:
+    description: "Stop the traffic generator."
diff --git a/layers/pingpong/actions/get-rate b/layers/pingpong/actions/get-rate
new file mode 100755
index 0000000..959b3e9
--- /dev/null
+++ b/layers/pingpong/actions/get-rate
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.get-rate')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/actions/get-server b/layers/pingpong/actions/get-server
new file mode 100755
index 0000000..52e0089
--- /dev/null
+++ b/layers/pingpong/actions/get-server
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.get-server')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/actions/get-state b/layers/pingpong/actions/get-state
new file mode 100755
index 0000000..446e8d7
--- /dev/null
+++ b/layers/pingpong/actions/get-state
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.get-state')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/actions/get-stats b/layers/pingpong/actions/get-stats
new file mode 100755
index 0000000..086afc2
--- /dev/null
+++ b/layers/pingpong/actions/get-stats
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.get-stats')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/actions/set-rate b/layers/pingpong/actions/set-rate
new file mode 100755
index 0000000..8fb723e
--- /dev/null
+++ b/layers/pingpong/actions/set-rate
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.set-rate')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/actions/set-server b/layers/pingpong/actions/set-server
new file mode 100755
index 0000000..d1e908f
--- /dev/null
+++ b/layers/pingpong/actions/set-server
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.set-server')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/actions/start-ping b/layers/pingpong/actions/start-ping
new file mode 100755
index 0000000..dee1ce1
--- /dev/null
+++ b/layers/pingpong/actions/start-ping
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.start-ping')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/actions/stop-ping b/layers/pingpong/actions/stop-ping
new file mode 100755
index 0000000..0a10695
--- /dev/null
+++ b/layers/pingpong/actions/stop-ping
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import sys
+sys.path.append('lib')
+
+from charms.reactive import main
+from charms.reactive import set_state
+from charmhelpers.core.hookenv import action_fail
+
+"""
+`set_state` only works here because it's flushed to disk inside the `main()`
+loop. remove_state will need to be called inside the action method.
+"""
+set_state('actions.stop-ping')
+
+try:
+    main()
+except Exception as e:
+    action_fail(repr(e))
diff --git a/layers/pingpong/config.yaml b/layers/pingpong/config.yaml
new file mode 100644
index 0000000..437524e
--- /dev/null
+++ b/layers/pingpong/config.yaml
@@ -0,0 +1,5 @@
+options:
+  mode:
+    type: string
+    default:
+    description: "The service type: [ping, pong]"
diff --git a/layers/pingpong/icon.svg b/layers/pingpong/icon.svg
new file mode 100644
index 0000000..e092eef
--- /dev/null
+++ b/layers/pingpong/icon.svg
@@ -0,0 +1,279 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>

+<!-- Created with Inkscape (http://www.inkscape.org/) -->

+

+<svg

+   xmlns:dc="http://purl.org/dc/elements/1.1/"

+   xmlns:cc="http://creativecommons.org/ns#"

+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

+   xmlns:svg="http://www.w3.org/2000/svg"

+   xmlns="http://www.w3.org/2000/svg"

+   xmlns:xlink="http://www.w3.org/1999/xlink"

+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"

+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"

+   width="96"

+   height="96"

+   id="svg6517"

+   version="1.1"

+   inkscape:version="0.48+devel r12274"

+   sodipodi:docname="Juju_charm_icon_template.svg">

+  <defs

+     id="defs6519">

+    <linearGradient

+       inkscape:collect="always"

+       xlink:href="#Background"

+       id="linearGradient6461"

+       gradientUnits="userSpaceOnUse"

+       x1="0"

+       y1="970.29498"

+       x2="144"

+       y2="970.29498"

+       gradientTransform="matrix(0,-0.66666669,0.6660448,0,-866.25992,731.29077)" />

+    <linearGradient

+       id="Background">

+      <stop

+         id="stop4178"

+         offset="0"

+         style="stop-color:#b8b8b8;stop-opacity:1" />

+      <stop

+         id="stop4180"

+         offset="1"

+         style="stop-color:#c9c9c9;stop-opacity:1" />

+    </linearGradient>

+    <filter

+       style="color-interpolation-filters:sRGB;"

+       inkscape:label="Inner Shadow"

+       id="filter1121">

+      <feFlood

+         flood-opacity="0.59999999999999998"

+         flood-color="rgb(0,0,0)"

+         result="flood"

+         id="feFlood1123" />

+      <feComposite

+         in="flood"

+         in2="SourceGraphic"

+         operator="out"

+         result="composite1"

+         id="feComposite1125" />

+      <feGaussianBlur

+         in="composite1"

+         stdDeviation="1"

+         result="blur"

+         id="feGaussianBlur1127" />

+      <feOffset

+         dx="0"

+         dy="2"

+         result="offset"

+         id="feOffset1129" />

+      <feComposite

+         in="offset"

+         in2="SourceGraphic"

+         operator="atop"

+         result="composite2"

+         id="feComposite1131" />

+    </filter>

+    <filter

+       style="color-interpolation-filters:sRGB;"

+       inkscape:label="Drop Shadow"

+       id="filter950">

+      <feFlood

+         flood-opacity="0.25"

+         flood-color="rgb(0,0,0)"

+         result="flood"

+         id="feFlood952" />

+      <feComposite

+         in="flood"

+         in2="SourceGraphic"

+         operator="in"

+         result="composite1"

+         id="feComposite954" />

+      <feGaussianBlur

+         in="composite1"

+         stdDeviation="1"

+         result="blur"

+         id="feGaussianBlur956" />

+      <feOffset

+         dx="0"

+         dy="1"

+         result="offset"

+         id="feOffset958" />

+      <feComposite

+         in="SourceGraphic"

+         in2="offset"

+         operator="over"

+         result="composite2"

+         id="feComposite960" />

+    </filter>

+    <clipPath

+       clipPathUnits="userSpaceOnUse"

+       id="clipPath873">

+      <g

+         transform="matrix(0,-0.66666667,0.66604479,0,-258.25992,677.00001)"

+         id="g875"

+         inkscape:label="Layer 1"

+         style="fill:#ff00ff;fill-opacity:1;stroke:none;display:inline">

+        <path

+           style="fill:#ff00ff;fill-opacity:1;stroke:none;display:inline"

+           d="m 46.702703,898.22775 50.594594,0 C 138.16216,898.22775 144,904.06497 144,944.92583 l 0,50.73846 c 0,40.86071 -5.83784,46.69791 -46.702703,46.69791 l -50.594594,0 C 5.8378378,1042.3622 0,1036.525 0,995.66429 L 0,944.92583 C 0,904.06497 5.8378378,898.22775 46.702703,898.22775 Z"

+           id="path877"

+           inkscape:connector-curvature="0"

+           sodipodi:nodetypes="sssssssss" />

+      </g>

+    </clipPath>

+    <filter

+       inkscape:collect="always"

+       id="filter891"

+       inkscape:label="Badge Shadow">

+      <feGaussianBlur

+         inkscape:collect="always"

+         stdDeviation="0.71999962"

+         id="feGaussianBlur893" />

+    </filter>

+  </defs>

+  <sodipodi:namedview

+     id="base"

+     pagecolor="#ffffff"

+     bordercolor="#666666"

+     borderopacity="1.0"

+     inkscape:pageopacity="0.0"

+     inkscape:pageshadow="2"

+     inkscape:zoom="4.0745362"

+     inkscape:cx="18.514671"

+     inkscape:cy="49.018169"

+     inkscape:document-units="px"

+     inkscape:current-layer="layer1"

+     showgrid="true"

+     fit-margin-top="0"

+     fit-margin-left="0"

+     fit-margin-right="0"

+     fit-margin-bottom="0"

+     inkscape:window-width="1920"

+     inkscape:window-height="1029"

+     inkscape:window-x="0"

+     inkscape:window-y="24"

+     inkscape:window-maximized="1"

+     showborder="true"

+     showguides="true"

+     inkscape:guide-bbox="true"

+     inkscape:showpageshadow="false">

+    <inkscape:grid

+       type="xygrid"

+       id="grid821" />

+    <sodipodi:guide

+       orientation="1,0"

+       position="16,48"

+       id="guide823" />

+    <sodipodi:guide

+       orientation="0,1"

+       position="64,80"

+       id="guide825" />

+    <sodipodi:guide

+       orientation="1,0"

+       position="80,40"

+       id="guide827" />

+    <sodipodi:guide

+       orientation="0,1"

+       position="64,16"

+       id="guide829" />

+  </sodipodi:namedview>

+  <metadata

+     id="metadata6522">

+    <rdf:RDF>

+      <cc:Work

+         rdf:about="">

+        <dc:format>image/svg+xml</dc:format>

+        <dc:type

+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />

+        <dc:title></dc:title>

+      </cc:Work>

+    </rdf:RDF>

+  </metadata>

+  <g

+     inkscape:label="BACKGROUND"

+     inkscape:groupmode="layer"

+     id="layer1"

+     transform="translate(268,-635.29076)"

+     style="display:inline">

+    <path

+       style="fill:url(#linearGradient6461);fill-opacity:1;stroke:none;display:inline;filter:url(#filter1121)"

+       d="m -268,700.15563 0,-33.72973 c 0,-27.24324 3.88785,-31.13513 31.10302,-31.13513 l 33.79408,0 c 27.21507,0 31.1029,3.89189 31.1029,31.13513 l 0,33.72973 c 0,27.24325 -3.88783,31.13514 -31.1029,31.13514 l -33.79408,0 C -264.11215,731.29077 -268,727.39888 -268,700.15563 Z"

+       id="path6455"

+       inkscape:connector-curvature="0"

+       sodipodi:nodetypes="sssssssss" />

+  </g>

+  <g

+     inkscape:groupmode="layer"

+     id="layer3"

+     inkscape:label="PLACE YOUR PICTOGRAM HERE"

+     style="display:inline" />

+  <g

+     inkscape:groupmode="layer"

+     id="layer2"

+     inkscape:label="BADGE"

+     style="display:none"

+     sodipodi:insensitive="true">

+    <g

+       style="display:inline"

+       transform="translate(-340.00001,-581)"

+       id="g4394"

+       clip-path="none">

+      <g

+         id="g855">

+        <g

+           inkscape:groupmode="maskhelper"

+           id="g870"

+           clip-path="url(#clipPath873)"

+           style="opacity:0.6;filter:url(#filter891)">

+          <path

+             transform="matrix(1.4999992,0,0,1.4999992,-29.999795,-237.54282)"

+             d="m 264,552.36218 a 12,12 0 1 1 -24,0 A 12,12 0 1 1 264,552.36218 Z"

+             sodipodi:ry="12"

+             sodipodi:rx="12"

+             sodipodi:cy="552.36218"

+             sodipodi:cx="252"

+             id="path844"

+             style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"

+             sodipodi:type="arc" />

+        </g>

+        <g

+           id="g862">

+          <path

+             sodipodi:type="arc"

+             style="color:#000000;fill:#f5f5f5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"

+             id="path4398"

+             sodipodi:cx="252"

+             sodipodi:cy="552.36218"

+             sodipodi:rx="12"

+             sodipodi:ry="12"

+             d="m 264,552.36218 a 12,12 0 1 1 -24,0 A 12,12 0 1 1 264,552.36218 Z"

+             transform="matrix(1.4999992,0,0,1.4999992,-29.999795,-238.54282)" />

+          <path

+             transform="matrix(1.25,0,0,1.25,33,-100.45273)"

+             d="m 264,552.36218 a 12,12 0 1 1 -24,0 A 12,12 0 1 1 264,552.36218 Z"

+             sodipodi:ry="12"

+             sodipodi:rx="12"

+             sodipodi:cy="552.36218"

+             sodipodi:cx="252"

+             id="path4400"

+             style="color:#000000;fill:#dd4814;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"

+             sodipodi:type="arc" />

+          <path

+             sodipodi:type="star"

+             style="color:#000000;fill:#f5f5f5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"

+             id="path4459"

+             sodipodi:sides="5"

+             sodipodi:cx="666.19574"

+             sodipodi:cy="589.50385"

+             sodipodi:r1="7.2431178"

+             sodipodi:r2="4.3458705"

+             sodipodi:arg1="1.0471976"

+             sodipodi:arg2="1.6755161"

+             inkscape:flatsided="false"

+             inkscape:rounded="0.1"

+             inkscape:randomized="0"

+             d="m 669.8173,595.77657 c -0.39132,0.22593 -3.62645,-1.90343 -4.07583,-1.95066 -0.44938,-0.0472 -4.05653,1.36297 -4.39232,1.06062 -0.3358,-0.30235 0.68963,-4.03715 0.59569,-4.47913 -0.0939,-0.44198 -2.5498,-3.43681 -2.36602,-3.8496 0.18379,-0.41279 4.05267,-0.59166 4.44398,-0.81759 0.39132,-0.22593 2.48067,-3.48704 2.93005,-3.4398 0.44938,0.0472 1.81505,3.67147 2.15084,3.97382 0.3358,0.30236 4.08294,1.2817 4.17689,1.72369 0.0939,0.44198 -2.9309,2.86076 -3.11469,3.27355 C 669.9821,591.68426 670.20862,595.55064 669.8173,595.77657 Z"

+             transform="matrix(1.511423,-0.16366377,0.16366377,1.511423,-755.37346,-191.93651)" />

+        </g>

+      </g>

+    </g>

+  </g>

+</svg>

diff --git a/layers/pingpong/layer.yaml b/layers/pingpong/layer.yaml
new file mode 100644
index 0000000..aa4dc07
--- /dev/null
+++ b/layers/pingpong/layer.yaml
@@ -0,0 +1,3 @@
+includes:
+    - layer:basic
+    - layer:vnfproxy
diff --git a/layers/pingpong/metadata.yaml b/layers/pingpong/metadata.yaml
new file mode 100644
index 0000000..1840743
--- /dev/null
+++ b/layers/pingpong/metadata.yaml
@@ -0,0 +1,13 @@
+name: pingpong
+summary: <Fill in summary here>
+maintainer: Adam Israel <Adam.Israel@ronin>
+description: |
+  <Multi-line description here>
+tags:
+  # Replace "misc" with one or more whitelisted tags from this list:
+  # https://jujucharms.com/docs/stable/authors-charm-metadata
+  - misc
+subordinate: false
+series:
+    - trusty
+    - xenial
diff --git a/layers/pingpong/reactive/pingpong.py b/layers/pingpong/reactive/pingpong.py
new file mode 100644
index 0000000..e88bd43
--- /dev/null
+++ b/layers/pingpong/reactive/pingpong.py
@@ -0,0 +1,247 @@
+from charmhelpers.core.hookenv import (
+    action_get,
+    action_fail,
+    action_set,
+    config,
+    status_set,
+)
+
+from charms.reactive import (
+    remove_state as remove_flag,
+    set_state as set_flag,
+    when,
+)
+import charms.sshproxy
+import json
+
+
+cfg = config()
+
+
+@when('config.changed')
+def config_changed():
+    if all(k in cfg for k in ['mode']):
+        if cfg['mode'] in ['ping', 'pong']:
+            set_flag('pingpong.configured')
+            status_set('active', 'ready!')
+            return
+    status_set('blocked', 'Waiting for configuration')
+
+
+def is_ping():
+    if cfg['mode'] == 'ping':
+        return True
+    return False
+
+
+def is_pong():
+    return not is_ping()
+
+
+def get_port():
+    port = 18888
+    if is_pong():
+        port = 18889
+    return port
+
+
+@when('pingpong.configured')
+@when('actions.start')
+def start():
+    err = ''
+    try:
+        cmd = "service {} start".format(cfg['mode'])
+        result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.start')
+
+
+@when('pingpong.configured')
+@when('actions.stop')
+def stop():
+    err = ''
+    try:
+        # Enter the command to stop your service(s)
+        cmd = "service {} stop".format(cfg['mode'])
+        result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.stop')
+
+
+@when('pingpong.configured')
+@when('actions.restart')
+def restart():
+    err = ''
+    try:
+        # Enter the command to restart your service(s)
+        cmd = "service {} restart".format(cfg['mode'])
+        result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.restart')
+
+
+@when('pingpong.configured')
+@when('actions.set-server')
+def set_server():
+    err = ''
+    try:
+        # Get the target service info
+        target_ip = action_get('server-ip')
+        target_port = action_get('server-port')
+
+        data = json.dumps({'ip': target_ip, 'port': target_port})
+
+        cmd = format_curl(
+            'POST',
+            '/server',
+            data,
+        )
+
+        result, err = charms.sshproxy._run(cmd)
+    except Exception as err:
+        print("error: {0}".format(err))
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.set-server')
+
+
+@when('pingpong.configured')
+@when('actions.set-rate')
+def set_rate():
+    err = ''
+    try:
+        if is_ping():
+            rate = action_get('rate')
+            cmd = format_curl('POST', '/rate', '{"rate": {}}'.format(rate))
+
+            result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.set-rate')
+
+
+@when('pingpong.configured')
+@when('actions.get-rate')
+def get_rate():
+    err = ''
+    try:
+        if is_ping():
+            cmd = format_curl('GET', '/rate')
+
+            result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.get-rate')
+
+
+@when('pingpong.configured')
+@when('actions.get-state')
+def get_state():
+    err = ''
+    try:
+        cmd = format_curl('GET', '/state')
+
+        result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.get-state')
+
+
+@when('pingpong.configured')
+@when('actions.get-stats')
+def get_stats():
+    err = ''
+    try:
+        cmd = format_curl('GET', '/stats')
+
+        result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.get-stats')
+
+
+@when('pingpong.configured')
+@when('actions.start-ping')
+def start_ping():
+    err = ''
+    try:
+        cmd = format_curl('POST', '/adminstatus/state', '{"enable":true}')
+
+        result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.start-ping')
+
+
+@when('pingpong.configured')
+@when('actions.stop-ping')
+def stop_ping():
+    err = ''
+    try:
+        cmd = format_curl('POST', '/adminstatus/state', '{"enable":false}')
+
+        result, err = charms.sshproxy._run(cmd)
+    except:
+        action_fail('command failed:' + err)
+    else:
+        action_set({'outout': result})
+    finally:
+        remove_flag('actions.stop-ping')
+
+
+def format_curl(method, path, data=None):
+    """ A utility function to build the curl command line. """
+
+    # method must be GET or POST
+    if method not in ['GET', 'POST']:
+        # Throw exception
+        return None
+
+    # Get our service info
+    host = cfg['ssh-hostname']
+    port = get_port()
+    mode = cfg['mode']
+
+    cmd = ['curl',
+           # '-D', '/dev/stdout',
+           '-H', '"Accept: application/vnd.yang.data+xml"',
+           '-H', '"Content-Type: application/vnd.yang.data+json"',
+           '-X', method]
+
+    if method == "POST" and data:
+        cmd.append('-d')
+        cmd.append("'{}'".format(data))
+
+    cmd.append(
+        'http://{}:{}/api/v1/{}{}'.format(host, port, mode, path)
+    )
+    return cmd
diff --git a/layers/pingpong/tests/00-setup b/layers/pingpong/tests/00-setup
new file mode 100755
index 0000000..f0616a5
--- /dev/null
+++ b/layers/pingpong/tests/00-setup
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+sudo add-apt-repository ppa:juju/stable -y
+sudo apt-get update
+sudo apt-get install amulet python-requests -y
diff --git a/layers/pingpong/tests/10-deploy b/layers/pingpong/tests/10-deploy
new file mode 100755
index 0000000..d1d4719
--- /dev/null
+++ b/layers/pingpong/tests/10-deploy
@@ -0,0 +1,35 @@
+#!/usr/bin/python3
+
+import amulet
+import requests
+import unittest
+
+
+class TestCharm(unittest.TestCase):
+    def setUp(self):
+        self.d = amulet.Deployment()
+
+        self.d.add('pingpong')
+        self.d.expose('pingpong')
+
+        self.d.setup(timeout=900)
+        self.d.sentry.wait()
+
+        self.unit = self.d.sentry['pingpong'][0]
+
+    def test_service(self):
+        # test we can access over http
+        page = requests.get('http://{}'.format(self.unit.info['public-address']))
+        self.assertEqual(page.status_code, 200)
+        # Now you can use self.d.sentry[SERVICE][UNIT] to address each of the units and perform
+        # more in-depth steps. Each self.d.sentry[SERVICE][UNIT] has the following methods:
+        # - .info - An array of the information of that unit from Juju
+        # - .file(PATH) - Get the details of a file on that unit
+        # - .file_contents(PATH) - Get plain text output of PATH file from that unit
+        # - .directory(PATH) - Get details of directory
+        # - .directory_contents(PATH) - List files and folders in PATH on that unit
+        # - .relation(relation, service:rel) - Get relation data from return service
+
+        
+if __name__ == '__main__':
+    unittest.main()