def createEntityListFromResponse(self, response, detail=False): """ Creates list of server objects from response to list command sent to API """ theList = [] data = response["servers"] for jsonObj in data: srv = Server("") srv.initFromResultDict(jsonObj) theList.append(srv) return EntityList(theList, detail, self)
def testPersonality(): s = Server(name="test", imageId=3, flavorId=1) p = Personality() f1 = File('/usr/local/personality1', \ 'this is a test. if it is legible, the test failed') f2 = File('/usr/local/personality2', \ 'this is another test. if it is legible, the test failed') p.files = [f1, f2] s.personality = p print "personality: ", s.personality print "files:" for file in p.files: print file.path, ' ', file.contents print "personality in server object:" print s.asJSON print "no personality in server object:" s.personality = None print s.asJSON