def pull_sizes(self): regions = models.Region.objects.values_list('backend_id', flat=True) for region in regions: manager = self._get_api(region) # XXX: Obviously each region has a different price, # find a better form of models relation for backend_size in manager.list_sizes(): size, _ = models.Size.objects.update_or_create( backend_id=backend_size.id, defaults={ 'name': backend_size.name, 'cores': backend_size.extra.get('cpu', 1), 'ram': self.gb2mb(backend_size.ram), 'disk': self.gb2mb(backend_size.disk), 'price': backend_size.price, }) current_regions = set(size.regions.all()) backend_regions = set( models.Region.objects.filter(backend_id__in=[ r for r, v in REGION_DETAILS.items() if backend_size.id in v['instance_types'] ])) size.regions.add(*(backend_regions - current_regions)) size.regions.remove(*(current_regions - backend_regions))
def test_instantiate_driver_valid_datacenters(self): datacenters = REGION_DETAILS.keys() datacenters = [d for d in datacenters if d != 'nimbus'] for datacenter in datacenters: EC2NodeDriver(*EC2_PARAMS, **{'datacenter': datacenter})
def test_instantiate_driver_valid_regions(self): regions = REGION_DETAILS.keys() regions = [d for d in regions if d != 'nimbus'] for region in regions: EC2NodeDriver(*EC2_PARAMS, **{'region': region})
def test_instantiate_driver_valid_datacenters(self): datacenters = REGION_DETAILS.keys() datacenters.remove('nimbus') for datacenter in datacenters: EC2NodeDriver(*EC2_PARAMS, datacenter=datacenter)