summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-12-07 23:25:15 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-12-07 23:25:15 -0600
commit2be0c8d53e4ef74e37441189f7aaa8374f8d0dfd (patch)
tree7620bd2c2d5620fad37f9562d84667064941e447
parent334cc509f08b125f9db76914efb9c7b2adfffeba (diff)
downloadnetconfapk-2be0c8d53e4ef74e37441189f7aaa8374f8d0dfd.tar.gz
netconfapk-2be0c8d53e4ef74e37441189f7aaa8374f8d0dfd.tar.bz2
netconfapk-2be0c8d53e4ef74e37441189f7aaa8374f8d0dfd.tar.xz
netconfapk-2be0c8d53e4ef74e37441189f7aaa8374f8d0dfd.zip
adelie-services: Vastly simplify YANG model
This restores the original behaviour/design. No real rationale was given for splitting into a status node other than that the server did not support returning the same node name for running and operational. It does now, so let's do this.
-rw-r--r--doc/service.rst10
-rw-r--r--ncserver/module/openrc.py9
-rw-r--r--yang-modules/adelie-services.yang54
3 files changed, 23 insertions, 50 deletions
diff --git a/doc/service.rst b/doc/service.rst
index b64870e..162b168 100644
--- a/doc/service.rst
+++ b/doc/service.rst
@@ -231,17 +231,13 @@ The data model for system services has the following structure:
::
+--rw services
- | +--rw service* [name]
- | +--rw name string
- | +--rw enabled boolean
- +--ro service-status
- +--ro service* [name]
- +--ro name string
+ +--rw service* [name]
+ +--rw name string
+--ro description? string
+ +--rw enabled boolean
+--ro status service-status
+--ro start-time? yang:date-and-time
-
Module
------
diff --git a/ncserver/module/openrc.py b/ncserver/module/openrc.py
index bbff980..e951af1 100644
--- a/ncserver/module/openrc.py
+++ b/ncserver/module/openrc.py
@@ -116,9 +116,8 @@ def check_alive(pidfile) -> bool:
try:
os.kill(pid, 0)
except OSError as ose:
- if ose.errno == errno.EPERM:
- return True # we can't send signal because it's alive
- return False
+ # If EPERM, we can't send the signal because it's alive.
+ return (ose.errno == errno.EPERM)
else:
return True
@@ -245,13 +244,13 @@ def running(node):
def operational(node):
"""Retrieve the service state for this device."""
- running(node) # Include the running configuration.
- svcs = util.subelm(node, 'svcs:service-status')
+ svcs = util.subelm(node, 'svcs:services')
for service in service_list():
svcnode = util.subelm(svcs, 'svcs:service')
svcnode.append(util.leaf_elm('svcs:name', service.name))
svcnode.append(util.leaf_elm('svcs:description', service.description))
+ svcnode.append(util.leaf_elm('svcs:enabled', service.enabled))
svcnode.append(util.leaf_elm(
'svcs:status', service.status().name.lower()
))
diff --git a/yang-modules/adelie-services.yang b/yang-modules/adelie-services.yang
index f006845..de7ed24 100644
--- a/yang-modules/adelie-services.yang
+++ b/yang-modules/adelie-services.yang
@@ -26,21 +26,16 @@ module adelie-services {
Copyright (c) 2020 Adélie Software and the persons identified
as authors of the code. All rights reserved.
-
+
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the NCSA License set forth
in the LICENSE file contained in the NETCONF APK repository
(https://code.foxkit.us/adelie/netconfapk/blob/current/LICENSE).
-
+
This version of this YANG module is part of the NETCONF APK
1.0 distribution; see the distributon for full legal notices.";
- revision 2020-09-29 {
- description
- "Separate state into its own container.";
- }
-
revision 2020-09-22 {
description
"Initial revision.";
@@ -82,7 +77,7 @@ module adelie-services {
list service {
key "name";
-
+
description
"The list of services on the device.";
@@ -95,38 +90,9 @@ module adelie-services {
consequences. It is not recommended.";
}
- leaf enabled {
- type boolean;
- mandatory true;
- description
- "This leaf contains the desired state of the service.
-
- When this leaf is true, the service will be started
- automatically by the device during system bootup.";
- }
- }
- }
-
- container service-status {
- config false;
- description
- "Contains information about the state of services on the
- device.";
-
- list service {
- key "name";
-
- description
- "The list of services on the device.";
-
- leaf name {
- type string;
- description
- "The name of the service.";
- }
-
leaf description {
type string;
+ config false;
description
"A textual description of the service.
@@ -135,8 +101,19 @@ module adelie-services {
service.";
}
+ leaf enabled {
+ type boolean;
+ mandatory true;
+ description
+ "This leaf contains the desired state of the service.
+
+ When this leaf is true, the service will be started
+ automatically by the device during system bootup.";
+ }
+
leaf status {
type service-status;
+ config false;
mandatory true;
description
"The current status of the service.";
@@ -144,6 +121,7 @@ module adelie-services {
leaf start-time {
type yang:date-and-time;
+ config false;
when "./status = 'running'";
description
"The time that this service entered the running state.";