Skip to content

Commit

Permalink
gnmi: ensure three-phase commit protocol
Browse files Browse the repository at this point in the history
Previously, only two phases of the commit protocol were utilized,
leading to lack of data validation before committing it.
This oversight resulted in compromised functionality of the
GNMI device simulator, as undesired data was sent.

This commit addresses the issue by implementing the complete
three-phase commit protocol, as well as fixing the existing
invalid data.

JIRA: LIGHTY-272
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
  • Loading branch information
ihrasko authored and Tobianas committed Nov 29, 2023
1 parent f16c9fa commit becee9e
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lighty-rcgnmi-app/download_yangs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ wget https://raw.githubusercontent.com/openconfig/public/ed650bd969afc2eb5f66d60
wget https://raw.githubusercontent.com/openconfig/public/ed650bd969afc2eb5f66d60b86b62ffa6fd5fb8e/release/models/system/openconfig-system-terminal.yang -P yangs
wget https://raw.githubusercontent.com/openconfig/public/ed650bd969afc2eb5f66d60b86b62ffa6fd5fb8e/release/models/types/openconfig-types.yang -P yangs
wget https://raw.githubusercontent.com/openconfig/public/ed650bd969afc2eb5f66d60b86b62ffa6fd5fb8e/release/models/types/openconfig-yang-types.yang -P yangs
wget https://raw.githubusercontent.com/openconfig/public/f3349778e3cb3b0987f3ec18acea329ea4bf30e6/release/models/interfaces/openconfig-if-types.yang -P yangs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"gnmi_simulator":{
"targetAddress": "0.0.0.0",
"targetPort": 3333,
"initialStateDataPath": "./simulator/initialJsonData.json",
"initialConfigDataPath": "./simulator/initialJsonData.json",
"initialStateDataPath": "./simulator/initialStateJsonData.json",
"initialConfigDataPath": "./simulator/initialConfigJsonData.json",
"certPath": "./simulator/certs/server.crt",
"certKeyPath": "./simulator/certs/server.key",
"yangsPath": "./yangs",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"openconfig-interfaces:interfaces": {
"interface": [
{
"name": "admin",
"config": {
"name": "admin",
"type": "openconfig-if-types:IF_ETHERNET"
}
}
]
},
"openconfig-system:system": {
"aaa": {
"authentication": {
"admin-user": {
"config": {
"admin-password": "password"
}
},
"config": {
"authentication-method": [
"openconfig-aaa-types:LOCAL"
]
}
}
},
"clock": {
"config": {
"timezone-name": "Europe/Stockholm"
}
},
"config": {
"hostname": "zz-tri-dev01",
"domain-name": "foo.bar.com",
"login-banner": "This device is for authorized use only",
"motd-banner": "Welcome to Open vSwitch"
},
"openconfig-openflow:openflow": {
"agent": {
"config": {
"backoff-interval": 5,
"datapath-id": "10:16:3e:00:00:00:00:00",
"failure-mode": "SECURE",
"inactivity-probe": 10,
"max-backoff": 10
}
},
"controllers": {
"controller": [
{
"config": {
"name": "main"
},
"connections": {
"connection": [
{
"aux-id": 0,
"config": {
"address": "192.0.2.10",
"aux-id": 0,
"port": 6633,
"priority": 1,
"source-interface": "admin",
"transport": "TLS"
}
}
]
},
"name": "main"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ assertHttpStatusCode $(curl -X PUT -o /dev/null -s -w "%{http_code} PUT %{url_ef
"openconfig-aaa-types:TACACS_ALL"
]
},
"state": {
"authentication-method": [
"openconfig-aaa-types:RADIUS_ALL"
]
},
"admin-user": {
"config": {
"admin-password": "password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ are performed on this device.

The application, lighty.io gNMI/RESTCONF is pre-prepared with [Openconfig YANG models](yangs).
These models are used by both gNMI application and gNMI device simulator. Device has already preconfigured state/config
data specified in [initialJsonData.json](simulator/initialJsonData.json) JSON file.
data specified in [initialStateJsonData.json](simulator/initialStateJsonData.json) JSON file.
To communicate with gNMI device it is required to use TLS communication with certificates and username and password
authorization.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"openconfig-interfaces:interfaces": {
"interface": [
{
"name": "admin",
"config": {
"name": "admin",
"type": "openconfig-if-types:IF_ETHERNET"
}
}
]
},
"openconfig-system:system": {
"aaa": {
"authentication": {
"admin-user": {
"config": {
"admin-password": "password"
}
},
"config": {
"authentication-method": [
"openconfig-aaa-types:LOCAL"
]
}
}
},
"clock": {
"config": {
"timezone-name": "Europe/Stockholm"
}
},
"config": {
"hostname": "zz-tri-dev01",
"domain-name": "foo.bar.com",
"login-banner": "This device is for authorized use only",
"motd-banner": "Welcome to Open vSwitch"
},
"openconfig-openflow:openflow": {
"agent": {
"config": {
"backoff-interval": 5,
"datapath-id": "00:16:3e:00:00:00:00:00",
"failure-mode": "SECURE",
"inactivity-probe": 10,
"max-backoff": 10
}
},
"controllers": {
"controller": [
{
"config": {
"name": "main"
},
"connections": {
"connection": [
{
"aux-id": 0,
"config": {
"address": "192.0.2.10",
"aux-id": 0,
"port": 6633,
"priority": 1,
"source-interface": "admin",
"transport": "TLS"
}
}
]
},
"name": "main"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"targetPort": 10161,
"certPath": "certificates/server.crt",
"certKeyPath": "certificates/server-pkcs8.key",
"initialConfigDataPath": "simulator/initialJsonData.json",
"initialStateDataPath": "simulator/initialJsonData.json",
"initialConfigDataPath": "simulator/initialConfigJsonData.json",
"initialStateDataPath": "simulator/initialStateJsonData.json",
"yangsPath": "../../lighty-models/openconfig-models/src/main/yang",
"username": "admin",
"password": "admin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private void modifyDataByPath(final DatastoreType datastoreType, final YangInsta
tx.merge(path, node);
}
final DOMStoreThreePhaseCommitCohort tpcc = tx.ready();
tpcc.canCommit().get();
tpcc.preCommit().get();
tpcc.commit().get();
} catch (final ExecutionException exception) {
Expand Down

0 comments on commit becee9e

Please sign in to comment.