def create(self): fields = self._get_changed_persistent_fields() try: db_obj = db_api.create_object(self._context, self.db_model, fields) except obj_exc.DBDuplicateEntry: raise NeutronObjectDuplicateEntry() self.from_db_object(db_obj)
def create(self): fields = self._get_changed_persistent_fields() try: db_obj = db_api.create_object(self._context, self.db_model, fields) except obj_exc.DBDuplicateEntry as db_exc: raise NeutronDbObjectDuplicateEntry(object_class=self.__class__, db_exception=db_exc) self.from_db_object(db_obj)
def _create_test_port(self, network): # TODO(ihrachys): replace with port.create() once we get an object # implementation for ports self._port = db_api.create_object(self.context, models_v2.Port, {'name': 'test-port1', 'network_id': network['id'], 'mac_address': 'fake_mac', 'admin_state_up': True, 'status': 'ACTIVE', 'device_id': 'fake_device', 'device_owner': 'fake_owner'})
def _create_test_network(self): # TODO(ihrachys): replace with network.create() once we get an object # implementation for networks self._network = db_api.create_object(self.context, models_v2.Network, {'name': 'test-network1'})