summaryrefslogtreecommitdiffstats
path: root/test/etc
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-20 02:14:02 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-20 02:14:02 +0000
commit357d903fda1d768a14f47fd7a36e1491a0fd0efb (patch)
tree02f409949edcc691c3105e403b9d9d28f09d6b90 /test/etc
parentd0632c4188c66006747c148338c9040431e80d3e (diff)
* struct.c (rb_struct_equal, rb_struct_eql): Handle comparison of recursive structures [ruby-core:24759]
* range.c (range_eq, range_eql): ditto for ranges git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/etc')
0 files changed, 0 insertions, 0 deletions
href='#n58'>58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
#
# Copyright (C) 2015  FreeIPA Contributors see COPYING for license
#

from collections import namedtuple

from ipalib import _
from ipalib import Command
from ipalib import errors
from ipalib import output
from ipalib.parameters import Int
from ipalib.plugable import Registry

from ipapython.dn import DN


__doc__ = _("""
Raise the IPA Domain Level.
""")

register = Registry()

DomainLevelRange = namedtuple('DomainLevelRange', ['min', 'max'])

domainlevel_output = (
    output.Output('result', int, _('Current domain level:')),
)


def get_domainlevel_dn(api):
    domainlevel_dn = DN(
        ('cn', 'Domain Level'),
        ('cn', 'ipa'),
        ('cn', 'etc'),
        api.env.basedn
    )

    return domainlevel_dn


def get_domainlevel_range(master_entry):
    try:
        return DomainLevelRange(
            int(master_entry['ipaMinDomainLevel'][0]),
            int(master_entry['ipaMaxDomainLevel'][0])
        )
    except KeyError:
        return DomainLevelRange(0, 0)


def get_master_entries(ldap, api):
    """
    Returns list of LDAPEntries representing IPA masters.
    """

    container_masters = DN(
        ('cn', 'masters'),
        ('cn', 'ipa'),
        ('cn', 'etc'),
        api.env.basedn
    )

    masters, _ = ldap.find_entries(
        filter="(cn=*)",
        base_dn=container_masters,
        scope=ldap.SCOPE_ONELEVEL,
        paged_search=True,  # we need to make sure to get all of them
    )

    return masters


@register()
class domainlevel_get(Command):
    __doc__ = _('Query current Domain Level.')

    has_output = domainlevel_output

    def execute(self, *args, **options):
        ldap = self.api.Backend.ldap2
        entry = ldap.get_entry(
            get_domainlevel_dn(self.api),
            ['ipaDomainLevel']
        )

        return {'result': int(entry.single_value['ipaDomainLevel'])}


@register()
class domainlevel_set(Command):
    __doc__ = _('Change current Domain Level.')

    has_output = domainlevel_output

    takes_args = (
        Int('ipadomainlevel',
            cli_name='level',
            label=_('Domain Level'),
            minvalue=0,
        ),
    )

    def execute(self, *args, **options):
        """