On 28 March 2013 15:50, Helga Velroyen <hel...@google.com> wrote: > This patch is a preparation for later patches in QA in this series > it refactors the instance QA to make it more flexible regarding > creation of instances with different disk templates. Right now we > only support creation of instances with disk templates 'drbd', 'plain', > and 'diskless'. With our current plans to improve storage handling, > we should make QA more flexible to also create instances of other > templates. This patch restructures the code in a way that instances > can be created more easily to be used in other QA scripts. > > Signed-off-by: Helga Velroyen <hel...@google.com> > --- > qa/qa_instance.py | 88 > ++++++++++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 80 insertions(+), 8 deletions(-) > > diff --git a/qa/qa_instance.py b/qa/qa_instance.py > index f1c2ab7..9ca36eb 100644 > --- a/qa/qa_instance.py > +++ b/qa/qa_instance.py > @@ -93,6 +105,68 @@ def _DiskTest(node, disk_template, fail=False): > return None > > > +def _CreateInstanceByDiskTemplateOneNode(nodes, disk_template, fail=False): > + """Creates an instance using the given disk template for disk templates > + for which one given node is sufficient. These templates are for example: > + plain, diskless, file, sharedfile, blockdev, rados. > + > + @type nodes: list of nodes > + @param nodes: a list of nodes, whose first element is used to create the > + instance > + @type disk_template: string > + @param disk_template: the disk template to be used by the instance > + @return: the created instance > + > + """ > + assert len(nodes) > 0
Why not "assert len(nodes) == 1"? > + return _CreateInstanceByDiskTemplateRaw( > + nodes[0].primary, disk_template, fail=fail) > + > + > +def _CreateInstanceDrbd8(nodes, fail=False): > + """Creates an instance using disk template 'drbd' on the given nodes. > + > + @type nodes: list of nodes > + @param nodes: nodes to be used by the instance > + @return: the created instance > + > + """ > + assert len(nodes) > 1 Same here. Bernardo