Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNMI sonic-db:CONFIG_DB model - some SET operations say that they fail, but in reality they add the data. #238

Open
TafkaMax opened this issue May 14, 2024 · 1 comment
Assignees
Labels

Comments

@TafkaMax
Copy link

I am building my own mainline sonic with these options:

    - sed -i 's/INCLUDE_ICCPD.*\sn/INCLUDE_ICCPD = y/' rules/config
    - sed -i 's/INCLUDE_RESTAPI.*\sn/INCLUDE_RESTAPI = y/' rules/config
    - sed -i 's/.*ENABLE_TRANSLIB_WRITE\s=\s.*/ENABLE_TRANSLIB_WRITE = y/' rules/config
    - sed -i 's/INCLUDE_FIPS.*\sy/INCLUDE_FIPS = n/' rules/config

So I have translib write enabled, which is the most important thing for gnmi I suppose.

I am building the Virtual Switch image to be run in GNS3 sonic-vs.img.gz

I am using nornir for automation with pygnmi and nornir_pygnmi as the interface to communicate with the sonic gnmi endpoint.

Some set operations work, but others don't. For example enabling and disabling features works. But when I try to update or replace SYSLOG_SERVER or NTP_SERVER it fails, but it also doesn't fail.

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNKNOWN
	details = "Error: Failed to apply patch on the following scopes:"
	debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-05-14T16:41:39.262722796+03:00", grpc_status:2, grpc_message:"Error: Failed to apply patch on the following scopes:"}"
>

The code itself looks like this:

def sonic_ntp(task: Task) -> MultiResult:
  ntp_servers = {}
  for ntp_server in task.host.get('ntp_servers'):
    ntp_servers[ntp_server] = {
      "association_type": "pool",
      "iburst": "off",
      "admin_state": "disabled",
      "version": 4,
    }

  NTP_SETTINGS = [
      (
        "/sonic-db:CONFIG_DB/localhost/NTP_SERVER",
        ntp_servers
      )
  ]
  result = task.run(name="Configure NTP settings for SONiC appliance", task=gnmi_set, update=NTP_SETTINGS, encoding='json_ietf')
  return result

As you can see the endpoint is /sonic-db:CONFIG_DB/localhost/NTP_SERVER (https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#ntp-servers)

The data is inserted into the model, but the pygnmi connection does not recieve something back that it wants and fails.

@sneelam20
Copy link
Contributor

@qiluo-msft Would you be able to take a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants