Commit 9ce0f34c authored by Sigmund Augdal's avatar Sigmund Augdal

Convert all macs to lower case before allowing them into the system.

Remove upper case macs also when removing a mac from a security group
parent 105274a2
......@@ -134,6 +134,7 @@ def get_group_members(etcd_client, group_id):
def get_groups_from_mac(etcd_client, mac):
mac = mac.lower()
groups = []
for group_id in get_security_groups(etcd_client):
_, members = get_group_members(etcd_client, group_id)
......@@ -143,6 +144,7 @@ def get_groups_from_mac(etcd_client, mac):
def add_mac_to_group(etcd_client, group_id, mac):
mac = mac.lower()
members_key = security_group_key(group_id) + "/members/by_mac"
raw_members, members = get_group_members(etcd_client, group_id)
if mac in members:
......@@ -153,11 +155,12 @@ def add_mac_to_group(etcd_client, group_id, mac):
def delete_mac_from_group(etcd_client, group_id, mac):
mac = mac.lower()
members_key = security_group_key(group_id) + "/members/by_mac"
raw_members, members = get_group_members(etcd_client, group_id)
if not mac in members:
if not mac in [m.lower() for m in members]:
return
members.remove(mac)
members = [m for m in members if m.lower() != mac]
new_members = "\n".join(members)
logging.debug("new members: %s", new_members)
if not new_members:
......
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