Skip to content

Commit

Permalink
feat: Added description of http interface (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsuki3939 authored Sep 28, 2023
1 parent f3b1248 commit 7e99727
Show file tree
Hide file tree
Showing 2 changed files with 293 additions and 1 deletion.
146 changes: 146 additions & 0 deletions content/en/docs/Getting started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,25 @@ You can create the `oc-circuit` Service by the following steps:
]
}
```
When using the http interface, please create the following JSON instead of the above JSON. (Specify the path of the service in "path" and the value of the service to be submitted in "value.)
```json
{
"path": "/services/oc_circuit/100",
"value": {
"vlanID": 100,
"endpoints": [
{
"device": "oc01",
"port": 1
},
{
"device": "oc02",
"port": 1
}
]
}
}
This sample Service requests both oc01 and oc02 device emulators to create a VLAN sub-interface with vlanID=100 on port 1.
Expand All @@ -270,12 +289,23 @@ This sample Service requests both oc01 and oc02 device emulators to create a VLA
kubectl -n kuesta-system port-forward svc/kuesta-server 9339:9339
```
If the http interface is used, the following is the case.
```bash
kubectl -n kuesta-system port-forward svc/kuesta-server 8080:8080
```
3: Send gNMI set request to kuesta-server using `gnmic`.
```bash
gnmic -a :9339 -u dummy -p dummy set --replace-path "/services/service[kind=oc_circuit][vlanID=100]" --encoding JSON --insecure --replace-file oc-circuit-vlan100.json
```
If you use the http interface, send the following POST Request to the Questa server using `curl`.
```bash
curl -X POST -H "Content-Type: application/json" -d @oc-circuit-vlan100.json http://localhost:8080/set
```
4: Check the PullRequest(PR) in your configuration repository on GitHub web console. Access [PR list](https://github.com/<your_org>/<your_config_repo>/pulls) then you will find the PR which titles as `[kuesta] Automated PR`. You can see what services and devices are configured by this PR on the PR comment, and their details from the `Files changed` tab.
5: Before merging PR branch, it is better to monitor `DeviceRollout` resource, which conducts a device configuration rollout. Run monitor with `kubectl`:
Expand Down Expand Up @@ -311,6 +341,12 @@ kuesta-testdata Healthy Completed
gnmic -a :9339 -u admin -p admin get --path "/devices/device[name=oc01]" --path "/devices/device[name=oc02]" --encoding JSON --insecure
```
If you use the http interface, send the following POST Request to the Questa server using `curl`.
```bash
curl -X POST -H "Content-Type: application/json" -d '{"paths": ["/devices/oc01", "/devices/oc02"]}' http://localhost:8080/get
```
The output displays the gNMI response payload like:
```json
Expand Down Expand Up @@ -357,6 +393,116 @@ The output displays the gNMI response payload like:
...
```
The response when using the http interface is as follows.
```json
[
{
"Interface": {
"Ethernet1": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet1",
"OperStatus": 1,
"SubInterface": {
"100": {
"AdminStatus": 1,
"Ifindex": 1,
"Index": 100,
"Name": "Ethernet1.100",
"OperStatus": 1
}
},
"Subinterface": {},
"Type": 80
},
"Ethernet2": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet2",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
},
"Ethernet3": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet3",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
}
},
"Vlan": {
"100": {
"Member": [],
"Name": "VLAN100",
"Status": 1,
"Tpid": 0,
"VlanId": 100
}
}
},
{
"Interface": {
"Ethernet1": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet1",
"OperStatus": 1,
"SubInterface": {
"100": {
"AdminStatus": 1,
"Ifindex": 1,
"Index": 100,
"Name": "Ethernet1.100",
"OperStatus": 1
}
},
"Subinterface": {},
"Type": 80
},
"Ethernet2": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet2",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
},
"Ethernet3": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet3",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
}
},
"Vlan": {
"100": {
"Member": [],
"Name": "VLAN100",
"Status": 1,
"Tpid": 0,
"VlanId": 100
}
}
}
]
```
You will find that vlan and vlan sub-interfaces of both devices oc01 and oc02 are configured correctly as implemented in the `oc-circuit` service model.
In addition, these device config changes are committed and pushed to your status repository, you can find these device config updates from the main branch head.
Expand Down
148 changes: 147 additions & 1 deletion content/ja/docs/Getting started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,49 @@ import (
}
```

httpインターフェースを利用する場合、上に代わって以下JSONを作成してください。(pathにはServiceのパス、valueには投入するServiceの値を指定)

```json
{
"path": "/services/oc_circuit/100",
"value": {
"vlanID": 100,
"endpoints": [
{
"device": "oc01",
"port": 1
},
{
"device": "oc02",
"port": 1
}
]
}
}
```

2: ローカルのKubernetesクラスタで動作しているKuestaサーバのPodに対してポートフォワーディングしてください。

```bash
kubectl -n kuesta-system port-forward svc/kuesta-server 9339:9339
```

3: `gnmic` を用いて、Kuestaサーバに対してgNMI SetRequestを送ってください
httpインターフェースを利用する場合は以下です

```bash
kubectl -n kuesta-system port-forward svc/kuesta-server 8080:8080
```

3: `gnmic`を用いて、Kuestaサーバに対してgNMI SetRequestを送ってください。
```bash
gnmic -a :9339 -u dummy -p dummy set --replace-path "/services/service[kind=oc_circuit][vlanID=100]" --encoding JSON --insecure --replace-file oc-circuit-vlan100.json
```

httpインターフェースを利用する場合は、`curl`を用いてKuestaサーバに対して以下POST Requestを送ってください。
```bash
curl -X POST -H "Content-Type: application/json" -d @oc-circuit-vlan100.json http://localhost:8080/set
```

4: GitHubのWebコンソールを用いて、本チュートリアル向けに作成したコンフィグ用のGitHubレポジトリのプルリクエスト(PullRequest: PR)を確認してください。
[PR一覧](https://github.com/<your_org>/<your_config_repo>/pulls) にアクセスすると、 `[kuesta] Automated PR` というタイトルのPRが確認できます。
PRのコメントを見ると、どのServiceとどのネットワーク装置が変更されたのかがわかりますし、 `Files changed` タブを確認すると詳細な変更点が確認できます。
Expand Down Expand Up @@ -312,6 +343,11 @@ kuesta-testdata Healthy Completed
gnmic -a :9339 -u admin -p admin get --path "/devices/device[name=oc01]" --path "/devices/device[name=oc02]" --encoding JSON --insecure
```

httpインターフェースを利用する場合は、`curl`を用いてKuestaサーバに対して以下POST Requestを送ってください。
```bash
curl -X POST -H "Content-Type: application/json" -d '{"paths": ["/devices/oc01", "/devices/oc02"]}' http://localhost:8080/get
```

以下のようなレスポンスが表示されます。

```json
Expand Down Expand Up @@ -358,6 +394,116 @@ gnmic -a :9339 -u admin -p admin get --path "/devices/device[name=oc01]" --path
...
```
httpインターフェースを使用した場合のレスポンスは以下です。
```json
[
{
"Interface": {
"Ethernet1": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet1",
"OperStatus": 1,
"SubInterface": {
"100": {
"AdminStatus": 1,
"Ifindex": 1,
"Index": 100,
"Name": "Ethernet1.100",
"OperStatus": 1
}
},
"Subinterface": {},
"Type": 80
},
"Ethernet2": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet2",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
},
"Ethernet3": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet3",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
}
},
"Vlan": {
"100": {
"Member": [],
"Name": "VLAN100",
"Status": 1,
"Tpid": 0,
"VlanId": 100
}
}
},
{
"Interface": {
"Ethernet1": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet1",
"OperStatus": 1,
"SubInterface": {
"100": {
"AdminStatus": 1,
"Ifindex": 1,
"Index": 100,
"Name": "Ethernet1.100",
"OperStatus": 1
}
},
"Subinterface": {},
"Type": 80
},
"Ethernet2": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet2",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
},
"Ethernet3": {
"AdminStatus": 1,
"Description": "",
"Enabled": false,
"Mtu": 9000,
"Name": "Ethernet3",
"OperStatus": 1,
"Subinterface": {},
"Type": 80
}
},
"Vlan": {
"100": {
"Member": [],
"Name": "VLAN100",
"Status": 1,
"Tpid": 0,
"VlanId": 100
}
}
}
]
```
レスポンスを確認すると、oc01とoc02の両方の装置エミュレータに対して、VLAN ID=100のVLAN定義とVLANサブインターフェースが設定されていることが分かります。
また、これらの装置コンフィグの変更内容はチュートリアル向けに作成したステータス用のGitレポジトリに対してコミット・プッシュされています。ステータス用のGitレポジトリのメインブランチのHEADを見ると、変更が保存されていることが確認できます。
Expand Down

0 comments on commit 7e99727

Please sign in to comment.