Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cinder/cinder/api/contrib/extended_snapshot_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _extend_snapshot(self, req, resp_snap):
def show(self, req, resp_obj, id):
context = req.environ['cinder.context']
if authorize(context):
# Attach our slave template to the response object
# Attach our subordinate template to the response object
resp_obj.attach(xml=ExtendedSnapshotAttributeTemplate())
snapshot = resp_obj.obj['snapshot']
self._extend_snapshot(req, snapshot)
Expand All @@ -58,7 +58,7 @@ def show(self, req, resp_obj, id):
def detail(self, req, resp_obj):
context = req.environ['cinder.context']
if authorize(context):
# Attach our slave template to the response object
# Attach our subordinate template to the response object
resp_obj.attach(xml=ExtendedSnapshotAttributesTemplate())
for snapshot in list(resp_obj.obj['snapshots']):
self._extend_snapshot(req, snapshot)
Expand Down Expand Up @@ -93,7 +93,7 @@ def construct(self):
make_snapshot(root)
alias = Extended_snapshot_attributes.alias
namespace = Extended_snapshot_attributes.namespace
return xmlutil.SlaveTemplate(root, 1, nsmap={alias: namespace})
return xmlutil.SubordinateTemplate(root, 1, nsmap={alias: namespace})


class ExtendedSnapshotAttributesTemplate(xmlutil.TemplateBuilder):
Expand All @@ -104,4 +104,4 @@ def construct(self):
make_snapshot(elem)
alias = Extended_snapshot_attributes.alias
namespace = Extended_snapshot_attributes.namespace
return xmlutil.SlaveTemplate(root, 1, nsmap={alias: namespace})
return xmlutil.SubordinateTemplate(root, 1, nsmap={alias: namespace})
2 changes: 1 addition & 1 deletion cinder/cinder/api/openstack/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def preserialize(self, content_type, default_serializers=None):
self.serializer = serializer()

def attach(self, **kwargs):
"""Attach slave templates to serializers."""
"""Attach subordinate templates to serializers."""

if self.media_type in kwargs:
self.serializer.attach(kwargs[self.media_type])
Expand Down
122 changes: 61 additions & 61 deletions cinder/cinder/api/xmlutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,13 @@ def wrap(self):
# We are a template
return self

def apply(self, master):
"""Hook method for determining slave applicability.
def apply(self, main):
"""Hook method for determining subordinate applicability.

An overridable hook method used to determine if this template
is applicable as a slave to a given master template.
is applicable as a subordinate to a given main template.

:param master: The master template to test.
:param main: The main template to test.
"""

return True
Expand All @@ -711,17 +711,17 @@ def tree(self):
return "%r: %s" % (self, self.root.tree())


class MasterTemplate(Template):
"""Represent a master template.
class MainTemplate(Template):
"""Represent a main template.

Master templates are versioned derivatives of templates that
additionally allow slave templates to be attached. Slave
Main templates are versioned derivatives of templates that
additionally allow subordinate templates to be attached. Subordinate
templates allow modification of the serialized result without
directly changing the master.
directly changing the main.
"""

def __init__(self, root, version, nsmap=None):
"""Initialize a master template.
"""Initialize a main template.

:param root: The root element of the template.
:param version: The version number of the template.
Expand All @@ -730,9 +730,9 @@ def __init__(self, root, version, nsmap=None):
template.
"""

super(MasterTemplate, self).__init__(root, nsmap)
super(MainTemplate, self).__init__(root, nsmap)
self.version = version
self.slaves = []
self.subordinates = []

def __repr__(self):
"""Return string representation of the template."""
Expand All @@ -746,89 +746,89 @@ def _siblings(self):

An overridable hook method to return the siblings of the root
element. This is the root element plus the root elements of
all the slave templates.
all the subordinate templates.
"""

return [self.root] + [slave.root for slave in self.slaves]
return [self.root] + [subordinate.root for subordinate in self.subordinates]

def _nsmap(self):
"""Hook method for computing the namespace dictionary.

An overridable hook method to return the namespace dictionary.
The namespace dictionary is computed by taking the master
The namespace dictionary is computed by taking the main
template's namespace dictionary and updating it from all the
slave templates.
subordinate templates.
"""

nsmap = self.nsmap.copy()
for slave in self.slaves:
nsmap.update(slave._nsmap())
for subordinate in self.subordinates:
nsmap.update(subordinate._nsmap())
return nsmap

def attach(self, *slaves):
"""Attach one or more slave templates.
def attach(self, *subordinates):
"""Attach one or more subordinate templates.

Attaches one or more slave templates to the master template.
Slave templates must have a root element with the same tag as
the master template. The slave template's apply() method will
be called to determine if the slave should be applied to this
master; if it returns False, that slave will be skipped.
(This allows filtering of slaves based on the version of the
master template.)
Attaches one or more subordinate templates to the main template.
Subordinate templates must have a root element with the same tag as
the main template. The subordinate template's apply() method will
be called to determine if the subordinate should be applied to this
main; if it returns False, that subordinate will be skipped.
(This allows filtering of subordinates based on the version of the
main template.)
"""

slave_list = []
for slave in slaves:
slave = slave.wrap()
subordinate_list = []
for subordinate in subordinates:
subordinate = subordinate.wrap()

# Make sure we have a tree match
if slave.root.tag != self.root.tag:
msg = (_("Template tree mismatch; adding slave %(slavetag)s "
"to master %(mastertag)s") %
{'slavetag': slave.root.tag,
'mastertag': self.root.tag})
if subordinate.root.tag != self.root.tag:
msg = (_("Template tree mismatch; adding subordinate %(subordinatetag)s "
"to main %(maintag)s") %
{'subordinatetag': subordinate.root.tag,
'maintag': self.root.tag})
raise ValueError(msg)

# Make sure slave applies to this template
if not slave.apply(self):
# Make sure subordinate applies to this template
if not subordinate.apply(self):
continue

slave_list.append(slave)
subordinate_list.append(subordinate)

# Add the slaves
self.slaves.extend(slave_list)
# Add the subordinates
self.subordinates.extend(subordinate_list)

def copy(self):
"""Return a copy of this master template."""
"""Return a copy of this main template."""

# Return a copy of the MasterTemplate
# Return a copy of the MainTemplate
tmp = self.__class__(self.root, self.version, self.nsmap)
tmp.slaves = self.slaves[:]
tmp.subordinates = self.subordinates[:]
return tmp


class SlaveTemplate(Template):
"""Represent a slave template.
class SubordinateTemplate(Template):
"""Represent a subordinate template.

Slave templates are versioned derivatives of templates. Each
slave has a minimum version and optional maximum version of the
master template to which they can be attached.
Subordinate templates are versioned derivatives of templates. Each
subordinate has a minimum version and optional maximum version of the
main template to which they can be attached.
"""

def __init__(self, root, min_vers, max_vers=None, nsmap=None):
"""Initialize a slave template.
"""Initialize a subordinate template.

:param root: The root element of the template.
:param min_vers: The minimum permissible version of the master
template for this slave template to apply.
:param max_vers: An optional upper bound for the master
:param min_vers: The minimum permissible version of the main
template for this subordinate template to apply.
:param max_vers: An optional upper bound for the main
template version.
:param nsmap: An optional namespace dictionary to be
associated with the root element of the
template.
"""

super(SlaveTemplate, self).__init__(root, nsmap)
super(SubordinateTemplate, self).__init__(root, nsmap)
self.min_vers = min_vers
self.max_vers = max_vers

Expand All @@ -839,23 +839,23 @@ def __repr__(self):
(self.__class__.__module__, self.__class__.__name__,
self.min_vers, self.max_vers, id(self)))

def apply(self, master):
"""Hook method for determining slave applicability.
def apply(self, main):
"""Hook method for determining subordinate applicability.

An overridable hook method used to determine if this template
is applicable as a slave to a given master template. This
version requires the master template to have a version number
is applicable as a subordinate to a given main template. This
version requires the main template to have a version number
between min_vers and max_vers.

:param master: The master template to test.
:param main: The main template to test.
"""

# Does the master meet our minimum version requirement?
if master.version < self.min_vers:
# Does the main meet our minimum version requirement?
if main.version < self.min_vers:
return False

# How about our maximum version requirement?
if self.max_vers is not None and master.version > self.max_vers:
if self.max_vers is not None and main.version > self.max_vers:
return False

return True
Expand Down
2 changes: 1 addition & 1 deletion cinder/cinder/compute/aggregate_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
A 'created' aggregate becomes 'changing' during the first request of
adding a host. During a 'changing' status no other requests will be accepted;
this is to allow the hypervisor layer to instantiate the underlying pool
without any potential race condition that may incur in master/slave-based
without any potential race condition that may incur in main/subordinate-based
configurations. The aggregate goes into the 'active' state when the underlying
pool has been correctly instantiated.
All other operations (e.g. add/remove hosts) that succeed will keep the
Expand Down
4 changes: 2 additions & 2 deletions cinder/cinder/openstack/common/gettextutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ def get_available_languages(domain):
# order matters) since our in-line message strings are en_US
language_list = ['en_US']
# NOTE(luisg): Babel <1.0 used a function called list(), which was
# renamed to locale_identifiers() in >=1.0, the requirements master list
# renamed to locale_identifiers() in >=1.0, the requirements main list
# requires >=0.9.6, uncapped, so defensively work with both. We can remove
# this check when the master list updates to >=1.0, and update all projects
# this check when the main list updates to >=1.0, and update all projects
list_identifiers = (getattr(localedata, 'list', None) or
getattr(localedata, 'locale_identifiers'))
locale_identifiers = list_identifiers()
Expand Down
Loading