rpc.h 2.87 KB
Newer Older
1
/*
2
 * Copyright (c) 2004-2017 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 
 * {{{EMULAB-LICENSE
 * 
 * This file is part of the Emulab network testbed software.
 * 
 * This file is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * }}}
22 23 24 25 26 27 28 29 30
 */

#ifndef _event_sched_rpc_h
#define _event_sched_rpc_h

#include "event-sched.h"

#ifdef __cplusplus

31 32 33
#include <xmlrpc-c/base.hpp>
#include <xmlrpc-c/girerr.hpp>
#include <xmlrpc-c/client.hpp>
34
#include <iostream>
35
#include "emulab_proxy.h"
36

37
int RPC_invoke(char const *method,
38 39 40 41 42 43 44 45 46
	       emulab::EmulabResponse *er_out,
	       emulab::spa_attr_t tag,
	       ...);

struct r_rpc_data {
	const char *certpath;
	const char *host;
	unsigned short port;
	int refcount;
47
	xmlrpc_c::clientXmlTransport *transport;
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
	pthread_mutex_t mutex;
};

extern struct r_rpc_data rpc_data;

#endif

#define DEFAULT_RPC_PORT 3069

#define ROBOT_TIMEOUT 10 * 60 /* seconds */

#ifdef __cplusplus
extern "C" {
#endif

extern const char *topography_name; // XXX temporary

typedef enum {
	ES_UNKNOWN,
	ES_ACTIVATING,
	ES_ACTIVE,
	ES_MODIFY_RESWAP,
} expt_state_t;
	
int RPC_init(const char *certpath, const char *host, unsigned short port);
int RPC_grab(void);
void RPC_drop(void);

int RPC_metadata(char *pid, char *eid);
expt_state_t RPC_expt_state(char *pid, char *eid);
int RPC_waitforactive(char *pid, char *eid);
int RPC_notifystart(char *pid, char *eid, char *timeline, int set_or_clear);
int RPC_agentlist(event_handle_t handle, char *pid, char *eid);
int RPC_grouplist(event_handle_t handle, char *pid, char *eid);
int RPC_eventlist(char *pid, char *eid,
		  event_handle_t handle, address_tuple_t tuple);

extern int SetExpPath(const char *path);
86
extern int AddUserEnv(const char *name, const char *value);
87 88

extern int AddAgent(event_handle_t handle,
89 90
		    const char *vname, const char *vnode, const char *nodeid,
		    const char *ipaddr, const char *type);
91

92 93
extern int AddGroup(event_handle_t handle, const char *groupname,
                    const char *agentname);
94 95

extern int AddEvent(event_handle_t handle, address_tuple_t tuple,
96 97 98
		    const char *exidx, const char *ftime, const char *objname,
                    const char *exargs, const char *objtype, const char *evttype,
                    const char *parent, const char *triggertype);
99 100 101 102 103 104 105

extern const char *XMLRPC_ROOT;
#ifdef __cplusplus
}
#endif

#endif