Ejemplo n.º 1
0
    def test_release_file(self):
        version.loaded = False
        real_open = __builtin__.open
        real_find_file = cfg.CONF.find_file

        def fake_find_file(self, name):
            if name == "release":
                return "/etc/patron/release"
            return real_find_file(self, name)

        def fake_open(path, *args, **kwargs):
            if path == "/etc/patron/release":
                data = """[Nova]
vendor = ACME Corporation
product = ACME Nova
package = 1337"""
                return StringIO.StringIO(data)

            return real_open(path, *args, **kwargs)

        self.stubs.Set(__builtin__, 'open', fake_open)
        self.stubs.Set(cfg.ConfigOpts, 'find_file', fake_find_file)

        self.assertEqual(version.vendor_string(), "ACME Corporation")
        self.assertEqual(version.product_string(), "ACME Nova")
        self.assertEqual(version.package_string(), "1337")
Ejemplo n.º 2
0
    def test_release_file(self):
        version.loaded = False
        real_open = __builtin__.open
        real_find_file = cfg.CONF.find_file

        def fake_find_file(self, name):
            if name == "release":
                return "/etc/patron/release"
            return real_find_file(self, name)

        def fake_open(path, *args, **kwargs):
            if path == "/etc/patron/release":
                data = """[Nova]
vendor = ACME Corporation
product = ACME Nova
package = 1337"""
                return StringIO.StringIO(data)

            return real_open(path, *args, **kwargs)

        self.stubs.Set(__builtin__, 'open', fake_open)
        self.stubs.Set(cfg.ConfigOpts, 'find_file', fake_find_file)

        self.assertEqual(version.vendor_string(), "ACME Corporation")
        self.assertEqual(version.product_string(), "ACME Nova")
        self.assertEqual(version.package_string(), "1337")
Ejemplo n.º 3
0
    def test_session_passes_version(self, mock_verify, mock_version,
                                    create_session):
        sess = mock.Mock()
        create_session.return_value = sess
        mock_version.return_value = ('version', 'brand')

        session.XenAPISession('url', 'username', 'password')

        expected_version = '%s %s %s' % (version.vendor_string(),
                                         version.product_string(),
                                         version.version_string_with_package())
        sess.login_with_password.assert_called_with('username', 'password',
                                                    expected_version,
                                                    'OpenStack')
Ejemplo n.º 4
0
    def _make_iso9660(self, path, tmpdir):
        publisher = "%(product)s %(version)s" % {
            'product': version.product_string(),
            'version': version.version_string_with_package()
            }

        utils.execute(CONF.mkisofs_cmd,
                      '-o', path,
                      '-ldots',
                      '-allow-lowercase',
                      '-allow-multidot',
                      '-l',
                      '-publisher',
                      publisher,
                      '-quiet',
                      '-J',
                      '-r',
                      '-V', 'config-2',
                      tmpdir,
                      attempts=1,
                      run_as_root=False)
Ejemplo n.º 5
0
    def __init__(self, url, user, pw):
        version_string = version.version_string_with_package()
        self.patron_version = _('%(vendor)s %(product)s %(version)s') % \
                              {'vendor': version.vendor_string(),
                               'product': version.product_string(),
                               'version': version_string}
        import XenAPI
        self.XenAPI = XenAPI
        self._sessions = queue.Queue()
        self.is_slave = False
        exception = self.XenAPI.Failure(
            _("Unable to log in to XenAPI "
              "(is the Dom0 disk full?)"))
        url = self._create_first_session(url, user, pw, exception)
        self._populate_session_pool(url, user, pw, exception)
        self.host_uuid = self._get_host_uuid()
        self.host_ref = self._get_host_ref()
        self.product_version, self.product_brand = \
            self._get_product_version_and_brand()

        self._verify_plugin_version()

        apply_session_helpers(self)
Ejemplo n.º 6
0
    def _make_iso9660(self, path, tmpdir):
        publisher = "%(product)s %(version)s" % {
            'product': version.product_string(),
            'version': version.version_string_with_package()
        }

        utils.execute(CONF.mkisofs_cmd,
                      '-o',
                      path,
                      '-ldots',
                      '-allow-lowercase',
                      '-allow-multidot',
                      '-l',
                      '-publisher',
                      publisher,
                      '-quiet',
                      '-J',
                      '-r',
                      '-V',
                      'config-2',
                      tmpdir,
                      attempts=1,
                      run_as_root=False)