Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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"))
Esempio n. 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"))
Esempio n. 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)
Esempio n. 13
0
 def get_data(self):
     out = api.cloudkittyclient(self.request).rating.hashmap.get_group()
     return api.identify(out)
Esempio n. 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
Esempio n. 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
Esempio n. 16
0
 def get_data(self):
     out = api.cloudkittyclient(self.request).hashmaps.thresholds.list(
         threshold_id=self.kwargs['threshold_id'])
     return api.identify(out)
Esempio n. 17
0
 def get_data(self):
     data = api.cloudkittyclient(self.request).pyscripts.scripts.list()
     data = api.identify(data, name=False)
     return data
Esempio n. 18
0
 def get_groups_data(self):
     client = api.cloudkittyclient(self.request)
     groups = client.hashmap.groups.list()
     return api.identify(groups)
Esempio n. 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)
Esempio n. 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
Esempio n. 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')
Esempio n. 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)
Esempio n. 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)
Esempio n. 24
0
 def get_data(self):
     out = api.cloudkittyclient(self.request).rating.hashmap.get_group()
     return api.identify(out)
Esempio n. 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
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')
Esempio n. 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')
Esempio n. 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')
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 39
0
 def get_data(self):
     data = api.cloudkittyclient(self.request).pyscripts.scripts.list()
     data = api.identify(data, name=False)
     return data
Esempio n. 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
Esempio n. 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)
Esempio n. 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
Esempio n. 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)
Esempio n. 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