cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
77
Views
0
Helpful
1
Replies

NSO Basic DNS Service failing ''Container' object has no attribute"

richbotham
Level 1
Level 1

Hi all,

I hope someone can show me the obvious mistake i'm making.

I am following this https://developer.cisco.com/docs/nso-guides-5.7/creating-a-service/#creating-a-service to create a basic DNS service.

Whenever i issue a "commit dry-run" i get this error

admin@ncs(config)# dns-config test dns-server 1.1.1.1
admin@ncs(config-dns-config-test)# commit dry-run 
Aborted: Python cb_create error. 'Container' object has no attribute 'sys'

my python code is very similar to the example

@Service.create
    def cb_create(self, tctx, root, service, proplist):
        self.log.info('Service create(service=', service._path, ')')
        dns_ip = service.dns_server
        router0_device = root.devices.device['router0']
        router0_config = router0_device.config
        dns_server_list = router0_config.sys.dns.server
        if dns_ip not in dns_server_list:
            dns_server_list.create(dns_ip)

my yang file is as follows - the same as the example

module dns-config {

  namespace "http://example.com/dns-config";
  prefix dns-config;

  import ietf-inet-types {
    prefix inet;
  }
  import tailf-common {
    prefix tailf;
  }
  import tailf-ncs {
    prefix ncs;
  }

  description
    "Bla bla...";

  revision 2016-01-01 {
    description
      "Initial revision.";
  }

  list dns-config {
    description "This is an RFS skeleton service";

    key name;
    leaf name {
      tailf:info "Unique service id";
      tailf:cli-allow-range;
      type string;
    }

    uses ncs:service-data;
    ncs:servicepoint dns-config-servicepoint;

    // may replace this with other ways of refering to the devices.
    leaf-list device {
      type leafref {
        path "/ncs:devices/ncs:device/ncs:name";
      }
    }

    // replace with your own stuff here
    leaf dns-server {
      type inet:ipv4-address;
    }
  }
}

my router package is as follows

 ~/ncs-6.2/nso-instance/packages/ ls -la
total 0
drwxr-xr-x@  4 rich  staff  128 10 Nov 15:59 .
drwxr-xr-x@ 13 rich  staff  416 10 Nov 16:16 ..
lrwxr-xr-x@  1 rich  staff   51  7 Nov 16:03 cisco-ios-cli-3.8 -> /Users/rich/ncs-6.2/packages/neds/cisco-ios-cli-3.8
drwxr-xr-x@  9 rich  staff  288 10 Nov 16:17 dns-config

Thanks

Rich

1 Reply 1

Check if the NED has the sys.dns.server path, i think it doesn’t and this is the issue.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io