Ejemplo n.º 1
0
 def test_get_boot_image_purposes_install_only(self):
     osystem = WindowsOS()
     arch, subarch, release, label = self.make_resource_path(
         files=['pxeboot.0'])
     self.assertItemsEqual([BOOT_IMAGE_PURPOSE.INSTALL],
                           osystem.get_boot_image_purposes(
                               arch, subarch, release, label))
Ejemplo n.º 2
0
 def test_validate_license_key(self):
     osystem = WindowsOS()
     parts = [factory.make_string(size=5) for _ in range(5)]
     key = "-".join(parts)
     self.assertTrue(
         osystem.validate_license_key(REQUIRE_LICENSE_KEY[0], key)
     )
Ejemplo n.º 3
0
 def test_validate_license_key_invalid(self):
     osystem = WindowsOS()
     keys = [factory.make_string() for _ in range(3)]
     for key in keys:
         self.assertFalse(
             osystem.validate_license_key(REQUIRE_LICENSE_KEY[0], key)
         )
Ejemplo n.º 4
0
 def test_compose_preseed_includes_metadata_url(self):
     osystem = WindowsOS()
     node = self.make_node()
     token = self.make_token()
     url = factory.make_name("url")
     preseed = osystem.compose_preseed("default", node, token, url)
     self.assertEqual(url, preseed["maas_metadata_url"])
Ejemplo n.º 5
0
 def test_requires_license_key_False(self):
     osystem = WindowsOS()
     not_required = set(WINDOWS_CHOICES.keys()).difference(
         REQUIRE_LICENSE_KEY
     )
     for release in not_required:
         self.assertFalse(osystem.requires_license_key(release))
Ejemplo n.º 6
0
 def test_get_boot_image_purposes_both(self):
     osystem = WindowsOS()
     arch, subarch, release, label = self.make_resource_path(
         files=["root-dd", "pxeboot.0"])
     self.assertItemsEqual(
         [BOOT_IMAGE_PURPOSE.XINSTALL, BOOT_IMAGE_PURPOSE.INSTALL],
         osystem.get_boot_image_purposes(arch, subarch, release, label),
     )
Ejemplo n.º 7
0
 def test_compose_preseed_truncates_hostname(self):
     osystem = WindowsOS()
     machine = factory.make_name('hostname', size=20)
     dns = factory.make_name('dns')
     hostname = '%s.%s' % (machine, dns)
     node = self.make_node(hostname=hostname)
     token = self.make_token()
     url = factory.make_name('url')
     preseed = osystem.compose_preseed('default', node, token, url)
     self.assertEqual(15, len(preseed['hostname']))
Ejemplo n.º 8
0
 def test_get_boot_image_purposes_xinstall(self):
     osystem = WindowsOS()
     arch = factory.make_name("arch")
     subarch = factory.make_name("subarch")
     release = factory.make_name("release")
     label = factory.make_name("label")
     self.assertItemsEqual(
         [BOOT_IMAGE_PURPOSE.XINSTALL],
         osystem.get_boot_image_purposes(arch, subarch, release, label),
     )
Ejemplo n.º 9
0
 def test_compose_preseed_truncates_hostname(self):
     osystem = WindowsOS()
     machine = factory.make_name("hostname", size=20)
     dns = factory.make_name("dns")
     hostname = "%s.%s" % (machine, dns)
     node = self.make_node(hostname=hostname)
     token = self.make_token()
     url = factory.make_name("url")
     preseed = osystem.compose_preseed("default", node, token, url)
     self.assertEqual(15, len(preseed["hostname"]))
Ejemplo n.º 10
0
 def test_compose_preseed_includes_oauth(self):
     osystem = WindowsOS()
     node = self.make_node()
     consumer_key = factory.make_name('consumer_key')
     token_key = factory.make_name('token_key')
     token_secret = factory.make_name('secret_key')
     token = self.make_token(consumer_key=consumer_key,
                             token_key=token_key,
                             token_secret=token_secret)
     url = factory.make_name('url')
     preseed = osystem.compose_preseed('default', node, token, url)
     self.assertEqual('', preseed['maas_oauth_consumer_secret'])
     self.assertEqual(consumer_key, preseed['maas_oauth_consumer_key'])
     self.assertEqual(token_key, preseed['maas_oauth_token_key'])
     self.assertEqual(token_secret, preseed['maas_oauth_token_secret'])
Ejemplo n.º 11
0
 def test_compose_preseed_has_required_keys(self):
     osystem = WindowsOS()
     node = self.make_node()
     token = self.make_token()
     url = factory.make_name('url')
     required_keys = [
         'maas_metadata_url',
         'maas_oauth_consumer_secret',
         'maas_oauth_consumer_key',
         'maas_oauth_token_key',
         'maas_oauth_token_secret',
         'hostname',
     ]
     preseed = osystem.compose_preseed('default', node, token, url)
     self.assertItemsEqual(required_keys, preseed.keys())
Ejemplo n.º 12
0
 def test_compose_preseed_has_required_keys(self):
     osystem = WindowsOS()
     node = self.make_node()
     token = self.make_token()
     url = factory.make_name("url")
     required_keys = [
         "maas_metadata_url",
         "maas_oauth_consumer_secret",
         "maas_oauth_consumer_key",
         "maas_oauth_token_key",
         "maas_oauth_token_secret",
         "hostname",
     ]
     preseed = osystem.compose_preseed("default", node, token, url)
     self.assertItemsEqual(required_keys, preseed.keys())
Ejemplo n.º 13
0
 def test_compose_pressed_not_implemented_for_curtin(self):
     osystem = WindowsOS()
     node = self.make_node()
     token = self.make_token()
     url = factory.make_name('url')
     self.assertRaises(NotImplementedError, osystem.compose_preseed,
                       'curtin', node, token, url)
Ejemplo n.º 14
0
 def test_compose_preseed_includes_oauth(self):
     osystem = WindowsOS()
     node = self.make_node()
     consumer_key = factory.make_name("consumer_key")
     token_key = factory.make_name("token_key")
     token_secret = factory.make_name("secret_key")
     token = self.make_token(
         consumer_key=consumer_key,
         token_key=token_key,
         token_secret=token_secret,
     )
     url = factory.make_name("url")
     preseed = osystem.compose_preseed("default", node, token, url)
     self.assertEqual("", preseed["maas_oauth_consumer_secret"])
     self.assertEqual(consumer_key, preseed["maas_oauth_consumer_key"])
     self.assertEqual(token_key, preseed["maas_oauth_token_key"])
     self.assertEqual(token_secret, preseed["maas_oauth_token_secret"])
Ejemplo n.º 15
0
        return "root-tgz", "tgz"


class OperatingSystemRegistry(Registry):
    """Registry for operating system classes."""


from provisioningserver.drivers.osystem.ubuntu import UbuntuOS
from provisioningserver.drivers.osystem.ubuntucore import UbuntuCoreOS
from provisioningserver.drivers.osystem.bootloader import BootLoaderOS
from provisioningserver.drivers.osystem.centos import CentOS
from provisioningserver.drivers.osystem.rhel import RHELOS
from provisioningserver.drivers.osystem.custom import CustomOS
from provisioningserver.drivers.osystem.windows import WindowsOS
from provisioningserver.drivers.osystem.suse import SUSEOS
from provisioningserver.drivers.osystem.caringo import CaringoOS

builtin_osystems = [
    UbuntuOS(),
    UbuntuCoreOS(),
    BootLoaderOS(),
    CentOS(),
    RHELOS(),
    CustomOS(),
    WindowsOS(),
    SUSEOS(),
    CaringoOS(),
]
for osystem in builtin_osystems:
    OperatingSystemRegistry.register_item(osystem.name, osystem)
Ejemplo n.º 16
0
 def test_requires_license_key_True(self):
     osystem = WindowsOS()
     for release in REQUIRE_LICENSE_KEY:
         self.assertTrue(osystem.requires_license_key(release))
Ejemplo n.º 17
0
 def test_get_release_title(self):
     osystem = WindowsOS()
     release = random.choice(list(WINDOWS_CHOICES))
     self.assertEqual(WINDOWS_CHOICES[release],
                      osystem.get_release_title(release))
Ejemplo n.º 18
0
 def test_get_default_release(self):
     osystem = WindowsOS()
     expected = osystem.get_default_release()
     self.assertEqual(expected, WINDOWS_DEFAULT)
Ejemplo n.º 19
0
 def test_get_boot_image_purposes_neither(self):
     osystem = WindowsOS()
     arch, subarch, release, label = self.make_resource_path()
     self.assertItemsEqual([],
                           osystem.get_boot_image_purposes(
                               arch, subarch, release, label))
Ejemplo n.º 20
0
 def test_get_xinstall_parameters(self):
     osystem = WindowsOS()
     image, image_type = osystem.get_xinstall_parameters(
         None, None, None, None)
     self.assertEqual('root-dd', image)
     self.assertEqual('dd-tgz', image_type)