← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/decobblerate-pserv-config into lp:maas

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/decobblerate-pserv-config into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/maas/decobblerate-pserv-config/+merge/119892

Still not hitting those import problems that I got when trying to do all these things in one big branch.  Goes to show, I guess, why baby steps are better.


Jeroen
-- 
https://code.launchpad.net/~jtv/maas/decobblerate-pserv-config/+merge/119892
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/decobblerate-pserv-config into lp:maas.
=== modified file 'etc/pserv.yaml'
--- etc/pserv.yaml	2012-07-31 16:31:44 +0000
+++ etc/pserv.yaml	2012-08-16 10:55:23 +0000
@@ -2,22 +2,6 @@
 ## Provisioning Server (pserv) configuration.
 ##
 
-## The port on which the Provisioning API will be made available.
-#
-# port: 5241
-
-## The credentials which the Provisioning API will require.
-#
-# username: <current user>
-# password:
-password: "test"
-
-## Network interface to bind the service on.
-# Keep this pointed at the loopback interface unless you really know what
-# you're doing.
-#
-# interface: "127.0.0.1"
-
 ## Where to log. This log can be rotated by sending SIGUSR1 to the
 ## running server.
 #
@@ -44,19 +28,6 @@
   # password: "test"
   # vhost: "/"
 
-## Cobbler configuration.  Defaults to the virtual development environment
-# (vdenv) cobbler.
-#
-cobbler:
-  # url: http://localhost/cobbler_api
-  # username: <current user>
-  # password: "test"
-
-  # vdenv specific; see vdenv/README.txt.
-  url: http://local.cobbler.dev/cobbler_api
-  username: cobbler
-  password: xcobbler
-
 ## TFTP configuration.
 #
 tftp:

=== modified file 'src/metadataserver/tests/test_api.py'
--- src/metadataserver/tests/test_api.py	2012-08-16 07:32:11 +0000
+++ src/metadataserver/tests/test_api.py	2012-08-16 10:55:23 +0000
@@ -46,7 +46,6 @@
     NodeUserData,
     )
 from metadataserver.nodeinituser import get_node_init_user
-from provisioningserver.testing.factory import ProvisioningFakeFactory
 
 
 class TestHelpers(DjangoTestCase):
@@ -119,7 +118,7 @@
         self.assertEqual(node, get_queried_node(request))
 
 
-class TestViews(DjangoTestCase, ProvisioningFakeFactory):
+class TestViews(DjangoTestCase):
     """Tests for the API views."""
 
     def make_node_client(self, node=None):
@@ -592,7 +591,7 @@
             response)
 
 
-class TestEnlistViews(DjangoTestCase, ProvisioningFakeFactory):
+class TestEnlistViews(DjangoTestCase):
     """Tests for the enlistment metadata views."""
 
     def test_get_instance_id(self):

=== modified file 'src/provisioningserver/config.py'
--- src/provisioningserver/config.py	2012-07-31 16:31:44 +0000
+++ src/provisioningserver/config.py	2012-08-16 10:55:23 +0000
@@ -15,10 +15,7 @@
     ]
 
 from getpass import getuser
-from os import (
-    environ,
-    urandom,
-    )
+from os import environ
 from os.path import abspath
 from threading import RLock
 
@@ -58,19 +55,6 @@
     vhost = String(if_missing="/")
 
 
-class ConfigCobbler(Schema):
-    """Configuration validator for connecting to Cobbler."""
-
-    if_key_missing = None
-
-    url = URL(
-        add_http=True, require_tld=False,
-        if_missing=b"http://localhost/cobbler_api";,
-        )
-    username = String(if_missing=getuser())
-    password = String(if_missing=b"test")
-
-
 class ConfigTFTP(Schema):
     """Configuration validator for the TFTP service."""
 
@@ -117,14 +101,9 @@
 
     if_key_missing = None
 
-    interface = String(if_empty=b"", if_missing=b"127.0.0.1")
-    port = Int(min=1, max=65535, if_missing=5241)
-    username = String(not_empty=True, if_missing=getuser())
-    password = String(not_empty=True, if_missing=urandom(12))
     logfile = String(if_empty=b"pserv.log", if_missing=b"pserv.log")
     oops = ConfigOops
     broker = ConfigBroker
-    cobbler = ConfigCobbler
     tftp = ConfigTFTP
 
     @classmethod

=== removed file 'src/provisioningserver/testing/factory.py'
--- src/provisioningserver/testing/factory.py	2012-08-16 06:37:22 +0000
+++ src/provisioningserver/testing/factory.py	1970-01-01 00:00:00 +0000
@@ -1,187 +0,0 @@
-# Copyright 2012 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Provisioning test-objects factory."""
-
-from __future__ import (
-    absolute_import,
-    print_function,
-    unicode_literals,
-    )
-
-__metaclass__ = type
-__all__ = [
-    'CobblerFakeFactory',
-    'ProvisioningFakeFactory',
-    ]
-
-from abc import ABCMeta
-from itertools import count
-from random import randint
-from time import time
-from xmlrpclib import Fault
-
-from provisioningserver.enum import POWER_TYPE
-from twisted.internet.defer import (
-    inlineCallbacks,
-    returnValue,
-    )
-
-
-names = ("test%d" % num for num in count(int(time())))
-
-
-def fake_name():
-    """Return a fake name. Each call returns a different name."""
-    return next(names)
-
-
-class ProvisioningFakeFactory:
-    """Mixin for test cases: factory of fake provisioning objects.
-
-    This can be used while testing against a real Cobbler, or a real
-    provisioning server with a fake Cobbler, or a fake provisioning server.
-
-    All objects you create using this factory will be cleaned up at the end of
-    each test.
-    """
-
-    __metaclass__ = ABCMeta
-
-    @staticmethod
-    def clean_up_objects(deleter, *object_names):
-        """Remove named objects from the PAPI.
-
-        `delete_func` is expected to be one of the ``delete_*_by_name``
-        methods of the Provisioning API. XML-RPC errors are ignored; this
-        function does its best to remove the object but a failure to do so is
-        not an error.
-        """
-        d = deleter(object_names)
-        if d is not None:
-            d.addErrback(lambda failure: failure.trap(Fault))
-        return d
-
-    @inlineCallbacks
-    def add_distro(self, papi, name=None):
-        """Creates a new distro object via `papi`.
-
-        Arranges for it to be deleted during test clean-up. If `name` is not
-        specified, `fake_name` will be called to obtain one.
-        """
-        if name is None:
-            name = fake_name()
-        # For the initrd and kernel, use a file that we know will exist for a
-        # running Cobbler instance (at least, on Ubuntu) so that we can test
-        # against remote instances, like one in odev.
-        initrd = "/etc/cobbler/settings"
-        kernel = "/etc/cobbler/version"
-        distro_name = yield papi.add_distro(name, initrd, kernel)
-        self.addCleanup(
-            self.clean_up_objects,
-            papi.delete_distros_by_name,
-            distro_name)
-        returnValue(distro_name)
-
-    @inlineCallbacks
-    def add_profile(self, papi, name=None, distro_name=None):
-        """Creates a new profile object via `papi`.
-
-        Arranges for it to be deleted during test clean-up. If `name` is not
-        specified, `fake_name` will be called to obtain one. If `distro_name`
-        is not specified, one will be obtained by calling `add_distro`.
-        """
-        if name is None:
-            name = fake_name()
-        if distro_name is None:
-            distro_name = yield self.add_distro(papi)
-        profile_name = yield papi.add_profile(name, distro_name)
-        self.addCleanup(
-            self.clean_up_objects,
-            papi.delete_profiles_by_name,
-            profile_name)
-        returnValue(profile_name)
-
-    @inlineCallbacks
-    def add_node(self, papi, name=None, hostname=None, profile_name=None,
-                 power_type=None, preseed_data=None):
-        """Creates a new node object via `papi`.
-
-        Arranges for it to be deleted during test clean-up. If `name` is not
-        specified, `fake_name` will be called to obtain one. If `profile_name`
-        is not specified, one will be obtained by calling `add_profile`.
-        """
-        if name is None:
-            name = fake_name()
-        if hostname is None:
-            hostname = fake_name()
-        if profile_name is None:
-            profile_name = yield self.add_profile(papi)
-        if power_type is None:
-            power_type = POWER_TYPE.WAKE_ON_LAN
-        if preseed_data is None:
-            preseed_data = ""
-        node_name = yield papi.add_node(
-            name, hostname, profile_name, power_type, preseed_data)
-        self.addCleanup(
-            self.clean_up_objects,
-            papi.delete_nodes_by_name,
-            node_name)
-        returnValue(node_name)
-
-
-class CobblerFakeFactory:
-    """Mixin for test cases: factory of fake objects in Cobbler.
-
-    Warning: there is no cleanup for these yet.  Don't just run this against
-    a real cobbler, or there will be trouble.
-    """
-
-    def default_to_file(self, attributes, attribute, required_attrs):
-        """If `attributes[attribute]` is missing, make it a file.
-
-        Sets the given attribute to a newly-created file, if it is a required
-        attribute and not already set in attributes.
-        """
-        if attribute in required_attrs and attribute not in attributes:
-            attributes[attribute] = self.make_file()
-
-    @inlineCallbacks
-    def default_to_object(self, attributes, attribute, required_attrs,
-                          session, cobbler_class):
-        """If `attributes[attribute]` is missing, make it an object.
-
-        Sets the given attribute to a newly-created Cobbler object, if it is
-        a required attribute and not already set in attributes.
-        """
-        if attribute in required_attrs and attribute not in attributes:
-            other_obj = yield self.fake_cobbler_object(session, cobbler_class)
-            attributes[attribute] = other_obj.name
-
-    @inlineCallbacks
-    def fake_cobbler_object(self, session, object_class, name=None,
-                            attributes=None):
-        """Create a fake Cobbler object.
-
-        :param session: `CobblerSession`.
-        :param object_class: concrete `CobblerObject` class to instantiate.
-        :param name: Option name for the object.
-        :param attributes: Optional dict of attribute values for the object.
-        """
-        if attributes is None:
-            attributes = {}
-        else:
-            attributes = attributes.copy()
-        unique_int = randint(1, 9999)
-        if name is None:
-            name = 'name-%s-%d' % (object_class.object_type, unique_int)
-        attributes['name'] = name
-        self.default_to_file(
-            attributes, 'kernel', object_class.required_attributes),
-        self.default_to_file(
-            attributes, 'initrd', object_class.required_attributes),
-        for attr in object_class.required_attributes:
-            if attr not in attributes:
-                attributes[attr] = '%s-%d' % (attr, unique_int)
-        new_object = yield object_class.new(session, name, attributes)
-        returnValue(new_object)

=== modified file 'src/provisioningserver/tests/test_config.py'
--- src/provisioningserver/tests/test_config.py	2012-07-31 16:31:44 +0000
+++ src/provisioningserver/tests/test_config.py	2012-08-16 10:55:23 +0000
@@ -101,7 +101,6 @@
     """Tests for `provisioningserver.config.Config`."""
 
     def test_defaults(self):
-        dummy_password = factory.make_name("password")
         expected = {
             'broker': {
                 'host': 'localhost',
@@ -110,11 +109,6 @@
                 'password': 'test',
                 'vhost': '/',
                 },
-            'cobbler': {
-                'url': 'http://localhost/cobbler_api',
-                'username': getuser(),
-                'password': 'test',
-                },
             'logfile': 'pserv.log',
             'oops': {
                 'directory': '',
@@ -125,24 +119,13 @@
                 'port': 5244,
                 'root': "/var/lib/tftpboot",
                 },
-            'interface': '127.0.0.1',
-            'port': 5241,
-            'username': getuser(),
-            'password': dummy_password,
             }
-        # The password field is set to a random 12-digit string if not
-        # specified. This prevents access, but makes testing easier in other
-        # parts.
-        self.patch(Config.field("password"), "if_missing", dummy_password)
         observed = Config.to_python({})
         self.assertEqual(expected, observed)
 
     def test_parse(self):
         # Configuration can be parsed from a snippet of YAML.
-        observed = Config.parse(
-            b'logfile: "/some/where.log"\n'
-            b'password: "black_sabbath"\n'
-            )
+        observed = Config.parse(b'logfile: "/some/where.log"\n')
         self.assertEqual("/some/where.log", observed["logfile"])
 
     def test_load(self):

=== modified file 'src/provisioningserver/tests/test_plugin.py'
--- src/provisioningserver/tests/test_plugin.py	2012-08-16 06:37:22 +0000
+++ src/provisioningserver/tests/test_plugin.py	2012-08-16 10:55:23 +0000
@@ -74,7 +74,6 @@
         self.tempdir = self.make_dir()
 
     def write_config(self, config):
-        config.setdefault("password", factory.getRandomString())
         config_filename = os.path.join(self.tempdir, "config.yaml")
         with open(config_filename, "wb") as stream:
             yaml.safe_dump(config, stream)