Beispiel #1
0
 def _create_legacy_dp_alloc(self):
     # Create all possible exits and entries
     table_offset = cfg.CONF.df.datapath_autoalloc_table_offset
     return app_base.DpAlloc(
         states=(),
         entrypoints={str(x): x for x in range(table_offset)},
         exitpoints={str(x): x for x in range(table_offset)},
         full_mapping={
             'source_port_key': 'reg6',
             'destination_port_key': 'reg7',
             'network_key': 'metadata',
         }
     )
Beispiel #2
0
    def _create_dp_alloc(self, specification):
        """
        Allocate the tables and registers for the given application (given
        by its specification)
        """
        public_mapping = specification.public_mapping.copy()
        unmapped_vars = self._public_variables.difference(public_mapping)

        # Convert to set() so the result won't be a frozenset()
        unmapped_regs = set(REGS).difference(
            public_mapping.values(),
        ).difference(
            specification.private_mapping.values(),
        )

        while unmapped_vars and unmapped_regs:
            public_mapping[unmapped_vars.pop()] = unmapped_regs.pop()

        if unmapped_vars:
            raise RuntimeError(
                _("Can't allocate enough registers for variables"),
            )

        states_dict = {
            state: next(self._table_generator)
            for state in specification.states
        }
        states = app_base.AttributeDict(**states_dict)

        exitpoints_dict = {
            exit.name: next(self._table_generator)
            for exit in specification.exitpoints
        }
        exitpoints = app_base.AttributeDict(**exitpoints_dict)

        entrypoints_dict = {
            entry.name: states[entry.target]
            for entry in specification.entrypoints
        }
        entrypoints = app_base.AttributeDict(**entrypoints_dict)

        return app_base.DpAlloc(
            states=states,
            exitpoints=exitpoints,
            entrypoints=entrypoints,
            full_mapping=public_mapping,
        )
Beispiel #3
0
def _parse_dp_alloc(dpalloc):
    kwargs = {k: app_base.AttributeDict(dpalloc.get(k, ()))
              for k in ('states', 'exitpoints', 'entrypoints', 'full_mapping')}
    return app_base.DpAlloc(**kwargs)