diff --git a/public_html/deployment/plugins/rollout/awx/rollout_awx.php b/public_html/deployment/plugins/rollout/awx/rollout_awx.php index 276cca0a4afe122d46175dcb707595fad07066dc..c9b315e1d7c7178ad2bdd6f35fba38db75581a82 100644 --- a/public_html/deployment/plugins/rollout/awx/rollout_awx.php +++ b/public_html/deployment/plugins/rollout/awx/rollout_awx.php @@ -9,6 +9,9 @@ * @author <axel.hahn@iml.unibe.ch> */ class rollout_awx extends rollout_base { + + // url part for AWX API request to set count of results per page + protected $_sAwxApiPaging='&page_size=10000&page=1'; /** * check requirements if the plugin could work @@ -86,7 +89,7 @@ class rollout_awx extends rollout_base { */ static public function getAwxInventories(){ $aResponse=$this->_httpRequest(array( - 'url'=>'/inventories/?order_by=name', + 'url'=>'/inventories/?order_by=name'.$this->_sAwxApiPaging, 'method'=>'GET', ) ); @@ -96,7 +99,20 @@ class rollout_awx extends rollout_base { } $aData=json_decode($aResponse['body'], 1); - $aReturn=array(); + $aReturn=[]; + if (!$aData || !isset($aData['count'])){ + $aReturn[]=[ + 'value'=>false, + 'label'=>'!!! Access to awx api failed !!!' + ]; + return $aReturn; + } + if(count($aData['results']) < $aData['count']){ + $aReturn[]=[ + 'value'=>false, + 'label'=>'>>>>>>>>> WARNING: fetched ' . count($aData['results']) . ' of ' .$aData['count'] . ' items only' + ]; + } foreach ($aData['results'] as $aItem){ $aReturn[$aItem['id']]= [ @@ -114,7 +130,7 @@ class rollout_awx extends rollout_base { */ static public function getAwxJobTemplates(){ $aResponse=$this->_httpRequest(array( - 'url'=>'/job_templates/?order_by=name', + 'url'=>'/job_templates/?order_by=name'.$this->_sAwxApiPaging, 'method'=>'GET', ) ); @@ -124,8 +140,20 @@ class rollout_awx extends rollout_base { } $aData=json_decode($aResponse['body'], 1); - $aReturn=array(); - + $aReturn=[]; + if (!$aData || !isset($aData['count'])){ + $aReturn[]=[ + 'value'=>false, + 'label'=>'!!! Access to awx api failed !!!' + ]; + return $aReturn; + } + if(count($aData['results']) < $aData['count']){ + $aReturn[]=[ + 'value'=>false, + 'label'=>'>>>>>>>>> WARNING: fetched ' . count($aData['results']) . ' of ' .$aData['count'] . ' items only' + ]; + } foreach ($aData['results'] as $aItem){ $aReturn[$aItem['id']]= [ 'value'=>$aItem['id'],