def enable_vlan_on_trunk_int(self, nexus_host, vlanid, interface): """Enable a VLAN on a trunk interface.""" # If more than one VLAN is configured on this interface then # include the 'add' keyword. if len(nexus_db_v2.get_port_switch_bindings(interface, nexus_host)) == 1: snippet = snipp.CMD_INT_VLAN_SNIPPET else: snippet = snipp.CMD_INT_VLAN_ADD_SNIPPET confstr = snippet % (interface, vlanid) confstr = self.create_xml_snippet(confstr) LOG.debug(_("NexusDriver: %s"), confstr) self._edit_config(nexus_host, target='running', config=confstr)
def test_nexusportswitchbinding_get(self): """Tests get of port bindings based on port and switch.""" npb11 = self._npb_test_obj(10, 100) npb21 = self._npb_test_obj(20, 100, switch='2.2.2.2') npb22 = self._npb_test_obj(20, 200, switch='2.2.2.2') self._add_bindings_to_db([npb11, npb21, npb22]) npb = self._get_port_switch_bindings(npb11) self.assertEqual(len(npb), 1) self._assert_bindings_match(npb[0], npb11) npb_all_p20 = self._get_port_switch_bindings(npb21) self.assertEqual(len(npb_all_p20), 2) npb = nexus_db_v2.get_port_switch_bindings(npb21.port, "dummySwitch") self.assertIsNone(npb)
def _get_port_switch_bindings(self, npb): """Get port bindings based on port and switch.""" return nexus_db_v2.get_port_switch_bindings(npb.port, npb.switch)