← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/maas-bug-955451 into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/maas-bug-955451 into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #955451 in MaaS: "Default Maas name is Www-data's Maas "
  https://bugs.launchpad.net/maas/+bug/955451

For more details, see:
https://code.launchpad.net/~rvb/maas/maas-bug-955451/+merge/97694

This branch fixes the default maas_name config to use the hostname.  This way, the displayed name will be "hostname MAAS".
-- 
https://code.launchpad.net/~rvb/maas/maas-bug-955451/+merge/97694
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-bug-955451 into lp:maas.
=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py	2012-03-14 15:40:45 +0000
+++ src/maasserver/models.py	2012-03-15 16:23:35 +0000
@@ -25,10 +25,10 @@
 import copy
 import datetime
 from errno import ENOENT
-import getpass
 from logging import getLogger
 import os
 import re
+from socket import gethostname
 import time
 from uuid import uuid1
 
@@ -761,7 +761,7 @@
         'update_from_choice': (
             [['archive.ubuntu.com', 'archive.ubuntu.com']]),
         # Network section configuration.
-        'maas_name': "%s's" % getpass.getuser().capitalize(),
+        'maas_name': gethostname(),
         'provide_dhcp': False,
         ## /settings
         }

=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py	2012-03-13 10:41:00 +0000
+++ src/maasserver/tests/test_models.py	2012-03-15 16:23:35 +0000
@@ -15,14 +15,12 @@
 from io import BytesIO
 import os
 import shutil
+from socket import gethostname
 
 from django.conf import settings
 from django.contrib.auth.models import User
 from django.core.exceptions import ValidationError
-from fixtures import (
-    EnvironmentVariableFixture,
-    TestWithFixtures,
-    )
+from fixtures import TestWithFixtures
 from maasserver.exceptions import (
     CannotDeleteUserException,
     PermissionDenied,
@@ -697,12 +695,8 @@
     """Test config default values."""
 
     def test_default_config_maas_name(self):
-        name = factory.getRandomString()
-        fixture = EnvironmentVariableFixture('LOGNAME', name)
-        self.useFixture(fixture)
         default_config = get_default_config()
-        self.assertEqual(
-            "%s's" % name.capitalize(), default_config['maas_name'])
+        self.assertEqual(gethostname(), default_config['maas_name'])
 
 
 class Listener: