|
| 1 | +# Hello Plugin |
| 2 | + |
| 3 | +## Hello World! |
| 4 | +*Hello* is an example plugin to demonstrate the features of Warnet's plugin architecture. It uses each of the hooks available in the `warnet deploy` command (see the example below for details). |
| 5 | + |
| 6 | +## Usage |
| 7 | +In your python virtual environment with Warnet installed and setup, create a new Warnet user folder (follow the prompts): |
| 8 | + |
| 9 | +`$ warnet new user_folder` |
| 10 | + |
| 11 | +`$ cd user_folder` |
| 12 | + |
| 13 | +Deploy the *hello* network. |
| 14 | + |
| 15 | +`$ warnet deploy networks/hello` |
| 16 | + |
| 17 | +While that is launching, take a look inside the `networks/hello/network.yaml` file. You can also see the copy below which includes commentary on the structure of plugins in the `network.yaml` file. |
| 18 | + |
| 19 | +Also, take a look at the `plugins/hello/plugin.py` file to see how plugins work and to find out how to author your own plugin. |
| 20 | + |
| 21 | +Once `deploy` completes, view the pods of the *hello* network by invoking `kubectl get all -A`. |
| 22 | + |
| 23 | +To view the various "Hello World!" messages, run `kubectl logs pod/POD_NAME` |
| 24 | + |
| 25 | +### A `network.yaml` example |
| 26 | +When you initialize a new Warnet network, Warnet will create a new `network.yaml` file. You can modify these files to fit your needs. |
| 27 | + |
| 28 | +For example, the `network.yaml` file below includes the *hello* plugin, lightning nodes, and the *simln* plugin. |
| 29 | + |
| 30 | +<details> |
| 31 | +<summary>network.yaml</summary> |
| 32 | + |
| 33 | +````yaml |
| 34 | +nodes: |
| 35 | + - name: tank-0000 |
| 36 | + addnode: |
| 37 | + - tank-0001 |
| 38 | + ln: |
| 39 | + lnd: true |
| 40 | + |
| 41 | + - name: tank-0001 |
| 42 | + addnode: |
| 43 | + - tank-0002 |
| 44 | + ln: |
| 45 | + lnd: true |
| 46 | + |
| 47 | + - name: tank-0002 |
| 48 | + addnode: |
| 49 | + - tank-0000 |
| 50 | + ln: |
| 51 | + lnd: true |
| 52 | + |
| 53 | + - name: tank-0003 |
| 54 | + addnode: |
| 55 | + - tank-0000 |
| 56 | + ln: |
| 57 | + lnd: true |
| 58 | + lnd: |
| 59 | + config: | |
| 60 | + bitcoin.timelockdelta=33 |
| 61 | + channels: |
| 62 | + - id: |
| 63 | + block: 300 |
| 64 | + index: 1 |
| 65 | + target: tank-0004-ln |
| 66 | + capacity: 100000 |
| 67 | + push_amt: 50000 |
| 68 | + |
| 69 | + - name: tank-0004 |
| 70 | + addnode: |
| 71 | + - tank-0000 |
| 72 | + ln: |
| 73 | + lnd: true |
| 74 | + lnd: |
| 75 | + channels: |
| 76 | + - id: |
| 77 | + block: 300 |
| 78 | + index: 2 |
| 79 | + target: tank-0005-ln |
| 80 | + capacity: 50000 |
| 81 | + push_amt: 25000 |
| 82 | + |
| 83 | + - name: tank-0005 |
| 84 | + addnode: |
| 85 | + - tank-0000 |
| 86 | + ln: |
| 87 | + lnd: true |
| 88 | + |
| 89 | +plugins: # Each plugin section has a number of hooks available (preDeploy, postDeploy, etc) |
| 90 | + preDeploy: # For example, the preDeploy hook means it's plugin will run before all other deploy code |
| 91 | + hello: |
| 92 | + entrypoint: "../../plugins/hello" # This entrypoint path is relative to the network.yaml file |
| 93 | + podName: "hello-pre-deploy" |
| 94 | + helloTo: "preDeploy!" |
| 95 | + postDeploy: |
| 96 | + hello: |
| 97 | + entrypoint: "../../plugins/hello" |
| 98 | + podName: "hello-post-deploy" |
| 99 | + helloTo: "postDeploy!" |
| 100 | + simln: # You can have multiple plugins per hook |
| 101 | + entrypoint: "../../plugins/simln" |
| 102 | + activity: '[{"source": "tank-0003-ln", "destination": "tank-0005-ln", "interval_secs": 1, "amount_msat": 2000}]' |
| 103 | + preNode: # preNode plugins run before each node is deployed |
| 104 | + hello: |
| 105 | + entrypoint: "../../plugins/hello" |
| 106 | + helloTo: "preNode!" |
| 107 | + postNode: |
| 108 | + hello: |
| 109 | + entrypoint: "../../plugins/hello" |
| 110 | + helloTo: "postNode!" |
| 111 | + preNetwork: |
| 112 | + hello: |
| 113 | + entrypoint: "../../plugins/hello" |
| 114 | + helloTo: "preNetwork!" |
| 115 | + podName: "hello-pre-network" |
| 116 | + postNetwork: |
| 117 | + hello: |
| 118 | + entrypoint: "../../plugins/hello" |
| 119 | + helloTo: "postNetwork!" |
| 120 | + podName: "hello-post-network" |
| 121 | +```` |
| 122 | + |
| 123 | +</details> |
| 124 | + |
0 commit comments