Explorar o código

Merged in FD3-751 (pull request #29)

FD3-751 update migrations y comando para eliminar dhcp hosts desde cablemodem

Approved-by: Maximiliano Schvindt <maximiliano@interlink.com.ar>
Guillermo Espinoza %!s(int64=6) %!d(string=hai) anos
pai
achega
49a66d8fec

+ 1 - 1
app/DoctrineMigrations/src/action.yml

@@ -48,5 +48,5 @@ insertorupdate:
           name: "Disable on delete"
           object_class: "CablemodemBundle\\Entity\\Cablemodem"
           event: "a:1:{i:0;s:9:\"preRemove\";}"
-          template: "echo {{object.mac}} Suspendido\r\nphp /opt/cablemodem/bin/console workflow:apply --entity=CablemodemBundle\\\\Entity\\\\Cablemodem --id={{object.id}} --workflow=cablemodem_workflow --transition=\"disable\""
+          template: "echo {{object.mac}} Suspendido\r\nphp /opt/cablemodem/bin/console workflow:apply --entity=CablemodemBundle\\\\Entity\\\\Cablemodem --id={{object.id}} --workflow=cablemodem_workflow --transition=\"disable\" --no-filters"
           tenancy_id: 1

+ 4 - 4
composer.lock

@@ -103,7 +103,7 @@
                     "homepage": "https://florian.ec"
                 }
             ],
-            "description": "Converts a string into a slug",
+            "description": "Converts a string into a slug.",
             "keywords": [
                 "slug",
                 "slugify"
@@ -1691,7 +1691,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "13431443af6cd4038230a15e05f593363a642ad1"
+                "reference": "8919bf2fec49fa73cd31b07a83a542bbd0767136"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -1721,7 +1721,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2018-11-22T18:10:58+00:00"
+            "time": "2018-11-23T13:16:02+00:00"
         },
         {
             "name": "incenteev/composer-parameter-handler",
@@ -6328,7 +6328,7 @@
         "voryx/restgeneratorbundle": 20
     },
     "prefer-stable": false,
-    "prefer-lowest": false,
+    "prefer-lowest": true,
     "platform": {
         "php": ">=5.5.9"
     },

+ 22 - 7
src/CablemodemBundle/Command/DHCPHostCRUDCommand.php

@@ -61,35 +61,50 @@ EOT
             'password' => $input->getOption('api-password'),
         ];
 
+        // deshabilito filtros, entre ellos soft_delete
         $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-        if ($this->cablemodem = $em->getRepository('CablemodemBundle:Cablemodem')->findOneByMac($this->mac)) {
+        $filters = $em->getFilters();
+        $enabledFilters = $filters->getEnabledFilters();
+        foreach ($enabledFilters as $filter_name => $filter) {
+            $filters->disable($filter_name);
+        }
+        
+        $this->cablemodem = $em->getRepository('CablemodemBundle:Cablemodem')->findOneByMac($this->mac);
+        if ($this->cablemodem) {
             // Crea el Host
-            $this->io->section('Creating DHCP Host');
+            if ($this->input->getOption('delete') != true) {
+                $this->io->section('Creating or updating DHCP Host');
+            } else {
+                $this->io->section('Deleting DHCP Host if exists');
+            }
             $this->io->success('RESULT: ' . $this->createHost());
             
             // Crea o elimina si existe el Host CPE
             $cpeFixedIP = $this->cablemodem->getCpeFixedIP();
             if ($cpeFixedIP) {
-                $this->io->section('Creating DHCP CPE Host');
+                $this->io->section('Creating or updating DHCP CPE Host');
                 $this->io->success('RESULT: ' . $this->createHost('cpe'));
             } else {
-                $this->io->section('Deleting DHCP CPE Host');
+                $this->io->section('Deleting DHCP CPE Host if exists');
                 $this->io->success('RESULT: ' . $this->deleteHost('cpe'));
             }
             
             // Crea o elimina si existe el Host MTA
             $mtaFixedIP = $this->cablemodem->getMtaFixedIP();
             if ($mtaFixedIP) {
-                $this->io->section('Creating DHCP MTA Host');
+                $this->io->section('Creating or updating DHCP MTA Host');
                 $this->io->success('RESULT: ' . $this->createHost('mta'));
             } else {
-                $this->io->section('Deleting DHCP MTA Host');
+                $this->io->section('Deleting DHCP MTA Host if exists');
                 $this->io->success('RESULT: ' . $this->deleteHost('mta'));
             }
-            
         } else {
             $output->writeln("<error>Cablemodem mac {$this->mac} not found</error>");
         }
+        
+        foreach ($enabledFilters as $filter_name => $filter) {
+            $filters->enable($filter_name);
+        }
     }
     
     /**