Пример #1
0
                continue
            free, modified = config_net.network_tree.get().getFreeNetwork(
                config_net.range_start.get(), config_net.range_end.get(), user)
            if not free:
                continue
            self.associate(free)
            if modified is None:
                modified = []
            modified.append(self)
            return free, modified
        raise errors.SiptrackError(
            'device unable to autoassign, no available networks')


# Add the objects in this module to the object registry.
o = object_registry.registerClass(DeviceTree)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Device)
o.registerChild(DeviceCategory)
o.registerChild(template.DeviceTemplate)
o.registerChild(config.ConfigNetworkAutoassign)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)

o = object_registry.registerClass(DeviceCategory)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Device)
o.registerChild(DeviceCategory)
o.registerChild(template.DeviceTemplate)
Пример #2
0
    def iterMissingNetworks(self):
        if self.protocol == 'ipv4':
            return ipv4.iter_missing_networks_from_tree(self)
        elif self.protocol == 'ipv6':
            return ipv6.iter_missing_networks_from_tree(self)
        else:
            raise errors.SiptrackError(
                'confused, invalid protocol in network tree?')

    def _get_protocol(self):
        return self._protocol.get()

    def _set_protocol(self, val):
        self._protocol.set(val)

    protocol = property(_get_protocol, _set_protocol)


# Add the objects in this module to the object registry.
o = object_registry.registerClass(NetworkTree)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(ipv4.Network)
o.registerChild(ipv4.NetworkRange)
o.registerChild(ipv6.Network)
o.registerChild(ipv6.NetworkRange)
o.registerChild(template.NetworkTemplate)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)
Пример #3
0
    def _encodeKeywords(self, keywords):
        ret = {}
        for key, value in keywords.iteritems():
            if type(key) == unicode:
                key = key.encode('utf-8')
            if type(value) == unicode:
                value = value.encode('utf-8')
            ret[key] = value
        return ret

    @defer.inlineCallbacks
    def expand(self, keywords):
        tmpl = yield self.template.get()
        tmpl = Template(tmpl)
        attributes = self._gatherAttributes()
        attributes.update(keywords)
        attributes = self._encodeKeywords(attributes)
        ret = tmpl.safe_substitute(attributes)
        defer.returnValue(ret)

# Add the objects in this module to the object registry.
o = object_registry.registerClass(DeviceConfig)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

o = object_registry.registerClass(DeviceConfigTemplate)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)
Пример #4
0
        if self.all_users.get():
            return True
        if not user:
            return False
        for u in self.users.get():
            if user.oid == u.oid:
                return True
        for g in self.groups.get():
            for u in g.users.get():
                if user.oid == u.oid:
                    return True
        return False

    def _remove(self, *args, **kwargs):
        super(Permission, self)._remove(*args, **kwargs)
        # Clear the global permission cache when a permission
        # is removed.
        self.perm_cache.clear()

    def _relocate(self, *args, **kwargs):
        super(Permission, self)._relocate(*args, **kwargs)
        # Clear the global permission cache when a permission
        # is moved.
        self.perm_cache.clear()

# Add the objects in this module to the object registry.
o = object_registry.registerClass(Permission)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)

Пример #5
0
    def set(self, new_value):
        match = False
        for pos, value in enumerate(self._values.get()):
            if new_value == value:
                match = pos
                break
        if not match:
            raise errors.SiptrackError('invalid value for set')
        self._value_pos.set(pos)

    def getValues(self):
        return self._values.get()

    def setValues(self, values):
        if type(values) != list or len(values) < 1:
            raise errors.SiptrackError('invalid counter values supplied')
        self._values.set(values)
        self._value_pos.set(0)

# Add the objects in this module to the object registry.
o = object_registry.registerClass(Counter)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

o = object_registry.registerClass(CounterLoop)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)
Пример #6
0
    def atype(self, val):
        self._atype = val
        self.storageAction(
            'write_data',
            {'name': 'attr-type', 'value': self._atype}
        )


    @property
    def lock_data(self):
        return self._lock_data.get()

    @lock_data.setter
    def lock_data(self, val):
        self._lock_data.set(val)


# Add the objects in this module to the object registry.
o = object_registry.registerClass(Attribute)
o.registerChild(Attribute)
o.registerChild(VersionedAttribute)

o = object_registry.registerClass(VersionedAttribute)
o.registerChild(Attribute)
o.registerChild(VersionedAttribute)

o = object_registry.registerClass(EncryptedAttribute)
o.registerChild(EncryptedAttribute)
o.registerChild(Attribute)
o.registerChild(VersionedAttribute)
Пример #7
0
        super(ConfigValue, self)._created(user)
        self.name.commit()
        self.value.commit()

    def _loaded(self, data):
        super(ConfigValue, self)._loaded()
        self.name.preload(data)
        self.value.preload(data)

    def _nameValidator(self, value):
        if type(value) not in [str, unicode]:
            raise errors.SiptrackError('invalid name for ConfigValue')
        for node in self.parent.listChildren(include=['config value']):
            if node == self:
                continue
            if node.name.get() == value:
                raise errors.SiptrackError(
                    'duplicate ConfigValue name detected')


# Add the objects in this module to the object registry.
o = object_registry.registerClass(ConfigNetworkAutoassign)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

o = object_registry.registerClass(ConfigValue)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)
Пример #8
0
    range = range_from_string(range)

    parent = network_tree
    while True:
        prev_parent = parent
        for net in parent.listChildren(include=[Network.class_name]):
            if range <= net.address:
                parent = net
                break
        # Found our nearest parent.
        if parent is prev_parent:
            break
    return parent


# Add the objects in this module to the object registry.
o = object_registry.registerClass(Network)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Network)
o.registerChild(NetworkRange)
o.registerChild(template.NetworkTemplate)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)

o = object_registry.registerClass(NetworkRange)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)
Пример #9
0
class View(treenodes.BaseNode):
    """A network/device/everything view.

    A view is the main toplevel object type. It contains everything from
    networks to devices to counters etc.
    """
    class_id = 'V'
    class_name = 'view'

    def __init__(self, oid, branch):
        super(View, self).__init__(oid, branch)


# Add the objects in this module to the object registry.
o = object_registry.registerClass(ViewTree)
o.registerChild(View)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(user.UserManagerLocal)
if user._have_ldap:
    o.registerChild(user.UserManagerLDAP)
    o.registerChild(user.UserManagerActiveDirectory)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)
o.registerChild(event.CommandQueue)
o.registerChild(event.EventTrigger)

o = object_registry.registerClass(View)
o.registerChild(container.ContainerTree)
o.registerChild(attribute.Attribute)
Пример #10
0
                continue
            free, modified = config_net.network_tree.get().getFreeNetwork(
                    config_net.range_start.get(),
                    config_net.range_end.get(),
                    user)
            if not free:
                continue
            self.associate(free)
            if modified is None:
                modified = []
            modified.append(self)
            return free, modified
        raise errors.SiptrackError('device unable to autoassign, no available networks')

# Add the objects in this module to the object registry.
o = object_registry.registerClass(DeviceTree)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Device)
o.registerChild(DeviceCategory)
o.registerChild(template.DeviceTemplate)
o.registerChild(config.ConfigNetworkAutoassign)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)

o = object_registry.registerClass(DeviceCategory)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Device)
o.registerChild(DeviceCategory)
o.registerChild(template.DeviceTemplate)
Пример #11
0
    class_name = 'container tree'

    def __init__(self, oid, branch):
        super(ContainerTree, self).__init__(oid, branch)


class Container(treenodes.BaseNode):
    """Container for attributes.

    This object type is pretty much obsolete.
    """
    class_id = 'C'
    class_name = 'container'

    def __init__(self, oid, branch):
        super(Container, self).__init__(oid, branch)


# Add the objects in this module to the object registry.
o = object_registry.registerClass(ContainerTree)
o.registerChild(Container)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

o = object_registry.registerClass(Container)
o.registerChild(Container)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)
Пример #12
0
        if event_type in ['node add', 'node remove', 'node update', 'node relocate']:
            node = args[0]
        elif event_type in ['node associate', 'node disassociate']:
            node1, node2 = args
        try:
            exec self._code.get()
            if self._error_timestamp.get() != 0:
                self._error_timestamp.set(0)
                self._error.set('')
        except Exception, e:
            log.msg('Exception caught when running %s: %s' % (self, str(e)))
            self._error_timestamp.set(int(time.time()))
            self._error.set(str(e))

# Add the objects in this module to the object registry.
o = object_registry.registerClass(Command)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

o = object_registry.registerClass(CommandQueue)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)
o.registerChild(Command)

o = object_registry.registerClass(EventTriggerRulePython)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)
Пример #13
0
    def validate(self, node, user):
        pass

    def apply(self, node, overwrite, user):
        include = ['attribute', 'versioned attribute']
        updated = [node]
        for assoc in list(
                node.listAssocRef(include=self.include.get(),
                                  exclude=self.exclude.get())):
            node.disAssocRef(assoc)
            updated.append(assoc)
        return updated


o = object_registry.registerClass(DeviceTemplate)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(TemplateRuleText)
o.registerChild(TemplateRuleFixed)
o.registerChild(TemplateRuleRegmatch)
o.registerChild(TemplateRuleBool)
o.registerChild(TemplateRuleDeleteAttribute)
o.registerChild(TemplateRuleInt)
o.registerChild(TemplateRulePassword)
o.registerChild(TemplateRuleAssignNetwork)
o.registerChild(TemplateRuleSubdevice)
o.registerChild(TemplateRuleFlushNodes)
o.registerChild(TemplateRuleFlushAssociations)

o = object_registry.registerClass(NetworkTemplate)
Пример #14
0
            updated += sk._updated_create
        if remove_self:
            updated += self.remove(recursive=True)
        return updated

    def _get_password_key(self):
        return self._password_key.get()

    def _set_password_key(self, val):
        self._password_key.set(val)

    password_key = property(_get_password_key, _set_password_key)


# Add the objects in this module to the object registry.
o = object_registry.registerClass(PasswordTree)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Password)
o.registerChild(PasswordKey)
o.registerChild(PasswordCategory)
o.registerChild(permission.Permission)

o = object_registry.registerClass(PasswordCategory)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Password)
o.registerChild(permission.Permission)
o.registerChild(PasswordCategory)

o = object_registry.registerClass(Password)
Пример #15
0
        ret = None
        if subkey and self.password:
            ret = subkey.getEncryptionString(self.password)
        return ret

    def _get_administrator(self):
        return self.user._administrator.get()

    def _set_administrator(self, val):
        self.user._administrator.set(val)

    administrator = property(_get_administrator, _set_administrator)


# Add the objects in this module to the object registry.
o = object_registry.registerClass(UserManagerLocal)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(UserLocal)
o.registerChild(UserGroup)

if _have_ldap:
    o = object_registry.registerClass(UserManagerLDAP)
    o.registerChild(attribute.Attribute)
    o.registerChild(attribute.VersionedAttribute)
    o.registerChild(UserLDAP)
    o.registerChild(UserGroup)
    o.registerChild(UserGroupLDAP)

    o = object_registry.registerClass(UserManagerActiveDirectory)
    o.registerChild(attribute.Attribute)
Пример #16
0
    def _created(self, user):
        super(ConfigValue, self)._created(user)
        self.name.commit()
        self.value.commit()

    def _loaded(self, data):
        super(ConfigValue, self)._loaded()
        self.name.preload(data)
        self.value.preload(data)

    def _nameValidator(self, value):
        if type(value) not in [str, unicode]:
            raise errors.SiptrackError('invalid name for ConfigValue')
        for node in self.parent.listChildren(include = ['config value']):
            if node == self:
                continue
            if node.name.get() == value:
                raise errors.SiptrackError('duplicate ConfigValue name detected')

# Add the objects in this module to the object registry.
o = object_registry.registerClass(ConfigNetworkAutoassign)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

o = object_registry.registerClass(ConfigValue)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)
Пример #17
0
    range = range_from_string(range)

    parent = network_tree
    while True:
        prev_parent = parent
        for net in parent.listChildren(include = [Network.class_name]):
            if range <= net.address:
                parent = net
                break
        # Found our nearest parent.
        if parent is prev_parent:
            break
    return parent

# Add the objects in this module to the object registry.
o = object_registry.registerClass(Network)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Network)
o.registerChild(NetworkRange)
o.registerChild(template.NetworkTemplate)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)

o = object_registry.registerClass(NetworkRange)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)

Пример #18
0
    class_name = 'container tree'

    def __init__(self, oid, branch):
        super(ContainerTree, self).__init__(oid, branch)

class Container(treenodes.BaseNode):
    """Container for attributes.

    This object type is pretty much obsolete.
    """
    class_id = 'C'
    class_name = 'container'

    def __init__(self, oid, branch):
        super(Container, self).__init__(oid, branch)


# Add the objects in this module to the object registry.
o = object_registry.registerClass(ContainerTree)
o.registerChild(Container)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

o = object_registry.registerClass(Container)
o.registerChild(Container)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(permission.Permission)

Пример #19
0
    def getSubkeyEncryptionStringForPasswordKey(self, password_key):
        subkey = self.getSubKeyForPasswordKey(password_key)
        ret = None
        if subkey and self.password:
            ret = subkey.getEncryptionString(self.password)
        return ret

    def _get_administrator(self):
        return self.user._administrator.get()
    def _set_administrator(self, val):
        self.user._administrator.set(val)
    administrator = property(_get_administrator, _set_administrator)

# Add the objects in this module to the object registry.
o = object_registry.registerClass(UserManagerLocal)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(UserLocal)
o.registerChild(UserGroup)

if _have_ldap:
    o = object_registry.registerClass(UserManagerLDAP)
    o.registerChild(attribute.Attribute)
    o.registerChild(attribute.VersionedAttribute)
    o.registerChild(UserLDAP)
    o.registerChild(UserGroup)
    o.registerChild(UserGroupLDAP)

    o = object_registry.registerClass(UserManagerActiveDirectory)
    o.registerChild(attribute.Attribute)
Пример #20
0
        sk = user.add(None, 'subkey', password_key, user_password, pk_password)
        updated = [sk]
        if hasattr(sk, '_updated_create'):
            updated += sk._updated_create
        if remove_self:
            updated += self.remove(recursive=True)
        return updated

    def _get_password_key(self):
        return self._password_key.get()
    def _set_password_key(self, val):
        self._password_key.set(val)
    password_key = property(_get_password_key, _set_password_key)

# Add the objects in this module to the object registry.
o = object_registry.registerClass(PasswordTree)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Password)
o.registerChild(PasswordKey)
o.registerChild(PasswordCategory)
o.registerChild(permission.Permission)

o = object_registry.registerClass(PasswordCategory)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(Password)
o.registerChild(permission.Permission)
o.registerChild(PasswordCategory)

o = object_registry.registerClass(Password)
Пример #21
0
                pass
        return False

    def iterMissingNetworks(self):
        if self.protocol == 'ipv4':
            return ipv4.iter_missing_networks_from_tree(self)
        elif self.protocol == 'ipv6':
            return ipv6.iter_missing_networks_from_tree(self)
        else:
            raise errors.SiptrackError('confused, invalid protocol in network tree?')

    def _get_protocol(self):
        return self._protocol.get()

    def _set_protocol(self, val):
        self._protocol.set(val)
    protocol = property(_get_protocol, _set_protocol)

# Add the objects in this module to the object registry.
o = object_registry.registerClass(NetworkTree)
o.registerChild(attribute.Attribute)
o.registerChild(attribute.VersionedAttribute)
o.registerChild(ipv4.Network)
o.registerChild(ipv4.NetworkRange)
o.registerChild(ipv6.Network)
o.registerChild(ipv6.NetworkRange)
o.registerChild(template.NetworkTemplate)
o.registerChild(config.ConfigValue)
o.registerChild(permission.Permission)