Beispiel #1
0
    def __init__(self, url, user, pw):
        version_string = version.version_string_with_package()
        self.nova_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
        self.host_checked = False
        exception = self.XenAPI.Failure(
            _("Unable to log in to XenAPI "
              "(is the Dom0 disk full?)"))
        self.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)
    def test_release_file(self):
        version.loaded = False
        real_open = builtins.open
        real_find_file = cfg.CONF.find_file

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

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

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

        self.stubs.Set(builtins, '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")
Beispiel #3
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/nova/release"
            return real_find_file(self, name)

        def fake_open(path, *args, **kwargs):
            if path == "/etc/nova/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")
Beispiel #4
0
    def _make_iso9660(self, path):
        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",
            self.tempdir,
            attempts=1,
            run_as_root=False,
        )
Beispiel #5
0
    def test_session_passes_version(self, mock_verify, mock_version, create_session, mock_platform_version):
        sess = mock.Mock()
        create_session.return_value = sess
        mock_version.return_value = ("version", "brand")
        mock_platform_version.return_value = (2, 1, 0)
        session.XenAPISession("http://someserver", "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")
Beispiel #6
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')
Beispiel #7
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')
    def test_release_file(self):
        version.loaded = False
        real_find_file = cfg.CONF.find_file

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

        self.stub_out('oslo_config.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")
    def _make_iso9660(self, path):
        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',
                      self.tempdir,
                      attempts=1,
                      run_as_root=False)
Beispiel #10
0
    def _make_iso9660(self, path):
        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',
                      self.tempdir,
                      attempts=1,
                      run_as_root=False)
Beispiel #11
0
    def _make_iso9660(self, path, tmpdir):
        publisher = "{product!s} {version!s}".format(**{
            '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)
Beispiel #12
0
    def __init__(self, url, user, pw):
        version_string = version.version_string_with_package()
        self.nova_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)