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
This commit is contained in:
Joshua Harlow 2014-05-05 17:42:08 -07:00
parent b5860111d0
commit a3f3c4eb5f
12 changed files with 55 additions and 21 deletions

@ -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]

@ -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

@ -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

@ -67,5 +67,3 @@ trove-client:
trove:
repo: git://github.com/openstack/trove.git
tag: 2013.2
oslo-messaging:
disabled: True

@ -67,7 +67,3 @@ trove-client:
trove:
repo: git://github.com/openstack/trove.git
tag: 2013.2
oslo-messaging:
disabled: True
pycadf:
disabled: True

@ -70,7 +70,3 @@ trove-client:
trove:
repo: git://github.com/openstack/trove.git
branch: stable/havana
oslo-messaging:
disabled: True
pycadf:
disabled: True

@ -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
...

@ -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
...

@ -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
...

@ -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
...

@ -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
...

@ -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
...