コード例 #1
0
    def list_instancetypes_cache(self):

	region = get_region()

	instance_types = region.get('instancetypes')
	if instance_types is not NO_VALUE:
		return instance_types
	dic = {}
	instance_types = self.list_instancetypes()
	for instance_type in instance_types:
		dic[instance_type.id] = instance_type.obj_to_dict()

	region.set('instancetypes', dic)
	return dic
コード例 #2
0
ファイル: OpenStackImages.py プロジェクト: Hawkgirl/ext_cloud
    def list_images_cache(self):
        from dogpile.cache.api import NO_VALUE
	from ext_cloud.utils.dogpile_utils import get_region

	region = get_region()

        images = region.get('images')
        if images is not NO_VALUE:
                return images
        dic = {}
        images = self.list_images()
        for image in images:
                dic[image.id] = image.obj_to_dict()

        region.set('images', dic)
        return dic
コード例 #3
0
    def get_instance_by_id_cache(self, instance_id):
	region = get_region()
	# check if instance id is in cache
	instances = region.get('instances')

	if instances is NO_VALUE:
		# cache not created for instances, create a cache of all instances
       		dic = {}
        	instances = self.list_instances()
        	for instance in instances:
               		dic[instance.id] = instance.obj_to_dict()

        	region.set('instances', dic)
		instances = dic

	if instance_id in instances:
		return instances[instance_id]

	# instance id not found. call get_instance_by_id which will throw error or return instance which is not in cache
	instance = self.get_instance_by_id(instance_id)
	return instance.obj_to_dic()