Explorar o código

FD3-807 shared secret docsis key fix

Guillermo Espinoza %!s(int64=6) %!d(string=hai) anos
pai
achega
3563500207

+ 1 - 0
.gitignore

@@ -22,3 +22,4 @@
 /app/config/bundles/ik/base-admin-bundle/parameters.yml
 /app/config/bundles/ik/device-bundle/parameters.yml
 /app/config/bundles/ik/webservice-bundle/parameters.yml
+/app/config/tenencia/cablemodem_*.yml

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
app/DoctrineMigrations/src/action.yml


+ 0 - 0
app/config/tenencia/cablemodem_1.yml.dist


+ 37 - 7
src/CablemodemBundle/Entity/Cablemodem.php

@@ -2,11 +2,7 @@
 
 namespace CablemodemBundle\Entity;
 
-use Doctrine\ORM\Mapping as ORM;
-use Gedmo\Mapping\Annotation as Gedmo;
-use JMS\Serializer\Annotation as JMS;
-use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
-use Symfony\Component\Validator\Constraints as Assert;
+use Base\AdminBundle\Interfaces\SoftDeleteInterface;
 use Base\AdminBundle\Traits\TenancyIdTrait;
 use Base\AdminBundle\Traits\TenancyIdTraitInterface;
 use DeviceBundle\Interfaces\DeviceInterface;
@@ -16,10 +12,15 @@ use MapBundle\Entity\Interfaces\LocationInterface;
 use MapBundle\Entity\Traits\LocationTrait;
 use WorkflowBundle\Entity\Interfaces\WorkflowInterface;
 use WorkflowBundle\Entity\Traits\WorkflowTrait;
-use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity as SoftDeleteable;
-use Base\AdminBundle\Interfaces\SoftDeleteInterface;
+use Doctrine\ORM\Mapping as ORM;
 use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
+use Gedmo\Mapping\Annotation as Gedmo;
+use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity as SoftDeleteable;
+use JMS\Serializer\Annotation as JMS;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Validator\Constraints as Assert;
 use Symfony\Component\Validator\Context\ExecutionContextInterface;
+use Symfony\Component\Yaml\Yaml;
 
 /**
  * @ORM\Entity(repositoryClass="CablemodemBundle\Repository\CablemodemRepository")
@@ -86,6 +87,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     /**
      * @ORM\ManyToOne(targetEntity="Node", fetch="EXTRA_LAZY", inversedBy="cablemodems")
      * @ORM\JoinColumn(name="node_id", referencedColumnName="id", onDelete="SET NULL")
+     * 
      * @JMS\MaxDepth(1)
      */
     protected $node;
@@ -93,6 +95,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     /**
      * @ORM\ManyToOne(targetEntity="Profile", fetch="EXTRA_LAZY", inversedBy="cablemodems")
      * @ORM\JoinColumn(name="profile_id", referencedColumnName="id", onDelete="SET NULL")
+     * 
      * @JMS\MaxDepth(1)
      *
      * @Assert\NotNull
@@ -548,6 +551,33 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
         return $this;
     }
 
+    /**
+     * @return string
+     */
+    public function getDocsis_key()
+    {
+        $docsis_key = '';
+        if ($this->tenancyId) {
+            global $kernel;
+            $dir = $kernel->getProjectDir();
+            $filename = "{$dir}/app/config/tenencia/cablemodem_{$this->tenancyId}.yml";
+            if (file_exists($filename)) {
+                $values = Yaml::parse(file_get_contents($filename));
+                if (isset($values['docsis_key'])) {
+                    $docsis_key = $values['docsis_key'];
+                }
+            }
+        }
+        if ($docsis_key == '' && $this->profile) {
+            $docsis_key = $this->profile->getDocsis_key();
+        }
+        if ($docsis_key == '' || $docsis_key == null) {
+            $docsis_key = 'cmts-default';
+        }
+
+        return $docsis_key;
+    }
+
     /**
      * @ORM\PreUpdate()
      * @ORM\PreUpdate()

+ 8 - 0
src/CablemodemBundle/Entity/Profile.php

@@ -379,6 +379,14 @@ class Profile  implements TenancyIdTraitInterface, PreRemoveBlockCascadeInterfac
     {
         return $this->getData('US_MaxRateSustained') ? $this->getData('US_MaxRateSustained') : $this->getDefault('US_MaxRateSustained');
     }
+    
+    /**
+     * @return string
+     */
+    public function getDocsis_key()
+    {
+        return $this->getData('docsis_key') ? $this->getData('docsis_key') : $this->getDefault('docsis_key');
+    }
 
     /**
      * @param string $name