Skip to content
Snippets Groups Projects
Commit 98862ce8 authored by hahn's avatar hahn
Browse files

update rollout plugins; use select (awx)

parent c2f7d5d9
No related branches found
No related tags found
1 merge request!11Support für Dropdowns mit Lookup - task #4630
......@@ -23,7 +23,7 @@
},
"jobtemplate": {
"type": "select",
"default": "36",
"default": "",
"callback": "getAwxJobTemplates",
"ttl": 120,
"per_scope": false
......@@ -46,9 +46,9 @@
"phase": {
"inventory": {
"type": "select",
"default": "example: 5",
"default": "",
"callback": "getAwxInventories",
"ttl": 10,
"ttl": 120,
"per_scope": false
}
}
......
......@@ -18,7 +18,7 @@
"extravars-label": "Extravars",
"extravars-hint": "Extravars als JSON Syntax.",
"inventory-label": "Inventory ID",
"inventory-label": "Inventory",
"inventory-hint": "AWX inventory zum Setzen der Phase und der zu installierenden Hosts",
"endoffile": ""
......
......@@ -18,7 +18,7 @@
"extravars-label": "Extravars",
"extravars-hint": "Extravars in JSON syntax",
"inventory-label": "Inventory ID",
"inventory-label": "Inventory",
"inventory-hint": "AWX inventory to define phase and set of hosts",
"endoffile": ""
......
......@@ -6,7 +6,7 @@
*
* Run an Https POST request to AWX
*
* @author axel
* @author <axel.hahn@iml.unibe.ch>
*/
class rollout_awx extends rollout_base {
......@@ -74,8 +74,8 @@ class rollout_awx extends rollout_base {
/**
* get AWX Job Templates and return them as array for select box
* [id] => array('value' => [ID], 'label' => [PLAYBOOK] [ID])
* get AWX inventories and return them as array for select box
* [id] => array('value' => [ID], 'label' => [NAME] [ID])
* @return array
*/
static public function getAwxInventories(){
......@@ -98,12 +98,7 @@ class rollout_awx extends rollout_base {
'label'=>$aItem['name'].' (id: '.$aItem['id'].')'
];
}
/*
echo '<pre>RETURN: ';
print_r($aReturn);
die(__METHOD__);
*/
return $aReturn;
}
/**
......@@ -113,7 +108,7 @@ class rollout_awx extends rollout_base {
*/
static public function getAwxJobTemplates(){
$aResponse=$this->_httpRequest(array(
'url'=>'/job_templates/?order_by=playbook',
'url'=>'/job_templates/?order_by=name',
'method'=>'GET',
)
);
......@@ -128,15 +123,9 @@ class rollout_awx extends rollout_base {
foreach ($aData['results'] as $aItem){
$aReturn[$aItem['id']]= [
'value'=>$aItem['id'],
'label'=>$aItem['playbook'].' (id: '.$aItem['id'].')'
'label'=>$aItem['name'].' (id: '.$aItem['id'].'; '.$aItem['playbook'].')'
];
}
/*
echo '<pre>RETURN: ';
print_r($aReturn);
die(__METHOD__);
*/
return $aReturn;
}
......@@ -148,6 +137,12 @@ class rollout_awx extends rollout_base {
return true;
}
/**
* get array with commands to execute to deploy a package
*
* @param string $sPhase phase
* @return array
*/
public function getDeployCommands($sPhase){
$aReturn=array();
$aConfig=$this->getConfig($sPhase);
......
......@@ -5,7 +5,7 @@
*
* no action
*
* @author axel
* @author <axel.hahn@iml.unibe.ch>
*/
class rollout_default extends rollout_base {
......@@ -25,10 +25,22 @@ class rollout_default extends rollout_base {
return true;
}
/**
* override general form renderer: show a single message that no
* configuration items exist
*
* @return string
*/
public function renderFormdata4Project() {
return $this->_t('no-cfg');
}
/**
* override general form renderer: show a single message that no
* configuration items exist
*
* @return string
*/
public function renderFormdata4Phase($sPhase) {
return $this->_t('no-cfg');
}
......
......@@ -6,7 +6,7 @@
*
* Run a SSH command on remote targets
*
* @author axel
* @author <axel.hahn@iml.unibe.ch>
*/
class rollout_ssh extends rollout_base {
......@@ -26,6 +26,12 @@ class rollout_ssh extends rollout_base {
return true;
}
/**
* get array with commands to execute to deploy a package
*
* @param string $sPhase phase
* @return array
*/
public function getDeployCommands($sPhase){
$aReturn=array();
$aConfig=$this->getConfig($sPhase);
......@@ -45,99 +51,4 @@ class rollout_ssh extends rollout_base {
return $aReturn;
}
/**
* form fields for project settings
* @return type
*/
public function __DISABLED__renderFormdata4Project() {
/*
$sReturn='';
$i=0;
$sNamePrefix='plugins[rollout]['.$this->getId().']';
$aValues=$this->getConfig();
$aFormdata=array(
array('type' => 'markup','value' => '<br>'.$this->_t('section-required').':'),
array(
'type' => 'text',
'name' => $sNamePrefix.'[user]',
'label' => $this->_t('user'),
'value' => $aValues['user'],
// 'required' => 'required',
'validate' => 'isastring',
'size' => 25,
'placeholder' => $this->_aCfgGlobal['user'],
),
array(
'type' => 'text',
'name' => $sNamePrefix.'[command]',
'label' => $this->_t('command'),
'value' => $aValues['command'],
// 'required' => 'required',
'validate' => 'isastring',
// 'size' => 100,
'placeholder' => $this->_aCfgGlobal['command'],
),
array('type' => 'markup','value' => '<br><br>'.$this->_t('section-optional').':'),
array(
'type' => 'text',
'name' => $sNamePrefix.'[privatekey]',
'label' => $this->_t('privatekey'),
'value' => $aValues['privatekey'],
// 'required' => 'required',
'validate' => 'isastring',
// 'size' => 100,
'placeholder' => $this->_aCfgGlobal['privatekey'],
),
array('type' => 'markup','value' => '<br><br>'.$this->_t('section-commands').':'),
array(
'type' => 'text',
'name' => $sNamePrefix.'[addkeycommand]',
'label' => $this->_t('addkeycommand'),
'value' => $aValues['addkeycommand'],
// 'required' => 'required',
'validate' => 'isastring',
// 'size' => 100,
'placeholder' => $this->_aCfgGlobal['addkeycommand'],
),
array(
'type' => 'text',
'name' => $sNamePrefix.'[testcommand]',
'label' => $this->_t('testcommand'),
'value' => $aValues['testcommand'],
// 'required' => 'required',
'validate' => 'isastring',
// 'size' => 100,
'placeholder' => $this->_aCfgGlobal['testcommand'],
),
);
*
*/
return 'WIP: project based setup for plugin [' . $this->getId() . ']<br>'
. $this->_renderForm4Vars('global', false)
// . $this->_renderForm($aFormdata, 'project')
// .$sReturn
. '<pre>DEBUG: GLOBAL settings - $this->_aCfgGlobal = ' . print_r($this->_aCfgGlobal, 1) . '</pre>'
. '<pre>DEBUG: PROJECT settings - $this->getConfig() = ' . print_r($this->getConfig(), 1) . '</pre>'
// .'<pre>DEBUG: $this->_aCfgProject ... plugin = '.print_r($this->_aCfgProject, 1).'</pre>'
;
}
/**
* form fields for project settings
* @return type
*/
public function __DISABLED__renderFormdata4Phase($sMyPhase) {
return 'WIP: pase based setup for plugin [' . $this->getId() . '] in phase '.$sMyPhase.'<br>'
. $this->_renderForm4Vars('global', $sMyPhase)
// . $this->_renderForm($aFormdata, 'project')
// .$sReturn
. '<pre>DEBUG: GLOBAL settings - $this->_aCfgGlobal = ' . print_r($this->_aCfgGlobal, 1) . '</pre>'
. '<pre>DEBUG: PROJECT settings - $this->getConfig() = ' . print_r($this->getConfig(), 1) . '</pre>'
. '<pre>DEBUG: PHASE settings - $this->getConfig("'.$sMyPhase.'") = ' . print_r($this->getConfig($sMyPhase), 1) . '</pre>'
;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment