示例#1
0
void
VMGahp::returnOutput(const char **results, const int count)
{
	int i=0;

	for( i=0; i<count; i++) {
		write_to_daemoncore_pipe("%s", results[i]);
		if( i < (count -1)) {
			write_to_daemoncore_pipe(" ");
		}
	}

	write_to_daemoncore_pipe("\n");
}
示例#2
0
int
VMGahp::waitForCommand(int   /*pipe_end*/)
{
	MyString *line = NULL;

	while((line = m_request_buffer.GetNextLine()) != NULL) {

		const char *command = line->Value();

		Gahp_Args args;
		VMRequest *new_req = NULL;

		if( m_inClassAd )  {
			if( strcasecmp(command, VMGAHP_COMMAND_CLASSAD_END) == 0 ) {
				m_inClassAd = false;

				// Everything is Ok. Now we got vmClassAd
				returnOutputSuccess();
			}else {
				if( !m_jobAd->Insert(command) ) {
					vmprintf(D_ALWAYS, "Failed to insert \"%s\" into classAd, "
							"ignoring this attribute\n", command);
				}
			}
		}else {
			if(parse_vmgahp_command(command, args) &&
					verifyCommand(args.argv, args.argc)) {
				new_req = preExecuteCommand(command, &args);

				if( new_req != NULL ) {
					// Execute the new request
					executeCommand(new_req);
					if(new_req->m_has_result) {
						movePendingReqToResultList(new_req);
						if (m_async_mode) {
							if (!m_new_results_signaled) {
								write_to_daemoncore_pipe("R\n");
							}
							// So that we only do it once
							m_new_results_signaled = true;
						}
					}
				}
			}else {
				returnOutputError();
			}
		}

		delete line;
		line = NULL;
	}

	// check if GetNextLine() returned NULL because of an error or EOF
	if(m_request_buffer.IsError() || m_request_buffer.IsEOF()) {
		vmprintf(D_ALWAYS, "Request buffer closed, exiting\n");
		cleanUp();
		DC_Exit(0);
	}
	return true;
}
示例#3
0
void
VMGahp::executeResults(void)
{
	write_to_daemoncore_pipe("S %d\n", numOfReqWithResult());

	// Print each result line
	printAllReqsWithResult();
	m_new_results_signaled = false;
}
示例#4
0
void
VMGahp::printAllReqsWithResult()
{
	char *one_result = NULL;
	MyString output;
	m_result_list.rewind();
	while( (one_result = m_result_list.next()) != NULL ) {
		output = one_result;
		output += "\n";
		write_to_daemoncore_pipe(vmgahp_stdout_pipe,
				output.Value(), output.Length());
		m_result_list.deleteCurrent();
	}
}
示例#5
0
void
VMGahp::executeCommands(void)
{
	MyString result;
	result += "S";

	int i = 0;
	while(commands_list[i] != NULL) {
		result += " ";
		result += commands_list[i];
		i++;
	}

	write_to_daemoncore_pipe("%s\n", result.Value());
}
示例#6
0
void
write_to_daemoncore_pipe(const char* fmt, ... )
{
	if( vmgahp_stdout_pipe == -1 ) {
		return;
	}

	MyString output;
	va_list args;
	va_start(args, fmt);
	output.vformatstr(fmt, args);
	write_to_daemoncore_pipe(vmgahp_stdout_pipe, 
			output.Value(), output.Length());
	va_end(args);
}
示例#7
0
void
VMGahp::executeSupportVMS(void)
{
	MyString result;
	result += "S";

	int i = 0;
	while(support_vms_list[i] != NULL) {
		result += " ";
		result += support_vms_list[i];
		i++;
	}

	vmprintf(D_FULLDEBUG, "Execute commands: %s\n", result.Value());
	write_to_daemoncore_pipe("%s\n", result.Value());
}
示例#8
0
void
VMGahp::executeVersion(void)
{
	write_to_daemoncore_pipe("S %s\n", vmgahp_version);
}