implement cdist install
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
2c30704ba7
commit
54815e2b29
7 changed files with 58 additions and 120 deletions
|
|
@ -158,7 +158,6 @@ class Config(object):
|
|||
self.local.save_cache()
|
||||
self.log.info("Finished successful run in %s seconds", time.time() - start_time)
|
||||
|
||||
|
||||
def object_list(self):
|
||||
"""Short name for object list retrieval"""
|
||||
for cdist_object in core.CdistObject.list_objects(self.local.object_path,
|
||||
|
|
|
|||
|
|
@ -101,6 +101,11 @@ class CdistType(object):
|
|||
"""Check whether a type is a singleton."""
|
||||
return os.path.isfile(os.path.join(self.absolute_path, "singleton"))
|
||||
|
||||
@property
|
||||
def is_install(self):
|
||||
"""Check whether a type is used for installation (if not: for configuration)"""
|
||||
return os.path.isfile(os.path.join(self.absolute_path, "install"))
|
||||
|
||||
@property
|
||||
def explorers(self):
|
||||
"""Return a list of available explorers"""
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2012-2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
|
|||
37
cdist/install.py
Normal file
37
cdist/install.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# 2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
import cdist.config
|
||||
import cdist.core
|
||||
|
||||
|
||||
class Install(cdist.config.Config):
|
||||
def object_list(self):
|
||||
"""Short name for object list retrieval.
|
||||
In install mode, we only care about install objects.
|
||||
"""
|
||||
for cdist_object in cdist.core.CdistObject.list_objects(self.local.object_path,
|
||||
self.local.type_path):
|
||||
if cdist_object.cdist_type.is_install:
|
||||
yield cdist_object
|
||||
else:
|
||||
self.log.debug("Running in install mode, ignoring non install object: {0}".format(cdist_object))
|
||||
|
|
@ -106,6 +106,16 @@ class TypeTestCase(test.CdistTestCase):
|
|||
cdist_type = core.CdistType(base_path, '__not_singleton')
|
||||
self.assertFalse(cdist_type.is_singleton)
|
||||
|
||||
def test_install_is_install(self):
|
||||
base_path = fixtures
|
||||
cdist_type = core.CdistType(base_path, '__install')
|
||||
self.assertTrue(cdist_type.is_install)
|
||||
|
||||
def test_not_install_is_install(self):
|
||||
base_path = fixtures
|
||||
cdist_type = core.CdistType(base_path, '__not_install')
|
||||
self.assertFalse(cdist_type.is_install)
|
||||
|
||||
def test_with_explorers(self):
|
||||
base_path = fixtures
|
||||
cdist_type = core.CdistType(base_path, '__with_explorers')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue