From a69105569fbce3c19643906a8ca569e76661a01e Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 5 Jul 2021 09:57:38 -0400 Subject: [PATCH] Add node PVC version data to Node information Allows API client to see the currently-active version of the node daemon. --- api-daemon/pvcapid/flaskapi.py | 3 +++ daemon-common/migrations/versions/2.json | 1 + daemon-common/node.py | 2 ++ daemon-common/zkhandler.py | 3 ++- docs/manuals/swagger.json | 4 ++++ node-daemon/pvcnoded/Daemon.py | 3 +++ 6 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 daemon-common/migrations/versions/2.json diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index f79fe1fb..560563c8 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -535,6 +535,9 @@ class API_Node_Root(Resource): domain_state: type: string description: The current domain (VM) state + pvc_version: + type: string + description: The current running PVC node daemon version cpu_count: type: integer description: The number of available CPU cores diff --git a/daemon-common/migrations/versions/2.json b/daemon-common/migrations/versions/2.json new file mode 100644 index 00000000..f9eb3009 --- /dev/null +++ b/daemon-common/migrations/versions/2.json @@ -0,0 +1 @@ +{"version": "2", "root": "", "base": {"root": "", "schema": "/schema", "schema.version": "/schema/version", "config": "/config", "config.maintenance": "/config/maintenance", "config.primary_node": "/config/primary_node", "config.primary_node.sync_lock": "/config/primary_node/sync_lock", "config.upstream_ip": "/config/upstream_ip", "config.migration_target_selector": "/config/migration_target_selector", "cmd": "/cmd", "cmd.node": "/cmd/nodes", "cmd.domain": "/cmd/domains", "cmd.ceph": "/cmd/ceph", "node": "/nodes", "domain": "/domains", "network": "/networks", "storage": "/ceph", "storage.util": "/ceph/util", "osd": "/ceph/osds", "pool": "/ceph/pools", "volume": "/ceph/volumes", "snapshot": "/ceph/snapshots"}, "node": {"name": "", "keepalive": "/keepalive", "mode": "/daemonmode", "data.active_schema": "/activeschema", "data.latest_schema": "/latestschema", "data.static": "/staticdata", "data.pvc_version": "/pvcversion", "running_domains": "/runningdomains", "count.provisioned_domains": "/domainscount", "count.networks": "/networkscount", "state.daemon": "/daemonstate", "state.router": "/routerstate", "state.domain": "/domainstate", "cpu.load": "/cpuload", "vcpu.allocated": "/vcpualloc", "memory.total": "/memtotal", "memory.used": "/memused", "memory.free": "/memfree", "memory.allocated": "/memalloc", "memory.provisioned": "/memprov", "ipmi.hostname": "/ipmihostname", "ipmi.username": "/ipmiusername", "ipmi.password": "/ipmipassword", "sriov": "/sriov", "sriov.pf": "/sriov/pf", "sriov.vf": "/sriov/vf"}, "sriov_pf": {"phy": "", "mtu": "/mtu", "vfcount": "/vfcount"}, "sriov_vf": {"phy": "", "pf": "/pf", "mtu": "/mtu", "mac": "/mac", "phy_mac": "/phy_mac", "config": "/config", "config.vlan_id": "/config/vlan_id", "config.vlan_qos": "/config/vlan_qos", "config.tx_rate_min": "/config/tx_rate_min", "config.tx_rate_max": "/config/tx_rate_max", "config.spoof_check": "/config/spoof_check", "config.link_state": "/config/link_state", "config.trust": "/config/trust", "config.query_rss": "/config/query_rss", "pci": "/pci", "pci.domain": "/pci/domain", "pci.bus": "/pci/bus", "pci.slot": "/pci/slot", "pci.function": "/pci/function", "used": "/used", "used_by": "/used_by"}, "domain": {"name": "", "xml": "/xml", "state": "/state", "profile": "/profile", "stats": "/stats", "node": "/node", "last_node": "/lastnode", "failed_reason": "/failedreason", "storage.volumes": "/rbdlist", "console.log": "/consolelog", "console.vnc": "/vnc", "meta.autostart": "/node_autostart", "meta.migrate_method": "/migration_method", "meta.node_selector": "/node_selector", "meta.node_limit": "/node_limit", "migrate.sync_lock": "/migrate_sync_lock"}, "network": {"vni": "", "type": "/nettype", "rule": "/firewall_rules", "rule.in": "/firewall_rules/in", "rule.out": "/firewall_rules/out", "nameservers": "/name_servers", "domain": "/domain", "reservation": "/dhcp4_reservations", "lease": "/dhcp4_leases", "ip4.gateway": "/ip4_gateway", "ip4.network": "/ip4_network", "ip4.dhcp": "/dhcp4_flag", "ip4.dhcp_start": "/dhcp4_start", "ip4.dhcp_end": "/dhcp4_end", "ip6.gateway": "/ip6_gateway", "ip6.network": "/ip6_network", "ip6.dhcp": "/dhcp6_flag"}, "reservation": {"mac": "", "ip": "/ipaddr", "hostname": "/hostname"}, "lease": {"mac": "", "ip": "/ipaddr", "hostname": "/hostname", "expiry": "/expiry", "client_id": "/clientid"}, "rule": {"description": "", "rule": "/rule", "order": "/order"}, "osd": {"id": "", "node": "/node", "device": "/device", "stats": "/stats"}, "pool": {"name": "", "pgs": "/pgs", "stats": "/stats"}, "volume": {"name": "", "stats": "/stats"}, "snapshot": {"name": "", "stats": "/stats"}} \ No newline at end of file diff --git a/daemon-common/node.py b/daemon-common/node.py index b2e127ce..82f43ea2 100644 --- a/daemon-common/node.py +++ b/daemon-common/node.py @@ -33,6 +33,7 @@ def getNodeInformation(zkhandler, node_name): node_coordinator_state = zkhandler.read(('node.state.router', node_name)) node_domain_state = zkhandler.read(('node.state.domain', node_name)) node_static_data = zkhandler.read(('node.data.static', node_name)).split() + node_pvc_version = zkhandler.read(('node.data.pvc_version', node_name)) node_cpu_count = int(node_static_data[0]) node_kernel = node_static_data[1] node_os = node_static_data[2] @@ -53,6 +54,7 @@ def getNodeInformation(zkhandler, node_name): 'daemon_state': node_daemon_state, 'coordinator_state': node_coordinator_state, 'domain_state': node_domain_state, + 'pvc_version': node_pvc_version, 'cpu_count': node_cpu_count, 'kernel': node_kernel, 'os': node_os, diff --git a/daemon-common/zkhandler.py b/daemon-common/zkhandler.py index 77343e0a..bd32adcc 100644 --- a/daemon-common/zkhandler.py +++ b/daemon-common/zkhandler.py @@ -440,7 +440,7 @@ class ZKHandler(object): # class ZKSchema(object): # Current version - _version = 1 + _version = 2 # Root for doing nested keys _schema_root = '' @@ -482,6 +482,7 @@ class ZKSchema(object): 'data.active_schema': '/activeschema', 'data.latest_schema': '/latestschema', 'data.static': '/staticdata', + 'data.pvc_version': '/pvcversion', 'running_domains': '/runningdomains', 'count.provisioned_domains': '/domainscount', 'count.networks': '/networkscount', diff --git a/docs/manuals/swagger.json b/docs/manuals/swagger.json index 41cdc1a9..dd5cb47e 100644 --- a/docs/manuals/swagger.json +++ b/docs/manuals/swagger.json @@ -464,6 +464,10 @@ "description": "The current operating system type", "type": "string" }, + "pvc_version": { + "description": "The current running PVC node daemon version", + "type": "string" + }, "running_domains": { "description": "The list of running domains (VMs) by UUID", "type": "string" diff --git a/node-daemon/pvcnoded/Daemon.py b/node-daemon/pvcnoded/Daemon.py index 69c8fb6e..609c7540 100644 --- a/node-daemon/pvcnoded/Daemon.py +++ b/node-daemon/pvcnoded/Daemon.py @@ -786,6 +786,7 @@ if config['daemon_mode'] == 'coordinator': init_routerstate = 'secondary' else: init_routerstate = 'client' + if zkhandler.exists(('node', myhostname)): logger.out("Node is " + fmt_green + "present" + fmt_end + " in Zookeeper", state='i') # Update static data just in case it's changed @@ -794,6 +795,7 @@ if zkhandler.exists(('node', myhostname)): (('node.state.daemon', myhostname), 'init'), (('node.state.router', myhostname), init_routerstate), (('node.data.static', myhostname), ' '.join(staticdata)), + (('node.data.pvc_version', myhostname), version), (('node.ipmi.hostname', myhostname), config['ipmi_hostname']), (('node.ipmi.username', myhostname), config['ipmi_username']), (('node.ipmi.password', myhostname), config['ipmi_password']), @@ -809,6 +811,7 @@ else: (('node.state.domain', myhostname), 'flushed'), (('node.state.router', myhostname), init_routerstate), (('node.data.static', myhostname), ' '.join(staticdata)), + (('node.data.pvc_version', myhostname), version), (('node.ipmi.hostname', myhostname), config['ipmi_hostname']), (('node.ipmi.username', myhostname), config['ipmi_username']), (('node.ipmi.password', myhostname), config['ipmi_password']),