-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvanilla-bash-netcat-w-client.yaml
92 lines (78 loc) · 3.09 KB
/
vanilla-bash-netcat-w-client.yaml
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
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# should be the same as what's in the docs, apart from this line
name: Simple Netcat with Client
location: localhost
services:
# the netcat server instance, running in listener mode (-l)
- type: brooklyn.entity.basic.VanillaSoftwareProcess
id: netcat-server
name: Simple Netcat Server
launch.command: |
echo hello | nc -l 4321 >> server-input &
echo $! > $PID_FILE
brooklyn.enrichers:
- type: brooklyn.policy.ha.ServiceFailureDetector
brooklyn.config:
# wait 15s after service fails before propagating failure
serviceFailedStabilizationDelay: 15s
brooklyn.policies:
- policyType: brooklyn.policy.ha.ServiceRestarter
brooklyn.config:
# repeated failures in a time window can cause the restarter to abort,
# propagating the failure; a time window of 0 will mean it always restarts!
failOnRecurringFailuresInThisDuration: 0
brooklyn.initializers:
# two sensors, recording the data sent to this netcat server:
- type: brooklyn.entity.software.ssh.SshCommandSensor
brooklyn.config:
name: output.last
command: tail -1 server-input
- type: brooklyn.entity.software.ssh.SshCommandSensor
brooklyn.config:
name: output.all
command: cat server-input
# a client to hit netcat
- type: brooklyn.entity.basic.VanillaSoftwareProcess
name: Simple Pinger
# set the hostname of the netcat instance as an env var for the scripts
env:
TARGET_HOSTNAME: $brooklyn:component("netcat-server").attributeWhenReady("host.name")
# start/check/stop are no-op
launch.command: ""
checkRunning.command: ""
stop.command: ""
brooklyn.initializers:
# but there is a sample effector which runs nc in client mode
- type: brooklyn.entity.software.ssh.SshCommandEffector
brooklyn.config:
name: sayHiNetcat
description: Echo a small hello string to the netcat entity
command: |
echo $message | nc $TARGET_HOSTNAME 4321
parameters:
message:
description: The string to pass to netcat
defaultValue: hi netcat
# and add an enricher at the root so all sensors from netcat-server are visible on the root
brooklyn.enrichers:
- enricherType: brooklyn.enricher.basic.Propagator
brooklyn.config:
enricher.producer: $brooklyn:component("netcat-server")
enricher.propagating.propagatingAll: true