~0x44/nova/bug838466

« back to all changes in this revision

Viewing changes to nova/tests/integrated/integrated_helpers.py

  • Committer: Justin Santa Barbara
  • Date: 2011-03-24 08:13:20 UTC
  • mto: This revision was merged to the branch mainline in revision 913.
  • Revision ID: justin@fathomdb.com-20110324081320-j2bm1kl00y86cg02
Created simple test case for server creation, so that we can have something to attach to...

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
                                                        self.secret,
74
74
                                                        self.auth_url)
75
75
 
 
76
    def get_unused_server_name(self):
 
77
        servers = self.openstack_api.get_servers()
 
78
        server_names = [server['name'] for server in servers]
 
79
        return generate_new_element(server_names, 'server')
 
80
 
 
81
    def get_invalid_image(self):
 
82
        images = self.openstack_api.get_images()
 
83
        image_ids = [image['id'] for image in images]
 
84
        return generate_new_element(image_ids, '', numeric=True)
 
85
 
 
86
    def get_valid_image(self, create=False):
 
87
        images = self.openstack_api.get_images()
 
88
        if create and not images:
 
89
            # TODO(justinsb): No way to create an image through API???
 
90
            #created_image = self.openstack_api.post_image(image)
 
91
            #images.append(created_image)
 
92
            raise exception.Error("No way to create an image through API??")
 
93
 
 
94
        if images:
 
95
            return images[0]
 
96
        return None
 
97
 
76
98
 
77
99
class IntegratedUnitTestContext(object):
78
100
    __INSTANCE = None