示例#1
0
 def get_data(self):
     # Add data to the context here...
     modules = api.identify(
         api.cloudkittyclient(self.request).modules.list(),
         name=True
     )
     return modules
示例#2
0
 def __init__(self, request, *args, **kwargs):
     super(BaseForm, self).__init__(request, *args, **kwargs)
     self.order_fields()
     groups = api.cloudkittyclient(request).hashmap.groups.list()
     groups = api.identify(groups)
     choices = [(group.id, group.name) for group in groups]
     choices.insert(0, (None, ' '))
     self.fields['group_id'].choices = choices
示例#3
0
 def get_data(self):
     summary = api.cloudkittyclient(self.request).report.get_summary(
         tenant_id=self.request.user.tenant_id,
         groupby=['tenant_id', 'res_type'])['summary']
     summary = api.identify(summary, key='res_type', name=True)
     summary.append(TemplatizableDict({
         'id': 'ALL',
         'res_type': 'TOTAL',
         'name': 'ALL',
         'rate': sum([float(i['rate']) for i in summary]),
     }))
     return summary
示例#4
0
 def get_data(self):
     summary = api.cloudkittyclient(self.request).report.get_summary(
         tenant_id=self.request.user.tenant_id,
         groupby=['tenant_id', 'res_type'])['summary']
     summary = api.identify(summary, key='res_type', name=True)
     summary.append(
         TemplatizableDict({
             'id': 'ALL',
             'res_type': 'TOTAL',
             'name': 'ALL',
             'rate': sum([float(i['rate']) for i in summary]),
         }))
     return summary
    def __init__(self, request, *args, **kwargs):
        super(BaseForm, self).__init__(request, *args, **kwargs)
        self.order_fields()
        groups = api.cloudkittyclient(request).hashmap.groups.list()
        groups = api.identify(groups)
        choices = [(group.id, group.name) for group in groups]
        choices.insert(0, ('', ' '))
        self.fields['group_id'].choices = choices

        tenants, __ = api_keystone.keystone.tenant_list(request)
        choices_tenants = [(tenant.id, tenant.name) for tenant in tenants]
        choices_tenants.insert(0, (None, ' '))
        self.fields['tenant_id'].choices = choices_tenants
示例#6
0
    def __init__(self, request, *args, **kwargs):
        super(BaseForm, self).__init__(request, *args, **kwargs)
        # self.order_fields(self.fields_order)
        groups = api.cloudkittyclient(
            request).rating.hashmap.get_group()['groups']
        groups = api.identify(groups, key='group_id', name=True)
        choices = [(group['id'], group['name']) for group in groups]
        choices.insert(0, ('', ' '))
        self.fields['group_id'].choices = choices

        tenants, __ = api_keystone.keystone.tenant_list(request)
        choices_tenants = [(tenant.id, tenant.name) for tenant in tenants]
        choices_tenants.insert(0, (None, ' '))
        self.fields['tenant_id'].choices = choices_tenants
示例#7
0
    def __init__(self, request, *args, **kwargs):
        super(BaseForm, self).__init__(request, *args, **kwargs)
        # self.order_fields(self.fields_order)
        groups = api.cloudkittyclient(
            request).rating.hashmap.get_group()['groups']
        groups = api.identify(groups, key='group_id', name=True)
        choices = [(group['id'], group['name']) for group in groups]
        choices.insert(0, ('', ' '))
        self.fields['group_id'].choices = choices

        tenants, __ = api_keystone.keystone.tenant_list(request)
        choices_tenants = [(tenant.id, tenant.name) for tenant in tenants]
        choices_tenants.insert(0, (None, ' '))
        self.fields['tenant_id'].choices = choices_tenants
示例#8
0
    def get_data(self):
        tenant_id = self.kwargs['project_id']
        if tenant_id == 'ALL':
            summary = self._get_cloud_total_summary()
        else:
            summary = api.cloudkittyclient(self.request).report.get_summary(
                groupby=['res_type'], tenant_id=tenant_id)['summary']

        summary.append({
            'tenant_id': tenant_id,
            'res_type': 'TOTAL',
            'rate': sum([float(item['rate']) for item in summary]),
        })
        summary = api.identify(summary, key='res_type', name=True)
        return summary
示例#9
0
    def get_data(self):
        summary = api.cloudkittyclient(self.request).report.get_summary(
            groupby=['tenant_id'], all_tenants=True)['summary']

        tenants, _ = api_keystone.tenant_list(self.request)
        tenants = {tenant.id: tenant.name for tenant in tenants}
        summary.append({
            'tenant_id': 'ALL',
            'rate': sum([float(item['rate']) for item in summary]),
        })
        summary = api.identify(summary, key='tenant_id')
        for tenant in summary:
            tenant['name'] = tenants.get(tenant.id, '-')
        summary[-1]['name'] = 'Cloud Total'
        return summary
示例#10
0
    def __init__(self, request, *args, **kwargs):
        super(CreateFieldForm, self).__init__(request, *args, **kwargs)
        service_id = kwargs['initial']['service_id']
        manager = api.cloudkittyclient(request).rating.hashmap
        service = manager.get_service(service_id=service_id)
        self.fields['service_name'].initial = service['name']

        try:
            fields = manager.get_field(service_id=service['name'])['fields']
        except exceptions.NotFound:
            fields = None
        if fields:
            fields = api.identify(fields)
            choices = sorted([(field, field) for field in fields['metadata']])
            self.fields['field'] = forms.DynamicChoiceField(label=_("Field"))
            self.fields['field'].choices = choices
        else:
            self.fields['field'] = forms.CharField(label=_("Field"))
示例#11
0
    def __init__(self, request, *args, **kwargs):
        super(CreateFieldForm, self).__init__(request, *args, **kwargs)
        service_id = kwargs['initial']['service_id']
        manager = api.cloudkittyclient(request).rating.hashmap
        service = manager.get_service(service_id=service_id)
        self.fields['service_name'].initial = service['name']

        try:
            fields = manager.get_field(service_id=service['name'])['fields']
        except exceptions.NotFound:
            fields = None
        if fields:
            fields = api.identify(fields)
            choices = sorted([(field, field) for field in fields['metadata']])
            self.fields['field'] = forms.DynamicChoiceField(
                label=_("Field"))
            self.fields['field'].choices = choices
        else:
            self.fields['field'] = forms.CharField(
                label=_("Field"))
示例#12
0
    def __init__(self, request, *args, **kwargs):
        super(CreateFieldForm, self).__init__(request, *args, **kwargs)
        service_id = kwargs['initial']['service_id']
        manager = api.cloudkittyclient(request)
        service = manager.hashmap.services.get(service_id=service_id)
        self.fields['service_name'].initial = service.name

        try:
            fields = manager.service_info.get(service_id=service.name)
        except exceptions.NotFound:
            fields = None

        if fields:
            fields = api.identify(fields)
            choices = sorted([(field, field) for field in fields.metadata])
            self.fields['field'] = forms.DynamicChoiceField(label=_("Field"),
                                                            required=True)
            self.fields['field'].choices = choices
        else:
            self.fields['field'] = forms.CharField(label=_("Field"),
                                                   required=True)
示例#13
0
 def get_data(self):
     out = api.cloudkittyclient(self.request).rating.hashmap.get_group()
     return api.identify(out)
示例#14
0
 def __init__(self, request, *args, **kwargs):
     super(CreateServiceForm, self).__init__(request, *args, **kwargs)
     services = api.cloudkittyclient(request).service_info.list()
     services = api.identify(services)
     choices = sorted([(s.service_id, s.service_id) for s in services])
     self.fields['service'].choices = choices
示例#15
0
 def __init__(self, request, *args, **kwargs):
     super(CreateServiceForm, self).__init__(request, *args, **kwargs)
     metrics = api.cloudkittyclient(request).info.get_metric()['metrics']
     metrics = api.identify(metrics, key='metric_id', name=True)
     choices = sorted([(s.metric_id, s.metric_id) for s in metrics])
     self.fields['service'].choices = choices
示例#16
0
 def get_data(self):
     out = api.cloudkittyclient(self.request).hashmaps.thresholds.list(
         threshold_id=self.kwargs['threshold_id'])
     return api.identify(out)
示例#17
0
 def get_data(self):
     data = api.cloudkittyclient(self.request).pyscripts.scripts.list()
     data = api.identify(data, name=False)
     return data
示例#18
0
 def get_groups_data(self):
     client = api.cloudkittyclient(self.request)
     groups = client.hashmap.groups.list()
     return api.identify(groups)
示例#19
0
 def get_fields_data(self):
     client = api.cloudkittyclient(self.request)
     fields = client.hashmap.fields.list(service_id=self.request.service_id)
     return api.identify(fields)
示例#20
0
 def get_data(self):
     modules = api.cloudkittyclient(
         self.request).rating.get_module()['modules']
     modules = api.identify(modules, key='module_id', name=True)
     return modules
示例#21
0
 def get_groups_data(self):
     client = api.cloudkittyclient(self.request)
     groups = client.rating.hashmap.get_group().get('groups', [])
     return api.identify(groups, key='group_id')
示例#22
0
 def get_service_thresholds_data(self):
     client = api.cloudkittyclient(self.request)
     thresholds = client.hashmap.thresholds.list(
         service_id=self.request.service_id)
     add_groupname(self.request, thresholds)
     return api.identify(thresholds)
示例#23
0
 def get_mappings_data(self):
     client = api.cloudkittyclient(self.request)
     mappings = client.hashmap.mappings.list(field_id=self.request.field_id)
     add_groupname(self.request, mappings)
     return api.identify(mappings)
示例#24
0
 def get_data(self):
     out = api.cloudkittyclient(self.request).rating.hashmap.get_group()
     return api.identify(out)
示例#25
0
 def get_data(self):
     data = api.cloudkittyclient(
         self.request).rating.pyscripts.list_scripts()['scripts']
     data = api.identify(data, key='script_id')
     return data
示例#26
0
 def get_mappings_data(self):
     client = api.cloudkittyclient(self.request)
     mappings = client.rating.hashmap.get_mapping(
         service_id=self.request.service_id).get('mappings', [])
     add_groupname(self.request, mappings)
     return api.identify(mappings, key='mapping_id', name=True)
示例#27
0
 def get_field_thresholds_data(self):
     client = api.cloudkittyclient(self.request)
     thresholds = client.rating.hashmap.get_threshold(
         field_id=self.request.field_id).get('thresholds', [])
     add_groupname(self.request, thresholds)
     return api.identify(thresholds, key='threshold_id', name=True)
示例#28
0
 def get_fields_data(self):
     client = api.cloudkittyclient(self.request)
     fields = client.rating.hashmap.get_field(
         service_id=self.request.service_id)['fields']
     return api.identify(fields, key='field_id')
示例#29
0
 def get_groups_data(self):
     client = api.cloudkittyclient(self.request)
     groups = client.rating.hashmap.get_group().get('groups', [])
     return api.identify(groups, key='group_id')
示例#30
0
 def get_fields_data(self):
     client = api.cloudkittyclient(self.request)
     fields = client.rating.hashmap.get_field(
         service_id=self.request.service_id)['fields']
     return api.identify(fields, key='field_id')
示例#31
0
 def get_field_thresholds_data(self):
     client = api.cloudkittyclient(self.request)
     thresholds = client.hashmap.thresholds.list(
         field_id=self.request.field_id)
     return api.identify(thresholds)
 def get_groups_data(self):
     client = api.cloudkittyclient(self.request)
     groups = client.hashmap.groups.list()
     return api.identify(groups)
示例#33
0
 def get_mappings_data(self):
     client = api.cloudkittyclient(self.request)
     mappings = client.hashmap.mappings.list(
         service_id=self.request.service_id)
     return api.identify(mappings)
 def get_field_thresholds_data(self):
     client = api.cloudkittyclient(self.request)
     thresholds = client.hashmap.thresholds.list(
         field_id=self.request.field_id)
     return api.identify(thresholds)
示例#35
0
 def get_data(self):
     out = api.cloudkittyclient(self.request).hashmap.groups.list(
     )
     return api.identify(out)
 def get_fields_data(self):
     client = api.cloudkittyclient(self.request)
     fields = client.hashmap.fields.list(service_id=self.request.service_id)
     return api.identify(fields)
示例#37
0
 def __init__(self, request, *args, **kwargs):
     super(CreateServiceForm, self).__init__(request, *args, **kwargs)
     metrics = api.cloudkittyclient(request).info.get_metric()['metrics']
     metrics = api.identify(metrics, key='metric_id', name=True)
     choices = sorted([(s.metric_id, s.metric_id) for s in metrics])
     self.fields['service'].choices = choices
 def get_mappings_data(self):
     client = api.cloudkittyclient(self.request)
     mappings = client.hashmap.mappings.list(
         service_id=self.request.service_id
     )
     return api.identify(mappings)
示例#39
0
 def get_data(self):
     data = api.cloudkittyclient(self.request).pyscripts.scripts.list()
     data = api.identify(data, name=False)
     return data
示例#40
0
 def get_data(self):
     data = api.cloudkittyclient(
         self.request).rating.pyscripts.list_scripts()['scripts']
     data = api.identify(data, key='script_id')
     return data
示例#41
0
 def get_field_thresholds_data(self):
     client = api.cloudkittyclient(self.request)
     thresholds = client.rating.hashmap.get_threshold(
         field_id=self.request.field_id).get('thresholds', [])
     add_groupname(self.request, thresholds)
     return api.identify(thresholds, key='threshold_id', name=True)
示例#42
0
 def get_data(self):
     # Add data to the context here...
     modules = api.identify(api.cloudkittyclient(
         self.request).modules.list(),
                            name=True)
     return modules
示例#43
0
 def get_mappings_data(self):
     client = api.cloudkittyclient(self.request)
     mappings = client.rating.hashmap.get_mapping(
         service_id=self.request.service_id).get('mappings', [])
     add_groupname(self.request, mappings)
     return api.identify(mappings, key='mapping_id', name=True)
示例#44
0
 def get_data(self):
     modules = api.cloudkittyclient(
         self.request).rating.get_module()['modules']
     modules = api.identify(modules, key='module_id', name=True)
     return modules