Esempio n. 1
0
    def execute(self, ns, all=None):
        """
        Implementation of 'mount show' command.
        """
        if all is False:
            transients = [
                mnt.Name for mnt in ns.LMI_TransientFileSystem.instances()
            ]

        yield formatter.NewTableCommand('Mounted filesystems')
        for mnt in mount.get_mounts(ns):
            # treat root specially (can be mounted twice - as a rootfs and with
            # a device)
            if mnt.FileSystemSpec == 'rootfs':
                continue

            if all is False and mnt.MountPointPath != '/':
                # do not list nodevice filesystems
                name = 'PATH=' + mnt.MountPointPath
                if name in transients:
                    continue

            opts_str = mount.build_opts_str(mnt)

            yield ('Filesystem',
                   '%s (%s)' % (mnt.FileSystemSpec, mnt.FileSystemType))
            yield ('Mountpoint', mnt.MountPointPath)
            yield ('Options', opts_str[0])
            yield ('OtherOptions', opts_str[1])
            yield ''
Esempio n. 2
0
 def execute(self, ns, devices=None, _deep=None):
     """
     Implementation of 'device provides' command.
     """
     for device in devices:
         yield formatter.NewTableCommand(title=device)
         for child in get_children(ns, device, _deep):
             yield get_obj_info(ns, child, self.app.config.human_friendly)
Esempio n. 3
0
 def execute(self, ns, devices=None, _deep=None):
     """
     Implementation of 'device depends' command.
     """
     for device in devices:
         yield formatter.NewTableCommand(title=device)
         for parent in get_parents(ns, device, _deep):
             yield get_obj_info(ns, parent, self.app.config.human_friendly)
Esempio n. 4
0
 def execute(self, ns, lvs=None):
     """
     Implementation of 'lv show' command.
     """
     if not lvs:
         lvs = lvm.get_lvs(ns)
     for lv in lvs:
         lv = str2device(ns, lv)
         cmd = formatter.NewTableCommand(title=lv.DeviceID)
         yield cmd
         for line in show.lv_show(ns, lv, self.app.config.human_friendly):
             yield line
Esempio n. 5
0
 def execute(self, ns, vgs=None):
     """
     Implementation of 'vg show' command.
     """
     if not vgs:
         vgs = lvm.get_vgs(ns)
     for vg in vgs:
         vg = str2vg(ns, vg)
         cmd = formatter.NewTableCommand(title=vg.InstanceID)
         yield cmd
         for line in show.vg_show(ns, vg, self.app.config.human_friendly):
             yield line
Esempio n. 6
0
 def execute(self, ns, partitions=None):
     """
     Implementation of 'partition show' command.
     """
     if not partitions:
         partitions = partition.get_partitions(ns)
     for part in partitions:
         part = str2device(ns, part)
         cmd = formatter.NewTableCommand(title=part.DeviceID)
         yield cmd
         for line in show.partition_show(ns, part,
                                         self.app.config.human_friendly):
             yield line
Esempio n. 7
0
 def execute(self, ns, devices=None):
     """
     Implementation of 'device show' command.
     """
     if not devices:
         devices = get_devices(ns)
     for dev in devices:
         dev = str2device(ns, dev)
         cmd = formatter.NewTableCommand(title=dev.DeviceID)
         yield cmd
         for line in show.device_show(ns, dev,
                                      self.app.config.human_friendly):
             yield line
 def execute(self, ns, devices=None):
     """
     Implementation of 'partition-table show' command.
     """
     if not devices:
         ret = partition.get_partition_tables(ns)
         devices = [i[0] for i in ret]
     for device in devices:
         device = str2device(ns, device)
         cmd = formatter.NewTableCommand(title=device.DeviceID)
         yield cmd
         for line in show.partition_table_show(
                 ns, device, self.app.config.human_friendly):
             yield line
Esempio n. 9
0
    def execute(self, ns, package_array):
        failed_identity_checks = []
        def _verify_identity(identity):
            failed_checks = list(software.verify_package(ns, identity))
            if len(failed_checks):
                failed_identity_checks.append((identity, failed_checks))
            else:
                LOG().debug('package "%s" passed', identity.ElementName)

        for_each_package_specs(ns, package_array, 'verify', _verify_identity)
        for identity, checks in failed_identity_checks:
            yield formatter.NewTableCommand(title=identity.ElementName)
            for file_check in checks:
                yield ( software.render_failed_flags(file_check.FailedFlags)
                      , file_check.Name)
Esempio n. 10
0
    def _print_errors(self, errors):
        """
        Print list of errors.
        Each error is a ``tuple``: ::

            (hostname, error_text)

        :param list errors: Errors to print.
        """
        fmt = formatter.TableFormatter(self.app.stderr,
                                       no_headings=self.app.config.no_headings)
        command1 = formatter.NewTableCommand("There were %d errors" %
                                             len(errors))
        command2 = formatter.NewTableHeaderCommand(("Host", "Error"))
        fmt.produce_output((command1, command2))
        fmt.produce_output(errors)
Esempio n. 11
0
def lf_show(ns, target):
    """
    Show detailed information about the target.

    Target can be either a file or a directory.

    :type target: string
    :param target: Full path to the target.
    """
    system = ns.Linux_ComputerSystem.first_instance()
    uf_name = ns.LMI_UnixFile.new_instance_name({
        'CSCreationClassName': system.classname,
        'CSName': system.name,
        'LFCreationClassName': 'ignored',
        'FSCreationClassName': 'ignored',
        'FSName': 'ignored',
        'LFName': target
    })
    try:
        uf = uf_name.to_instance()
    except:
        raise LmiFailed("Could not get target: %s" % target)

    ident = uf.associators(AssocClass='LMI_FileIdentity')[0]

    yield formatter.NewTableCommand(title=uf.Name)
    yield ('Type', get_file_identification(ident))
    yield ('Readable', ident.Readable)
    yield ('Writeable', ident.Writeable)
    yield ('Executable', ident.Executable)
    yield ('UserID', uf.UserID)
    yield ('GroupID', uf.GroupID)
    yield ('SaveText', uf.SaveText)
    yield ('SetGid', uf.SetGid)
    yield ('SetUid', uf.SetUid)
    yield ('FileSize', ident.FileSize)
    yield ('LastAccessed', ident.LastAccessed)
    yield ('LastModified', ident.LastModified)
    yield ('FileInodeNumber', uf.FileInodeNumber)
    yield ('SELinuxCurrentContext', uf.SELinuxCurrentContext)
    yield ('SELinuxExpectedContext', uf.SELinuxExpectedContext)