コード例 #1
0
 def handle(self, request, data):
     try:
         params = {
             'visibility': 'public' if data['public'] else 'private',
             'protected': data['protected']
         }
         glance.metadefs_namespace_update(request,
                                          self.initial['namespace_id'],
                                          **params)
         msg = _('Namespace successfully updated.')
         messages.success(request, msg)
     except Exception:
         msg = _('Error updating attributes for namespace.')
         redirect = reverse(constants.METADATA_INDEX_URL)
         exceptions.handle(request, msg, redirect=redirect)
         return False
     return True
コード例 #2
0
 def update_cell(self, request, datum, namespace_name, cell_name,
                 new_cell_value):
     # inline update namespace info
     try:
         namespace_obj = datum
         # updating changed value by new value
         if cell_name == 'public':
             cell_name = 'visibility'
             if new_cell_value:
                 new_cell_value = 'public'
             else:
                 new_cell_value = 'private'
         setattr(namespace_obj, cell_name, new_cell_value)
         properties = {cell_name: new_cell_value}
         glance.metadefs_namespace_update(request, namespace_name,
                                          **properties)
     except Exception:
         exceptions.handle(request, ignore=True)
         return False
     return True
コード例 #3
0
ファイル: tables.py プロジェクト: 28607895/horizon
 def update_cell(self, request, datum, namespace_name,
                 cell_name, new_cell_value):
     # inline update namespace info
     try:
         namespace_obj = datum
         # updating changed value by new value
         if cell_name == 'public':
             cell_name = 'visibility'
             if new_cell_value:
                 new_cell_value = 'public'
             else:
                 new_cell_value = 'private'
         setattr(namespace_obj, cell_name, new_cell_value)
         properties = {cell_name: new_cell_value}
         glance.metadefs_namespace_update(
             request,
             namespace_name,
             **properties)
     except Exception:
         exceptions.handle(request, ignore=True)
         return False
     return True