* Finish create vm template.
This commit is contained in:
@@ -5,3 +5,8 @@ ALTER TABLE `zt_host` ADD `expiredDate` datetime NOT NULL AFTER `type`;
|
||||
ALTER TABLE `zt_host` ADD `virtualSoftware` varchar(30) NOT NULL DEFAULT '' AFTER `secret`;
|
||||
ALTER TABLE `zt_asset` ADD `registerDate` datetime NOT NULL AFTER `editedDate`;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `type` varchar(30) NOT NULL DEFAULT 'normal' AFTER `hostID`;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `imageFile` varchar(300) NOT NULL;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `createdBy` varchar(30) NOT NULL;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `createdDate` datetime NOT NULL;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `editedBy` varchar(30) NOT NULL;
|
||||
ALTER TABLE `zt_vmtemplate` ADD `editedDate` datetime NOT NULL;
|
||||
|
||||
@@ -150,17 +150,22 @@ class zahost extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createTemplate()
|
||||
public function createTemplate($hostID)
|
||||
{
|
||||
$host = $this->zahost->getById($hostID);
|
||||
if($_POST)
|
||||
{
|
||||
$this->zahost->createTemplate();
|
||||
$this->zahost->createTemplate($host);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browse')));
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browseTemplate', "id={$hostID}")));
|
||||
}
|
||||
|
||||
$imageFiles = $this->zahost->imageFiles($host);
|
||||
$imageFilesOptions = array_combine(array_column($imageFiles, 'macAddress'), array_column($imageFiles, 'name'));
|
||||
|
||||
$this->view->title = $this->lang->zahost->createTemplate;
|
||||
$this->view->imageFiles = $imageFilesOptions;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
+31
-31
@@ -49,10 +49,10 @@ $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion;
|
||||
$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang;
|
||||
$lang->zahost->vmTemplate->imageFile = $lang->zahost->imageFile;
|
||||
|
||||
$lang->vm->langList = array();
|
||||
$lang->vm->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->vm->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->vm->langList['en_us'] = 'American English';
|
||||
$lang->zahost->langList = array();
|
||||
$lang->zahost->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->zahost->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->zahost->langList['en_us'] = 'American English';
|
||||
|
||||
$lang->zahost->empty = 'No Host';
|
||||
$lang->zahost->templateEmpty = 'No Template';
|
||||
@@ -71,33 +71,33 @@ $lang->zahost->zaHostTypeList['physical'] = 'Physical';
|
||||
|
||||
$lang->zahost->confirmDelete = 'Do you want to delete this host?';
|
||||
|
||||
$lang->vm->versionList = array();
|
||||
$lang->vm->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->vm->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['winServer']['2008'] = '2008';
|
||||
$lang->vm->versionList['winServer']['2012'] = '2012';
|
||||
$lang->vm->versionList['winServer']['2016'] = '2016';
|
||||
$lang->vm->versionList['winServer']['2019'] = '2019';
|
||||
$lang->vm->versionList['debian']['9'] = '9';
|
||||
$lang->vm->versionList['debian']['10'] = '10';
|
||||
$lang->vm->versionList['debian']['11'] = '11';
|
||||
$lang->vm->versionList['ubuntu']['16'] = '16';
|
||||
$lang->vm->versionList['ubuntu']['18'] = '18';
|
||||
$lang->vm->versionList['ubuntu']['20'] = '20';
|
||||
$lang->vm->versionList['centos']['6'] = '6';
|
||||
$lang->vm->versionList['centos']['7'] = '7';
|
||||
$lang->vm->versionList['centos']['8'] = '8';
|
||||
$lang->zahost->versionList = array();
|
||||
$lang->zahost->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->zahost->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['winServer']['2008'] = '2008';
|
||||
$lang->zahost->versionList['winServer']['2012'] = '2012';
|
||||
$lang->zahost->versionList['winServer']['2016'] = '2016';
|
||||
$lang->zahost->versionList['winServer']['2019'] = '2019';
|
||||
$lang->zahost->versionList['debian']['9'] = '9';
|
||||
$lang->zahost->versionList['debian']['10'] = '10';
|
||||
$lang->zahost->versionList['debian']['11'] = '11';
|
||||
$lang->zahost->versionList['ubuntu']['16'] = '16';
|
||||
$lang->zahost->versionList['ubuntu']['18'] = '18';
|
||||
$lang->zahost->versionList['ubuntu']['20'] = '20';
|
||||
$lang->zahost->versionList['centos']['6'] = '6';
|
||||
$lang->zahost->versionList['centos']['7'] = '7';
|
||||
$lang->zahost->versionList['centos']['8'] = '8';
|
||||
|
||||
$lang->zahost->notice = new stdclass();
|
||||
$lang->zahost->notice->ip = '『%s』incorrect format!';
|
||||
|
||||
+31
-31
@@ -49,10 +49,10 @@ $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion;
|
||||
$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang;
|
||||
$lang->zahost->vmTemplate->imageFile = $lang->zahost->imageFile;
|
||||
|
||||
$lang->vm->langList = array();
|
||||
$lang->vm->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->vm->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->vm->langList['en_us'] = 'American English';
|
||||
$lang->zahost->langList = array();
|
||||
$lang->zahost->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->zahost->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->zahost->langList['en_us'] = 'American English';
|
||||
|
||||
$lang->zahost->empty = 'No Host';
|
||||
$lang->zahost->templateEmpty = 'No Template';
|
||||
@@ -71,33 +71,33 @@ $lang->zahost->zaHostTypeList['physical'] = 'Physical';
|
||||
|
||||
$lang->zahost->confirmDelete = 'Do you want to delete this host?';
|
||||
|
||||
$lang->vm->versionList = array();
|
||||
$lang->vm->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->vm->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['winServer']['2008'] = '2008';
|
||||
$lang->vm->versionList['winServer']['2012'] = '2012';
|
||||
$lang->vm->versionList['winServer']['2016'] = '2016';
|
||||
$lang->vm->versionList['winServer']['2019'] = '2019';
|
||||
$lang->vm->versionList['debian']['9'] = '9';
|
||||
$lang->vm->versionList['debian']['10'] = '10';
|
||||
$lang->vm->versionList['debian']['11'] = '11';
|
||||
$lang->vm->versionList['ubuntu']['16'] = '16';
|
||||
$lang->vm->versionList['ubuntu']['18'] = '18';
|
||||
$lang->vm->versionList['ubuntu']['20'] = '20';
|
||||
$lang->vm->versionList['centos']['6'] = '6';
|
||||
$lang->vm->versionList['centos']['7'] = '7';
|
||||
$lang->vm->versionList['centos']['8'] = '8';
|
||||
$lang->zahost->versionList = array();
|
||||
$lang->zahost->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->zahost->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['winServer']['2008'] = '2008';
|
||||
$lang->zahost->versionList['winServer']['2012'] = '2012';
|
||||
$lang->zahost->versionList['winServer']['2016'] = '2016';
|
||||
$lang->zahost->versionList['winServer']['2019'] = '2019';
|
||||
$lang->zahost->versionList['debian']['9'] = '9';
|
||||
$lang->zahost->versionList['debian']['10'] = '10';
|
||||
$lang->zahost->versionList['debian']['11'] = '11';
|
||||
$lang->zahost->versionList['ubuntu']['16'] = '16';
|
||||
$lang->zahost->versionList['ubuntu']['18'] = '18';
|
||||
$lang->zahost->versionList['ubuntu']['20'] = '20';
|
||||
$lang->zahost->versionList['centos']['6'] = '6';
|
||||
$lang->zahost->versionList['centos']['7'] = '7';
|
||||
$lang->zahost->versionList['centos']['8'] = '8';
|
||||
|
||||
$lang->zahost->notice = new stdclass();
|
||||
$lang->zahost->notice->ip = '『%s』incorrect format!';
|
||||
|
||||
+31
-31
@@ -49,10 +49,10 @@ $lang->zahost->vmTemplate->osVersion = $lang->zahost->osVersion;
|
||||
$lang->zahost->vmTemplate->osLang = $lang->zahost->osLang;
|
||||
$lang->zahost->vmTemplate->imageFile = $lang->zahost->imageFile;
|
||||
|
||||
$lang->vm->langList = array();
|
||||
$lang->vm->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->vm->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->vm->langList['en_us'] = 'American English';
|
||||
$lang->zahost->langList = array();
|
||||
$lang->zahost->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->zahost->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->zahost->langList['en_us'] = 'American English';
|
||||
|
||||
$lang->zahost->empty = 'No Host';
|
||||
$lang->zahost->templateEmpty = 'No Template';
|
||||
@@ -71,33 +71,33 @@ $lang->zahost->zaHostTypeList['physical'] = 'Physical';
|
||||
|
||||
$lang->zahost->confirmDelete = 'Do you want to delete this host?';
|
||||
|
||||
$lang->vm->versionList = array();
|
||||
$lang->vm->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->vm->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['winServer']['2008'] = '2008';
|
||||
$lang->vm->versionList['winServer']['2012'] = '2012';
|
||||
$lang->vm->versionList['winServer']['2016'] = '2016';
|
||||
$lang->vm->versionList['winServer']['2019'] = '2019';
|
||||
$lang->vm->versionList['debian']['9'] = '9';
|
||||
$lang->vm->versionList['debian']['10'] = '10';
|
||||
$lang->vm->versionList['debian']['11'] = '11';
|
||||
$lang->vm->versionList['ubuntu']['16'] = '16';
|
||||
$lang->vm->versionList['ubuntu']['18'] = '18';
|
||||
$lang->vm->versionList['ubuntu']['20'] = '20';
|
||||
$lang->vm->versionList['centos']['6'] = '6';
|
||||
$lang->vm->versionList['centos']['7'] = '7';
|
||||
$lang->vm->versionList['centos']['8'] = '8';
|
||||
$lang->zahost->versionList = array();
|
||||
$lang->zahost->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->zahost->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['winServer']['2008'] = '2008';
|
||||
$lang->zahost->versionList['winServer']['2012'] = '2012';
|
||||
$lang->zahost->versionList['winServer']['2016'] = '2016';
|
||||
$lang->zahost->versionList['winServer']['2019'] = '2019';
|
||||
$lang->zahost->versionList['debian']['9'] = '9';
|
||||
$lang->zahost->versionList['debian']['10'] = '10';
|
||||
$lang->zahost->versionList['debian']['11'] = '11';
|
||||
$lang->zahost->versionList['ubuntu']['16'] = '16';
|
||||
$lang->zahost->versionList['ubuntu']['18'] = '18';
|
||||
$lang->zahost->versionList['ubuntu']['20'] = '20';
|
||||
$lang->zahost->versionList['centos']['6'] = '6';
|
||||
$lang->zahost->versionList['centos']['7'] = '7';
|
||||
$lang->zahost->versionList['centos']['8'] = '8';
|
||||
|
||||
$lang->zahost->notice = new stdclass();
|
||||
$lang->zahost->notice->ip = '『%s』incorrect format!';
|
||||
|
||||
+31
-31
@@ -52,10 +52,10 @@ $lang->zahost->vmTemplate->imageFile = $lang->zahost->imageFile;
|
||||
$lang->zahost->empty = 'No Host';
|
||||
$lang->zahost->templateEmpty = 'No Template';
|
||||
|
||||
$lang->vm->langList = array();
|
||||
$lang->vm->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->vm->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->vm->langList['en_us'] = 'American English';
|
||||
$lang->zahost->langList = array();
|
||||
$lang->zahost->langList['zh_cn'] = 'Simplified Chinese';
|
||||
$lang->zahost->langList['zh_tw'] = 'Traditional Chinese';
|
||||
$lang->zahost->langList['en_us'] = 'American English';
|
||||
|
||||
$lang->zahost->statusList['online'] = 'Online';
|
||||
|
||||
@@ -71,33 +71,33 @@ $lang->zahost->zaHostTypeList['physical'] = 'Physical';
|
||||
|
||||
$lang->zahost->confirmDelete = 'Do you want to delete this host?';
|
||||
|
||||
$lang->vm->versionList = array();
|
||||
$lang->vm->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->vm->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->vm->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->vm->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->vm->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->vm->versionList['winServer']['2008'] = '2008';
|
||||
$lang->vm->versionList['winServer']['2012'] = '2012';
|
||||
$lang->vm->versionList['winServer']['2016'] = '2016';
|
||||
$lang->vm->versionList['winServer']['2019'] = '2019';
|
||||
$lang->vm->versionList['debian']['9'] = '9';
|
||||
$lang->vm->versionList['debian']['10'] = '10';
|
||||
$lang->vm->versionList['debian']['11'] = '11';
|
||||
$lang->vm->versionList['ubuntu']['16'] = '16';
|
||||
$lang->vm->versionList['ubuntu']['18'] = '18';
|
||||
$lang->vm->versionList['ubuntu']['20'] = '20';
|
||||
$lang->vm->versionList['centos']['6'] = '6';
|
||||
$lang->vm->versionList['centos']['7'] = '7';
|
||||
$lang->vm->versionList['centos']['8'] = '8';
|
||||
$lang->zahost->versionList = array();
|
||||
$lang->zahost->versionList['winxp']['all'] = 'Windows XP';
|
||||
$lang->zahost->versionList['win7']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win7']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win7']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win7']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win10']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win10']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win10']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win10']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['win11']['home'] = 'Home Basic';
|
||||
$lang->zahost->versionList['win11']['professional'] = 'Professional';
|
||||
$lang->zahost->versionList['win11']['enterprise'] = 'Enterprise';
|
||||
$lang->zahost->versionList['win11']['ultimate'] = 'Ultimate';
|
||||
$lang->zahost->versionList['winServer']['2008'] = '2008';
|
||||
$lang->zahost->versionList['winServer']['2012'] = '2012';
|
||||
$lang->zahost->versionList['winServer']['2016'] = '2016';
|
||||
$lang->zahost->versionList['winServer']['2019'] = '2019';
|
||||
$lang->zahost->versionList['debian']['9'] = '9';
|
||||
$lang->zahost->versionList['debian']['10'] = '10';
|
||||
$lang->zahost->versionList['debian']['11'] = '11';
|
||||
$lang->zahost->versionList['ubuntu']['16'] = '16';
|
||||
$lang->zahost->versionList['ubuntu']['18'] = '18';
|
||||
$lang->zahost->versionList['ubuntu']['20'] = '20';
|
||||
$lang->zahost->versionList['centos']['6'] = '6';
|
||||
$lang->zahost->versionList['centos']['7'] = '7';
|
||||
$lang->zahost->versionList['centos']['8'] = '8';
|
||||
|
||||
$lang->zahost->notice = new stdclass();
|
||||
$lang->zahost->notice->ip = '『%s』incorrect format!';
|
||||
|
||||
+35
-3
@@ -110,10 +110,11 @@ class zahostModel extends model
|
||||
/**
|
||||
* Create vm template.
|
||||
*
|
||||
* @param Object $host
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createTemplate()
|
||||
public function createTemplate($host)
|
||||
{
|
||||
$template = fixer::input('post')
|
||||
->setIF($this->post->diskSize > 0, 'diskSize', $this->post->diskSize * 1024)
|
||||
@@ -122,14 +123,45 @@ class zahostModel extends model
|
||||
$this->dao->insert(TABLE_VMTEMPLATE)->data($template)
|
||||
->batchCheck($this->config->zahost->createTemplate->requiredFields, 'notempty')
|
||||
->batchCheck('cpuCoreNum,diskSize,memorySize', 'gt', 0)
|
||||
->autoCheck()
|
||||
->exec();
|
||||
->autoCheck();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$vmTemplateList = $this->imageFiles($host);
|
||||
foreach($vmTemplateList as $vmTemp)
|
||||
{
|
||||
if($vmTemp->macAddress == $template->macAddress)
|
||||
{
|
||||
$template->imageFile = $vmTemp->diskFile;
|
||||
unset($template->macAddress);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$template->createdBy = $this->app->user->account;
|
||||
$template->createdDate = helper::now();
|
||||
|
||||
$this->dao->insert(TABLE_VMTEMPLATE)->data($template) ->autoCheck()->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$templateID = $this->dao->lastInsertID();
|
||||
$this->loadModel('action')->create('vmtemplate', $templateID, 'Created');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image files from ZAgent server.
|
||||
*
|
||||
* @param object $host
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function imageFiles($host)
|
||||
{
|
||||
$result = json_decode(commonModel::http("http://{$host->publicIP}:8086/api/v1/kvm/listTmpl?token={$host->secret}"));
|
||||
if(empty($result) || $result->code != 200) return array();
|
||||
|
||||
return $result->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get host by id.
|
||||
*
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class="btn-toolbar pull-right" id='createActionMenu'>
|
||||
<?php
|
||||
$misc = "class='btn btn-primary'";
|
||||
$link = $this->createLink('zahost', 'createTemplate');
|
||||
$link = $this->createLink('zahost', 'createTemplate', "hostID={$hostID}");
|
||||
echo html::a($link, "<i class='icon icon-plus'></i>" . $lang->zahost->createTemplate, '', $misc);
|
||||
?>
|
||||
</div>
|
||||
@@ -32,7 +32,7 @@
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->zahost->templateEmpty;?></span>
|
||||
<?php if(common::hasPriv('zahost', 'createTemplate')) common::printLink('zahost', 'createTemplate', '', '<i class="icon icon-plus"></i> ' . $lang->zahost->createTemplate, '', 'class="btn btn-info"');?>
|
||||
<?php if(common::hasPriv('zahost', 'createTemplate')) common::printLink('zahost', 'createTemplate', "hostID={$hostID}", '<i class="icon icon-plus"></i> ' . $lang->zahost->createTemplate, '', 'class="btn btn-info"');?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
|
||||
<?php js::set('zahostConfig', $config->zahost);?>
|
||||
<?php js::set('zahostLang', $lang->zahost);?>
|
||||
<?php js::set('templateID', '');?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->zahost->createTemplate;?></h2>
|
||||
@@ -21,7 +20,7 @@
|
||||
<form method='post' target='hiddenwin' id='ajaxForm' class="load-indicator main-form form-ajax">
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-120px'><?php echo $lang->zahost->name;?></th>
|
||||
<th class='w-200px'><?php echo $lang->zahost->name;?></th>
|
||||
<td><?php echo html::input('name', '', "class='form-control'");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
@@ -34,7 +33,7 @@
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('memorySize', '', "class='form-control'");?>
|
||||
<span class="input-group-addon">MB</span>
|
||||
<span class='input-group-addon'>MB</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -43,7 +42,7 @@
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('diskSize', '', "class='form-control'");?>
|
||||
<span class='input-group-addon id='unit'>GB</span>
|
||||
<span class='input-group-addon' id='unit'>GB</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -64,8 +63,7 @@
|
||||
<td><?php echo html::select('osLang', $lang->zahost->langList, '', "class='form-control chosen'")?></td>
|
||||
<tr>
|
||||
<th><?php echo $lang->zahost->vmTemplate->imageFile;?></th>
|
||||
<td><?php echo html::select('imageFile', '', '', "class='form-control chosen'")?></td>
|
||||
</tr>
|
||||
<td><?php echo html::select('macAddress', $imageFiles, '', "class='form-control chosen'")?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='text-center form-actions'>
|
||||
|
||||
Reference in New Issue
Block a user