Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUmarAsad authored Jul 20, 2023
2 parents dd11b3c + 42cba90 commit 300b353
Show file tree
Hide file tree
Showing 60 changed files with 1,454 additions and 86 deletions.
52 changes: 46 additions & 6 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, namespace, socket=None):
none-zero values.
build: sequentially increase within a minor version domain.
"""
self.CURRENT_VERSION = 'version_4_0_3'
self.CURRENT_VERSION = 'version_4_0_4'

self.TABLE_NAME = 'VERSIONS'
self.TABLE_KEY = 'DATABASE'
Expand Down Expand Up @@ -646,6 +646,7 @@ def migrate_feature_timer(self):
config['delayed'] = state
config.pop('has_timer')
self.configDB.set_entry('FEATURE', feature, config)

def migrate_route_table(self):
"""
Handle route table migration. Migrations handled:
Expand All @@ -669,6 +670,33 @@ def migrate_route_table(self):
if 'protocol' not in route_attr:
self.appDB.set(self.appDB.APPL_DB, route_key, 'protocol', '')

def migrate_dns_nameserver(self):
"""
Handle DNS_NAMESERVER table migration. Migrations handled:
If there's no DNS_NAMESERVER in config_DB, load DNS_NAMESERVER from minigraph
"""
if not self.minigraph_data or 'DNS_NAMESERVER' not in self.minigraph_data:
return
dns_table = self.configDB.get_table('DNS_NAMESERVER')
if not dns_table:
for addr, config in self.minigraph_data['DNS_NAMESERVER'].items():
self.configDB.set_entry('DNS_NAMESERVER', addr, config)

def migrate_routing_config_mode(self):
# DEVICE_METADATA - synchronous_mode entry
if not self.minigraph_data or 'DEVICE_METADATA' not in self.minigraph_data:
return
device_metadata_old = self.configDB.get_entry('DEVICE_METADATA', 'localhost')
device_metadata_new = self.minigraph_data['DEVICE_METADATA']['localhost']
# overwrite the routing-config-mode as per minigraph parser
# Criteria for update:
# if config mode is missing in base OS or if base and target modes are not same
# Eg. in 201811 mode is "unified", and in newer branches mode is "separated"
if ('docker_routing_config_mode' not in device_metadata_old and 'docker_routing_config_mode' in device_metadata_new) or \
(device_metadata_old.get('docker_routing_config_mode') != device_metadata_new.get('docker_routing_config_mode')):
device_metadata_old['docker_routing_config_mode'] = device_metadata_new.get('docker_routing_config_mode')
self.configDB.set_entry('DEVICE_METADATA', 'localhost', device_metadata_old)

def update_edgezone_aggregator_config(self):
"""
Update cable length configuration in ConfigDB for T0 neighbor interfaces
Expand Down Expand Up @@ -1041,19 +1069,29 @@ def version_4_0_3(self):
Version 4_0_3.
"""
log.log_info('Handling version_4_0_3')

self.migrate_config_db_switchport_mode()

# Updating DNS nameserver
self.migrate_dns_nameserver()
self.set_version('version_4_0_4')
return 'version_4_0_4'

def version_4_0_4(self):
"""
Version 4_0_4.
This is the latest version for master branch
"""
log.log_info('Handling version_4_0_4')

self.migrate_config_db_switchport_mode()
self.set_version('version_4_0_4')
return 'version_4_0_5'

def version_4_0_5(self):
"""
Version 4_0_5.
This is the latest version for master branch
"""
log.log_info('Handling version_4_0_5')
return None


def get_version(self):
version = self.configDB.get_entry(self.TABLE_NAME, self.TABLE_KEY)
Expand Down Expand Up @@ -1103,6 +1141,8 @@ def common_migration_ops(self):

# Updating edgezone aggregator cable length config for T0 devices
self.update_edgezone_aggregator_config()
# update FRR config mode based on minigraph parser on target image
self.migrate_routing_config_mode()

def migrate(self):
version = self.get_version()
Expand Down
Loading

0 comments on commit 300b353

Please sign in to comment.