~rvb/maas/bug-1070765-hostname2

« back to all changes in this revision

Viewing changes to src/provisioningserver/tests/test_tftp.py

[r=julian-edwards][bug=][author=allenap] Use the node-facing address of the cluster controller as the iSCSI host.

The cluster and node addresses are passed over to the pxeconfig view.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    inlineCallbacks,
36
36
    succeed,
37
37
    )
 
38
from twisted.python import context
38
39
from zope.interface.verify import verifyObject
39
40
 
40
41
 
213
214
        mac = factory.getRandomMACAddress(b"-")
214
215
        config_path = compose_config_path(mac)
215
216
        backend = TFTPBackend(self.make_dir(), b"http://example.com/")
 
217
        # python-tx-tftp sets up call context so that backends can discover
 
218
        # more about the environment in which they're running.
 
219
        call_context = {
 
220
            "local": (
 
221
                factory.getRandomIPAddress(),
 
222
                factory.getRandomPort()),
 
223
            "remote": (
 
224
                factory.getRandomIPAddress(),
 
225
                factory.getRandomPort()),
 
226
            }
216
227
 
217
228
        @partial(self.patch, backend, "get_config_reader")
218
229
        def get_config_reader(params):
220
231
            params_json_reader = BytesReader(params_json)
221
232
            return succeed(params_json_reader)
222
233
 
223
 
        reader = yield backend.get_reader(config_path)
 
234
        reader = yield context.call(
 
235
            call_context, backend.get_reader, config_path)
224
236
        output = reader.read(10000)
225
 
        expected_params = dict(mac=mac)
 
237
        # The addresses provided by python-tx-tftp in the call context are
 
238
        # passed over the wire as address:port strings.
 
239
        expected_params = {
 
240
            "mac": mac,
 
241
            "local": call_context["local"][0],  # address only.
 
242
            "remote": call_context["remote"][0],  # address only.
 
243
            }
226
244
        observed_params = json.loads(output)
227
245
        self.assertEqual(expected_params, observed_params)
228
246