Beispiel #1
0
 def match_fn(self, event, row, old):
     if self.conditions and not idlutils.row_match(row, self.conditions):
         return False
     if self.old_conditions:
         if not old:
             return False
         try:
             if not idlutils.row_match(old, self.old_conditions):
                 return False
         except (KeyError, AttributeError):
             # Its possible that old row may not have all columns in it
             return False
     return True
Beispiel #2
0
 def run_idl(self, txn):
     ls = self.api.lookup('Logical_Switch', self.switch)
     for acl in [
             a for a in ls.acls if idlutils.row_match(a, self.conditions)
     ]:
         ls.delvalue('acls', acl)
         acl.delete()
Beispiel #3
0
 def run_idl(self, txn):
     self.result = [
         rowview.RowView(r) if self.row else
         {c: idlutils.get_column_value(r, c)
          for c in self.columns} for r in self.table.rows.values()
         if idlutils.row_match(r, self.conditions)
     ]
Beispiel #4
0
    def run_idl(self, txn):
        conditions = [('external_ids', '=', {'iface-id': self.port_id})]
        rows_to_delete = []
        for table in ['QoS', 'Queue']:
            for r in self.api._tables[table].rows.values():
                if idlutils.row_match(r, conditions):
                    rows_to_delete.append(r)

        for r in rows_to_delete:
            r.delete()
Beispiel #5
0
 def run_idl(self, txn):
     # reduce search space if we have any indexed column and '=' match
     rows = (idlutils.index_condition_match(self.table, *self.conditions)
             or self.table.rows.values())
     self.result = [
         rowview.RowView(r) if self.row else
         {c: idlutils.get_column_value(r, c)
          for c in self.columns} for r in rows
         if idlutils.row_match(r, self.conditions)
     ]
Beispiel #6
0
    def matches(self, event, row, old=None):
        if event not in self.events:
            return False
        if row._table.name != self.table:
            return False
        if self.conditions and not idlutils.row_match(row, self.conditions):
            return False
        if self.old_conditions:
            if not old:
                return False
            try:
                if not idlutils.row_match(old, self.old_conditions):
                    return False
            except (KeyError, AttributeError):
                # Its possible that old row may not have all columns in it
                return False

        LOG.debug("%s : Matched %s, %s, %s %s", self.event_name, self.table,
                  self.events, self.conditions, self.old_conditions)
        return True
Beispiel #7
0
 def run_idl(self, txn):
     lr = self.api.lookup('Logical_Router', self.router)
     found = False
     for nat in [r for r in lr.nat
                 if idlutils.row_match(r, self.conditions)]:
         found = True
         lr.delvalue('nat', nat)
         nat.delete()
         if self.match_ip:
             break
     if self.match_ip and not (found or self.if_exists):
         raise idlutils.RowNotFound(table='NAT', col=self.col,
                                    match=self.match_ip)
Beispiel #8
0
    def run_idl(self, txn):
        conditions = [('external_ids', '=', {'iface-id': self.port_id})]
        queue_table = self.api._tables['Queue']
        for r in queue_table.rows.values():
            if idlutils.row_match(r, conditions):
                dscp = self.qos.get_dscp_marking()
                dscp = dscp if dscp else []
                setattr(r, 'dscp', dscp)

                max_kbps = self.qos.get_max_kbps()
                max_bps = max_kbps * 1024 if max_kbps else 0
                other_config = getattr(r, 'other_config', {})
                other_config['max-rate'] = str(max_bps)
                other_config['min-rate'] = str(max_bps)
                setattr(r, 'other_config', other_config)

        qos_table = self.api._tables['QoS']
        for r in qos_table.rows.values():
            if idlutils.row_match(r, conditions):
                external_ids = getattr(r, 'external_ids', {})
                external_ids['version'] = str(self.qos.version)
                external_ids['qos-id'] = self.qos.id
                setattr(r, 'external_ids', external_ids)
Beispiel #9
0
 def run_idl(self, txn):
     ls = self.api.lookup('Logical_Switch', self.switch)
     for row in ls.qos_rules:
         if idlutils.row_match(row, self.conditions):
             ls.delvalue('qos_rules', row)
             row.delete()
Beispiel #10
0
 def run_idl(self, txn):
     entity = self.api.lookup(self.lookup_table, self.entity)
     for acl in [a for a in entity.acls
                 if idlutils.row_match(a, self.conditions)]:
         entity.delvalue('acls', acl)
         acl.delete()