|
36 | 36 | SYSTEMCTL_ACTION_RESTART="restart"
|
37 | 37 | SYSTEMCTL_ACTION_RESET_FAILED="reset-failed"
|
38 | 38 |
|
| 39 | +DEFAULT_NAMESPACE = '' |
39 | 40 | # ========================== Syslog wrappers ==========================
|
40 | 41 |
|
41 | 42 | def log_debug(msg):
|
@@ -632,6 +633,8 @@ def config():
|
632 | 633 | if os.geteuid() != 0:
|
633 | 634 | exit("Root privileges are required for this operation")
|
634 | 635 |
|
| 636 | + SonicDBConfig.load_sonic_global_db_config() |
| 637 | + |
635 | 638 |
|
636 | 639 | config.add_command(aaa.aaa)
|
637 | 640 | config.add_command(aaa.tacacs)
|
@@ -915,26 +918,46 @@ def load_minigraph():
|
915 | 918 | log_info("'load_minigraph' stopping services...")
|
916 | 919 | _stop_services()
|
917 | 920 |
|
918 |
| - config_db = ConfigDBConnector() |
919 |
| - config_db.connect() |
920 |
| - client = config_db.get_redis_client(config_db.CONFIG_DB) |
921 |
| - client.flushdb() |
922 |
| - if os.path.isfile('/etc/sonic/init_cfg.json'): |
923 |
| - command = "{} -H -m -j /etc/sonic/init_cfg.json --write-to-db".format(SONIC_CFGGEN_PATH) |
924 |
| - else: |
925 |
| - command = "{} -H -m --write-to-db".format(SONIC_CFGGEN_PATH) |
926 |
| - run_command(command, display_cmd=True) |
927 |
| - client.set(config_db.INIT_INDICATOR, 1) |
928 |
| - if device_type != 'MgmtToRRouter': |
929 |
| - run_command('pfcwd start_default', display_cmd=True) |
| 921 | + # For Single Asic platform the namespace list has the empty string |
| 922 | + # for mulit Asic platform the empty string to generate the config |
| 923 | + # for host |
| 924 | + namespace_list = [DEFAULT_NAMESPACE] |
| 925 | + num_npus = sonic_device_util.get_num_npus() |
| 926 | + if num_npus > 1: |
| 927 | + namespace_list += sonic_device_util.get_namespaces() |
| 928 | + |
| 929 | + for namespace in namespace_list: |
| 930 | + if namespace is DEFAULT_NAMESPACE: |
| 931 | + config_db = ConfigDBConnector() |
| 932 | + cfggen_namespace_option = " " |
| 933 | + ns_cmd_prefix = " " |
| 934 | + else: |
| 935 | + config_db = ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) |
| 936 | + cfggen_namespace_option = " -n {}".format(namespace) |
| 937 | + ns_cmd_prefix = "sudo ip netns exec {}".format(namespace) |
| 938 | + config_db.connect() |
| 939 | + client = config_db.get_redis_client(config_db.CONFIG_DB) |
| 940 | + client.flushdb() |
| 941 | + if os.path.isfile('/etc/sonic/init_cfg.json'): |
| 942 | + command = "{} -H -m -j /etc/sonic/init_cfg.json {} --write-to-db".format(SONIC_CFGGEN_PATH, cfggen_namespace_option) |
| 943 | + else: |
| 944 | + command = "{} -H -m --write-to-db {} ".format(SONIC_CFGGEN_PATH,cfggen_namespace_option) |
| 945 | + run_command(command, display_cmd=True) |
| 946 | + client.set(config_db.INIT_INDICATOR, 1) |
| 947 | + |
| 948 | + # These commands are not run for host on multi asic platform |
| 949 | + if num_npus == 1 or namespace is not DEFAULT_NAMESPACE: |
| 950 | + if device_type != 'MgmtToRRouter': |
| 951 | + run_command('{} pfcwd start_default'.format(ns_cmd_prefix), display_cmd=True) |
| 952 | + run_command("{} config qos reload".format(ns_cmd_prefix), display_cmd=True) |
| 953 | + |
| 954 | + # Write latest db version string into db |
| 955 | + db_migrator='/usr/bin/db_migrator.py' |
| 956 | + if os.path.isfile(db_migrator) and os.access(db_migrator, os.X_OK): |
| 957 | + run_command(db_migrator + ' -o set_version' + cfggen_namespace_option) |
| 958 | + |
930 | 959 | if os.path.isfile('/etc/sonic/acl.json'):
|
931 | 960 | run_command("acl-loader update full /etc/sonic/acl.json", display_cmd=True)
|
932 |
| - run_command("config qos reload", display_cmd=True) |
933 |
| - |
934 |
| - # Write latest db version string into db |
935 |
| - db_migrator='/usr/bin/db_migrator.py' |
936 |
| - if os.path.isfile(db_migrator) and os.access(db_migrator, os.X_OK): |
937 |
| - run_command(db_migrator + ' -o set_version') |
938 | 961 |
|
939 | 962 | # We first run "systemctl reset-failed" to remove the "failed"
|
940 | 963 | # status from all services before we attempt to restart them
|
|
0 commit comments