~allenap/maas/yamlconf-script

« back to all changes in this revision

Viewing changes to src/provisioningserver/testing/fakeapi.py

  • Committer: Gavin Panella
  • Date: 2012-06-01 11:57:46 UTC
  • mfrom: (296.2.309 maas)
  • Revision ID: gavin.panella@canonical.com-20120601115746-e5iia0e5h8k7mpw9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
"""
13
13
 
14
14
from __future__ import (
 
15
    absolute_import,
15
16
    print_function,
16
17
    unicode_literals,
17
18
    )
22
23
    "FakeSynchronousProvisioningAPI",
23
24
    ]
24
25
 
 
26
from base64 import b64encode
25
27
from functools import wraps
26
28
 
27
29
from provisioningserver.interfaces import IProvisioningAPI
73
75
        self.distros = FakeProvisioningDatabase()
74
76
        self.profiles = FakeProvisioningDatabase()
75
77
        self.nodes = FakeProvisioningDatabase()
76
 
        # Record power_type settings for nodes (by node name).  This is
77
 
        # not part of the provisioning-server node as returned to the
78
 
        # maasserver, so it's not stored as a regular attribute even if
79
 
        # it works like one internally.
80
 
        self.power_types = {}
81
78
        # This records nodes that start/stop commands have been issued
82
79
        # for.  If a node has been started, its name maps to 'start'; if
83
80
        # it has been stopped, its name maps to 'stop' (whichever
93
90
        self.profiles[name]["distro"] = distro
94
91
        return name
95
92
 
96
 
    def add_node(self, name, profile, power_type, metadata):
 
93
    def add_node(self, name, hostname, profile, power_type, preseed_data):
 
94
        self.nodes[name]["hostname"] = hostname
97
95
        self.nodes[name]["profile"] = profile
98
96
        self.nodes[name]["mac_addresses"] = []
99
 
        self.nodes[name]["metadata"] = metadata
100
 
        self.power_types[name] = power_type
 
97
        self.nodes[name]["ks_meta"] = {
 
98
            "MAAS_PRESEED": b64encode(preseed_data),
 
99
            }
 
100
        self.nodes[name]["power_type"] = power_type
101
101
        return name
102
102
 
103
103
    def modify_distros(self, deltas):