Migrates Apex to Python
[apex.git] / apex / inventory / inventory.py
similarity index 88%
rename from lib/python/apex/inventory.py
rename to apex/inventory/inventory.py
index 64f47b4..dd731a8 100644 (file)
@@ -7,12 +7,13 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
-import yaml
 import json
 import platform
 
-from .common import constants
-from .common import utils
+import yaml
+
+from apex.common import constants
+from apex.common import utils
 
 
 class Inventory(dict):
@@ -60,7 +61,7 @@ class Inventory(dict):
         super().__init__({'nodes': list(map(munge_nodes, init_dict['nodes']))})
 
         # verify number of nodes
-        if ha and len(self['nodes']) < 5:
+        if ha and len(self['nodes']) < 5 and not virtual:
             raise InventoryException('You must provide at least 5 '
                                      'nodes for HA baremetal deployment')
         elif len(self['nodes']) < 2:
@@ -79,16 +80,6 @@ class Inventory(dict):
     def dump_instackenv_json(self):
         print(json.dumps(dict(self), sort_keys=True, indent=4))
 
-    def dump_bash(self, path=None):
-        """
-        Prints settings for bash consumption.
-
-        If optional path is provided, bash string will be written to the file
-        instead of stdout.
-        """
-        bash_str = "{}={}\n".format('root_disk_list', str(self.root_device))
-        utils.write_str(bash_str, path)
-
 
 class InventoryException(Exception):
     def __init__(self, value):