function sg_commitUpdatePortl2address($object_id, $port_id, $port_l2address) { $db_l2address = l2addressForDatabase($port_l2address); global $dbxlink; $dbxlink->exec('LOCK TABLES Port WRITE'); if (alreadyUsedL2Address($db_l2address, $object_id)) { $dbxlink->exec('UNLOCK TABLES'); // FIXME: it is more correct to throw InvalidArgException here // and convert it to InvalidRequestArgException at upper level, // when there is a mean to do that. throw new InvalidRequestArgException('port_l2address', $db_l2address, 'address belongs to another object'); } usePreparedUpdateBlade('Port', array('l2address' => $db_l2address === '' ? NULL : $db_l2address), array('id' => $port_id, 'object_id' => $object_id)); $dbxlink->exec('UNLOCK TABLES'); }
function commitUpdatePort($object_id, $port_id, $port_name, $port_type_id, $port_label, $port_l2address, $port_reservation_comment) { $db_l2address = l2addressForDatabase($port_l2address); global $dbxlink; $dbxlink->exec('LOCK TABLES Port WRITE'); if (alreadyUsedL2Address($db_l2address, $object_id)) { $dbxlink->exec('UNLOCK TABLES'); // FIXME: it is more correct to throw InvalidArgException here // and convert it to InvalidRequestArgException at upper level, // when there is a mean to do that. throw new InvalidRequestArgException('port_l2address', $db_l2address, 'address belongs to another object'); } $prev_comment = getPortReservationComment($port_id); $reservation_comment = mb_strlen($port_reservation_comment) ? $port_reservation_comment : NULL; usePreparedUpdateBlade('Port', array('name' => $port_name, 'type' => $port_type_id, 'label' => $port_label, 'reservation_comment' => $reservation_comment, 'l2address' => $db_l2address === '' ? NULL : $db_l2address), array('id' => $port_id, 'object_id' => $object_id)); $dbxlink->exec('UNLOCK TABLES'); if ($prev_comment !== $reservation_comment) { addPortLogEntry($port_id, sprintf("Reservation changed from '%s' to '%s'", $prev_comment, $reservation_comment)); } }