~maas-committers/maas/trunk

« back to all changes in this revision

Viewing changes to src/maasserver/clusterrpc/testing/boot_images.py

[r=allenap][bug=1366108][author=blake-rouse] Use get_boot_images_for RPC call for determining the preseed type. This removes the need to use BootImage table and contacts the cluster directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Helpers for boot image rpc testing."""
 
5
 
 
6
from __future__ import (
 
7
    absolute_import,
 
8
    print_function,
 
9
    unicode_literals,
 
10
    )
 
11
 
 
12
str = None
 
13
 
 
14
__metaclass__ = type
 
15
__all__ = [
 
16
    'make_rpc_boot_image',
 
17
    ]
 
18
 
 
19
from maasserver.testing.factory import factory
 
20
 
 
21
 
 
22
def make_rpc_boot_image(
 
23
        osystem=None, release=None, architecture=None, subarchitecture=None,
 
24
        label=None, purpose=None, xinstall_type=None, xinstall_path=None):
 
25
    """Return boot image that would be returned from a ListBootImages RPC call.
 
26
    """
 
27
    if osystem is None:
 
28
        osystem = factory.make_name('os')
 
29
    if release is None:
 
30
        release = factory.make_name('series')
 
31
    if architecture is None:
 
32
        architecture = factory.make_name('arch')
 
33
    if subarchitecture is None:
 
34
        subarchitecture = factory.make_name('subarch')
 
35
    if label is None:
 
36
        label = factory.make_name('label')
 
37
    if purpose is None:
 
38
        purpose = factory.make_name('purpose')
 
39
    if xinstall_type is None:
 
40
        xinstall_type = factory.make_name('xi_type')
 
41
    if xinstall_path is None:
 
42
        xinstall_path = factory.make_name('xi_path')
 
43
    return {
 
44
        'osystem': osystem,
 
45
        'release': release,
 
46
        'architecture': architecture,
 
47
        'subarchitecture': subarchitecture,
 
48
        'label': label,
 
49
        'purpose': purpose,
 
50
        'xinstall_type': xinstall_type,
 
51
        'xinstall_path': xinstall_path,
 
52
        }