|
@@ -32,6 +32,7 @@ class KEAHostReservationSubscriber implements EventSubscriber
|
|
return array(
|
|
return array(
|
|
'postPersist',
|
|
'postPersist',
|
|
'postUpdate',
|
|
'postUpdate',
|
|
|
|
+ 'preRemove',
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,12 +55,21 @@ class KEAHostReservationSubscriber implements EventSubscriber
|
|
/**
|
|
/**
|
|
* @param LifecycleEventArgs $args
|
|
* @param LifecycleEventArgs $args
|
|
*/
|
|
*/
|
|
- public function execute(LifecycleEventArgs $args)
|
|
|
|
|
|
+ public function preRemove(LifecycleEventArgs $args)
|
|
|
|
+ {
|
|
|
|
+ $this->execute($args, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param LifecycleEventArgs $args
|
|
|
|
+ * @param boolean $remove
|
|
|
|
+ */
|
|
|
|
+ public function execute(LifecycleEventArgs $args, $remove = false)
|
|
{
|
|
{
|
|
$entity = $args->getEntity();
|
|
$entity = $args->getEntity();
|
|
if ($entity instanceof Host) {
|
|
if ($entity instanceof Host) {
|
|
|
|
|
|
- if ($entity->getFixedAddress()) {
|
|
|
|
|
|
+ if ($entity->getFixedAddress() && $remove == false) {
|
|
$query = "
|
|
$query = "
|
|
INSERT INTO kea.hosts (dhcp_identifier,
|
|
INSERT INTO kea.hosts (dhcp_identifier,
|
|
dhcp_identifier_type,
|
|
dhcp_identifier_type,
|
|
@@ -78,7 +88,7 @@ class KEAHostReservationSubscriber implements EventSubscriber
|
|
$databaseConnection = $this->serviceContainer->get('database_connection');
|
|
$databaseConnection = $this->serviceContainer->get('database_connection');
|
|
$stmt = $databaseConnection->prepare($query);
|
|
$stmt = $databaseConnection->prepare($query);
|
|
$stmt->bindValue("mac", hex2bin(str_replace(':', '', $entity->getMac())));
|
|
$stmt->bindValue("mac", hex2bin(str_replace(':', '', $entity->getMac())));
|
|
- if ($entity->getFixedAddress()) {
|
|
|
|
|
|
+ if ($entity->getFixedAddress() && $remove == false) {
|
|
$stmt->bindValue("type", 'hw-address');
|
|
$stmt->bindValue("type", 'hw-address');
|
|
$stmt->bindValue("ip", $entity->getFixedAddress());
|
|
$stmt->bindValue("ip", $entity->getFixedAddress());
|
|
}
|
|
}
|