Reload config after config modifications in shell
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Fri, 16 Nov 2012 16:59:19 +0000 (18:59 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Fri, 16 Nov 2012 16:59:19 +0000 (18:59 +0200)
kamaki/cli/commands/config_cli.py
kamaki/cli/config.py

index e76bda9..c726747 100644 (file)
@@ -77,6 +77,7 @@ class config_set(_command_init):
         section = section or 'global'
         self.config.set(section, key, value)
         self.config.write()
+        self.config.reload()
 
 
 @command(config_cmds)
@@ -88,3 +89,4 @@ class config_delete(_command_init):
         section = section or 'global'
         self.config.remove_option(section, key)
         self.config.write()
+        self.config.reload()
index f2f51a9..cfb893f 100644 (file)
@@ -106,6 +106,9 @@ class Config(RawConfigParser):
             for option, val in options.items():
                 self.set(section, option, val)
 
+    def reload(self):
+        self = self.__init__(self.path)
+
     def apis(self):
         return [api for api in self.sections() if api != 'global']
 
@@ -148,4 +151,5 @@ class Config(RawConfigParser):
         with open(self.path, 'w') as f:
             os.chmod(self.path, 0600)
             f.write(HEADER.lstrip())
+            f.flush()
             RawConfigParser.write(self, f)