Add support for 2-level dynamic keys
This commit is contained in:
parent
85aba7cc18
commit
9985e1dadd
|
@ -1 +1 @@
|
|||
{"version": "0", "root": "", "base": {"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": {"keepalive": "/keepalive", "mode": "/daemonmode", "data.active_schema": "/activeschema", "data.latest_schema": "/latestschema", "data.static": "/staticdata", "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"}, "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": {"type": "/nettype", "rules": "/firewall_rules", "nameservers": "/name_servers", "domain": "/domain", "ip4.gateway": "/ip4_gateway", "ip4.network": "/ip4_network", "ip4.dhcp": "/dhcp4_flag", "ip4.reservations": "/dhcp4_reservations", "ip4.dhcp_start": "/dhcp4_start", "ip4.dhcp_end": "/dhcp4_end", "ip6.gateway": "/ip6_gateway", "ip6.network": "/ip6_network", "ip6.dhcp": "/dhcp6_flag"}, "osd": {"node": "/node", "device": "/device", "stats": "/stats"}, "pool": {"pgs": "/pgs", "stats": "/stats"}, "volume": {"stats": "/stats"}, "snapshot": {"stats": "/stats"}}
|
||||
{"version": "0", "root": "", "base": {"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": {"keepalive": "/keepalive", "mode": "/daemonmode", "data.active_schema": "/activeschema", "data.latest_schema": "/latestschema", "data.static": "/staticdata", "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"}, "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": {"type": "/nettype", "rules": "/firewall_rules", "rules.in": "/firewall_rules/in", "rules.out": "/firewall_rules/out", "nameservers": "/name_servers", "domain": "/domain", "ip4.gateway": "/ip4_gateway", "ip4.network": "/ip4_network", "ip4.dhcp": "/dhcp4_flag", "ip4.reservation": "/dhcp4_reservations", "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"}, "osd": {"node": "/node", "device": "/device", "stats": "/stats"}, "pool": {"pgs": "/pgs", "stats": "/stats"}, "volume": {"stats": "/stats"}, "snapshot": {"stats": "/stats"}}
|
|
@ -165,7 +165,16 @@ class ZKHandler(object):
|
|||
def get_schema_path(self, key):
|
||||
if isinstance(key, tuple):
|
||||
# This is a key tuple with both an ipath and an item
|
||||
if len(key) == 2:
|
||||
# 2-length normal tuple
|
||||
ipath, item = key
|
||||
elif len(key) == 4:
|
||||
# 4-length sub-level tuple
|
||||
ipath, item, sub_ipath, sub_item = key
|
||||
return self.schema.path(ipath, item=item) + self.schema.path(sub_ipath, item=sub_item)
|
||||
else:
|
||||
# This is an invalid key
|
||||
return None
|
||||
elif isinstance(key, str):
|
||||
# This is a key string with just an ipath
|
||||
ipath = key
|
||||
|
@ -484,18 +493,26 @@ class ZKSchema(object):
|
|||
'network': {
|
||||
'type': '/nettype',
|
||||
'rules': '/firewall_rules',
|
||||
'rules.in': '/firewall_rules/in',
|
||||
'rules.out': '/firewall_rules/out',
|
||||
'nameservers': '/name_servers',
|
||||
'domain': '/domain',
|
||||
'ip4.gateway': '/ip4_gateway',
|
||||
'ip4.network': '/ip4_network',
|
||||
'ip4.dhcp': '/dhcp4_flag',
|
||||
'ip4.reservations': '/dhcp4_reservations',
|
||||
'ip4.reservation': '/dhcp4_reservations',
|
||||
'ip4.dhcp_start': '/dhcp4_start',
|
||||
'ip4.dhcp_end': '/dhcp4_end',
|
||||
'ip6.gateway': '/ip6_gateway',
|
||||
'ip6.network': '/ip6_network',
|
||||
'ip6.dhcp': '/dhcp6_flag'
|
||||
},
|
||||
# The schema of an individual network DHCP(v4) reservation entry (/networks/{vni}/dhcp4_reservations/{mac})
|
||||
'reservation': {
|
||||
'mac': '', # The root key
|
||||
'ip': '/ipaddr',
|
||||
'hostname': '/hostname'
|
||||
},
|
||||
# The schema of an individual OSD entry (/ceph/osds/{osd_id})
|
||||
'osd': {
|
||||
'node': '/node',
|
||||
|
@ -594,7 +611,10 @@ class ZKSchema(object):
|
|||
if item is None:
|
||||
return self.schema.get(itype).get('.'.join(ipath))
|
||||
else:
|
||||
base_path = self.schema.get('base').get(itype)
|
||||
base_path = self.schema.get('base').get(itype, None)
|
||||
if base_path is None:
|
||||
# This should only really happen for second-layer key types where the helper functions join them together
|
||||
base_path = ''
|
||||
sub_path = self.schema.get(itype).get('.'.join(ipath))
|
||||
if sub_path is None:
|
||||
sub_path = ''
|
||||
|
|
Loading…
Reference in New Issue