Example #1
0
 private static function saveCircuit($gri, $desc, $status, $start, $end, $bandwidth, $path)
 {
     $conn = Connection::findOne(['external_id' => $gri]);
     if ($conn == null) {
         $conn = new Connection();
         $conn->external_id = $gri;
         $conn->name = $desc;
         $conn->type = 'OSCARS';
         $conn->status = 'PROVISIONED';
         $conn->version = 1;
         $conn->dataplane_status = $status == 'ACTIVE' ? 'ACTIVE' : 'INACTIVE';
         $conn->auth_status = 'UNEXECUTED';
         $conn->resources_status = 'PROVISIONED';
         $conn->start = DateUtils::timestampToDB($start);
         $conn->finish = DateUtils::timestampToDB($end);
         $conn->bandwidth = $bandwidth;
         if ($conn->save()) {
             Yii::trace($path);
             for ($i = 0; $i < count($path); $i++) {
                 $point = new ConnectionPath();
                 $point->conn_id = $conn->id;
                 $point->path_order = $i;
                 $urnArray = explode(":", $path[$i]);
                 Yii::trace($urnArray);
                 $point->vlan = explode('=', $urnArray[7])[1];
                 Yii::trace($point->vlan);
                 $point->domain = explode('=', $urnArray[3])[1];
                 Yii::trace($point->domain);
                 $urnArray[7] = '';
                 $urnArray[6] = '';
                 $point->port_urn = substr(implode(':', $urnArray), 0, -2);
                 Yii::trace($point->port_urn);
                 $point->save();
             }
             OscarsService::associateNSICircuits($conn);
         } else {
             Yii::trace($conn->getErrors());
         }
     } else {
         $conn->dataplane_status = $status == 'ACTIVE' ? 'ACTIVE' : 'INACTIVE';
         $conn->save();
     }
 }