Ejemplo n.º 1
0
 public function createList(array $deviceArray)
 {
     //Get App User
     $appUserObj = $this->axl->getAppUser(env('CUCM_LOGIN'));
     Log::info('getAppUser(),$appUserObj,', [$appUserObj]);
     //Create Device Array
     $appUserDeviceArray = createDeviceArray($appUserObj, $deviceArray);
     Log::info('createDeviceArray(),$appUserDeviceArray,', [$appUserDeviceArray]);
     //Associate Devices to App User
     $res = $this->axl->updateAppUser(env('CUCM_LOGIN'), $appUserDeviceArray);
     Log::info('updateAppUser(),$res,', [$res]);
     //Create RIS Port Phone Array
     $risArray = createRisPhoneArray($deviceArray);
     Log::info('createRisPhoneArray(),$risArray,', [$risArray]);
     //Get Device IP's from RIS Port
     $SelectCmDeviceResult = $this->sxml->getDeviceIp($risArray);
     Log::info('getDeviceIp(),$SelectCmDeviceResult,', [$SelectCmDeviceResult]);
     //Process RIS Port Results
     $risPortResults = processRisResults($SelectCmDeviceResult, $risArray);
     //Fetch device model from type product
     for ($i = 0; $i < count($risPortResults); $i++) {
         if ($risPortResults[$i]['IsRegistered']) {
             $results = $this->axl->executeSQLQuery('SELECT name FROM typeproduct WHERE enum = "' . $risPortResults[$i]['Product'] . '"');
             $risPortResults[$i]['Model'] = $results->return->row->name;
         }
     }
     Log::info('processRisResults(),$risPortResults,', [$risPortResults]);
     return $risPortResults;
 }
Ejemplo n.º 2
0
 /**
  * @return \Illuminate\View\View
  * @internal param Request $request
  */
 public function store()
 {
     // Avoid PHP timeouts when querying large clusters
     set_time_limit(0);
     // Create the RisPort Soap Client
     $sxml = new RisSoap();
     // Query CUCM for device name and model
     $data = executeQuery('SELECT d.name devicename, t.name model FROM device d INNER JOIN typemodel t ON d.tkmodel = t.enum');
     // $deviceList will hold our array for RisPort
     $deviceList = [];
     // Loop SQL data and assign devicename to $deviceList
     foreach ($data as $i) {
         $deviceList[] = $i->devicename;
     }
     // Generate our ['Item' => deviceName] array for RisPort
     $deviceList = createRisPhoneArray($deviceList);
     // $finalReport is the array we'll send to the view
     $finalReport = [];
     // RisPort has a 1000 device query limit.  Use chunk to divide it up
     foreach (array_chunk($deviceList, 1000, true) as $chunk) {
         // Query RisPort for device registration info
         $SelectCmDeviceResult = $sxml->getDeviceIp($chunk);
         // Call a function to process the RisPort results and get IP's
         $res = processRisResults($SelectCmDeviceResult, $chunk);
         // Loop each RisPort result and obtain the model
         foreach ($res as $key => $value) {
             // Look into the SQL data to find the model information
             foreach ($data as $device) {
                 if ($value['DeviceName'] == $device->devicename) {
                     $res[$key]['Model'] = $device->model;
                 }
             }
         }
         // Combine 'chunks' of the RisPort data
         $finalReport = array_merge($finalReport, $res);
     }
     return view('registration.show', compact('finalReport'));
 }
Ejemplo n.º 3
0
 /**
  * Execute the job.
  *
  * @internal param $devices
  * @return void
  */
 public function handle()
 {
     $risArray = createRisPhoneArray($this->devices);
     $sxml = new RisSoap();
     $risResults = $sxml->getDeviceIP($risArray);
     $finalReport = processRisResults($risResults, $risArray);
     foreach ($finalReport as $key => $value) {
         if (!filter_var($value['IpAddress'], FILTER_VALIDATE_IP)) {
             $finalReport[$key]['Firmware'] = 'Unavailable';
             $finalReport[$key]['Model'] = 'Unavailable';
             continue;
         }
         $res = executeQuery('SELECT name FROM typeproduct WHERE enum = "' . $value['Product'] . '"');
         //            $finalReport[$key]['Model'] = $res[0]->name;
         $finalReport[$key]['Model'] = 'Cisco 9971';
         $client = new Client();
         //                $crawler = $client->request('GET', 'http://' . $value['IpAddress']);
         $crawler = $client->request('GET', 'http://' . '10.188.52.25');
         switch ($finalReport[$key]['Model']) {
             case 'Cisco 7945':
             case 'Cisco 7965':
             case 'Cisco 7975':
                 $finalReport[$key]['Firmware'] = $crawler->filter('DIV TABLE TR')->eq(5)->filter('td')->eq(2)->text();
                 break;
             case 'Cisco 9951':
                 $finalReport[$key]['Firmware'] = $crawler->filter('DIV TABLE TR')->eq(3)->filter('td')->eq(2)->text();
                 break;
             case 'Cisco 9971':
                 $finalReport[$key]['Firmware'] = $crawler->filter('DIV TABLE TR')->eq(5)->filter('td')->eq(2)->text();
                 break;
             default:
                 $finalReport[$key]['Firmware'] = 'Unavailable';
         }
     }
     return $finalReport;
 }
Ejemplo n.º 4
0
/**
 * @param $deviceList
 * @return mixed
 */
function generateEraserList($deviceList)
{
    $macList = array_column($deviceList, 'mac');
    $axl = new AxlSoap();
    $user = $axl->getAxlUser();
    $devices = createDeviceArray($user, $macList);
    $res = $axl->updateAxlUser($devices);
    $risArray = createRisPhoneArray($macList);
    // Get Device IP's
    $sxml = new RisSoap();
    $risResults = $sxml->getDeviceIP($risArray);
    $risPortResults = processRisResults($risResults, $risArray);
    //Fetch device model from type product
    for ($i = 0; $i < count($risPortResults); $i++) {
        if ($risPortResults[$i]['IsRegistered']) {
            $results = $axl->executeQuery('SELECT name FROM typeproduct WHERE enum = "' . $risPortResults[$i]['Product'] . '"');
            $risPortResults[$i]['Model'] = $results->return->row->name;
        }
    }
    foreach ($deviceList as $row) {
        $key = array_search($row['mac'], array_column($risPortResults, 'DeviceName'));
        $risPortResults[$key]['type'] = $row['type'];
        if (isset($row['bulk_id'])) {
            $risPortResults[$key]['bulk_id'] = $row['bulk_id'];
        }
    }
    return $risPortResults;
}