コード例 #1
0
ファイル: UserPlugin.py プロジェクト: capc/middleware
        for i in range(start_gid, end_gid):
            if not self.datastore.exists('groups', ('id', '=', i)):
                gid = i
                break

        if not gid:
            raise RpcException(errno.ENOSPC, 'No free GIDs available')

        return gid


@description("Create an user in the system")
@accepts(h.all_of(
    h.ref('user'),
    h.required('username', 'group'),
    h.forbidden('builtin', 'logged-in', 'sessions'),
    h.object({'password': {'type': 'string'}}),
    h.any_of(
        h.required('password'),
        h.required('unixhash', 'smbhash'),
        h.required('password_disabled')),
))
class UserCreateTask(Task):
    def describe(self, user):
        return "Adding user {0}".format(user['username'])

    def verify(self, user):

        errors = []

        for code, message in check_unixname(user['username']):
コード例 #2
0
            if not self.datastore.exists('groups', ('id', '=', i)):
                gid = i
                break

        if not gid:
            raise RpcException(errno.ENOSPC, 'No free GIDs available')

        return gid


@description("Create an user in the system")
@accepts(
    h.all_of(
        h.ref('user'),
        h.required('username', 'group'),
        h.forbidden('builtin', 'logged-in', 'sessions'),
        h.object({'password': {
            'type': 'string'
        }}),
        h.any_of(h.required('password'), h.required('unixhash', 'smbhash'),
                 h.required('password_disabled')),
    ))
class UserCreateTask(Task):
    def describe(self, user):
        return "Adding user {0}".format(user['username'])

    def verify(self, user):

        errors = []

        for code, message in check_unixname(user['username']):
コード例 #3
0
        return name


@description("Deletes interface")
@accepts(str)
class DeleteInterfaceTask(Task):
    def verify(self, name):
        raise NotImplementedError()

    def run(self, name):
        raise NotImplementedError()


@description("Alters network interface configuration")
@accepts(str, h.all_of(h.ref('network-interface'), h.forbidden('id', 'type')))
class ConfigureInterfaceTask(Task):
    def verify(self, name, updated_fields):
        if not self.datastore.exists('network.interfaces', ('id', '=', name)):
            raise VerifyException(errno.ENOENT,
                                  'Interface {0} does not exist'.format(name))

        return ['system']

    def run(self, name, updated_fields):
        if updated_fields.get('dhcp'):
            # Check for DHCP inconsistencies
            # 1. Check whether DHCP is enabled on other interfaces
            # 2. Check whether DHCP configures default route and/or DNS server addresses
            dhcp_used = self.datastore.exists('network.interfaces',
                                              ('dhcp', '=', True),
コード例 #4
0
ファイル: NetworkPlugin.py プロジェクト: capc/middleware

@description("Deletes interface")
@accepts(str)
class DeleteInterfaceTask(Task):
    def verify(self, name):
        raise NotImplementedError()

    def run(self, name):
        raise NotImplementedError()


@description("Alters network interface configuration")
@accepts(str, h.all_of(
    h.ref('network-interface'),
    h.forbidden('id', 'type')
))
class ConfigureInterfaceTask(Task):
    def verify(self, name, updated_fields):
        if not self.datastore.exists('network.interfaces', ('id', '=', name)):
            raise VerifyException(errno.ENOENT, 'Interface {0} does not exist'.format(name))

        return ['system']

    def run(self, name, updated_fields):
        if updated_fields.get('dhcp'):
            # Check for DHCP inconsistencies
            # 1. Check whether DHCP is enabled on other interfaces
            # 2. Check whether DHCP configures default route and/or DNS server addresses
            dhcp_used = self.datastore.exists('network.interfaces', ('dhcp', '=', True), ('id' '!=', name))
            dhcp_global = self.dispatcher.configstore.get('network.dhcp.assign_gateway') or \