Пример #1
0
    def uninstall(self, iobject, name=None, **kwargs):
        atomic = kwargs.get('atomic')
        ignore = kwargs.get('ignore')
        assert (isinstance(atomic, Atomic))
        args = atomic.args
        con_obj = None if not name else self.has_container(name)
        # We have a container by that name, need to stop and delete it
        if con_obj:
            if con_obj.running:
                self.stop_container(con_obj)
            self.delete_container(con_obj.id)

        if args.force:
            self.delete_containers_by_image(iobject, force=True)
        else:
            containers_by_image = self.get_containers_by_image(iobject)
            if len(containers_by_image) > 0:
                containers_active = ", ".join(
                    [i.name for i in containers_by_image])
                raise ValueError(
                    "Containers `%s` are using this image, delete them first or use --force"
                    % containers_active)

        uninstall_command = iobject.get_label('UNINSTALL')
        command_line_args = args.args

        cmd = []
        if uninstall_command:
            try:
                cmd = cmd + uninstall_command
            except TypeError:
                cmd = cmd + uninstall_command.split()
        if command_line_args:
            cmd += command_line_args

        cmd = atomic.gen_cmd(cmd)
        cmd = atomic.sub_env_strings(cmd)
        atomic.display(cmd)
        if args.display:
            return 0

        if cmd:
            result = util.check_call(cmd, env=atomic.cmd_env())
            if result == 0:
                util.InstallData.delete_by_id(iobject.id, name, ignore=ignore)
            return result

        system_package_nvra = None
        if not ignore:
            install_data = util.InstallData.get_install_data_by_id(iobject.id)
            system_package_nvra = install_data.get("system_package_nvra", None)
        if system_package_nvra:
            RPMHostInstall.uninstall_rpm(system_package_nvra)

        # Delete the entry in the install data
        last_image = util.InstallData.delete_by_id(iobject.id,
                                                   name,
                                                   ignore=ignore)
        if last_image:
            return self.delete_image(iobject.image, force=args.force)
Пример #2
0
    def uninstall(self, iobject, name=None, **kwargs):
        atomic = kwargs.get('atomic')
        ignore = kwargs.get('ignore')
        assert(isinstance(atomic, Atomic))
        args = atomic.args
        con_obj = None if not name else self.has_container(name)
        # We have a container by that name, need to stop and delete it
        if con_obj:
            if con_obj.running:
                self.stop_container(con_obj)
            self.delete_container(con_obj.id)

        if args.force:
            self.delete_containers_by_image(iobject, force=True)
        else:
            containers_by_image = self.get_containers_by_image(iobject)
            if len(containers_by_image) > 0:
                containers_active = ", ".join([i.name for i in containers_by_image])
                raise ValueError("Containers `%s` are using this image, delete them first or use --force" % containers_active)

        uninstall_command = iobject.get_label('UNINSTALL')
        command_line_args = args.args

        cmd = []
        if uninstall_command:
            try:
                cmd = cmd + uninstall_command
            except TypeError:
                cmd = cmd + uninstall_command.split()
        if command_line_args:
            cmd += command_line_args

        cmd = atomic.gen_cmd(cmd)
        cmd = atomic.sub_env_strings(cmd)
        atomic.display(cmd)
        if args.display:
            return 0


        if cmd:
            result = util.check_call(cmd, env=atomic.cmd_env())
            if result == 0:
                util.InstallData.delete_by_id(iobject.id, ignore=ignore)
            return result

        system_package_nvra = None
        if not ignore:
            install_data = util.InstallData.get_install_data_by_id(iobject.id)
            system_package_nvra = install_data.get("system_package_nvra", None)
        if system_package_nvra:
            RPMHostInstall.uninstall_rpm(system_package_nvra)

        # Delete the entry in the install data
        util.InstallData.delete_by_id(iobject.id, ignore=ignore)
        return self.delete_image(iobject.image, force=args.force)
Пример #3
0
    def uninstall(self, iobject, name=None, **kwargs):
        atomic = kwargs.get('atomic')
        ignore = kwargs.get('ignore')
        assert(isinstance(atomic, Atomic))
        args = atomic.args
        con_obj = None if not name else self.has_container(name)
        # We have a container by that name, need to stop and delete it
        if con_obj:
            if con_obj.running:
                self.stop_container(con_obj)
            self.delete_container(con_obj.id)

        if args.force:
            self.delete_containers_by_image(iobject, force=True)

        uninstall_command = iobject.get_label('UNINSTALL')
        command_line_args = args.args

        cmd = []
        if uninstall_command:
            try:
                cmd = cmd + uninstall_command
            except TypeError:
                cmd = cmd + uninstall_command.split()
        if command_line_args:
            cmd += command_line_args

        cmd = atomic.gen_cmd(cmd)
        cmd = atomic.sub_env_strings(cmd)
        atomic.display(cmd)
        if args.display:
            return 0
        if cmd:
            return util.check_call(cmd, env=atomic.cmd_env())

        install_data = util.InstallData.get_install_data_by_id(iobject.id)
        system_package_nvra = install_data.get("system_package_nvra", None)
        if system_package_nvra:
            RPMHostInstall.uninstall_rpm(system_package_nvra)

        # Delete the entry in the install data
        util.InstallData.delete_by_id(iobject.id, ignore=ignore)
        return self.delete_image(iobject.image, force=args.force)