Skip to content

Commit

Permalink
DM: Allocate and persist irb address from each subnet of a VN for eac…
Browse files Browse the repository at this point in the history
…h PR

- Allocate one ip from each subnet of a VN for each PR.
- Persist the ip and the association with VN, Subnet, PR in cassandra DB
- On DM restart, read the DB state and maintain allocated ip map in local memory
- On update/restart, find differences between allocated
  ip map vs VNC DB state of VN, and take necessary actions
- GW IP of the subnet is configured on the MX as the
  virtual-gateway-address under the IRB IP address

Change-Id: Ifcfdf96069a353cf2be1e03a83922796d4dd3471
Closes-Bug: #1465070
  • Loading branch information
sbalineni committed Aug 18, 2015
1 parent 4ab5fd4 commit ccfce2b
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/config/api-server/vnc_cfg_types.py
Expand Up @@ -566,7 +566,7 @@ def http_delete_fail(cls, id, obj_dict, db_conn):

@classmethod
def ip_alloc(cls, vn_fq_name, subnet_name, count):
ip_list = [cls.addr_mgmt.ip_alloc_req(vn_fq_name, subnet_name)
ip_list = [cls.addr_mgmt.ip_alloc_req(vn_fq_name, sub=subnet_name)
for i in range(count)]
msg = 'AddrMgmt: reserve %d IP for vn=%s, subnet=%s - %s' \
% (count, vn_fq_name, subnet_name if subnet_name else '', ip_list)
Expand All @@ -580,7 +580,7 @@ def ip_free(cls, vn_fq_name, subnet_name, ip_list):
% (ip_list, vn_fq_name, subnet_name if subnet_name else '')
cls.addr_mgmt.config_log(msg, level=SandeshLevel.SYS_DEBUG)
for ip_addr in ip_list:
cls.addr_mgmt.ip_free_req(ip_addr, vn_fq_name, subnet_name)
cls.addr_mgmt.ip_free_req(ip_addr, vn_fq_name, sub=subnet_name)
# end ip_free

@classmethod
Expand Down
27 changes: 27 additions & 0 deletions src/config/common/vnc_cassandra.py
Expand Up @@ -66,6 +66,33 @@ def __init__(self, server_list, reset_config, db_prefix, keyspaces, logger,
self._obj_fq_name_cf = self._cf_dict[self._OBJ_FQ_NAME_CF_NAME]
# end __init__

def get_cf(self, func):
return self._cf_dict.get(func)
#end

def add(self, func, key, value):
try:
self.get_cf(func).insert(key, value)
return True
except:
return False
#end

def get(self, func, key):
try:
return self.get_cf(func).get(key)
except:
return None
#end

def delete(self, func, key):
try:
self.get_cf(func).remove(key)
return True
except:
return False
#end

def _update_sandesh_status(self, status, msg=''):
ConnectionState.update(conn_type=ConnectionType.DATABASE,
name='Cassandra', status=status, message=msg,
Expand Down

0 comments on commit ccfce2b

Please sign in to comment.