//$Id: SchedulingFilter.bsh,v 1.1.4.1 2002/10/21 11:53:40 chinnaraj Exp $
// This array contains the host names and the time during which they can be provisioned.
String[][] hostsAndTime = {
                        	{"localhost","11-12"},
	                        {"host1","16-17"},
                          };
hostTable = new Hashtable();
for(i = 0 ; i < hostsAndTime.length ; i++)
{
	hostTable.put(hostsAndTime[i][0],hostsAndTime[i][1]);
}
configTasks = template.getConfigTasks(); // Getting the ConfigTasks present in the Template.
for(i = 0 ; i < configTasks.size() ; i++)
{
	devices = configTasks.elementAt(i).getDevices(); // Getting the devices.
	for(j = 0 ; j < devices.length ; j++)
	{
		MOName = devices[j].getDeviceName(); 
		// Checking whether the hashtable contains the devicename and whether the device
		// can be provisioned now.
		if(hostTable.containsKey(MOName))
		{
			calendar = new GregorianCalendar();
			hour = calendar.get(Calendar.HOUR_OF_DAY);
			declaredHour = hostTable.get(MOName);
			dash = declaredHour.indexOf("-");
			from = Integer.parseInt(declaredHour.substring(0,dash).trim());
			to = Integer.parseInt(declaredHour.substring(dash+1).trim());
			if(!(hour >= from && hour < to))
			{
				throw new com.adventnet.nms.provisioning.OperationFailedException("The specified host cannot be provisioned during this time.");
			}
		}
	}
}
return template;
