Exemple #1
0
 def execute(self, ns, devices=None, _deep=None):
     """
     Implementation of 'device provides' command.
     """
     for device in devices:
         yield fcmd.NewTableCommand(title=device)
         for child in  get_children(ns, device, _deep):
             yield get_obj_info(ns, child, self.app.config.human_friendly)
Exemple #2
0
 def execute(self, ns, devices=None, _deep=None):
     """
     Implementation of 'device depends' command.
     """
     for device in devices:
         yield fcmd.NewTableCommand(title=device)
         for parent in  get_parents(ns, device, _deep):
             yield get_obj_info(ns, parent, self.app.config.human_friendly)
Exemple #3
0
    def execute(self, ns, package_array):
        identity_checks = []

        def _verify_identity(identity):
            failed_checks = list(software.verify_package(ns, identity))
            identity_checks.append((identity, failed_checks))

        for_each_package_specs(ns, package_array, 'verify', _verify_identity)
        for identity, failed_checks in identity_checks:
            if len(failed_checks):
                yield fcmd.NewTableCommand(title=identity.ElementName)
                for file_check in failed_checks:
                    yield (software.render_failed_flags(
                        file_check.FailedFlags), file_check.Name)
            elif self.app.config.verbose:
                yield fcmd.NewTableCommand(title=identity.ElementName)
                yield ('', 'passed')
            else:
                LOG().debug('Package "%s" passed.', identity.ElementName)
Exemple #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 = fcmd.NewTableCommand(title=lv.DeviceID)
         yield cmd
         for line in show.lv_show(ns, lv, self.app.config.human_friendly):
             yield line
Exemple #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 = fcmd.NewTableCommand(title=vg.InstanceID)
         yield cmd
         for line in show.vg_show(ns, vg, self.app.config.human_friendly):
             yield line
Exemple #6
0
 def execute(self, ns, devices=None):
     """
     Implementation of 'raid show' command.
     """
     if not devices:
         devices = raid.get_raids(ns)
     for r in devices:
         r = str2device(ns, r)
         cmd = fcmd.NewTableCommand(title=r.DeviceID)
         yield cmd
         for line in show.raid_show(ns, r, self.app.config.human_friendly):
             yield line
 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 = fcmd.NewTableCommand(title=part.DeviceID)
         yield cmd
         for line in show.partition_show(ns, part,
                 self.app.config.human_friendly):
             yield line
Exemple #8
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 = fcmd.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 = fcmd.NewTableCommand(title=device.DeviceID)
         yield cmd
         for line in show.partition_table_show(
                 ns, device, self.app.config.human_friendly):
             yield line
Exemple #10
0
def cmd_show_devices(ns, device_names=None):
    """
    Implementation of 'net show devices' command.
    """
    for device in list_devices(ns, device_names):
        yield fcmd.NewTableCommand(title="Device %s" % device.ElementName)
        yield ("Operating Status", ns.LMI_IPNetworkConnection.OperatingStatusValues.value_name(device.OperatingStatus))
        yield ("MAC Address", get_mac(ns, device))
        for ip, prefix in get_ipv4_addresses(ns, device):
            yield ("IPv4 Address", "%s/%s" % (ip, prefix))
        for ip, mask in get_ipv6_addresses(ns, device):
            yield ("IPv6 Address", "%s/%s" % (ip, mask))
        for gw in get_default_gateways(ns, device):
            yield ("Default Gateway", gw)
        for dns in get_dns_servers(ns, device):
            yield ("DNS Server", dns)
        for setting in get_active_settings(ns, device):
            yield ("Active Setting", setting.Caption)
        for setting in get_available_settings(ns, device):
            yield ("Available Setting", setting.Caption)
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 = get_computer_system(ns)
    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 CIMError as err:
        raise LmiFailed('Could not get target "%s": %s' % (target, err))

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

    yield fcmd.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)
Exemple #12
0
def cmd_show_settings(ns, captions=None):
    for setting in list_settings(ns, captions):
        yield fcmd.NewTableCommand(title="Setting %s" % setting.Caption)

        # Type
        if setting.classname == "LMI_BondingSlaveSettingData":
            yield ("Type", "Bond slave")
        elif setting.classname == "LMI_BondingMasterSettingData":
            yield ("Type", "Bond master")
            yield ("Interface", setting.InterfaceName)
            yield ("MIIMon", setting.MIIMon)
            yield ("Mode",
                   ns.LMI_BondingMasterSettingData.ModeValues.value_name(
                       setting.Mode))
            yield ("UpDelay", setting.UpDelay)
            yield ("DownDelay", setting.DownDelay)
            yield ("ARPInterval", setting.ARPInterval)
            if len(setting.ARPIPTarget) > 0:
                yield ("ARPIPTarget", ", ".join(setting.ARPIPTarget))
        elif setting.classname == "LMI_BridgingSlaveSettingData":
            yield ("Type", "Bridge slave")
        elif setting.classname == "LMI_BridgingMasterSettingData":
            yield ("Type", "Bridge master")
            yield ("Interface", setting.InterfaceName)

        ip4method = get_setting_ip4_method(ns, setting)
        if ip4method != SETTING_IP_METHOD_DISABLED:
            yield ("IPv4", SETTING_IP_METHOD_DESC.get(ip4method, 'Unknown'))
        ip6method = get_setting_ip6_method(ns, setting)
        if ip6method != SETTING_IP_METHOD_DISABLED:
            yield ("IPv6", SETTING_IP_METHOD_DESC.get(ip6method, 'Unknown'))

        for subsetting in get_sub_setting(ns, setting):
            if subsetting.classname == 'LMI_ExtendedStaticIPAssignmentSettingData':
                if subsetting.ProtocolIFType == ns.LMI_ExtendedStaticIPAssignmentSettingData.ProtocolIFTypeValues.IPv4:
                    version = "IPv4"
                    masks = subsetting.SubnetMasks
                else:
                    version = "IPv6"
                    masks = subsetting.IPv6SubnetPrefixLengths

                for i in range(len(subsetting.IPAddresses)):
                    mask = masks[i] if i < len(masks) else "(none)"
                    gateway = subsetting.GatewayAddresses[i] if i < len(
                        subsetting.GatewayAddresses) else None

                    if i < len(subsetting.GatewayAddresses) and len(
                            subsetting.GatewayAddresses[i]) > 0:
                        yield ("%s Address" % version,
                               "%s/%s %s" % (subsetting.IPAddresses[i], mask,
                                             subsetting.GatewayAddresses[i]))
                    else:
                        yield ("%s Address" % version,
                               "%s/%s" % (subsetting.IPAddresses[i], mask))

            elif subsetting.classname == 'LMI_DNSSettingData':
                for dns in subsetting.DNSServerAddresses:
                    yield ("DNS Server", dns)
            elif subsetting.classname in ('LMI_BridgingMasterSettingData',
                                          'LMI_BondingMasterSettingData'):
                yield ("Master Setting", subsetting.Caption)
            elif subsetting.classname in ('LMI_BridgingSlaveSettingData',
                                          'LMI_BondingSlaveSettingData'):
                yield ("Slave Setting", subsetting.Caption)
        # Don't show device for bridge and bond master
        if setting.classname not in ('LMI_BondingMasterSettingData',
                                     'LMI_BridgingMasterSettingData'):
            for device in get_applicable_devices(ns, setting):
                yield ("Device", device.ElementName)
        if is_setting_active(ns, setting):
            yield ("Status", "Active")
        else:
            yield ("Status", "Inactive")

        for route in get_static_routes(ns, setting):
            if route.AddressType == ns.LMI_IPRouteSettingData.AddressTypeValues.IPv4:
                yield ("IPv4 Static Route", "%s/%s %d %s" %
                       (route.DestinationAddress, route.DestinationMask,
                        route.RouteMetric, route.NextHop))
            else:
                yield ("IPv6 Static Route", "%s/%s %d %s" %
                       (route.DestinationAddress, route.PrefixLength,
                        route.RouteMetric, route.NextHop))