Esempio n. 1
0
 def test_lsn_port_info_get(self):
     self.mock_request.return_value = {
         "tags": [
             {
                 "scope": "n_mac_address",
                 "tag": "fa:16:3e:27:fd:a0"
             },
             {
                 "scope": "n_subnet_id",
                 "tag": "foo_subnet_id"
             },
         ],
         "mac_address":
         "aa:bb:cc:dd:ee:ff",
         "ip_address":
         "0.0.0.0/0",
         "uuid":
         "foo_lsn_port_id"
     }
     result = lsnlib.lsn_port_info_get(self.cluster, 'foo_lsn_id',
                                       'foo_lsn_port_id')
     self.mock_request.assert_called_once_with(
         'GET',
         '/ws.v1/lservices-node/foo_lsn_id/lport/foo_lsn_port_id',
         cluster=self.cluster)
     self.assertIn('subnet_id', result)
     self.assertIn('mac_address', result)
Esempio n. 2
0
 def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True):
     try:
         obj = lsn_db.lsn_port_get_for_mac(context, mac, raise_on_err=raise_on_err)
         return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
     except p_exc.LsnPortNotFound:
         with excutils.save_and_reraise_exception() as ctxt:
             ctxt.reraise = False
             if self.sync_on_missing:
                 lsn_id, lsn_port_id = super(PersistentLsnManager, self).lsn_port_get_by_mac(
                     context, network_id, mac, raise_on_err=raise_on_err
                 )
                 subnet_id = lsn_api.lsn_port_info_get(self.cluster, lsn_id, lsn_port_id).get("subnet_id")
                 self.lsn_port_save(context, lsn_port_id, subnet_id, mac, lsn_id)
                 return (lsn_id, lsn_port_id)
             if raise_on_err:
                 ctxt.reraise = True
Esempio n. 3
0
 def test_lsn_port_info_get(self):
     self.mock_request.return_value = {
         "tags": [
             {"scope": "n_mac_address", "tag": "fa:16:3e:27:fd:a0"},
             {"scope": "n_subnet_id", "tag": "foo_subnet_id"},
         ],
         "mac_address": "aa:bb:cc:dd:ee:ff",
         "ip_address": "0.0.0.0/0",
         "uuid": "foo_lsn_port_id"
     }
     result = lsnlib.lsn_port_info_get(
         self.cluster, 'foo_lsn_id', 'foo_lsn_port_id')
     self.mock_request.assert_called_once_with(
         'GET', '/ws.v1/lservices-node/foo_lsn_id/lport/foo_lsn_port_id',
         cluster=self.cluster)
     self.assertIn('subnet_id', result)
     self.assertIn('mac_address', result)
Esempio n. 4
0
 def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True):
     try:
         obj = lsn_db.lsn_port_get_for_mac(
             context, mac, raise_on_err=raise_on_err)
         return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
     except p_exc.LsnPortNotFound:
         if self.sync_on_missing:
             lsn_id, lsn_port_id = (
                 super(PersistentLsnManager, self).lsn_port_get_by_mac(
                     context, network_id, mac,
                     raise_on_err=raise_on_err))
             subnet_id = lsn_api.lsn_port_info_get(
                 self.cluster, lsn_id, lsn_port_id).get('subnet_id')
             self.lsn_port_save(
                 context, lsn_port_id, subnet_id, mac, lsn_id)
             return (lsn_id, lsn_port_id)
         if raise_on_err:
             raise
Esempio n. 5
0
 def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True):
     try:
         obj = lsn_db.lsn_port_get_for_mac(
             context, mac, raise_on_err=raise_on_err)
         return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
     except p_exc.LsnPortNotFound:
         with excutils.save_and_reraise_exception() as ctxt:
             ctxt.reraise = False
             if self.sync_on_missing:
                 lsn_id, lsn_port_id = (
                     super(PersistentLsnManager, self).lsn_port_get_by_mac(
                         context, network_id, mac,
                         raise_on_err=raise_on_err))
                 subnet_id = lsn_api.lsn_port_info_get(
                     self.cluster, lsn_id, lsn_port_id).get('subnet_id')
                 self.lsn_port_save(
                     context, lsn_port_id, subnet_id, mac, lsn_id)
                 return (lsn_id, lsn_port_id)
             if raise_on_err:
                 ctxt.reraise = True
Esempio n. 6
0
 def lsn_port_get(self, context, network_id, subnet_id, raise_on_err=True):
     try:
         obj = lsn_db.lsn_port_get_for_subnet(context,
                                              subnet_id,
                                              raise_on_err=raise_on_err)
         return (obj.lsn_id, obj.lsn_port_id) if obj else (None, None)
     except p_exc.LsnPortNotFound:
         if self.sync_on_missing:
             lsn_id, lsn_port_id = (super(PersistentLsnManager,
                                          self).lsn_port_get(
                                              context,
                                              network_id,
                                              subnet_id,
                                              raise_on_err=raise_on_err))
             mac_addr = lsn_api.lsn_port_info_get(
                 self.cluster, lsn_id, lsn_port_id)['mac_address']
             self.lsn_port_save(context, lsn_port_id, subnet_id, mac_addr,
                                lsn_id)
             return (lsn_id, lsn_port_id)
         if raise_on_err:
             raise