-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add restart iperf * modify file name * 可視化周りのファイルを追加 * move flowdata * update docker compose network * update grafana docker compose * update grafana dashboard * update demoscript name --------- Co-authored-by: mddo <mddo> Co-authored-by: Shota Muto <[email protected]>
- Loading branch information
Showing
15 changed files
with
1,130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/bash | ||
|
||
### containerlab server login & sudo password Setting | ||
###Example | ||
###$ cat env/passwords | ||
###--- | ||
###"^SSH password:\\s*?$": "login password" | ||
###"^BECOME password.*:\\s*?$": "login password" | ||
|
||
# shellcheck disable=SC1091 | ||
source ./demo_vars | ||
|
||
# option check | ||
while getopts d option; do | ||
case $option in | ||
d) | ||
# data check, debug | ||
# -> without container lab; does not build emulated-env | ||
WITH_CLAB=false | ||
echo "# Check: with_clab = $WITH_CLAB" | ||
;; | ||
*) | ||
echo "Unknown option detected, $option" | ||
exit 1 | ||
esac | ||
done | ||
|
||
# configure iperf client/server | ||
if "${WITH_CLAB:-true}"; then | ||
ansible-runner run . -p /data/project/playbooks/restart-iperf.yaml --container-option="--net=${API_BRIDGE}" \ | ||
--container-volume-mount="$PWD:/data" --container-image="${ANSIBLERUNNER_IMAGE}" \ | ||
--process-isolation --process-isolation-executable docker \ | ||
--cmdline "-e ansible_runner_dir=${ANSIBLE_RUNNER_DIR} -e playground_dir=${PLAYGROUND_DIR} -e login_user=${LOCALSERVER_USER} -e network_name=${NETWORK_NAME} -k -K " | ||
fi |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
demo/copy_to_emulated_env/project/playbooks/restart-iperf.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--- | ||
- hosts: docker-host | ||
gather_facts: false | ||
become: yes | ||
vars: | ||
ansible_user: "{{ login_user}}" | ||
ansible_python_interpreter: /usr/bin/python3 | ||
|
||
tasks: | ||
- name: deploy containerlab | ||
shell: | ||
cmd: "containerlab deploy --topo clab-topo.yaml --reconfigure" | ||
args: | ||
chdir: "{{ ansible_runner_dir }}/clab" | ||
|
||
- name: enable bgp license | ||
shell: | ||
cmd: "sudo containerlab exec --topo clab-topo.yaml --label clab-node-kind=juniper_crpd --cmd 'cli request system license add /tmp/license.key'" | ||
args: | ||
chdir: "{{ ansible_runner_dir }}/clab" | ||
|
||
- name: "get convert table" | ||
uri: | ||
url: "http://localhost:15000/topologies/{{ network_name }}/emulated_asis/topology" | ||
method: "GET" | ||
body_format: json | ||
register: topology | ||
|
||
- name: search L3 network index | ||
set_fact: | ||
layer3index: "{{ l3_index }}" | ||
when: item['network-id'] == "layer3" | ||
loop: "{{ topology.json | json_query('*.network[]') }}" | ||
loop_control: | ||
index_var: l3_index | ||
|
||
- name: generate iperf endpoint static-route info | ||
set_fact: | ||
iperf_list: "{{ iperf_list | default([]) + [ item ] }}" | ||
vars: | ||
query: '*.network[{{ layer3index }}].node[*]' | ||
when: item["mddo-topology:l3-node-attributes"]["node-type"] == 'endpoint' | ||
loop: "{{ topology.json | json_query(query) | flatten }}" | ||
|
||
- name: import setup_iperf.yaml task | ||
ansible.builtin.import_tasks: setup_iperf.yaml | ||
when: iperf_list is defined | ||
|
||
|
||
- name: "get convert table" | ||
uri: | ||
url: "http://localhost:15000/topologies/{{ network_name }}/emulated_asis/topology" | ||
method: "GET" | ||
body_format: json | ||
register: topology | ||
|
||
|
||
- name: generate iperf command parameter | ||
shell: | ||
cmd: "python3 generate_iperf_command.py {{ playground_dir }}/configs/{{ network_name }}/original_asis/flowdata/flowdata.csv clab/static-route.yaml > project/playbooks/configs/iperf_params.json" | ||
args: | ||
chdir: "{{ ansible_runner_dir }}" | ||
|
||
|
||
- name: iperf server command | ||
debug: | ||
msg: '{{ common }} /bin/bash -c "nohup iperf3 -s -p {{ item.1.number }} > out_{{ item.1.number }}.log &"' | ||
vars: | ||
common: "sudo containerlab inspect --all --format json | jq '.containers[] | select( .name | contains (\"{{ item.0['node'] }}\")) | .name' | xargs -ICONTAINER docker exec CONTAINER " | ||
with_subelements: | ||
- "{{ lookup('file', './configs/iperf_params.json') }}" | ||
- port | ||
|
||
- name: iperf server command | ||
shell: | ||
cmd: '{{ common }} /bin/bash -c "nohup iperf3 -s -p {{ item.1.number }} > out_{{ item.1.number }}.log 2>&1 &"' | ||
args: | ||
chdir: "{{ ansible_runner_dir }}/clab" | ||
vars: | ||
common: "sudo containerlab inspect --all --format json | jq '.containers[] | select( .name | contains (\"{{ item.0['node'] }}\")) | .name' | xargs -ICONTAINER docker exec CONTAINER " | ||
with_subelements: | ||
- "{{ lookup('file', './configs/iperf_params.json') }}" | ||
- port | ||
|
||
|
||
- name: iperf client command | ||
debug: | ||
msg: '{{ common }} /bin/bash -c "nohup iperf3 -t 0 -c {{ item.1["dest_address"] }} -b {{ item.1.rate | int }}K -p {{ item.1.number }} > out_{{ item.0.node }}.log &"' | ||
vars: | ||
common: "sudo containerlab inspect --all --format json | jq '.containers[] | select( .name | contains (\"{{ item.1['source'] }}\")) | .name' | xargs -ICONTAINER docker exec CONTAINER " | ||
with_subelements: | ||
- "{{ lookup('file', './configs/iperf_params.json') }}" | ||
- port | ||
|
||
- name: iperf client command | ||
shell: | ||
cmd: '{{ common }} /bin/bash -c "nohup iperf3 -t 0 -c {{ item.1["dest_address"] }} -b {{ item.1.rate | int }}K -p {{ item.1.number }} > out_{{ item.0.node }}.log 2>&1 &"' | ||
args: | ||
chdir: "{{ ansible_runner_dir }}/clab" | ||
vars: | ||
common: "sudo containerlab inspect --all --format json | jq '.containers[] | select( .name | contains (\"{{ item.1['source'] }}\")) | .name' | xargs -ICONTAINER docker exec CONTAINER " | ||
with_subelements: | ||
- "{{ lookup('file', './configs/iperf_params.json') }}" | ||
- port |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
services: | ||
grafana: | ||
image: grafana/grafana-oss:10.0.3 | ||
container_name: grafana | ||
ports: | ||
- target: 3000 | ||
published: 23000 | ||
volumes: | ||
# Grafanaの設定ファイル | ||
- type: bind | ||
source: ./grafana/grafana.ini | ||
#source: ./servers/grafana/grafana.ini | ||
target: /etc/grafana/grafana.ini | ||
# データソースのprovisioning | ||
- type: bind | ||
source: ./grafana/datasources | ||
#source: ./servers/grafana/datasources | ||
target: /etc/grafana/provisioning/datasources | ||
# ダッシュボードのprovisioning | ||
- type: bind | ||
source: ./grafana/dashboards | ||
#source: ./servers/grafana/dashboards | ||
target: /etc/grafana/provisioning/dashboards | ||
# データの永続化 | ||
# - type: volume | ||
# source: grafana-data | ||
# target: /var/lib/grafana | ||
restart: always | ||
logging: | ||
options: | ||
max-size: 50m | ||
|
||
prometheus: | ||
image: prom/prometheus:v2.46.0 | ||
container_name: prometheus | ||
ports: | ||
- target: 9090 | ||
published: 9090 | ||
volumes: | ||
# ./prometheus配下に存在する設定ファイルのマウント | ||
- type: bind | ||
source: ./prometheus/ | ||
target: /etc/prometheus/ | ||
# 収集したデータの永続化用volume | ||
# - type: volume | ||
# source: prometheus-data | ||
# target: /prometheus | ||
command: | ||
# コンフィグファイルのパスの指定 | ||
- --config.file=/etc/prometheus/prometheus.yaml | ||
restart: always | ||
logging: | ||
options: | ||
max-size: 50m | ||
|
||
cadvisor: | ||
image: gcr.io/cadvisor/cadvisor:v0.38.6 | ||
container_name: cadvisor | ||
volumes: | ||
- /:/rootfs:ro | ||
- /var/run:/var/run:rw | ||
- /sys:/sys:ro | ||
- /var/lib/docker/:/var/lib/docker:ro | ||
depends_on: | ||
- redis | ||
redis: | ||
image: redis:7.0.12 | ||
container_name: redis | ||
|
||
volumes: | ||
prometheus-data: | ||
grafana-data: | ||
networks: | ||
default: | ||
ipam: | ||
config: | ||
- subnet: 192.168.255.0/24 |
14 changes: 14 additions & 0 deletions
14
demo/copy_to_emulated_env/visualize/grafana/dashboards/dashboard.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: 1 | ||
|
||
providers: | ||
- name: 'mddo' | ||
orgID: 1 | ||
folder: 'General' | ||
folderUid: '' | ||
type: file | ||
disableDeletion: false | ||
updateIntervalSeconds: 30 | ||
allowUiUpdates: true | ||
options: | ||
path: /etc/grafana/provisioning/dashboards | ||
foldersFromFilesStructure: true |
Oops, something went wrong.