docs: small cleanup for grpc/python docs

This commit is contained in:
Blake Harnden 2020-09-14 08:41:38 -07:00
parent 7fdb114375
commit 8ca52bf475
2 changed files with 34 additions and 28 deletions

View file

@ -114,16 +114,17 @@ core.events(session_id, event_listener, [core_pb2.EventType.NODE])
Links can be configured at the time of creation or during runtime. Links can be configured at the time of creation or during runtime.
Currently supported configuration options:
* bandwidth (bps)
* delay (us)
* duplicate (%)
* jitter (us)
* loss (%)
```python ```python
from core.api.grpc import core_pb2 from core.api.grpc import core_pb2
# configuring when creating a link # configuring when creating a link
# below are the currently supported configuration options
# bandwidth in bps
# delay in us
# duplicate in %
# jitter in us
# loss in %
options = core_pb2.LinkOptions( options = core_pb2.LinkOptions(
bandwidth=54_000_000, bandwidth=54_000_000,
delay=5000, delay=5000,
@ -387,15 +388,16 @@ Services help generate and run bash scripts on nodes for a given purpose.
Configuring the files of a service results in a specific hard coded script being Configuring the files of a service results in a specific hard coded script being
generated, instead of the default scripts, that may leverage dynamic generation. generated, instead of the default scripts, that may leverage dynamic generation.
The following features can be configured for a service:
* files - files that will be generated
* directories - directories that will be mounted unique to the node
* startup - commands to run start a service
* validate - commands to run to validate a service
* shutdown - commands to run to stop a service
Editing service properties: Editing service properties:
```python ```python
# configure a service, for a node, for a given session # configure a service, for a node, for a given session
# modify any of the following features
# the files and the names that will be generated
# the directories that will be mounted unique to the node
# startup commands to run
# validation commands to run
# shutdown commands to run
core.set_node_service( core.set_node_service(
session_id, session_id,
node_id, node_id,
@ -408,12 +410,13 @@ core.set_node_service(
) )
``` ```
When editing a service file, it must be the name of `config`
file that the service will generate.
Editing a service file: Editing a service file:
```python ```python
# to edit the contents of a generated file you can specify # to edit the contents of a generated file you can specify
# the service, the file name, and its contents # the service, the file name, and its contents
# the file name must map to one of the files the service
# supports by default or one added from a command above
core.set_node_service_file( core.set_node_service_file(
session_id, session_id,
node_id, node_id,

View file

@ -94,16 +94,17 @@ session.config_handlers.append(event_listener)
Links can be configured at the time of creation or during runtime. Links can be configured at the time of creation or during runtime.
Currently supported configuration options:
* bandwidth (bps)
* delay (us)
* dup (%)
* jitter (us)
* loss (%)
```python ```python
from core.emulator.data import LinkOptions from core.emulator.data import LinkOptions
# configuring when creating a link # configuring when creating a link
# below are the currently supported configuration options
# bandwidth in bps
# delay in us
# duplicate in %
# jitter in us
# loss in %
options = LinkOptions( options = LinkOptions(
bandwidth=54_000_000, bandwidth=54_000_000,
delay=5000, delay=5000,
@ -364,15 +365,16 @@ Services help generate and run bash scripts on nodes for a given purpose.
Configuring the files of a service results in a specific hard coded script being Configuring the files of a service results in a specific hard coded script being
generated, instead of the default scripts, that may leverage dynamic generation. generated, instead of the default scripts, that may leverage dynamic generation.
The following features can be configured for a service:
* configs - files that will be generated
* dirs - directories that will be mounted unique to the node
* startup - commands to run start a service
* validate - commands to run to validate a service
* shutdown - commands to run to stop a service
Editing service properties: Editing service properties:
```python ```python
# configure a service, for a node, for a given session # configure a service, for a node, for a given session
# modify any of the following features
# the files and the names that will be generated, called configs here
# the directories that will be mounted unique to the node
# startup commands to run
# validation commands to run
# shutdown commands to run
session.services.set_service(node_id, service_name) session.services.set_service(node_id, service_name)
service = session.services.get_service(node_id, service_name) service = session.services.get_service(node_id, service_name)
service.configs = ("file1.sh", "file2.sh") service.configs = ("file1.sh", "file2.sh")
@ -382,12 +384,13 @@ service.validate = ()
service.shutdown = () service.shutdown = ()
``` ```
When editing a service file, it must be the name of `config`
file that the service will generate.
Editing a service file: Editing a service file:
```python ```python
# to edit the contents of a generated file you can specify # to edit the contents of a generated file you can specify
# the service, the file name, and its contents # the service, the file name, and its contents
# the file name must map to one of the files the service
# supports by default or one added from a command above
session.services.set_service_file( session.services.set_service_file(
node_id, node_id,
service_name, service_name,