当前位置: 首页>>代码示例>>Python>>正文


Python messages.success方法代码示例

本文整理汇总了Python中horizon.messages.success方法的典型用法代码示例。如果您正苦于以下问题:Python messages.success方法的具体用法?Python messages.success怎么用?Python messages.success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizon.messages的用法示例。


在下文中一共展示了messages.success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        instance = data.get('instance_id')
        try:
            api.trove.user_update_attributes(
                request,
                instance,
                data['user_name'],
                host=data['user_host'],
                new_name=data['new_name'],
                new_password=data['new_password'],
                new_host=data['new_host'])

            messages.success(request,
                             _('Updated user "%s".') % data['user_name'])
        except Exception as e:
            redirect = reverse("horizon:project:databases:detail",
                               args=(instance,))
            exceptions.handle(request, _('Unable to update user. %s') % e,
                              redirect=redirect)
        return True 
开发者ID:openstack,项目名称:trove-dashboard,代码行数:22,代码来源:forms.py

示例2: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        try:
            datastore = data['datastore'].split(',')[0]
            datastore_version = data['datastore'].split(',')[1]

            api.trove.configuration_create(request, data['name'], "{}",
                                           description=data['description'],
                                           datastore=datastore,
                                           datastore_version=datastore_version)

            messages.success(request, _('Created configuration group'))
        except Exception as e:
            redirect = reverse("horizon:project:database_configurations:index")
            exceptions.handle(request, _('Unable to create configuration '
                                         'group. %s') % e, redirect=redirect)
        return True 
开发者ID:openstack,项目名称:trove-dashboard,代码行数:18,代码来源:forms.py

示例3: collect

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def collect(request):
    macro = {'collect_status': 'Collection failed'}
    status = 0

    BASE_DIR = settings.ROOT_PATH
    # CUR_DIR = os.getcwd()
    os.chdir(BASE_DIR + '/don/ovs')
    cmd = 'sudo python collector.py'
    for line in run_command(cmd):
        if line.startswith('STATUS:') and line.find('Writing collected info') != -1:
            status = 1
            macro['collect_status'] = \
                "Collecton successful. Click visualize to display"
    # res = collector.main()
    os.chdir(BASE_DIR)
    if status:
        messages.success(request, macro['collect_status'])
    else:
        messages.error(request, macro['collect_status'])
    resp = HttpResponse(json.dumps(macro), content_type="application/json")
    return resp 
开发者ID:CiscoSystems,项目名称:don,代码行数:23,代码来源:views.py

示例4: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        try:
            api.monitor.notification_create(
                request,
                name=data['name'],
                type=data['type'],
                address=data['address'],
                period=int(data['period']))
            messages.success(request,
                             _('Notification method has been created '
                               'successfully.'))
        except Exception as e:
            exceptions.handle(request,
                              _('Unable to create the notification '
                                'method: %s') % e)
            return False
        return True 
开发者ID:openstack,项目名称:monasca-ui,代码行数:19,代码来源:forms.py

示例5: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        try:
            alarm_actions = [notification.get('id')
                             for notification in data['notifications']]
            api.monitor.alarm_create(
                request,
                name=data['name'],
                expression=data['expression'],
                description=data['description'],
                severity=data['severity'],
                alarm_actions=alarm_actions,
                ok_actions=alarm_actions,
                undetermined_actions=alarm_actions,
            )
            messages.success(request,
                             _('Alarm has been created successfully.'))
        except Exception as e:
            exceptions.handle(request, _('Unable to create the alarm: %s') % e.message)
            return False
        return True 
开发者ID:openstack,项目名称:monasca-ui,代码行数:22,代码来源:forms.py

示例6: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        try:
            alarm_def = api.monitor.alarmdef_get(request, self.initial['id'])
            api.monitor.alarmdef_update(
                request,
                alarm_id=self.initial['id'],
                severity=data['severity'],
                name=data['name'],
                expression=data['expression'],
                description=data['description'],
                match_by=alarm_def['match_by'],
                actions_enabled=data['actions_enabled'],
                alarm_actions=data['alarm_actions'],
                ok_actions=data['ok_actions'],
                undetermined_actions=data['undetermined_actions'],
            )
            messages.success(request,
                             _('Alarm definition has been updated.'))
        except Exception as e:
            exceptions.handle(request, _('%s') % e)
            return False
        return True 
开发者ID:openstack,项目名称:monasca-ui,代码行数:24,代码来源:forms.py

示例7: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        snapshot_id = self.initial['snapshot_id']
        try:
            manila.share_snapshot_allow(
                request, snapshot_id,
                access_to=data['access_to'],
                access_type=data['access_type'])
            message = _('Creating snapshot rule for "%s"') % data['access_to']
            messages.success(request, message)
            return True
        except Exception:
            redirect = reverse(
                "horizon:project:share_snapshots:share_snapshot_manage_rules",
                args=[self.initial['snapshot_id']])
            exceptions.handle(
                request, _('Unable to add snapshot rule.'), redirect=redirect) 
开发者ID:openstack,项目名称:manila-ui,代码行数:18,代码来源:forms.py

示例8: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        share_id = self.initial['share_id']
        is_public = data['is_public'] if self.enable_public_shares else False
        try:
            share = manila.share_get(self.request, share_id)
            manila.share_update(
                request, share, data['name'], data['description'],
                is_public=is_public)
            message = _('Updating share "%s"') % data['name']
            messages.success(request, message)
            return True
        except Exception:
            redirect = reverse("horizon:project:shares:index")
            exceptions.handle(request,
                              _('Unable to update share.'),
                              redirect=redirect) 
开发者ID:openstack,项目名称:manila-ui,代码行数:18,代码来源:forms.py

示例9: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        try:
            send_data = {'name': data['name']}
            if data['description']:
                send_data['description'] = data['description']
            share_net_id = data.get('neutron_net_id', data.get('nova_net_id'))
            share_net_id = share_net_id.strip()
            if self.neutron_enabled and share_net_id:
                send_data['neutron_net_id'] = share_net_id
                subnet_key = 'subnet-choices-%s' % share_net_id
                if subnet_key in data:
                    send_data['neutron_subnet_id'] = data[subnet_key]
            elif not self.neutron_enabled and share_net_id:
                send_data['nova_net_id'] = data['nova_net_id']
            share_network = manila.share_network_create(request, **send_data)
            messages.success(request, _('Successfully created share'
                                        ' network: %s') % send_data['name'])
            return share_network
        except Exception:
            exceptions.handle(request, _('Unable to create share network.'))
            return False 
开发者ID:openstack,项目名称:manila-ui,代码行数:23,代码来源:forms.py

示例10: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        sec_service_id = self.initial['sec_service_id']
        try:
            manila.security_service_update(request, sec_service_id,
                                           name=data['name'],
                                           description=data['description'])

            message = _('Successfully updated security service '
                        '"%s"') % data['name']
            messages.success(request, message)
            return True
        except Exception:
            redirect = reverse("horizon:project:security_services:index")
            exceptions.handle(request,
                              _('Unable to update security service.'),
                              redirect=redirect) 
开发者ID:openstack,项目名称:manila-ui,代码行数:18,代码来源:forms.py

示例11: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        share_name = _get_id_if_name_empty(data)
        try:
            result = manila.migration_get_progress(request,
                                                   self.initial['share_id'])
            progress = result[1]
            messages.success(
                request,
                _('Migration of share %(name)s is at %(progress)s percent.') %
                {'name': share_name, 'progress': progress['total_progress']})
            return True
        except Exception:
            exceptions.handle(request, _("Unable to obtain progress of "
                                         "migration of share %s at this "
                                         "moment.") % share_name)
        return False 
开发者ID:openstack,项目名称:manila-ui,代码行数:18,代码来源:forms.py

示例12: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        replica_id = self.initial['replica_id']
        try:
            replica = manila.share_replica_get(self.request, replica_id)
            manila.share_replica_reset_status(
                request, replica, data["replica_status"])
            message = _("Reseting replica ('%(id)s') status from '%(from)s' "
                        "to '%(to)s'.") % {
                            "id": replica_id,
                            "from": replica.replica_state,
                            "to": data["replica_status"]}
            messages.success(request, message)
            return True
        except Exception:
            redirect = reverse("horizon:admin:shares:index")
            exceptions.handle(
                request,
                _("Unable to reset status of replica '%s'.") % replica_id,
                redirect=redirect) 
开发者ID:openstack,项目名称:manila-ui,代码行数:21,代码来源:forms.py

示例13: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        s_id = self.initial['share_group_snapshot_id']
        try:
            manila.share_group_snapshot_reset_state(
                request, s_id, data["status"])
            message = _(
                "Reseting share group snapshot ('%(id)s') status "
                "from '%(from)s' to '%(to)s'.") % {
                    "id": self.initial['share_group_snapshot_name'] or s_id,
                    "from": self.initial['share_group_snapshot_status'],
                    "to": data["status"]}
            messages.success(request, message)
            return True
        except Exception:
            redirect = reverse("horizon:admin:share_group_snapshots:index")
            exceptions.handle(
                request,
                _("Unable to reset status of share group snapshot "
                  "'%s'.") % s_id,
                redirect=redirect)
        return False 
开发者ID:openstack,项目名称:manila-ui,代码行数:23,代码来源:forms.py

示例14: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        try:
            toscal = yaml.load(data['tosca'], Loader=yaml.SafeLoader)
            vnfd_name = data['name']
            vnfd_description = data['description']
            tosca_arg = {'vnfd': {'name': vnfd_name,
                                  'description': vnfd_description,
                                  'attributes': {'vnfd': toscal}}}
            vnfd_instance = api.tacker.create_vnfd(request, tosca_arg)
            messages.success(request,
                             _('VNF Catalog entry %s has been created.') %
                             vnfd_instance['vnfd']['name'])
            return toscal
        except Exception as e:
            msg = _('Unable to create TOSCA. %s')
            msg %= e.message.split('Failed validating', 1)[0]
            exceptions.handle(request, message=msg)
            return False 
开发者ID:openstack,项目名称:tacker-horizon,代码行数:20,代码来源:forms.py

示例15: handle

# 需要导入模块: from horizon import messages [as 别名]
# 或者: from horizon.messages import success [as 别名]
def handle(self, request, data):
        try:
            toscal = data['tosca']
            vnffgd_name = data['name']
            vnffgd_description = data['description']
            tosca_arg = {'vnffgd': {'name': vnffgd_name,
                                    'description': vnffgd_description,
                                    'template': {'vnffgd': toscal}}}
            vnffgd_instance = api.tacker.create_vnffgd(request, tosca_arg)
            messages.success(request,
                             _('VNFFG Catalog entry %s has been created.') %
                             vnffgd_instance['vnffgd']['name'])
            return toscal
        except Exception as e:
            msg = _('Unable to create TOSCA. %s')
            msg %= e.message.split('Failed validating', 1)[0]
            exceptions.handle(request, message=msg)
            return False 
开发者ID:openstack,项目名称:tacker-horizon,代码行数:20,代码来源:forms.py


注:本文中的horizon.messages.success方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。