def handle(self, request, data): # Update the default quotas. # `fixed_ips` update for quota class is not supported by novaclient # WRS: Also remove 'floating_ips', 'security_group_rules' and # 'security_groups' as they are also no longer supported by novaclient nova_data = { key: value for key, value in data.items() if key in quotas.NOVA_QUOTA_FIELDS and (key != 'fixed_ips' and key != 'floating_ips' and key != 'security_group_rules' and key != 'security_groups') } is_error_nova = False is_error_cinder = False is_volume_service_enabled = cinder.is_volume_service_enabled(request) # Update the default quotas for nova. try: nova.default_quota_update(request, **nova_data) except Exception: is_error_nova = True # Update the default quotas for cinder. if is_volume_service_enabled: cinder_data = { key: value for key, value in data.items() if key in quotas.CINDER_QUOTA_FIELDS } try: cinder.default_quota_update(request, **cinder_data) except Exception: is_error_cinder = True else: LOG.debug('Unable to update Cinder default quotas' ' because the Cinder volume service is disabled.') # Analyze errors (if any) to determine what success and error messages # to display to the user. if is_error_nova and not is_error_cinder: if is_volume_service_enabled: self.success_message = _('Default quotas updated for Cinder.') exceptions.handle(request, _('Unable to update default quotas' ' for Nova.')) else: return False elif is_error_cinder and not is_error_nova: self.success_message = _('Default quotas updated for Nova.') exceptions.handle(request, _('Unable to update default quotas for Cinder.')) elif is_error_nova and is_error_cinder: return False return True
def handle(self, request, context): nova_data = { key: value for key, value in context.items() if key in quotas.NOVA_QUOTA_FIELDS } try: nova.default_quota_update(request, **nova_data) return True except Exception: exceptions.handle(request, _('Unable to update default compute quotas.')) return False
def handle(self, request, context): nova_data = { key: value for key, value in context.items() if key in quotas.NOVA_QUOTA_FIELDS } try: nova.default_quota_update(request, **nova_data) return True except Exception: exceptions.handle(request, _('Unable to update default compute quotas.')) return False
def handle(self, request, data): # Update the default quotas. # `fixed_ips` update for quota class is not supported by novaclient nova_data = dict([(key, data[key]) for key in ALL_NOVA_QUOTA_FIELDS if key != "fixed_ips"]) try: nova.default_quota_update(request, **nova_data) if base.is_service_enabled(request, "volume"): cinder_data = dict([(key, data[key]) for key in quotas.CINDER_QUOTA_FIELDS]) cinder.default_quota_update(request, **cinder_data) except Exception: exceptions.handle(request, _("Unable to update default quotas.")) return True
def handle(self, request, data): # Update the default quotas. # `fixed_ips` update for quota class is not supported by novaclient nova_data = { key: value for key, value in data.items() if key in quotas.NOVA_QUOTA_FIELDS and key != 'fixed_ips' } is_error_nova = False is_error_cinder = False is_volume_service_enabled = cinder.is_volume_service_enabled(request) # Update the default quotas for nova. try: nova.default_quota_update(request, **nova_data) except Exception: is_error_nova = True # Update the default quotas for cinder. if is_volume_service_enabled: cinder_data = { key: value for key, value in data.items() if key in quotas.CINDER_QUOTA_FIELDS } try: cinder.default_quota_update(request, **cinder_data) except Exception: is_error_cinder = True else: LOG.debug('Unable to update Cinder default quotas' ' because the Cinder volume service is disabled.') # Analyze errors (if any) to determine what success and error messages # to display to the user. if is_error_nova and not is_error_cinder: if is_volume_service_enabled: self.success_message = _('Default quotas updated for Cinder.') exceptions.handle(request, _('Unable to update default quotas' ' for Nova.')) else: return False elif is_error_cinder and not is_error_nova: self.success_message = _('Default quotas updated for Nova.') exceptions.handle(request, _('Unable to update default quotas for Cinder.')) elif is_error_nova and is_error_cinder: return False return True
def handle(self, request, data): # Update the default quotas. nova_data = { key: value for key, value in data.items() if key in quotas.NOVA_QUOTA_FIELDS } is_error_nova = False is_error_cinder = False is_volume_service_enabled = cinder.is_volume_service_enabled(request) # Update the default quotas for nova. try: nova.default_quota_update(request, **nova_data) except Exception: is_error_nova = True # Update the default quotas for cinder. if is_volume_service_enabled: cinder_data = { key: value for key, value in data.items() if key in quotas.CINDER_QUOTA_FIELDS } try: cinder.default_quota_update(request, **cinder_data) except Exception: is_error_cinder = True else: LOG.debug('Unable to update Cinder default quotas' ' because the Cinder volume service is disabled.') # Analyze errors (if any) to determine what success and error messages # to display to the user. if is_error_nova and not is_error_cinder: if is_volume_service_enabled: self.success_message = _('Default quotas updated for Cinder.') exceptions.handle( request, _('Unable to update default quotas' ' for Nova.')) else: return False elif is_error_cinder and not is_error_nova: self.success_message = _('Default quotas updated for Nova.') exceptions.handle(request, _('Unable to update default quotas for Cinder.')) elif is_error_nova and is_error_cinder: return False return True
def handle(self, request, data): # Update the default quotas. # `fixed_ips` update for quota class is not supported by novaclient nova_data = dict([(key, data[key]) for key in ALL_NOVA_QUOTA_FIELDS if key != 'fixed_ips']) try: nova.default_quota_update(request, **nova_data) if base.is_service_enabled(request, 'volume'): cinder_data = dict([(key, data[key]) for key in quotas.CINDER_QUOTA_FIELDS]) cinder.default_quota_update(request, **cinder_data) except Exception: exceptions.handle(request, _('Unable to update default quotas.')) return True
def handle(self, request, data): # Update the default quotas. # `fixed_ips` update for quota class is not supported by novaclient nova_data = dict([(key, data[key]) for key in ALL_NOVA_QUOTA_FIELDS if key != 'fixed_ips']) is_error_nova = False is_error_cinder = False is_volume_service_enabled = cinder.is_volume_service_enabled(request) # Update the default quotas for nova. try: nova.default_quota_update(request, **nova_data) except Exception: is_error_nova = True # Update the default quotas for cinder. try: if is_volume_service_enabled: cinder_data = dict([(key, data[key]) for key in quotas.CINDER_QUOTA_FIELDS]) cinder.default_quota_update(request, **cinder_data) else: LOG.debug('Unable to update Cinder default quotas' ' because the Cinder volume service is disabled.') except Exception: is_error_cinder = True # Analyze errors (if any) to determine what success and error messages # to display to the user. if is_error_nova and not is_error_cinder: if is_volume_service_enabled: self.success_message = _('Default quotas updated for Cinder.') exceptions.handle( request, _('Unable to update default quotas' ' for Nova.')) else: return False elif is_error_cinder and not is_error_nova: self.success_message = _('Default quotas updated for Nova.') exceptions.handle(request, _('Unable to update default quotas for Cinder.')) elif is_error_nova and is_error_cinder: return False return True