Commit 3f2dfa87 authored by Anmol Vatsa's avatar Anmol Vatsa

remoterevokewfa

parent 41bcf104
import traceback
import capnet as cp
import capnet.util as util
def grant2all(cap, nodes):
for name,node in nodes.iteritems():
node.grant.grant(cap)
def remoterevoke(protocol, ctrlid, RECVNODES_TIMEOUT = 2):
rpkey = "RP_REMOTEREVOKE"
rp0, me_props, broker = util.recv_preamble(protocol)
local_nodes = util.recv_nodes(protocol, rp0.recv_iter_timeout(RECVNODES_TIMEOUT))
print("Get remote rp from broker with key="+ctrlid+"/"+rpkey)
rp = broker.lookup(ctrlid+"/"+rpkey)
print("Got remote RP from broker")
print("Recv remote cap to grant to all local")
remotecap = rp.recv()
print("Got remote cap")
print("Grant to all local")
grant2all(remotecap, local_nodes)
print("now revoke")
remotecap.revoke()
print("revoke done")
if __name__ == '__main__':
import sys
if len(sys.argv) < 2:
print("Usage: python remoterevoke_a <interface> [<other-cloud-id>]")
exit()
p = cp.Protocol(sys.argv[1])
ctrlid= "cntrl2"
if len(sys.argv) == 3:
ctrlid = sys.argv[2]
remoterevoke(p, ctrlid)
import traceback
import capnet as cp
import capnet.util as util
import time
def sendcap(protocol, RECVNODES_TIMEOUT = 2):
rpkey = "RP_REMOTEREVOKE"
rp0, me_props, broker = util.recv_preamble(protocol)
rp = protocol.create(cp.RP)
print("Register rp to broker with key="+rpkey)
broker.register(rpkey, rp)
print("registered")
print("get a local cap")
nb2 = rp0.recv()
print("recevied")
print("Send cal on rp")
rp.send(nb2)
print("sent")
print("now just wait around so the wfa does not terminate and lose the rp cap")
while True:
time.sleep(10)
if __name__ == '__main__':
import sys
if len(sys.argv) < 2:
print("Usage: python remoterevoke_b <interface>")
exit()
p = cp.Protocol(sys.argv[1])
sendcap(p)
......@@ -1884,9 +1884,9 @@ int proxy_node_grant_remote_cap(struct cnode* node_grant_cnode, cn_principal_t*
* subsec: Create RPC RemoteRevoke Request
******************************************************************************/
int proxy_remote_revoke(cn_principal_t* as, cptr_t cptr) {
struct timespec timespec;
clock_gettime(CLOCK_REALTIME, &timespec);
c_log_debug("DEBUG:%s:%lu.%lu:Start", __func__, timespec.tv_sec, timespec.tv_nsec);
struct timespec starttime;
clock_gettime(CLOCK_REALTIME, &starttime);
c_log_debug("DEBUG:%s:%lu.%lu:Start", __func__, starttime.tv_sec, starttime.tv_nsec);
int res = 0;
cn_obj_lock(as);
......@@ -1919,9 +1919,15 @@ int proxy_node_grant_remote_cap(struct cnode* node_grant_cnode, cn_principal_t*
remote_revoke_req->requester_id = (uint64_t)as;
remote_revoke_req->cptr = cptr2ul(shadow->cap_id);
struct timespec reqstarttime;
clock_gettime(CLOCK_REALTIME, &reqstarttime);
ControllerRPC__RPCMessage* rpc_resp;
res = _perform_intercomm_rpc(shadow->remote_end, rpc_req, &rpc_resp);
struct timespec reqendtime;
clock_gettime(CLOCK_REALTIME, &reqendtime);
cn_obj_unlock(shadow);
cap_cnode_put(to_revoke_cnode);
......@@ -1964,9 +1970,10 @@ int proxy_node_grant_remote_cap(struct cnode* node_grant_cnode, cn_principal_t*
fail_unlock:
cn_obj_unlock(as);
clock_gettime(CLOCK_REALTIME, &timespec);
c_log_debug("DEBUG:%s:%lu.%lu:End", __func__, timespec.tv_sec, timespec.tv_nsec);
struct timespec endtime;
clock_gettime(CLOCK_REALTIME, &endtime);
c_log_debug("DEBUG:%s:%lu.%lu:End", __func__, endtime.tv_sec, endtime.tv_nsec);
c_log_debug("DEBUG:%s:End-Start:%lu", __func__, mytimediff(starttime, endtime) - mytimediff(reqstarttime, reqendtime));
return res;
}
/******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment