In this section, I will record each step that I implemented the custom service oaibbu from example service and took vHHS as an example.
In this section, I will record each step that I implemented the custom service oaibbu from example service and took vHHS as an example.
Synchronizer Design Guidelines
Synchronizer and data model
- Synchronizers act as the link between the data model and the functional half of the system.
- the data model contains a clean, abstract and declarative representation of the system
Earlier releases (3.0 and before) required additional files (mostly Python code) to on-board a service, including a REST API, a TOSCA API, and an Admin GUI. These components are now auto-generated from the models rather than coded by hand.
CiaB development loop
- Make changes to your service code and propagate them to your CiaB host
- Teardown the existing XOS installation and clean up OpenStack to remove any leftover instances or networks
1 | cd cord/build |
- (Optional)
- Test and verify your changes.
Create a XOS service based on your service
Synchronizers are processes that run continuously, checking for changes to the Tenant model and applying them to the running Instances. In this case, we’re using TenantWithContainer, which creates a Virtual Machine Instance for us.
XOS Synchronizers are located in the xos/synchronizers directory in the XOS source tree. It’s customary to name the synchronizer directory with the same name as your service. The example code given below is in the XOS repo at xos/synchronizers/exampleservice.
Define a model (xproto)
- Define a model
- XPROTO is a combination of Google Protocol Buffers and some XOS- specific annotations
- The XPROTO Header, which contains options that are global to the rest of the file
- The Service model, which manages the service as a whole
- The ServiceInstance model, which manages tenant-specific (per-service-instance) state
name
specifies a name for your serviceapp_label
configures the internal xos database application that is attached to these models
A Service model extends (inherits from) the XOS base Service model. At its head is a set of option declarations such as verbose_name
, which specifies a human-readable name for the service model. Then follows a set of field definitions.
oaibbu.xproto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20option name = "oaiBBU";
option app_label = "oaibbu";
message OAIBBUService (Service){
option verbose_name = "OAI Virtual Base Band Unit";
}
message OAIBBUVendor (XOSBase){
option verbose_name = "OAI Vitrual Base Band Unit Vendor";
required string name = 1 [help_text = "vendor name", max_length = 32, null = False, db_index = False, blank = False];
required manytoone image->Image:+ = 2 [help_text = "select image for this vendor", db_index = True, null = False, blank = False];
required manytoone flavor->Flavor:+ = 3 [help_text = "select openstack flavor for vendor image", db_index = True, null = False, blank = False];
}
message OAIBBUTenant (TenantWithContainer){
option verbose_name = "OAI Vitrual Base Band Unit Instance";
optional manytoone oaibbu_vendor->OAIBBUVendor:vendor_tenants = 1 [help_text = "select vendor of choice, leave blank for slice default", db_index = True, null = True, blank = True];
}
Define a syncrhronizer
The Synchronizer has three parts:
- The synchronizer python program,
- model policies which enact changes on the data model
- a playbook (typically Ansible) that configures the underlying system. The following describes how to construct these.
model-deps
Note: Earlier versions included a tool to track model dependencies, but today it is sufficient to create a file named model-deps
with the contents: {}
.
=> Create a file named model-deps
with the contents: {}
.
synchronizer python program
It loads and runs the default xos-synchronizer
module in it’s own Docker container.
To configure this module, create a file named exampleservice_config.yaml
, which specifies various configuration and logging options:
exampleservice-synchronizer.py
:
1 | #!/usr/bin/env python |
oaibbu-synchronizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#!/usr/bin/env python
# This imports and runs ../../xos-observer.py
import importlib
import os
import sys
from xosconfig import Config
config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/oaibbu_config.yaml')
Config.init(config_file, 'synchronizer-config-schema.yaml')
observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../synchronizers/new_base")
sys.path.append(observer_path)
mod = importlib.import_module("xos-synchronizer")
mod.main()
config yaml:
- list the path of your synchronizer component
exampleservice_config.yaml1
2
3
4
5
6
7
8
9
10
11
12
13
14name: exampleservice
accessor:
username: xosadmin@opencord.org
password: "@/opt/xos/services/exampleservice/credentials/xosadmin@opencord.org"
required_models:
- ExampleService
- ExampleServiceInstance
- ServiceDependency
- ServiceMonitoringAgentInfo
dependency_graph: "/opt/xos/synchronizers/exampleservice/model-deps"
steps_dir: "/opt/xos/synchronizers/exampleservice/steps"
sys_dir: "/opt/xos/synchronizers/exampleservice/sys"
model_policies_dir: "/opt/xos/synchronizers/exampleservice/model_policies"
models_dir: "/opt/xos/synchronizers/exampleservice/models"
oaibbu_config.yaml1
2
3
4
5
6
7
8name: oaibbu-synchronizer
accessor:
username: xosadmin@opencord.org
password: "@/opt/xos/services/oaibbu/credentials/xosadmin@opencord.org"
dependency_graph: "/opt/xos/synchronizers/oaibbu/model-deps"
steps_dir: "/opt/xos/synchronizers/oaibbu/steps"
sys_dir: "/opt/xos/synchronizers/oaibbu/sys"
model_policies_dir: "/opt/xos/synchronizers/oaibbu/model_policies"
/steps/sync_oaibbutenant.py
1 | import os |
files in Synchronizer
oaibbu.xproto
- Define a model
- XPROTO is a combination of Google Protocol Buffers and some XOS- specific annotations
- The XPROTO Header, which contains options that are global to the rest of the file
- The Service model, which manages the service as a whole
- The ServiceInstance model, which manages tenant-specific (per-service-instance) state
oaibbu-synchonizer.py
- replace config yaml file
oaibbu_config.yaml
- Modify synchonizer path
sync_oaibbutenant.py
- setting of the tenant information