Skip to content

Commit

Permalink
Cleanup, operationally, Capone plugin.
Browse files Browse the repository at this point in the history
There were a few files where the capone items were directly coded in the core of fog. This left potential issues.  Move these rather implicit calls to a hook within the capone plugin itself. The only left over capone items are for init option generation and the capone.php file within the service directory.
  • Loading branch information
mastacontrola committed Dec 30, 2016
1 parent 7bfc7f2 commit c90f023
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 230 deletions.
129 changes: 2 additions & 127 deletions packages/web/lib/fog/bootmenu.class.php
Expand Up @@ -221,8 +221,6 @@ public function __construct($Host = null)
'FOG_KEYMAP',
'FOG_KEY_SEQUENCE',
'FOG_MEMTEST_KERNEL',
'FOG_PLUGIN_CAPONE_DMI',
'FOG_PLUGIN_CAPONE_SHUTDOWN',
'FOG_PXE_BOOT_IMAGE',
'FOG_PXE_BOOT_IMAGE_32',
'FOG_PXE_HIDDENMENU_TIMEOUT',
Expand All @@ -240,8 +238,6 @@ public function __construct($Host = null)
$keymap,
$keySequence,
$memtest,
$caponeDMI,
$caponeShutdown,
$imagefile,
$init_32,
$hiddenTimeout,
Expand All @@ -261,53 +257,6 @@ public function __construct($Host = null)
false,
''
);
if (!in_array('capone', (array)$_SESSION['PluginsInstalled'])) {
$serviceNames = array(
'FOG_EFI_BOOT_EXIT_TYPE',
'FOG_KERNEL_ARGS',
'FOG_KERNEL_DEBUG',
'FOG_KERNEL_LOGLEVEL',
'FOG_KERNEL_RAMDISK_SIZE',
'FOG_KEYMAP',
'FOG_KEY_SEQUENCE',
'FOG_MEMTEST_KERNEL',
'FOG_PXE_BOOT_IMAGE',
'FOG_PXE_BOOT_IMAGE_32',
'FOG_PXE_HIDDENMENU_TIMEOUT',
'FOG_PXE_MENU_HIDDEN',
'FOG_PXE_MENU_TIMEOUT',
'FOG_TFTP_PXE_KERNEL',
'FOG_TFTP_PXE_KERNEL_32',
);
list(
$exit,
$kernelArgs,
$kernelDebug,
$kernelLogLevel,
$kernelRamDisk,
$keymap,
$keySequence,
$memtest,
$imagefile,
$init_32,
$hiddenTimeout,
$hiddenmenu,
$menuTimeout,
$bzImage,
$bzImage32
) = self::getSubObjectIDs(
'Service',
array(
'name' => $serviceNames
),
'value',
false,
'AND',
'name',
false,
''
);
}
$memdisk = 'memdisk';
$loglevel = $kernelLogLevel;
$ramsize = $kernelRamDisk;
Expand Down Expand Up @@ -394,15 +343,8 @@ public function __construct($Host = null)
)
);
$this->_initrd = "imgfetch $imagefile";
self::_caponeMenu(
$this->_storage,
$this->_path,
$this->_shutdown,
$caponeDMI,
$caponeShutdown,
$StorageNode,
self::$FOGCore
);
self::$HookManager
->processEvent('BOOT_MENU_ITEM');
$PXEMenuID = @max(
self::getSubObjectIDs(
'PXEMenuOptions',
Expand Down Expand Up @@ -448,73 +390,6 @@ public function __construct($Host = null)
$this->getTasking();
}
}
/**
* If it doesn't exist, create the capone menu
*
* @param string $storage the storage
* @param string $path the path
* @param mixed $shutdown if shutdown is to be used
* @param string $DMISet Capone's dmi field
* @param mixed $Shutdown Capone's shutdown field
* @param StorageNode $StorageNode The Storage Node to use
* @param FOGCore $FOGCore FOGCore class
*
* @return void
*/
private static function _caponeMenu(
&$storage,
&$path,
&$shutdown,
$DMISet,
$Shutdown,
&$StorageNode,
&$FOGCore
) {
if (!in_array('capone', (array)$_SESSION['PluginsInstalled'])) {
return;
}
if (!$DMISet) {
return;
}
$storage = $StorageNode->get('ip');
$path = $StorageNode->get('path');
$shutdown = $Shutdown;
$dmi = $DMISet;
$args = trim("mode=capone shutdown=$shutdown");
$CaponeMenu = self::getClass('PXEMenuOptions')
->set('name', 'fog.capone')
->load('name');
if (!$CaponeMenu->isValid()) {
$CaponeMenu->set('name', 'fog.capone')
->set('description', _('Capone Deploy'))
->set('args', $args)
->set('params', null)
->set('default', 0)
->set('regMenu', 2);
}
$setArgs = explode(' ', trim($CaponeMenu->get('args')));
$neededArgs = explode(' ', trim($args));
$sureArgs = array();
array_walk(
$setArgs,
function (&$arg, &$index) use (&$sureArgs) {
if (!preg_match('#^dmi=#', $arg)) {
$sureArgs[] = $arg;
}
}
);
$setArgs = $sureArgs;
array_walk(
$neededArgs,
function (&$arg, &$index) use (&$setArgs) {
if (!in_array($arg, $setArgs)) {
$setArgs[] = $arg;
}
}
);
$setArgs[] = sprintf('dmi=%s', $dmi);
$CaponeMenu->set('args', implode(' ', $setArgs))->save();
}
/**
* Sets the default menu item
*
Expand Down
2 changes: 1 addition & 1 deletion packages/web/lib/fog/system.class.php
Expand Up @@ -53,7 +53,7 @@ private static function _versionCompare()
public function __construct()
{
self::_versionCompare();
define('FOG_VERSION', '33');
define('FOG_VERSION', '15');
define('FOG_SCHEMA', 244);
define('FOG_BCACHE_VER', 110);
define('FOG_SVN_REVISION', 6052);
Expand Down
5 changes: 4 additions & 1 deletion packages/web/lib/pages/pluginmanagementpage.class.php
Expand Up @@ -594,7 +594,10 @@ public function installedPost()
throw new Exception(_('Settings Updated'));
}
if (isset($_REQUEST['addass'])) {
$Image = self::getClass('Image', $_REQUEST['image']);
$Image = new Image($_REQUEST['image']);
if (!$Image->isValid()) {
throw new Exception(_('Must have an image associated'));
}
$OS = $Image->getOS();
$Capone = self::getClass('Capone')
->set('imageID', $_REQUEST['image'])
Expand Down
107 changes: 107 additions & 0 deletions packages/web/lib/plugins/capone/hooks/addbootmenuitem.hook.php
@@ -0,0 +1,107 @@
<?php
/**
* Creates the capone menu item.
*
* PHP Version 5
*
* @category AddBootMenuItem
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
/**
* Creates the capone menu item.
*
* @category AddBootMenuItem
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
class AddBootMenuItem extends Hook
{
/**
* The name of this hook.
*
* @var string
*/
public $name = 'AddBootMenuItem';
/**
* The description of this hook.
*
* @var string
*/
public $description = 'Add capone menu item';
/**
* The active flag.
*
* @var bool
*/
public $active = true;
/**
* The node this hook enacts with.
*
* @var string
*/
public $node = 'capone';
/**
* Creates the storage node.
*
* @return void
*/
public function addBootMenuItem()
{
if (!in_array($this->node, (array)$_SESSION['PluginsInstalled'])) {
return;
}
$dmi = self::getSetting('FOG_PLUGIN_CAPONE_DMI');
$shutdown = self::getSetting('FOG_PLUGIN_CAPONE_SHUTDOWN');
if (!$dmi) {
return;
}
$exists = self::getClass('PXEMenuOptionsManager')
->exists('fog.capone', '', 'name');
$args = trim("mode=capone shutdown=$shutdown");
$entry = self::getClass('PXEMenuOptions')
->set('name', 'fog.capone')
->load('name');
if (!$exists) {
$entry
->set('name', 'fog.capone')
->set('description', _('Capone Deploy'))
->set('args', $args)
->set('params', null)
->set('default', 0)
->set('regMenu', 2);
}
$setArgs = explode(' ', trim($entry->get('args')));
$neededArgs = explode(' ', trim($args));
$sureArgs = array();
foreach ((array)$setArgs as &$arg) {
if (!preg_match('#^dmi=#', $arg)) {
$sureArgs[] = $arg;
}
unset($arg);
}
$setArgs = $sureArgs;
foreach ((array)$neededArgs as &$arg) {
if (!in_array($arg, $setArgs)) {
$setArgs[] = $arg;
}
unset($arg);
}
$setArgs[] = sprintf('dmi=%s', $dmi);
$entry
->set('args', implode(' ', $setArgs))
->save();
}
}
$HookManager
->register(
'BOOT_MENU_ITEM',
array(
new AddBootMenuItem(),
'addBootMenuItem'
)
);
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: fog-project-2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-23 19:33-0500\n"
"POT-Creation-Date: 2016-12-29 20:31-0500\n"
"PO-Revision-Date: 2016-05-23 07:36-0400\n"
"Last-Translator: vspushbullet <vspushbullet@gmail.com>\n"
"Language-Team: German\n"
Expand Down Expand Up @@ -939,11 +939,7 @@ msgstr "Registriert"
msgid "Set Failed"
msgstr "Fehler beim"

#: /var/www/fog/lib/fog/bootmenu.class.php:489
msgid "Capone Deploy"
msgstr "Capone bereitstellen"

#: /var/www/fog/lib/fog/bootmenu.class.php:1481
#: /var/www/fog/lib/fog/bootmenu.class.php:1356
#, fuzzy
msgid "No valid storage nodes found"
msgstr "Ungültige Speicherknoten"
Expand Down Expand Up @@ -5966,20 +5962,25 @@ msgstr "Plugin installiert!"
msgid "Settings Updated"
msgstr "Einstellungen aktualisiert"

#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:604
#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:599
#, fuzzy
msgid "Must have an image associated"
msgstr "Snap-in muss zu einer Gruppe verknüpft haben"

#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:607
msgid "Failed to save assignment"
msgstr "Fehler beim Speichern der Zuordnung"

#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:606
#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:609
msgid "Assignment saved successfully"
msgstr "Auftrag erfolgreich gespeichert"

#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:612
#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:615
#, fuzzy
msgid "Destroyed assignments"
msgstr "Zerstörte Zuordnung"

#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:614
#: /var/www/fog/lib/pages/pluginmanagementpage.class.php:617
msgid "Destroyed assignment"
msgstr "Zerstörte Zuordnung"

Expand Down Expand Up @@ -6725,6 +6726,10 @@ msgstr "Aktuelle Sendung"
msgid "WOL Broadcast Management"
msgstr "WOL Broadcast Management"

#: /var/www/fog/lib/plugins/capone/hooks/addbootmenuitem.hook.php:72
msgid "Capone Deploy"
msgstr "Capone bereitstellen"

#: /var/www/fog/lib/db/pdodb.class.php:90
#: /var/www/fog/lib/db/mysql.class.php:16
msgid "Failed to connect"
Expand Down Expand Up @@ -9149,9 +9154,6 @@ msgstr "Es gibt keine Orte auf diesem Server."
#~ "Eine Datei für das Snap-in verwenden müssen entweder hochgeladen oder aus "
#~ "der bereits vorhandenen Liste ausgewählt werden"

#~ msgid "Must have snapin associated to a group"
#~ msgstr "Snap-in muss zu einer Gruppe verknüpft haben"

#~ msgid "Snapin added, Editing now!"
#~ msgstr "Snap-in hinzugefügt, jetzt bearbeiten!"

Expand Down

0 comments on commit c90f023

Please sign in to comment.