예제 #1
0
from lmi.scripts.common import command
from lmi.scripts.logicalfile import logicalfile

class Lister(command.LmiLister):
    COLUMNS = ('Type', 'Name', 'Mode', 'Current SELinux Context')
    OPT_NO_UNDERSCORES = True
    CALLABLE = logicalfile.lf_list

class Show(command.LmiLister):
    COLUMNS = ('Name', 'Value')
    OPT_NO_UNDERSCORES = True
    CALLABLE = logicalfile.lf_show

class CreateDir(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = logicalfile.lf_createdir

class DeleteDir(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = logicalfile.lf_deletedir

Lf = command.register_subcommands(
        'Lf', __doc__,
        { 'list'    : Lister,
          'createdir'  : CreateDir,
          'deletedir'  : DeleteDir,
          'show'    : Show,
        },
    )
예제 #2
0
class Remove(command.LmiCheckResult):
    EXPECT = None

    def transform_options(self, options):
        """
        Change 'group' list to string
        Rename 'user' to 'users'
        """
        options['<group>'] = options.pop('<group>')[0]
        options['<users>'] = options.pop('<user>')

    def execute(self, ns, group, users):
        group_inst = account.get_group(ns, group)
        user_insts = []
        for user in users:
            user_inst = account.get_user(ns, user)
            user_insts.append(user_inst)
        account.remove_from_group(ns, group_inst, user_insts)

Group = command.register_subcommands(
        'group', __doc__,
        { 'list'    : Lister
        , 'create'  : Create
        , 'delete'  : Delete
        , 'listuser': ListUser
        , 'adduser' : Add
        , 'removeuser': Remove
        },
    )
예제 #3
0
        options['service'] = 'sssd'
        
class SetDebugLevel(command.LmiCheckResult):
    OPT_NO_UNDERSCORES = True
    EXPECT = 0
    
    def execute(self, ns, level,
                until_restart=False,
                all=False,
                monitor=False,
                services=None,
                domains=None):
        components = []
        if services is not None:
            components.extend(services.split(','))
        if domains is not None:
            components.extend(domains.split(','))
        if monitor:
            components.append('monitor')
        return sssd.set_debug_level(ns, level, all, until_restart, components)
    
SSSD = command.register_subcommands(
        'SSSD', __doc__,
        { 'status'              : Status
        , 'restart'             : Restart
        , 'set-debug-level'     : SetDebugLevel
        , 'service'             : ServiceCommands
        , 'domain'              : DomainCommands
        },
    )
예제 #4
0
    def transform_options(self, options):
        """
        Rename 'device' option to 'devices' parameter name for better
        readability.
        """
        options['<devices>'] = options.pop('<device>')

    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

PartitionTable = command.register_subcommands(
        'PartitionTable', __doc__,
        { 'list'    : Lister ,
          'create'  : Create,
          'show'    : Show,
        },
    )
예제 #5
0
        """
        Return unique ID of a device or a Volume group.
        """
        if lmi_isinstance(obj, ns.CIM_StorageExtent):
            return obj.DeviceID
        else:
            return obj.InstanceID


Storage = command.register_subcommands(
    "storage",
    __doc__,
    {
        "list": Lister,
        "show": Show,
        "tree": Tree,
        "provides": Provides,
        "depends": Depends,
        "fs": lmi.scripts.storage.cmd.fs.FS,
        "luks": lmi.scripts.storage.cmd.luks.LUKS,
        "lv": lmi.scripts.storage.cmd.lv.LV,
        "mount": lmi.scripts.storage.cmd.mount.Mount,
        "partition": lmi.scripts.storage.cmd.partition.Partition,
        "partition-table": lmi.scripts.storage.cmd.partition_table.PartitionTable,
        "raid": lmi.scripts.storage.cmd.raid.Raid,
        "vg": lmi.scripts.storage.cmd.vg.VG,
        "thinpool": lmi.scripts.storage.cmd.thinpool.ThinPool,
        "thinlv": lmi.scripts.storage.cmd.thinlv.ThinLV,
    },
)
예제 #6
0
    -p, --password  Optional password for the authentication. If omitted you
                    will be prompted for one.
    -d, --domain    The domain to be joined/left.
"""

from lmi.scripts.common import command


class Show(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = 'lmi.scripts.realmd:show'


class Join(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = 'lmi.scripts.realmd:join'


class Leave(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = 'lmi.scripts.realmd:leave'


Realmd = command.register_subcommands('Realmd',
                                      __doc__, {
                                          'show': Show,
                                          'join': Join,
                                          'leave': Leave
                                      },
                                      fallback_command=Show)
예제 #7
0
    def execute(self, ns, layouts, model, variant, options, _convert=False):
        if not model:
            model = ''
        if not variant:
            variant = ''
        if not options:
            options = ''
        loc.set_x11_keymap(ns, layouts, model, variant, options, _convert)


class SetVCKeyboard(command.LmiCheckResult):
    EXPECT = None

    def execute(self, ns, keymap, keymap_toggle, _convert=False):
        if not keymap_toggle:
            keymap_toggle = ''
        loc.set_vc_keyboard(ns, keymap, keymap_toggle, _convert)


Locale = command.register_subcommands(
    'Locale',
    __doc__,
    {
        'show': Show,
        'set-locale': SetLocale,
        'set-x11-keymap': SetX11Keymap,
        'set-vc-keyboard': SetVCKeyboard,
    },
)
예제 #8
0
class System(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_system_info'

class Motherboard(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_motherboard_info'

class Cpu(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_cpu_info'

class Memory(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_memory_info'

class PCI(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_pci_info'

class Disks(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_disks_info'

Hardware = command.register_subcommands(
        'Hardware', __doc__,
        { 'all'          : All
        , 'system'       : System
        , 'motherboard'  : Motherboard
        , 'cpu'          : Cpu
        , 'memory'       : Memory
        , 'pci'          : PCI
        , 'disks'        : Disks
        },
        fallback_command=All
    )
예제 #9
0
        """
        for vg in vgs:
            lvm.delete_vg(ns, vg)


class Show(command.LmiLister):
    COLUMNS = ("Name", "Value")

    def transform_options(self, options):
        """
        Rename 'vg' option to 'vgs' parameter name for better
        readability.
        """
        options["<vgs>"] = options.pop("<vg>")

    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


Vg = command.register_subcommands("vg", __doc__, {"list": Lister, "create": Create, "delete": Delete, "show": Show})
예제 #10
0
    def execute(self, ns):
        return cmd_suspend(ns)


class Hibernate(command.LmiCheckResult):
    EXPECT = 0

    def execute(self, ns):
        return cmd_hibernate(ns)


class Poweroff(command.LmiCheckResult):
    EXPECT = 0

    def execute(self, ns, _force):
        return cmd_poweroff(ns, _force)


class Reboot(command.LmiCheckResult):
    EXPECT = 0

    def execute(self, ns, _force):
        return cmd_reboot(ns, _force)


PowerManagement = command.register_subcommands(
    "PowerManagement",
    __doc__,
    {"list": Lister, "suspend": Suspend, "hibernate": Hibernate, "poweroff": Poweroff, "reboot": Reboot},
)
예제 #11
0
        """
        fs.create_fs(ns, devices, fstype, _label)


class Delete(command.LmiCheckResult):
    EXPECT = None

    def transform_options(self, options):
        """
        Rename 'device' option to 'devices' parameter name for better
        readability.
        """
        options['<devices>'] = options.pop('<device>')

    def execute(self, ns, devices):
        """
        Implementation of 'fs delete' command.
        """
        for dev in devices:
            fs.delete_format(ns, dev)


Fs = command.register_subcommands(
        'fs', __doc__,
        { 'list'    : Lister ,
          'create'  : Create,
          'delete'  : Delete,
          'list-supported': ListSupported,
        },
    )
예제 #12
0
파일: cmd.py 프로젝트: jsafrane/openlmi-doc
        loc.set_locale(ns, locales, values)

class SetX11Keymap(command.LmiCheckResult):
    EXPECT = None

    def execute(self, ns, layouts, model, variant, options, _convert=False):
        if not model:
            model = ''
        if not variant:
            variant = ''
        if not options:
            options = ''
        loc.set_x11_keymap(ns, layouts, model, variant, options, _convert)

class SetVCKeyboard(command.LmiCheckResult):
    EXPECT = None

    def execute(self, ns, keymap, keymap_toggle, _convert=False):
        if not keymap_toggle:
            keymap_toggle = ''
        loc.set_vc_keyboard(ns, keymap, keymap_toggle, _convert)

Locale = command.register_subcommands(
        'Locale', __doc__,
        { 'show' : Show,
          'set-locale' : SetLocale,
          'set-x11-keymap' : SetX11Keymap,
          'set-vc-keyboard' : SetVCKeyboard,
        },
    )
예제 #13
0
class SetLocalRTC(command.LmiCheckResult):
    EXPECT = None

    def execute(self, ns, on, off, _fix_system=False):
        value=False
        if on:
            value=True
        loc.set_local_rtc(ns, value, _fix_system)

class SetNTP(command.LmiCheckResult):
    EXPECT = None

    def execute(self, ns, on, off):
        value=False
        if on:
            value=True
        loc.set_ntp(ns, value)

Locale = command.register_subcommands(
        'Locale', __doc__,
        { 'show' : Show,
          'set-locale' : SetLocale,
          'set-x11-keymap' : SetX11Keymap,
          'set-vc-keyboard' : SetVCKeyboard,
          'set-time' : SetTime,
          'set-timezone' : SetTimezone,
          'set-local-rtc' : SetLocalRTC,
          'set-ntp' : SetNTP,
        },
    )
예제 #14
0
            shell=None,
            uid=None,
            gid=None,
            reserved=None,
            no_user_home=False,
            no_user_group=False,
            password=None,
            plain_password=False):

        account.create_user(ns, name,
                gecos=gecos,
                home=directory,
                create_home=not no_user_home,
                shell=shell,
                uid=uid,
                gid=gid,
                create_group=not no_user_group,
                reserved=reserved,
                password=password,
                plain_password=plain_password)


User = command.register_subcommands(
        'user', __doc__,
        { 'list'    : Lister
        , 'show'    : Show
        , 'create'  : Create
        , 'delete'  : Delete
        },
    )
예제 #15
0
    def get_obj_id(self, ns, obj):
        """
        Return unique ID of a device or a Volume group.
        """
        if lmi_isinstance(obj, ns.CIM_StorageExtent):
            return obj.DeviceID
        else:
            return obj.InstanceID


Storage = command.register_subcommands(
        'storage', __doc__,
        { 'list'    : Lister,
          'show'    : Show,
          'tree'    : Tree,
          'provides': Provides,
          'depends' : Depends,
          'fs'      : lmi.scripts.storage.cmd.fs.FS,
          'luks'      : lmi.scripts.storage.cmd.luks.LUKS,
          'lv'      : lmi.scripts.storage.cmd.lv.LV,
          'mount'   : lmi.scripts.storage.cmd.mount.Mount,
          'partition': lmi.scripts.storage.cmd.partition.Partition,
          'partition-table': lmi.scripts.storage.cmd.partition_table.PartitionTable,
          'raid'    : lmi.scripts.storage.cmd.raid.Raid,
          'vg'      : lmi.scripts.storage.cmd.vg.VG,
          'thinpool': lmi.scripts.storage.cmd.thinpool.ThinPool,
          'thinlv'  : lmi.scripts.storage.cmd.thinlv.ThinLV,
        },
    )

예제 #16
0
    def execute(self, ns, service, _try=False):
        return srv.reload_service(ns, service, force=True, just_try=_try)

class Show(command.LmiShowInstance):

    DYNAMIC_PROPERTIES = True

    def execute(self, ns, service):
        columns = (
                ('Name', lambda i: srv.RE_SUFFIX.sub('', i.Name)),
                'Caption',
                ('Enabled', lambda i: srv.get_enabled_string(ns, i)),
                ('Status', lambda i: srv.get_status_string(ns, i)))

        return columns, srv.get_service(ns, service)

Service = command.register_subcommands(
        'Service', __doc__,
        { 'list'    : Lister
        , 'show'    : Show
        , 'start'   : Start
        , 'stop'    : Stop
        , 'enable'  : Enable
        , 'disable' : Disable
        , 'restart' : Restart
        , 'reload'  : Reload
        , 'reload-or-restart' : ReloadOrRestart
        },
    )
예제 #17
0
파일: cmd.py 프로젝트: jsafrane/openlmi-doc
Options:
    -u, --user      The username to be used when authenticating to the domain.
    -p, --password  Optional password for the authentication. If omitted you
                    will be prompted for one.
    -d, --domain    The domain to be joined/left.
"""

from lmi.scripts.common import command

class Show(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = 'lmi.scripts.realmd:show'

class Join(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = 'lmi.scripts.realmd:join'

class Leave(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = 'lmi.scripts.realmd:leave'

Realmd = command.register_subcommands(
        'Realmd', __doc__,
        { 'show'         : Show
        , 'join'         : Join
        , 'leave'        : Leave
        },
        fallback_command=Show
    )
예제 #18
0
    def transform_options(self, options):
        options['reverse'] = options.pop('--reverse')
        options['tail'] = options.pop('--tail')

class Logger(command.LmiCheckResult):
    CALLABLE = journ.log_message
    EXPECT = 0

class Watcher(command.LmiCheckResult):
    CALLABLE = journ.watch
    EXPECT = 0


Journald = command.register_subcommands(
        'Journald', __doc__,
        { 'list'   : Lister
        , 'logger' : Logger
        , 'watch'  : Watcher
        },
    )

class JournaldCMD(LmiSelectCommand):
        """
        Test for provider version requirements
        """
        SELECT = [
                ( 'OpenLMI-Journald >= 0.4.2',
                  # command already defined with register_subcommands()
                  Journald )
                 ]
예제 #19
0
class Suspend(PowerCmd):
    
    def get_cmd_code(self, force=False):
        return POWER_STATE_SUSPEND

class Hibernate(PowerCmd):

    def get_cmd_code(self, force=False):
        return POWER_STATE_HIBERNATE

class Poweroff(PowerCmd):

    def get_cmd_code(self, force=False):
        return POWER_STATE_POWEROFF_FORCE if force else POWER_STATE_POWEROFF

class Reboot(PowerCmd):

    def get_cmd_code(self, force=False):
        return POWER_STATE_REBOOT_FORCE if force else POWER_STATE_REBOOT

PowerManagement = command.register_subcommands(
    'PowerManagement', __doc__,
    {
        'list':       Lister,
        'suspend':    Suspend,
        'hibernate':  Hibernate,
        'poweroff':   Poweroff,
        'reboot':     Reboot
    },
)
예제 #20
0
    CALLABLE = 'lmi.scripts.hardware:get_motherboard_info'


class Cpu(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_cpu_info'


class Memory(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_memory_info'


class PCI(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_pci_info'


class Disks(HwBase):
    CALLABLE = 'lmi.scripts.hardware:get_disks_info'


Hardware = command.register_subcommands('Hardware',
                                        __doc__, {
                                            'all': All,
                                            'system': System,
                                            'motherboard': Motherboard,
                                            'cpu': Cpu,
                                            'memory': Memory,
                                            'pci': PCI,
                                            'disks': Disks
                                        },
                                        fallback_command=All)
예제 #21
0
    def transform_options(self, options):
        """
        Change 'group' list to string
        Rename 'user' to 'users'
        """
        options['<group>'] = options.pop('<group>')[0]
        options['<users>'] = options.pop('<user>')

    def execute(self, ns, group, users):
        group_inst = account.get_group(ns, group)
        user_insts = []
        for user in users:
            user_inst = account.get_user(ns, user)
            user_insts.append(user_inst)
        account.remove_from_group(ns, group_inst, user_insts)


Group = command.register_subcommands(
    'group',
    __doc__,
    {
        'list': Lister,
        'create': Create,
        'delete': Delete,
        'listuser': ListUser,
        'adduser': Add,
        'removeuser': Remove
    },
)
예제 #22
0

class Delete(command.LmiCheckResult):
    EXPECT = None

    def transform_options(self, options):
        """
        Rename 'device' option to 'devices' parameter name for better
        readability.
        """
        options['<devices>'] = options.pop('<device>')

    def execute(self, ns, devices):
        """
        Implementation of 'fs delete' command.
        """
        for dev in devices:
            fs.delete_format(ns, dev)


Fs = command.register_subcommands(
    'fs',
    __doc__,
    {
        'list': Lister,
        'create': Create,
        'delete': Delete,
        'list-supported': ListSupported,
    },
)
예제 #23
0
        options['<users>'] = options.pop('<user>')


class Create(command.LmiCheckResult):
    CALLABLE = create_user
    EXPECT = None

    def verify_options(self, opts):
        _password = opts['--password']
        _plainpassword = opts['--plainpassword']
        _uid = opts['--uid']
        _gid = opts['--gid']
        if _password is not None and _plainpassword is not None:
            raise LmiInvalidOptions("Must set only one of password options")
        if _uid is not None and not _uid.isdigit():
            raise LmiInvalidOptions("User ID must be a number")
        if _gid is not None and not _gid.isdigit():
            raise LmiInvalidOptions("Group ID must be a number")


User = command.register_subcommands(
    'user',
    __doc__,
    {
        'list': Lister,
        'show': Show,
        'delete': Delete,
        'create': Create
    },
)
예제 #24
0
    EXPECT = 0

    def execute(self, ns, master_caption, device_name):
        setting = get_setting_by_caption(ns, master_caption)
        device = get_device_by_name(ns, device_name)
        return enslave(ns, setting, device)

    def transform_options(self, options):
        """
        Activate takes only one caption and device, get only one element
        from the list for better readability.
        """
        if '<device_name>' in options and len(options['<device_name>']) > 0:
            options['<device_name>'] = options['<device_name>'][0]


Networking = command.register_subcommands(
    'Networking',
    __doc__,
    {
        'device': Device,
        'setting': Setting,
        'activate': Activate,
        'deactivate': Deactivate,
        'enslave': Enslave,
        'address': Address,
        'route': Route,
        'dns': Dns
    },
)
예제 #25
0
class Logger(command.LmiCheckResult):
    CALLABLE = journ.log_message
    EXPECT = 0


class Watcher(command.LmiCheckResult):
    CALLABLE = journ.watch
    EXPECT = 0


Journald = command.register_subcommands(
    'Journald',
    __doc__,
    {
        'list': Lister,
        'logger': Logger,
        'watch': Watcher
    },
)


class JournaldCMD(LmiSelectCommand):
    """
        Test for provider version requirements
        """
    SELECT = [(
        'OpenLMI-Journald >= 0.4.2',
        # command already defined with register_subcommands()
        Journald)]
예제 #26
0
            try:
                repo = software.get_repository(ns, repoid)
                software.set_repository_enabled(ns, repo, enable=self.enable)
                modified.append(repoid)
            except errors.LmiFailed as err:
                LOG().warn(str(err))
        return modified


class DisableRepository(ChangeEnabledState):
    @property
    def enable(self):
        return False


Software = command.register_subcommands(
    "Software",
    __doc__,
    {
        "list": Lister,
        "search": Search,
        "show": Show,
        "install": Install,
        "update": Update,
        "remove": Remove,
        "verify": Verify,
        "enable": ChangeEnabledState,
        "disable": DisableRepository,
    },
)
예제 #27
0
    OPT_NO_UNDERSCORES = True
    EXPECT = None


class SetLabel(command.LmiCheckResult):
    CALLABLE = sel.set_file_label
    OPT_NO_UNDERSCORES = True
    EXPECT = None


class Restore(command.LmiCheckResult):
    CALLABLE = sel.restore
    OPT_NO_UNDERSCORES = True
    EXPECT = None


Selinux = command.register_subcommands(
    "Selinux",
    __doc__,
    {
        "show": Show,
        "list": ListElements,
        "set-state": SetState,
        "set-boolean": SetBoolean,
        "set-port": SetPort,
        "get-label": GetLabel,
        "set-label": SetLabel,
        "restore": Restore,
    },
)
예제 #28
0
    def transform_options(self, options):
        """
        Rename 'device' option to 'devices' parameter name for better
        readability.
        """
        options['<devices>'] = options.pop('<device>')

    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 = formatter.NewTableCommand(title=r.DeviceID)
            yield cmd
            for line in show.raid_show(ns, r, self.app.config.human_friendly):
                yield line


Raid = command.register_subcommands(
        'raid', __doc__,
        { 'list'    : Lister ,
          'create'  : Create,
          'delete'  : Delete,
          'show'    : Show,
        },
    )
예제 #29
0
                fs_type=None,
                options=None,
                other_options=None):
        """
        Implementation of 'mount create' command.
        """
        return mount.mount_create(ns, device, mountpoint, fs_type, options,
                                  other_options)


class Delete(command.LmiCheckResult):
    EXPECT = None

    def execute(self, ns, target):
        """
        Implementation of 'mount delete' command.
        """
        return mount.mount_delete(ns, target)


Mount = command.register_subcommands(
    'Mount',
    __doc__,
    {
        'list': Lister,
        'create': Create,
        'delete': Delete,
        'show': Show,
    },
)
예제 #30
0
        Rename 'partitions' option to 'partition' parameter name for better
        readability.
        """
        options['<partitions>'] = options.pop('<partition>')

    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


Partition = command.register_subcommands(
    'Partition',
    __doc__,
    {
        'list': Lister,
        'create': Create,
        'delete': Delete,
        'show': Show,
    },
)
예제 #31
0
    def transform_options(self, options):
        """
        Change 'group' list to string
        Rename 'user' to 'users'
        """
        options['<group>'] = options.pop('<group>')[0]
        options['<users>'] = options.pop('<user>')

class Remove(command.LmiCheckResult):
    CALLABLE = remove_from_group
    EXPECT = None

    def transform_options(self, options):
        """
        Change 'group' list to string
        Rename 'user' to 'users'
        """
        options['<group>'] = options.pop('<group>')[0]
        options['<users>'] = options.pop('<user>')

Group = command.register_subcommands(
        'group', __doc__,
        { 'show'    : Show
        , 'listusers' : ListUsers
        , 'create'  : Create
        , 'delete'  : Delete
        , 'add'     : Add
        , 'remove'  : Remove
        },
    )
예제 #32
0
                # Don't show children of already displayed elements
                continue

            # Display the device
            yield (self.prepare_tree_line(level, info[0], queue),) + info[1:]
            shown.add(devid)
            # And inspect all children
            children = [ dep[1] for dep in deps if dep[0] == devid ]
            for child in reversed(children):
                queue.append((child, level + 1))

    def get_obj_id(self, ns, obj):
        """
        Return unique ID of a device or a Volume group.
        """
        if lmi_isinstance(obj, ns.CIM_StorageExtent):
            return obj.DeviceID
        else:
            return obj.InstanceID


Storage = command.register_subcommands(
        'storage', __doc__,
        { 'list'    : Lister,
          'show'    : Show,
          'tree'    : Tree,
          'provides': Provides,
          'depends' : Depends,
        },
    )
예제 #33
0
    OPT_NO_UNDERSCORES = True
    EXPECT = None

class GetLabel(command.LmiCheckResult):
    CALLABLE = sel.get_file_label
    OPT_NO_UNDERSCORES = True
    EXPECT = None

class SetLabel(command.LmiCheckResult):
    CALLABLE = sel.set_file_label
    OPT_NO_UNDERSCORES = True
    EXPECT = None

class Restore(command.LmiCheckResult):
    CALLABLE = sel.restore
    OPT_NO_UNDERSCORES = True
    EXPECT = None

Selinux = command.register_subcommands(
        'Selinux', __doc__,
        { 'show' : Show,
          'list' : ListElements,
          'set-state' : SetState,
          'set-boolean' : SetBoolean,
          'set-port' : SetPort,
          'get-label' : GetLabel,
          'set-label' : SetLabel,
          'restore' : Restore,
        },
    )
예제 #34
0
    OPT_NO_UNDERSCORES = True
    CALLABLE = logicalfile.lf_list


class Show(command.LmiLister):
    COLUMNS = ('Name', 'Value')
    OPT_NO_UNDERSCORES = True
    CALLABLE = logicalfile.lf_show


class CreateDir(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = logicalfile.lf_createdir


class DeleteDir(command.LmiCheckResult):
    EXPECT = None
    CALLABLE = logicalfile.lf_deletedir


Lf = command.register_subcommands(
    'Lf',
    __doc__,
    {
        'list': Lister,
        'createdir': CreateDir,
        'deletedir': DeleteDir,
        'show': Show,
    },
)
예제 #35
0
        return srv.reload_service(ns, service)


class ReloadOrRestart(command.LmiCheckResult):
    EXPECT = 0

    def execute(self, ns, service, _try=False):
        return srv.reload_service(ns, service, force=True, just_try=_try)


class Show(command.LmiShowInstance):
    CALLABLE = srv.get_service
    PROPERTIES = ('Name', 'Caption', ('Enabled',
                                      lambda i: i.EnabledDefault == 2),
                  ('Active', 'Started'), 'Status')


Service = command.register_subcommands(
    'Service',
    __doc__,
    {
        'list': Lister,
        'show': Show,
        'start': Start,
        'stop': Stop,
        'restart': Restart,
        'reload': Reload,
        'reload-or-restart': ReloadOrRestart
    },
)
예제 #36
0
    OWN_USAGE = True

class Enslave(command.LmiCheckResult):
    EXPECT = 0
    def execute(self, ns, master_caption, device_name):
        setting = get_setting_by_caption(ns, master_caption)
        device = get_device_by_name(ns, device_name)
        return enslave(ns, setting, device)

    def transform_options(self, options):
        """
        Activate takes only one caption and device, get only one element
        from the list for better readability.
        """
        if '<device_name>' in options and len(options['<device_name>']) > 0:
            options['<device_name>'] = options['<device_name>'][0]

Networking = command.register_subcommands(
    'Networking', __doc__,
    {
        'device':     Device,
        'setting':    Setting,
        'activate':   Activate,
        'deactivate': Deactivate,
        'enslave':    Enslave,
        'address':    Address,
        'route':      Route,
        'dns':        Dns
    },
)
예제 #37
0
            # Display the device
            yield (self.prepare_tree_line(level, info[0], queue), ) + info[1:]
            shown.add(devid)
            # And inspect all children
            children = [dep[1] for dep in deps if dep[0] == devid]
            for child in reversed(children):
                queue.append((child, level + 1))

    def get_obj_id(self, ns, obj):
        """
        Return unique ID of a device or a Volume group.
        """
        if lmi_isinstance(obj, ns.CIM_StorageExtent):
            return obj.DeviceID
        else:
            return obj.InstanceID


Storage = command.register_subcommands(
    'storage',
    __doc__,
    {
        'list': Lister,
        'show': Show,
        'tree': Tree,
        'provides': Provides,
        'depends': Depends,
    },
)
예제 #38
0
    def execute(self, ns, repository_array):
        modified = []
        for repoid in repository_array:
            try:
                repo = software.get_repository(ns, repoid)
                software.set_repository_enabled(ns, repo, enable=self.enable)
                modified.append(repoid)
            except errors.LmiFailed as err:
                LOG().warn(str(err))
        return modified

class DisableRepository(ChangeEnabledState):

    @property
    def enable(self):
        return False

Software = command.register_subcommands(
        'Software', __doc__,
        { 'list'    : Lister
        , 'search'  : Search
        , 'show'    : Show
        , 'install' : Install
        , 'update'  : Update
        , 'remove'  : Remove
        , 'verify'  : Verify
        , 'enable'  : ChangeEnabledState
        , 'disable' : DisableRepository
        }
    )
예제 #39
0
    def get_cmd_code(self, force=False):
        return POWER_STATE_SUSPEND


class Hibernate(PowerCmd):
    def get_cmd_code(self, force=False):
        return POWER_STATE_HIBERNATE


class Poweroff(PowerCmd):
    def get_cmd_code(self, force=False):
        return POWER_STATE_POWEROFF_FORCE if force else POWER_STATE_POWEROFF


class Reboot(PowerCmd):
    def get_cmd_code(self, force=False):
        return POWER_STATE_REBOOT_FORCE if force else POWER_STATE_REBOOT


PowerManagement = command.register_subcommands(
    'PowerManagement',
    __doc__,
    {
        'list': Lister,
        'suspend': Suspend,
        'hibernate': Hibernate,
        'poweroff': Poweroff,
        'reboot': Reboot
    },
)
예제 #40
0
    def transform_options(self, options):
        """
        Rename 'partitions' option to 'partition' parameter name for better
        readability.
        """
        options['<partitions>'] = options.pop('<partition>')

    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


Partition = command.register_subcommands(
        'Partition', __doc__,
        { 'list'    : Lister ,
          'create'  : Create,
          'delete'  : Delete,
          'show'    : Show,
        },
    )
예제 #41
0
    def execute(self, ns, repository_array):
        modified = []
        for repoid in repository_array:
            try:
                repo = software.get_repository(ns, repoid)
                software.set_repository_enabled(ns, repo, enable=self.enable)
                modified.append(repoid)
            except errors.LmiFailed as err:
                LOG().warn(str(err))
        return modified

class DisableRepository(ChangeEnabledState):

    @property
    def enable(self):
        return False

Software = command.register_subcommands(
        'Software', __doc__,
        { 'list'    : Lister
        , 'show'    : Show
        , 'install' : Install
        , 'update'  : Update
        , 'remove'  : Remove
        , 'verify'  : Verify
        , 'enable'  : ChangeEnabledState
        , 'disable' : DisableRepository
        }
    )
예제 #42
0
        """
        options['<group>'] = options.pop('<group>')[0]
        options['<users>'] = options.pop('<user>')


class Remove(command.LmiCheckResult):
    CALLABLE = remove_from_group
    EXPECT = None

    def transform_options(self, options):
        """
        Change 'group' list to string
        Rename 'user' to 'users'
        """
        options['<group>'] = options.pop('<group>')[0]
        options['<users>'] = options.pop('<user>')


Group = command.register_subcommands(
    'group',
    __doc__,
    {
        'show': Show,
        'listusers': ListUsers,
        'create': Create,
        'delete': Delete,
        'add': Add,
        'remove': Remove
    },
)
예제 #43
0
class All(command.LmiLister):
    CALLABLE = 'lmi.scripts.hardware:get_all_info'
    COLUMNS = EMPTY_LINE

class System(command.LmiLister):
    CALLABLE = 'lmi.scripts.hardware:get_system_info'
    COLUMNS = EMPTY_LINE

class Chassis(command.LmiLister):
    CALLABLE = 'lmi.scripts.hardware:get_chassis_info'
    COLUMNS = EMPTY_LINE

class Cpu(command.LmiLister):
    CALLABLE = 'lmi.scripts.hardware:get_cpu_info'
    COLUMNS = EMPTY_LINE

class Memory(command.LmiLister):
    CALLABLE = 'lmi.scripts.hardware:get_memory_info'
    COLUMNS = EMPTY_LINE

Hardware = command.register_subcommands(
        'Hardware', __doc__,
        { 'all'     : All
        , 'system'  : System
        , 'chassis' : Chassis
        , 'cpu'     : Cpu
        , 'memory'  : Memory
        },
        fallback_command=All
    )