Commit b454dc94 authored by Sigmund Augdal's avatar Sigmund Augdal

Added support for references on groups and entries

parent c55f83f5
......@@ -76,6 +76,10 @@ def set_group_name(etcd_client, group_id, name, library=False):
etcd_client.set(group_key(group_id, library=library) + "/name", name)
def set_group_ref(etcd_client, group_id, ref, library=False):
etcd_client.set(group_key(group_id, library=library) + "/ref", ref)
def set_group_cloud(etcd_client, group_id, cloudid, library=False):
if cloudid:
etcd_client.set(group_key(group_id, library=library) + "/cloud", str(cloudid))
......@@ -117,9 +121,9 @@ def get_library_groups(etcd_client, cloudid=None):
if len(parts) < 2:
continue
group_id, info = parts[-2:]
if info not in ('cloud', 'name', 'lock', 'cidr', 'comment'):
if info not in ('cloud', 'name', 'lock', 'cidr', 'comment', 'ref', 'entryref'):
continue
if info in ('cidr', 'comment'):
if info in ('cidr', 'comment', 'entryref'):
if len(parts) < 4:
logging.warning('unexpected etcd key {}'.format(entry.key))
continue
......@@ -138,12 +142,14 @@ def get_library_groups(etcd_client, cloudid=None):
return groups
def add_library_entry(etcd_client, group_id, cidr, comment):
def add_library_entry(etcd_client, group_id, cidr, comment, entryref=None):
entry_id = uuid.uuid4()
entry_key = library_group_entry_key(group_id, entry_id)
ipaddress.ip_network(cidr)
etcd_client.set(entry_key + '/cidr', cidr)
etcd_client.set(entry_key + '/comment', comment)
if entryref:
etcd_client.set(entry_key + '/entryref', entryref)
return entry_id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment