Call to undefined method Group::addMember
-
When you put some client in a group and schedule a task (deploy) to this group and then you want to this schedules in tha task view it looks like this:
[ATTACH]136[/ATTACH]
and in the appache error logs:
PHP Fatal error: Call to undefined method Group::addMember() in /var/www/fog/management/lib/FOGCore.class.php on line 210, referer: [url]http://*******/fog/management/index.php?node=tasks&sub=active[/url]
thanks!
[url=“/_imported_xf_attachments/0/136_fog_empty.png?:”]fog_empty.png[/url]
-
Known bug. Thank you for reporting.
-
[B][FONT=Ubuntu][COLOR=#333333]Fatal error[/COLOR][/FONT][/B][FONT=Ubuntu][COLOR=#333333]: Call to undefined method Group::addMember() in[/COLOR][/FONT][B][FONT=Ubuntu][COLOR=#333333]/var/www/fog/management/lib/FOGCore.class.php[/COLOR][/FONT][/B][FONT=Ubuntu][COLOR=#333333] on line [/COLOR][/FONT][B][FONT=Ubuntu][COLOR=#333333]210[/COLOR][/FONT][/B]
[B][FONT=Ubuntu][COLOR=#333333][/COLOR][/FONT][/B]
Anyone figure out how to fix this bug or at the very least get task scheduler to come up without the error? -
We have this error after upgrading from 0.29 to 0.32. Anyone know the fix?
-
From other post, you can try this to see if it fixes it. I personally have not tried it, but looks like you are having the same problems as the blank task creation page. Make sure you backup your file before you try this!
sudo gedit [B][FONT=Ubuntu][COLOR=#333333]/var/www/fog/management/lib/FOGCore.class.php[/COLOR][/FONT][/B][FONT=Ubuntu][COLOR=#333333] [/COLOR][/FONT]
Search Menu > Replace
Search for: &$tmp
Replace with: $tmp
Replace All
Save
Close
Then try again -
Its not &$tmp. It does not exist anywhere in FOGCore.class.php
-
As it states, addMember() is an undefined method, where is addMember defined within the FOGCore.class.php? I can’t find it and does the same issue occur For Storage group?
Line
[FONT=monospace][COLOR=#000000][RIGHT]286[/RIGHT][/COLOR][/FONT][FONT=monospace][COLOR=#000000] $storagegroup->addMember( $sn );[/COLOR][/FONT]
[FONT=monospace][COLOR=#000000][RIGHT]210[/RIGHT][/COLOR][/FONT][FONT=monospace][COLOR=#000000] $group->addMember( $host );[/COLOR][/FONT]Both of these lines call for the same method, but the method doesn’t actually exist within FOGCore.class.php. I’ll download the tar and see if I can find the method to help with the troubleshooting of this.
[FONT=monospace][COLOR=#000000]B[/COLOR][/FONT] -
Try changing the line 210 to:
$this->Group->addMember( $host );
Maybe this will help as the Group class appears to contain the addMember method.
If that doesn’t work, try:
$Group->addMember ($host);
I’m not running 0.32 so I can’t be a good tester for this! Sorry.
and if the variables really need to be adjusted for try:
$group = $this->Group->addMember( $host ); or
$group = $Group->addMember( $host );Also, if The storage group is having the same type of issue try:
$storagegroup = $this->StorageGroup->addMember( $sn ); or
$storagegroup = $StorageGroup->addMember( $sn ); or
$this->StorageGroup->addMember( $sn ); or
$StorageGroup->addMember( $sn );I know this is a lot, but it’s the best advice I can give.
-
Thanks for looking into this Tom.
Tried your suggestion but it didn’t work. -
Modify FOGCore.class.php
line 137
else if ( $group != null )
{
[B]//add copy from below[/B]
[B]$task = new ScheduledTask( $host, $group, $timer, $ar[“stTaskType”], $ar[“stID”] );[/B]
[B]$task->setShutdownAfterTask( $ar[“stShutDown”] == 1 );[/B]
[B]$task->setOther1( $ar[“stOther1”] );[/B]
[B]$task->setOther2( $ar[“stOther2”] );[/B]
[B]$task->setOther3( $ar[“stOther3”] );[/B]
[B]$task->setOther4( $ar[“stOther4”] );[/B]
[B]$task->setOther5( $ar[“stOther5”] );[/B]
[B]$arTasks[] = $task;[/B]
[B]// start Comment[/B]
[B]/* if ( $group->getCount() > 0 )[/B]
[B]{[/B]
[B]$arRm = array();[/B]
[B]$hosts = $group->getMembers();[/B]
[B]for( $i = 0; $i < count($hosts); $i++ )[/B]
[B]{[/B]
[B]if ( $hosts[$i] != null )[/B]
[B]{[/B]
[B]$h = $hosts[$i];[/B]
[B]if ( ! ($h->isReadyToImage() && $h->getImage()->getStorageGroup()->getID() == $groupid ) )[/B]
[B]{[/B]
[B]$arRm[] = $h;[/B]
[B]}[/B]
[B]}[/B]
[B]}[/B][B]//echo ( "Before: " . $group->getCount() );[/B]
[B]for( $i = 0; $i < count($arRm); $i++ )[/B]
[B]{[/B]
[B]$group->removeMember( $arRm[$i] );[/B]
[B]}[/B]
[B]//echo ( "After: " . $group->getCount() );[/B][B]$task = new ScheduledTask( $host, $group, $timer, $ar[“stTaskType”], $ar[“stID”] );[/B]
[B]$task->setShutdownAfterTask( $ar[“stShutDown”] == 1 );[/B]
[B]$task->setOther1( $ar[“stOther1”] );[/B]
[B]$task->setOther2( $ar[“stOther2”] );[/B]
[B]$task->setOther3( $ar[“stOther3”] );[/B]
[B]$task->setOther4( $ar[“stOther4”] );[/B]
[B]$task->setOther5( $ar[“stOther5”] );[/B]
[B]$arTasks[] = $task;[/B]
[B]} */[/B]
[B]//end comment[/B]
[B]//and comment also from below (Line 212 for me) BOLD[/B]
$group = null;
while( $ar = mysql_fetch_array( $res ) )
{
if ( $group == null )
{
$group = new Group($ar[“groupID”], $ar[“groupName”], $ar[“groupDesc”] );
}
[B] /* $hid = $ar[“hostid”];[/B]
[B] if ( $hid !== null && is_numeric( $hid ) )[/B]
[B] {[/B]
[B] $host = $this->getHostById( $hid );[/B]
[B] if ( $host != null ) [/B]
[B] $group->addMember( $host );[/B]
[B] } */[/B]
}
return $group;Test OK for me
-
Ritchy thanks for that, but still no luck.
[B]Fatal error[/B]: Call to undefined method Group::addMember() in [B]/var/www/fog/management/lib/FOGCore.class.php[/B] on line [B]221[/B]
With your changes line 210 is now 221 but still has same error
Line 137 to 224 below:-
[CODE] else if ( $group != null )
{
//add copy from below
$task = new ScheduledTask( $host, $group, $timer, $ar[“stTaskType”], $ar[“stID”] );
$task->setShutdownAfterTask( $ar[“stShutDown”] == 1 );
$task->setOther1( $ar[“stOther1”] );
$task->setOther2( $ar[“stOther2”] );
$task->setOther3( $ar[“stOther3”] );
$task->setOther4( $ar[“stOther4”] );
$task->setOther5( $ar[“stOther5”] );
$arTasks[] = $task;
// start Comment
/*if ( $group->getCount() > 0 )
{
$arRm = array();
$hosts = $group->getMembers();
for( $i = 0; $i < count($hosts); $i++ )
{
if ( $hosts[$i] != null )
{
$h = $hosts[$i];
if ( ! ($h->isReadyToImage() && $h->getImage()->getStorageGroup()->getID() == $groupid ) )
{
$arRm[] = $h;
}
}
}//echo ( "Before: " . $group->getCount() ); for( $i = 0; $i < count($arRm); $i++ ) { $group->removeMember( $arRm[$i] ); } //echo ( "After: " . $group->getCount() ); $task = new ScheduledTask( $host, $group, $timer, $ar["stTaskType"], $ar["stID"] ); $task->setShutdownAfterTask( $ar["stShutDown"] == 1 ); $task->setOther1( $ar["stOther1"] ); $task->setOther2( $ar["stOther2"] ); $task->setOther3( $ar["stOther3"] ); $task->setOther4( $ar["stOther4"] ); $task->setOther5( $ar["stOther5"] ); $arTasks[] = $task; }*/ //end comment } } } } } return $arTasks; } function getGroupById( $id ) { if ( $this->db != null && is_numeric( $id ) && $id >= 0 ) { $sql = "SELECT groupID, groupName, groupDesc, gmHostID as hostid FROM groups inner join groupMembers on ( groups.groupID = groupMembers.gmGroupID ) WHERE groupID = $id"; $res = mysql_query( $sql, $this->db ) or die( mysql_error() ); $group = null; while( $ar = mysql_fetch_array( $res ) ) { if ( $group == null ) { $group = new Group($ar["groupID"], $ar["groupName"], $ar["groupDesc"] ); } $hid = $ar["hostid"]; if ( $hid !== null && is_numeric( $hid ) ) { $host = $this->getHostById( $hid ); if ( $host != null ) $group->addMember( $host ); } } return $group; [/CODE]
-
Replace &$tmp to $tmp in the tasks.confirm.include.php file.
-
Done that Tom, Same issue.
After doing Ritchy’s changes, line 221 still has:-
$group->addMember( $host ); -
This post is deleted! -
Hello,
I modified my post,
I forgot to say that we
also comment below[ATTACH]551[/ATTACH]
Its Work
sorry[url=“/_imported_xf_attachments/0/551_Capture du 2014-02-19 23_19_53.png?:”]Capture du 2014-02-19 23_19_53.png[/url]
-
Thanks Ricthy that worked. Much appreciated.
-
I’ve followed your instructions ritchy_purple however I found that this broke group scheduled tasks. Single host scheduled tasks still ran but group ones would not as the script no longer returns a list of hosts that are members of the group.
I’ve written some more in-depth instructions and a solution (based on this thread) that gets both the Web GUI and group scheduled tasks working
[url]http://fogproject.org/forum/threads/scheduled-tasks-and-fog-0-32.10345/[/url]
Neil