示例#1
0
    def get_console_output(self, instance):
        console_log = os.path.join(FLAGS.instances_path, instance["name"], "console.log")

        libvirt_utils.chown(console_log, os.getuid())

        fd = self._conn.find_domain(instance["name"])

        self.baremetal_nodes.get_console_output(console_log, fd["node_id"])

        fpath = console_log

        return libvirt_utils.load_file(fpath)
示例#2
0
    def get_console_output(self, instance):
        console_log = os.path.join(FLAGS.instances_path, instance['name'],
                                   'console.log')

        libvirt_utils.chown(console_log, os.getuid())

        fd = self._conn.find_domain(instance['name'])

        self.baremetal_nodes.get_console_output(console_log, fd['node_id'])

        fpath = console_log

        return libvirt_utils.load_file(fpath)
示例#3
0
文件: driver.py 项目: a3linux/nova
    def get_console_output(self, instance):
        console_log = os.path.join(CONF.instances_path, instance['name'],
                                   'console.log')

        libvirt_utils.chown(console_log, os.getuid())

        fd = self._conn.find_domain(instance['name'])

        self.baremetal_nodes.get_console_output(console_log, fd['node_id'])

        fpath = console_log

        return libvirt_utils.load_file(fpath)
示例#4
0
    def _age_and_verify_swap_images(self, context, base_dir):
        LOG.debug('Verify swap images')

        for ent in self.back_swap_images:
            base_file = os.path.join(base_dir, ent)
            if ent in self.used_swap_images and os.path.exists(base_file):
                    libvirt_utils.chown(base_file, os.getuid())
                    os.utime(base_file, None)
            elif self.remove_unused_base_images:
                self._remove_swap_file(base_file)

        error_images = self.used_swap_images - self.back_swap_images
        for error_image in error_images:
            LOG.warn(_LW('%s swap image was used by instance'
                         ' but no back files existing!'), error_image)
示例#5
0
    def _age_and_verify_swap_images(self, context, base_dir):
        LOG.debug('Verify swap images')

        for ent in self.back_swap_images:
            base_file = os.path.join(base_dir, ent)
            if ent in self.used_swap_images and os.path.exists(base_file):
                    libvirt_utils.chown(base_file, os.getuid())
                    os.utime(base_file, None)
            elif self.remove_unused_base_images:
                self._remove_swap_file(base_file)

        error_images = self.used_swap_images - self.back_swap_images
        for error_image in error_images:
            LOG.warn(_LW('%s swap image was used by instance'
                         ' but no back files existing!'), error_image)
示例#6
0
 def test_chown(self, mock_execute):
     libvirt_utils.chown('/some/path', 'soren')
     mock_execute.assert_called_once_with('chown', 'soren', '/some/path',
                                          run_as_root=True)
示例#7
0
    def _handle_base_image(self, img_id, base_file):
        """Handle the checks for a single base image."""

        image_bad = False
        image_in_use = False

        LOG.info(_('image %(id)s at (%(base_file)s): checking'),
                 {'id': img_id,
                  'base_file': base_file})

        if base_file in self.unexplained_images:
            self.unexplained_images.remove(base_file)

        if (base_file and os.path.exists(base_file)
            and os.path.isfile(base_file)):
            # _verify_checksum returns True if the checksum is ok, and None if
            # there is no checksum file
            checksum_result = self._verify_checksum(img_id, base_file)
            if checksum_result is not None:
                image_bad = not checksum_result

            # Give other threads a chance to run
            time.sleep(0)

        instances = []
        if img_id in self.used_images:
            local, remote, instances = self.used_images[img_id]

            if local > 0 or remote > 0:
                image_in_use = True
                LOG.info(_('image %(id)s at (%(base_file)s): '
                           'in use: on this node %(local)d local, '
                           '%(remote)d on other nodes sharing this instance '
                           'storage'),
                         {'id': img_id,
                          'base_file': base_file,
                          'local': local,
                          'remote': remote})

                self.active_base_files.append(base_file)

                if not base_file:
                    LOG.warning(_('image %(id)s at (%(base_file)s): warning '
                                  '-- an absent base file is in use! '
                                  'instances: %(instance_list)s'),
                                {'id': img_id,
                                 'base_file': base_file,
                                 'instance_list': ' '.join(instances)})

        if image_bad:
            self.corrupt_base_files.append(base_file)

        if base_file:
            if not image_in_use:
                LOG.debug(_('image %(id)s at (%(base_file)s): image is not in '
                            'use'),
                          {'id': img_id,
                           'base_file': base_file})
                self.removable_base_files.append(base_file)

            else:
                LOG.debug(_('image %(id)s at (%(base_file)s): image is in '
                            'use'),
                          {'id': img_id,
                           'base_file': base_file})
                if os.path.exists(base_file):
                    virtutils.chown(base_file, os.getuid())
                    os.utime(base_file, None)
示例#8
0
    def _handle_base_image(self, img_id, base_file):
        """Handle the checks for a single base image."""

        image_bad = False
        image_in_use = False

        LOG.info(_('image %(id)s at (%(base_file)s): checking'),
                 {'id': img_id,
                  'base_file': base_file})

        if base_file in self.unexplained_images:
            self.unexplained_images.remove(base_file)

        if (base_file and os.path.exists(base_file)
                and os.path.isfile(base_file)):
            # _verify_checksum returns True if the checksum is ok, and None if
            # there is no checksum file
            checksum_result = self._verify_checksum(img_id, base_file)
            if checksum_result is not None:
                image_bad = not checksum_result

            # Give other threads a chance to run
            time.sleep(0)

        instances = []
        if img_id in self.used_images:
            local, remote, instances = self.used_images[img_id]

            if local > 0 or remote > 0:
                image_in_use = True
                LOG.info(_('image %(id)s at (%(base_file)s): '
                           'in use: on this node %(local)d local, '
                           '%(remote)d on other nodes sharing this instance '
                           'storage'),
                         {'id': img_id,
                          'base_file': base_file,
                          'local': local,
                          'remote': remote})

                self.active_base_files.append(base_file)

                if not base_file:
                    LOG.warning(_('image %(id)s at (%(base_file)s): warning '
                                  '-- an absent base file is in use! '
                                  'instances: %(instance_list)s'),
                                {'id': img_id,
                                 'base_file': base_file,
                                 'instance_list': ' '.join(instances)})

        if image_bad:
            self.corrupt_base_files.append(base_file)

        if base_file:
            if not image_in_use:
                LOG.debug(_('image %(id)s at (%(base_file)s): image is not in '
                            'use'),
                          {'id': img_id,
                           'base_file': base_file})
                self.removable_base_files.append(base_file)

            else:
                LOG.debug(_('image %(id)s at (%(base_file)s): image is in '
                            'use'),
                          {'id': img_id,
                           'base_file': base_file})
                if os.path.exists(base_file):
                    virtutils.chown(base_file, os.getuid())
                    os.utime(base_file, None)
示例#9
0
 def test_chown(self, mock_execute):
     libvirt_utils.chown("/some/path", "soren")
     mock_execute.assert_called_once_with("chown", "soren", "/some/path", run_as_root=True)
示例#10
0
文件: imagecache.py 项目: osrg/nova
 def inner_refresh_timestamp():
     if os.path.exists(base_file):
         virtutils.chown(base_file, os.getuid())
         os.utime(base_file, None)
示例#11
0
    def _handle_base_image(self, img_id, base_file):
        """Handle the checks for a single base image."""

        image_bad = False
        image_in_use = False

        LOG.info(_("image %(id)s at (%(base_file)s): checking"), {"id": img_id, "base_file": base_file})

        if base_file in self.unexplained_images:
            self.unexplained_images.remove(base_file)

        if base_file and os.path.exists(base_file) and os.path.isfile(base_file):
            # _verify_checksum returns True if the checksum is ok, and None if
            # there is no checksum file
            checksum_result = self._verify_checksum(img_id, base_file)
            if not checksum_result is None:
                image_bad = not checksum_result

            # Give other threads a chance to run
            time.sleep(0)

        instances = []
        if img_id in self.used_images:
            local, remote, instances = self.used_images[img_id]

            if local > 0 or remote > 0:
                image_in_use = True
                LOG.info(
                    _(
                        "image %(id)s at (%(base_file)s): "
                        "in use: on this node %(local)d local, "
                        "%(remote)d on other nodes sharing this instance "
                        "storage"
                    ),
                    {"id": img_id, "base_file": base_file, "local": local, "remote": remote},
                )

                self.active_base_files.append(base_file)

                if not base_file:
                    LOG.warning(
                        _(
                            "image %(id)s at (%(base_file)s): warning "
                            "-- an absent base file is in use! "
                            "instances: %(instance_list)s"
                        ),
                        {"id": img_id, "base_file": base_file, "instance_list": " ".join(instances)},
                    )

        if image_bad:
            self.corrupt_base_files.append(base_file)

        if base_file:
            if not image_in_use:
                LOG.debug(
                    _("image %(id)s at (%(base_file)s): image is not in " "use"), {"id": img_id, "base_file": base_file}
                )
                self.removable_base_files.append(base_file)

            else:
                LOG.debug(
                    _("image %(id)s at (%(base_file)s): image is in " "use"), {"id": img_id, "base_file": base_file}
                )
                if os.path.exists(base_file):
                    virtutils.chown(base_file, os.getuid())
                    os.utime(base_file, None)