From a3f3c4eb5facb830b61d55d17b58cd8f50c029b4 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 5 May 2014 17:42:08 -0700 Subject: [PATCH] Automatically disable/enable components not found in origins Instead of blowing up with components that are existent but not disabled, just disable them automatically if they are present in the persona file (which most will be) but not present in the origins file (which some may not be) and those components are not listed under a no-origin persona section. This is to accomodate persona files having more components than an origins file (which may be ok if those components are not actually needed). Change-Id: Ia5c51177a58ba686cf008f2958d72543705953cb --- anvil/persona.py | 25 ++++++++++++++++++++--- conf/origins/havana-2013.2.1.yaml | 4 ---- conf/origins/havana-2013.2.2.yaml | 4 ---- conf/origins/havana-2013.2.3.yaml | 2 -- conf/origins/havana-2013.2.yaml | 4 ---- conf/origins/havana-git.yaml | 4 ---- conf/personas/in-a-box/basic-all.yaml | 6 ++++++ conf/personas/in-a-box/basic-neutron.yaml | 6 ++++++ conf/personas/in-a-box/basic-qpid.yaml | 5 +++++ conf/personas/in-a-box/basic-trove.yaml | 5 +++++ conf/personas/in-a-box/basic-web.yaml | 6 ++++++ conf/personas/in-a-box/basic.yaml | 5 +++++ 12 files changed, 55 insertions(+), 21 deletions(-) diff --git a/anvil/persona.py b/anvil/persona.py index 1873e1a5..9f1a6e63 100644 --- a/anvil/persona.py +++ b/anvil/persona.py @@ -16,6 +16,7 @@ import six +from anvil import colorizer from anvil import log as logging from anvil import utils @@ -30,14 +31,32 @@ class Persona(object): self.wanted_components = components or [] self.wanted_subsystems = kargs.get('subsystems') or {} self.component_options = kargs.get('options') or {} + self.no_origins = kargs.get('no-origin') or [] def verify(self, distro, origins_fn): # Filter out components that are disabled in origins file + origins = utils.load_yaml(origins_fn) + for c in self.wanted_components: + if c not in origins: + if c in self.no_origins: + LOG.debug("Automatically enabling component %s, not" + " present in origins file %s but present in" + " desired persona %s (origin not required).", + c, origins_fn, self.source) + origins[c] = { + 'disabled': False, + } + else: + LOG.warn("Automatically disabling %s, not present in" + " origin file but present in desired" + " persona (origin required).", + colorizer.quote(c, quote_color='red')) + origins[c] = { + 'disabled': True, + } disabled_components = set(key - for key, value in six.iteritems( - utils.load_yaml(origins_fn)) + for key, value in six.iteritems(origins) if value.get('disabled')) - self.wanted_components = [c for c in self.wanted_components if c not in disabled_components] diff --git a/conf/origins/havana-2013.2.1.yaml b/conf/origins/havana-2013.2.1.yaml index a671163c..201144df 100644 --- a/conf/origins/havana-2013.2.1.yaml +++ b/conf/origins/havana-2013.2.1.yaml @@ -67,7 +67,3 @@ trove-client: trove: repo: git://github.com/openstack/trove.git tag: 2013.2.1 -oslo-messaging: - disabled: True -pycadf: - disabled: True diff --git a/conf/origins/havana-2013.2.2.yaml b/conf/origins/havana-2013.2.2.yaml index b387bc5e..3e08c039 100644 --- a/conf/origins/havana-2013.2.2.yaml +++ b/conf/origins/havana-2013.2.2.yaml @@ -67,7 +67,3 @@ trove-client: trove: repo: git://github.com/openstack/trove.git tag: 2013.2.2 -oslo-messaging: - disabled: True -pycadf: - disabled: True diff --git a/conf/origins/havana-2013.2.3.yaml b/conf/origins/havana-2013.2.3.yaml index 21978cf4..9c482e07 100644 --- a/conf/origins/havana-2013.2.3.yaml +++ b/conf/origins/havana-2013.2.3.yaml @@ -67,5 +67,3 @@ trove-client: trove: repo: git://github.com/openstack/trove.git tag: 2013.2 -oslo-messaging: - disabled: True diff --git a/conf/origins/havana-2013.2.yaml b/conf/origins/havana-2013.2.yaml index 5ea1e576..48421321 100644 --- a/conf/origins/havana-2013.2.yaml +++ b/conf/origins/havana-2013.2.yaml @@ -67,7 +67,3 @@ trove-client: trove: repo: git://github.com/openstack/trove.git tag: 2013.2 -oslo-messaging: - disabled: True -pycadf: - disabled: True diff --git a/conf/origins/havana-git.yaml b/conf/origins/havana-git.yaml index 612abbec..7bb3075d 100644 --- a/conf/origins/havana-git.yaml +++ b/conf/origins/havana-git.yaml @@ -70,7 +70,3 @@ trove-client: trove: repo: git://github.com/openstack/trove.git branch: stable/havana -oslo-messaging: - disabled: True -pycadf: - disabled: True diff --git a/conf/personas/in-a-box/basic-all.yaml b/conf/personas/in-a-box/basic-all.yaml index b0d15ec7..547f76a1 100644 --- a/conf/personas/in-a-box/basic-all.yaml +++ b/conf/personas/in-a-box/basic-all.yaml @@ -93,6 +93,12 @@ subsystems: - collector - compute - central +no-origin: +# These components don't need an origin to be enabled +- general +- db +- rabbit-mq +- openvswitch supports: - rhel ... diff --git a/conf/personas/in-a-box/basic-neutron.yaml b/conf/personas/in-a-box/basic-neutron.yaml index 2557e356..cf6dce37 100644 --- a/conf/personas/in-a-box/basic-neutron.yaml +++ b/conf/personas/in-a-box/basic-neutron.yaml @@ -67,6 +67,12 @@ subsystems: - api - scheduler - volume +no-origin: +# These components don't need an origin to be enabled +- general +- db +- rabbit-mq +- openvswitch supports: - rhel ... diff --git a/conf/personas/in-a-box/basic-qpid.yaml b/conf/personas/in-a-box/basic-qpid.yaml index aab03b5f..de6bee08 100644 --- a/conf/personas/in-a-box/basic-qpid.yaml +++ b/conf/personas/in-a-box/basic-qpid.yaml @@ -55,6 +55,11 @@ subsystems: - api - scheduler - volume +no-origin: +# These components don't need an origin to be enabled +- general +- db +- qpid supports: - rhel ... diff --git a/conf/personas/in-a-box/basic-trove.yaml b/conf/personas/in-a-box/basic-trove.yaml index 4bc6d186..e36a167a 100644 --- a/conf/personas/in-a-box/basic-trove.yaml +++ b/conf/personas/in-a-box/basic-trove.yaml @@ -57,6 +57,11 @@ subsystems: - api - scheduler - volume +no-origin: +# These components don't need an origin to be enabled +- general +- db +- rabbit-mq supports: - rhel ... diff --git a/conf/personas/in-a-box/basic-web.yaml b/conf/personas/in-a-box/basic-web.yaml index acc51e7f..ea34c56e 100644 --- a/conf/personas/in-a-box/basic-web.yaml +++ b/conf/personas/in-a-box/basic-web.yaml @@ -79,6 +79,12 @@ subsystems: - api - scheduler - volume +no-origin: +# These components don't need an origin to be enabled +- general +- db +- rabbit-mq +- openvswitch supports: - rhel ... diff --git a/conf/personas/in-a-box/basic.yaml b/conf/personas/in-a-box/basic.yaml index 546a9976..3aaed5b3 100644 --- a/conf/personas/in-a-box/basic.yaml +++ b/conf/personas/in-a-box/basic.yaml @@ -55,6 +55,11 @@ subsystems: - api - scheduler - volume +no-origin: +# These components don't need an origin to be enabled +- general +- db +- rabbit-mq supports: - rhel ...