add localstorage label handling 92/2092/1
authorBalint Tobik <balint.tobik@nokia.com>
Tue, 3 Dec 2019 15:55:12 +0000 (16:55 +0100)
committerBalint Tobik <balint.tobik@nokia.com>
Tue, 3 Dec 2019 15:58:02 +0000 (16:58 +0100)
Signed-off-by: Balint Tobik <balint.tobik@nokia.com>
Change-Id: I61dfedb8bea91cb072dd50217b3f3b844c6b0c2f

cmdatahandlers/src/cmdatahandlers/hosts/config.py

index df31dc1..7547dbe 100644 (file)
@@ -178,6 +178,9 @@ class Config(config.Config):
         if self.is_sriov_enabled(hostname):
             labels.update({"sriov": "enabled"})
 
         if self.is_sriov_enabled(hostname):
             labels.update({"sriov": "enabled"})
 
+        if self.is_localstorage_used(hostname):
+            labels.update({"localstorage": "enabled"})
+            
         black_list = ['name']
         return {name: attributes
                 for name, attributes in labels.iteritems()
         black_list = ['name']
         return {name: attributes
                 for name, attributes in labels.iteritems()
@@ -237,6 +240,16 @@ class Config(config.Config):
                 return True
         return False
 
                 return True
         return False
 
+    def is_localstorage_used(self, hostname):
+        storageprofs = self.get_storage_profiles(hostname)
+        storageprofconf = self.confman.get_storage_profiles_config_handler()
+        for profile in storageprofs:
+            if "shared" in self.config[storageprofconf.ROOT][profile]:
+                for volume in self.config[storageprofconf.ROOT][profile]["shared"]["volumes"]:
+                    if volume["name"] == 'caas_app':
+                        return True
+        return False
+        
     def get_enabled_hosts(self):
         """ get the list of enabled hosts in the cloud
 
     def get_enabled_hosts(self):
         """ get the list of enabled hosts in the cloud