[Kimchi-devel] [PATCH 4/5] [WOK] Make dynamic the state_dir path in Kimchi.

Aline Manera alinefm at linux.vnet.ibm.com
Wed Sep 30 15:24:09 UTC 2015


Hi Paulo,

I firstly agreed with that change but we will loose compatibility with 
older Kimchi versions.
Even though we will update the objectstore to reflect the new API, 
changing the directory structure is more intrusive IMO and it will 
impact in changing the file system in the host system and I don't agree 
Kimchi should do that without user awareness.

So my suggestion is to keep the file structure as it is today.

Regards,
Aline Manera

On 29/09/2015 10:08, pvital at linux.vnet.ibm.com wrote:
> From: Paulo Vital <pvital at linux.vnet.ibm.com>
>
> Removed the hard-coded state_dir path (/var/lib/kimchi) and make it dynamic to
> get based on PluginPaths() value. By default, this value is set to
> /var/lib/wok/plugins/kimchi.
>
> Changed the state_dir path (/var/lib/kimchi) to the new path using Wok
> structure (/var/lib/wok/plugins/kimchi) in documentation and tests.
>
> Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
> ---
>   src/wok/plugins/kimchi/docs/README.md                   | 2 +-
>   src/wok/plugins/kimchi/model/libvirtstoragepool.py      | 4 +++-
>   src/wok/plugins/kimchi/model/storagepools.py            | 2 +-
>   src/wok/plugins/kimchi/tests/test_mock_storagepool.py   | 2 +-
>   src/wok/plugins/kimchi/tests/test_mock_storagevolume.py | 2 +-
>   src/wok/plugins/kimchi/tests/test_model.py              | 2 +-
>   src/wok/plugins/kimchi/tests/test_model_storagepool.py  | 2 +-
>   src/wok/plugins/kimchi/tests/test_storagepoolxml.py     | 2 +-
>   src/wok/plugins/kimchi/tests/test_template.py           | 2 +-
>   9 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/src/wok/plugins/kimchi/docs/README.md b/src/wok/plugins/kimchi/docs/README.md
> index f400333..b52892a 100644
> --- a/src/wok/plugins/kimchi/docs/README.md
> +++ b/src/wok/plugins/kimchi/docs/README.md
> @@ -223,7 +223,7 @@ new template using the "+" button in the upper right corner.
>
>   To create a template, you need an ISO on your host or using remote one.
>   If you are willing to use your own ISO, please copy it to out of box storage
> -pool (default path is: /var/lib/kimchi/isos).
> +pool (default path is: /var/lib/wok/plugins/kimchi/isos).
>
>   Known Issues
>   ------------
> diff --git a/src/wok/plugins/kimchi/model/libvirtstoragepool.py b/src/wok/plugins/kimchi/model/libvirtstoragepool.py
> index 5da0b3b..108c381 100644
> --- a/src/wok/plugins/kimchi/model/libvirtstoragepool.py
> +++ b/src/wok/plugins/kimchi/model/libvirtstoragepool.py
> @@ -23,6 +23,7 @@ import os
>   import tempfile
>   from lxml.builder import E
>
> +from wok.config import PluginPaths
>   from wok.exception import InvalidParameter, OperationFailed, TimeoutExpired
>   from wok.rollbackcontext import RollbackContext
>   from wok.utils import parse_cmd_output, run_command, wok_log
> @@ -77,7 +78,8 @@ class NetfsPoolDef(StoragePoolDef):
>
>       def __init__(self, poolArgs):
>           super(NetfsPoolDef, self).__init__(poolArgs)
> -        self.path = '/var/lib/kimchi/nfs_mount/' + self.poolArgs['name']
> +        self.path = PluginPaths('kimchi').state_dir + '/nfs_mount/'
> +        self.path = self.path + self.poolArgs['name']
>
>       def prepare(self, conn):
>           mnt_point = tempfile.mkdtemp(dir='/tmp')
> diff --git a/src/wok/plugins/kimchi/model/storagepools.py b/src/wok/plugins/kimchi/model/storagepools.py
> index db68252..1764fe9 100644
> --- a/src/wok/plugins/kimchi/model/storagepools.py
> +++ b/src/wok/plugins/kimchi/model/storagepools.py
> @@ -79,7 +79,7 @@ class StoragePoolsModel(object):
>               pools[default_pool] = {'path': '/var/lib/libvirt/images'}
>
>           if config.get("server", "create_iso_pool") == "true":
> -            pools['ISO'] = {'path': '/var/lib/kimchi/isos'}
> +            pools['ISO'] = {'path': PluginPaths('kimchi').state_dir + '/isos'}
>
>           error_msg = ("Please, check the configuration in %s/template.conf to "
>                        "ensure it has a valid storage pool." %
> diff --git a/src/wok/plugins/kimchi/tests/test_mock_storagepool.py b/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
> index 5cf5b3e..07c3e07 100644
> --- a/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
> +++ b/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
> @@ -82,7 +82,7 @@ class MockStoragepoolTests(unittest.TestCase):
>                'path': '/tmp/kimchi-images'},
>               {'type': 'netfs', 'name': u'kīмсhīUnitTestNSFPool',
>                'source': {'host': 'localhost',
> -                        'path': '/var/lib/kimchi/nfs-pool'}},
> +                        'path': '/var/lib/wok/plugins/kimchi/nfs-pool'}},
>               {'type': 'scsi', 'name': u'kīмсhīUnitTestSCSIFCPool',
>                'source': {'adapter_name': fc_devs[0]}},
>               {'type': 'iscsi', 'name': u'kīмсhīUnitTestISCSIPool',
> diff --git a/src/wok/plugins/kimchi/tests/test_mock_storagevolume.py b/src/wok/plugins/kimchi/tests/test_mock_storagevolume.py
> index 9d0a5ad..643fe1b 100644
> --- a/src/wok/plugins/kimchi/tests/test_mock_storagevolume.py
> +++ b/src/wok/plugins/kimchi/tests/test_mock_storagevolume.py
> @@ -77,7 +77,7 @@ class MockStorageVolumeTests(unittest.TestCase):
>                'path': '/tmp/kimchi-images'},
>               {'type': 'netfs', 'name': u'kīмсhīUnitTestNSFPool',
>                'source': {'host': 'localhost',
> -                        'path': '/var/lib/kimchi/nfs-pool'}},
> +                        'path': '/var/lib/wok/plugins/kimchi/nfs-pool'}},
>               {'type': 'scsi', 'name': u'kīмсhīUnitTestSCSIFCPool',
>                'source': {'adapter_name': fc_devs[0]}},
>               {'type': 'iscsi', 'name': u'kīмсhīUnitTestISCSIPool',
> diff --git a/src/wok/plugins/kimchi/tests/test_model.py b/src/wok/plugins/kimchi/tests/test_model.py
> index 7c89048..4b8ea69 100644
> --- a/src/wok/plugins/kimchi/tests/test_model.py
> +++ b/src/wok/plugins/kimchi/tests/test_model.py
> @@ -49,7 +49,7 @@ invalid_repository_urls = ['www.fedora.org',       # missing protocol
>                              'http://www.fedora',    # invalid domain name
>                              'file:///home/foobar']  # invalid path
>
> -TMP_DIR = '/var/lib/kimchi/tests/'
> +TMP_DIR = '/var/lib/wok/plugins/kimchi/tests/'
>   UBUNTU_ISO = TMP_DIR + 'ubuntu14.04.iso'
>
>
> diff --git a/src/wok/plugins/kimchi/tests/test_model_storagepool.py b/src/wok/plugins/kimchi/tests/test_model_storagepool.py
> index 5f9b966..7c5d6eb 100644
> --- a/src/wok/plugins/kimchi/tests/test_model_storagepool.py
> +++ b/src/wok/plugins/kimchi/tests/test_model_storagepool.py
> @@ -107,7 +107,7 @@ class StoragepoolTests(unittest.TestCase):
>               self.assertEquals(len(storagepools) + 3, len(pools))
>
>               # Create a pool with an existing path
> -            tmp_path = tempfile.mkdtemp(dir='/var/lib/kimchi')
> +            tmp_path = tempfile.mkdtemp(dir='/var/lib/wok/plugins/kimchi')
>               rollback.prependDefer(os.rmdir, tmp_path)
>               req = json.dumps({'name': 'existing_path', 'type': 'dir',
>                                 'path': tmp_path})
> diff --git a/src/wok/plugins/kimchi/tests/test_storagepoolxml.py b/src/wok/plugins/kimchi/tests/test_storagepoolxml.py
> index 7e45cca..86c3198 100644
> --- a/src/wok/plugins/kimchi/tests/test_storagepoolxml.py
> +++ b/src/wok/plugins/kimchi/tests/test_storagepoolxml.py
> @@ -53,7 +53,7 @@ class StoragepoolXMLTests(unittest.TestCase):
>                    <dir path='/var/export'/>
>                  </source>
>                  <target>
> -                 <path>/var/lib/kimchi/nfs_mount/unitTestNFSPool</path>
> +                 <path>/var/lib/wok/plugins/kimchi/nfs_mount/unitTestNFSPool</path>
>                  </target>
>                </pool>
>                """},
> diff --git a/src/wok/plugins/kimchi/tests/test_template.py b/src/wok/plugins/kimchi/tests/test_template.py
> index c7de182..ca95c91 100644
> --- a/src/wok/plugins/kimchi/tests/test_template.py
> +++ b/src/wok/plugins/kimchi/tests/test_template.py
> @@ -311,7 +311,7 @@ class TemplateTests(unittest.TestCase):
>                'path': '/tmp/kimchi-images'},
>               {'type': 'netfs', 'name': u'kīмсhīUnitTestNSFPool',
>                'source': {'host': 'localhost',
> -                        'path': '/var/lib/kimchi/nfs-pool'}},
> +                        'path': '/var/lib/wok/plugins/kimchi/nfs-pool'}},
>               {'type': 'scsi', 'name': u'kīмсhīUnitTestSCSIFCPool',
>                'source': {'adapter_name': fc_devs[0]}},
>               {'type': 'iscsi', 'name': u'kīмсhīUnitTestISCSIPool',
> --
> 2.4.3




More information about the Kimchi-devel mailing list