示例#1
0
    def UpdateValue(self, request, context):
        if request.row >= len(self.conn_mat.rows) or request.col >= len(
                self.conn_mat.rows[request.row].vals):
            return chaosmonkey_pb2.Status(ret=1)

        self.conn_mat.rows[request.row].vals[request.col] = request.val
        return chaosmonkey_pb2.Status(ret=0)
示例#2
0
 def UpdateValue(self, request, context):
     global conn_mat
     if request.row >= len(conn_mat.rows) or request.col >= len(
             conn_mat.rows[request.row].vals):
         return chaosmonkey_pb2.Status(ret=1)
     conn_mat.rows[request.row].vals[request.col] = request.val
     print('New edit to ConnMat')
     return chaosmonkey_pb2.Status(ret=0)
示例#3
0
 def KillANode(self, request, context):
     global conn_mat
     node_index = request.node_index
     N = len(conn_mat)
     if node_index < 0 or node_index >= N:
         return chaosmonkey_pb2.Status(ret=1)
     for id in range(N):
         conn_mat[id][node_index] = 1.0
         conn_mat[node_index][id] = 1.0
     return chaosmonkey_pb2.Status(ret=0)
示例#4
0
 def UpdateValue(self, request, context):
     global chaosMatrix
     print("update matrix")
     print chaosMatrix
     print("at " + str(request.row) + "," + str(request.col))
     print("with value " + str(request.val))
     chaosMatrix[request.row][request.col] = request.val
     print chaosMatrix
     return chaosmonkey_pb2.Status(ret=chaosmonkey_pb2.OK)
示例#5
0
 def UploadMatrix(self, request, context):
     global chaosMatrix
     print("upload matrix")
     chaosMatrix = []
     for i in request.rows:
         l = []
         for j in i.vals:
             l.append(j)
         chaosMatrix.append(list(l))
     print chaosMatrix
     return chaosmonkey_pb2.Status(ret=chaosmonkey_pb2.OK)
示例#6
0
    def UploadMatrix(self, request, context):
        global conn_mat

        mat = list()
        for row in request.rows:
            to_row = list()
            for e in row.vals:
                to_row.append(e)
            mat.append(to_row)

        conn_mat = mat
        return chaosmonkey_pb2.Status(ret=0)
示例#7
0
 def UpdateValue(self, request, context):
     try:
         print("CM: Updating new matrix value")
         r = request.row
         c = request.col
         v = request.val
         self.fail_mat[r][c] = v
         print("CM: New failure matrix:")
         print(self)
         resp = chaosmonkey_pb2.Status(ret=0)
         return resp
     except Exception as e:
         print(e)
示例#8
0
 def UploadMatrix(self, request, context):
     try:
         print("CM: Updating new matrix")
         new_mat = []
         for row in range(len(request.rows)):
             r = [float(v) for v in request.rows[row].vals]
             new_mat.append(r)
         self.fail_mat = new_mat.copy()
         print("CM: New failure matrix:")
         print(self)
         resp = chaosmonkey_pb2.Status(ret=0)
         return resp
     except Exception as e:
         print(e)
示例#9
0
 def UploadMatrix(self, request, context):
     self.conn_mat = request
     return chaosmonkey_pb2.Status(ret=0)
示例#10
0
 def UpdateValue(self, request, context):
     global conn_mat
     if request.row >= len(conn_mat) or request.col >= len(conn_mat):
         return chaosmonkey_pb2.Status(ret=1)
     conn_mat[request.row][request.col] = request.val
     return chaosmonkey_pb2.Status(ret=0)
示例#11
0
 def UploadMatrix(self, request, context):
     global conn_mat
     conn_mat = request
     print('New ConnMat uploaded')
     return chaosmonkey_pb2.Status(ret=0)