Exemplo n.º 1
0
 def _create_dvr_mac_address(self, context, host):
     """Create DVR mac address for a given host."""
     base_mac = cfg.CONF.dvr_base_mac.split(':')
     max_retries = cfg.CONF.mac_generation_retries
     for attempt in reversed(range(max_retries)):
         try:
             with context.session.begin(subtransactions=True):
                 mac_address = utils.get_random_mac(base_mac)
                 dvr_mac_binding = DistributedVirtualRouterMacAddress(
                     host=host, mac_address=mac_address)
                 context.session.add(dvr_mac_binding)
                 LOG.debug(
                     "Generated DVR mac for host %(host)s "
                     "is %(mac_address)s", {
                         'host': host,
                         'mac_address': mac_address
                     })
             dvr_macs = self.get_dvr_mac_address_list(context)
             # TODO(vivek): improve scalability of this fanout by
             # sending a single mac address rather than the entire set
             self.notifier.dvr_mac_address_update(context, dvr_macs)
             return self._make_dvr_mac_address_dict(dvr_mac_binding)
         except db_exc.DBDuplicateEntry:
             LOG.debug(
                 "Generated DVR mac %(mac)s exists."
                 " Remaining attempts %(attempts_left)s.", {
                     'mac': mac_address,
                     'attempts_left': attempt
                 })
     LOG.error(_LE("MAC generation error after %s attempts"), max_retries)
     raise ext_dvr.MacAddressGenerationFailure(host=host)
Exemplo n.º 2
0
 def _create_dvr_mac_address(self, context, host):
     """Create DVR mac address for a given host."""
     base_mac = cfg.CONF.dvr_base_mac.split(':')
     try:
         return self._create_dvr_mac_address_retry(context, host, base_mac)
     except db_exc.DBDuplicateEntry:
         LOG.error(_LE("MAC generation error after %s attempts"),
                   db_api.MAX_RETRIES)
     raise ext_dvr.MacAddressGenerationFailure(host=host)