def test_charge_report_filter_tag(infra_provider, request):
    """Tests creation of chargeback report that is filtered by tag

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargeback for Vms",
        report_fields=[
            "CPU Used",
            "CPU Used Cost",
            "Memory Used",
            "Memory Used Cost",
            "Owner",
            "vCPUs Allocated Cost",
            "Total Cost",
        ],
        filter=dict(
            filter_show_costs="My Company Tag",
            filter_tag_cat="Location",
            filter_tag_value="Chicago"
        )
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))

    report.queue(wait_for_finish=True)
def test_charge_report_filter_owner(infra_provider, request):
    """Tests creation of chargeback report that is filtered by owner

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargeback for Vms",
        report_fields=[
            "Network I/O Used",
            "Network I/O Used Cost",
            "Storage Used",
            "Storage Used Cost",
            "Disk I/O Used",
            "Disk I/O Used Cost",
            "Owner",
            "Total Cost",
        ],
        filter=dict(
            filter_show_costs="Owner",
            filter_owner="Administrator"
        )
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))
    report.queue(wait_for_finish=True)
def test_charge_report_filter_owner(setup_first_provider, request):
    """Tests creation of chargeback report that is filtered by owner

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargebacks",
        report_fields=[
            "Network I/O Used",
            "Network I/O Used Cost",
            "Storage Used",
            "Storage Used Cost",
            "Disk I/O Used",
            "Disk I/O Used Cost",
            "Owner",
            "Total Cost",
        ],
        filter_show_costs="Owner",
        filter_owner="Administrator",
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))

    flash.assert_message_match('Report "{}" was added'.format(report.menu_name))
    report.queue(wait_for_finish=True)
def test_charge_report_filter_tag(setup_first_provider, request):
    """Tests creation of chargeback report that is filtered by tag

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargebacks",
        report_fields=[
            "CPU Used",
            "CPU Used Cost",
            "Memory Used",
            "Memory Used Cost",
            "Owner",
            "vCPUs Allocated Cost",
            "Total Cost",
        ],
        filter_show_costs="My Company Tag",
        filter_tag_cat="Location",
        filter_tag_value="Chicago",
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))

    flash.assert_message_match('Report "{}" was added'.format(report.menu_name))
    report.queue(wait_for_finish=True)
def chargeback_report_custom(vm_ownership, assign_custom_rate, interval):
    """Create a Chargeback report based on a custom rate; Queue the report"""
    owner = vm_ownership
    data = {
        'menu_name':
        interval,
        'title':
        interval,
        'base_report_on':
        'Chargeback for Vms',
        'report_fields': [
            'Memory Used', 'Memory Used Cost', 'Owner', 'CPU Used',
            'CPU Used Cost', 'Disk I/O Used', 'Disk I/O Used Cost',
            'Network I/O Used', 'Network I/O Used Cost', 'Storage Used',
            'Storage Used Cost'
        ],
        'filter': {
            'filter_show_costs': 'Owner',
            'filter_owner': owner,
            'interval_end': 'Today (partial)'
        }
    }
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('Queuing chargeback report for {} rate'.format(interval))
    report.queue(wait_for_finish=True)

    if not list(report.get_saved_reports()[0].data.rows):
        pytest.skip('Empty report')
    else:
        yield list(report.get_saved_reports()[0].data.rows)

    if report.exists:
        report.delete()
Beispiel #6
0
def metering_report(vm_ownership, provider):
    # Create a Metering report based on VM owner; Queue the report.
    owner = vm_ownership
    data = {
        'menu_name': 'cb_' + provider.name,
        'title': 'cb_' + provider.name,
        'base_report_on': 'Metering for VMs',
        'report_fields': ['Owner', 'Memory Used',
        'CPU Used', 'Disk I/O Used',
        'Network I/O Used', 'Storage Used',
        'Existence Hours Metric', 'Metering Used Metric'],
        'filter': {
            'filter_show_costs': 'Owner',
            'filter_owner': owner,
            'interval_end': 'Today (partial)'
        }
    }
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('Queuing Metering report for {} provider'.format(provider.name))
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data.rows)
    report.delete()
Beispiel #7
0
def chargeback_report_default(vm_ownership, assign_compute_default_rate,
                              provider):
    # Create a Chargeback report based on the default Compute rate; Queue the report.
    owner = vm_ownership
    data = {
        'menu_name':
        'cb_' + provider.name,
        'title':
        'cb_' + provider.name,
        'base_report_on':
        'Chargeback for Vms',
        'report_fields': [
            'Memory Used', 'Memory Used Cost', 'Owner', 'CPU Used',
            'CPU Used Cost', 'Disk I/O Used', 'Disk I/O Used Cost',
            'Network I/O Used', 'Network I/O Used Cost'
        ],
        'filter_show_costs':
        'Owner',
        'filter_owner':
        owner,
        'interval_end':
        'Today (partial)'
    }
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('QUEUING DEFAULT CHARGEBACK REPORT FOR {} PROVIDER'.format(
        provider.name))
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data[0].rows)
    report.delete()
def chargeback_report_custom(vm_ownership, assign_custom_rate, provider):
    # Create a Chargeback report based on a custom rate; Queue the report
    owner = vm_ownership
    data = {
        'menu_name': 'cb_custom_' + provider.name,
        'title': 'cb_custom' + provider.name,
        'base_report_on': 'Chargeback for Vms',
        'report_fields': ['Memory Used', 'Memory Used Cost', 'Owner',
        'CPU Used', 'CPU Used Cost',
        'Disk I/O Used', 'Disk I/O Used Cost',
        'Network I/O Used', 'Network I/O Used Cost',
        'Storage Used', 'Storage Used Cost'],
        'filter': {
            'filter_show_costs': 'Owner',
            'filter_owner': owner,
            'interval_end': 'Today (partial)'
        }
    }
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('Queuing chargeback report with custom rate for {} provider'.format(provider.name))
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data.rows)
    report.delete()
def chargeback_report_custom(assign_compute_custom_rate, provider):
    # Create a Chargeback report based on a custom Compute rate; Queue the report
    title = 'report_' + assign_compute_custom_rate
    data = {
        'menu_name':
        title,
        'title':
        title,
        'base_report_on':
        'Chargeback for Projects',
        'report_fields': [
            'Archived', 'Chargeback Rates', 'Fixed Compute Metric',
            'Cpu Cores Used Cost', 'Cpu Cores Used Metric', 'Network I/O Used',
            'Network I/O Used Cost', 'Fixed Compute Cost 1',
            'Fixed Compute Cost 2', 'Memory Used', 'Memory Used Cost',
            'Provider Name', 'Fixed Total Cost', 'Total Cost'
        ],
        'filter_show_costs':
        'Project',
        'provider':
        provider.name,
        'project':
        'All Container Projects'
    }
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('QUEUING CUSTOM CHARGEBACK REPORT FOR {} PROVIDER'.format(
        provider.name))
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data)
    report.delete()
def metering_report(vm_ownership, provider):
    # Create a Metering report based on VM owner; Queue the report.
    owner = vm_ownership
    data = {
        'menu_name': 'cb_' + provider.name,
        'title': 'cb_' + provider.name,
        'base_report_on': 'Metering for VMs',
        'report_fields': ['Owner', 'Memory Used',
        'CPU Used', 'Disk I/O Used',
        'Network I/O Used', 'Storage Used',
        'Existence Hours Metric', 'Metering Used Metric'],
        'filter': {
            'filter_show_costs': 'Owner',
            'filter_owner': owner,
            'interval_end': 'Today (partial)'
        }
    }
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('Queuing Metering report for {} provider'.format(provider.name))
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data.rows)
    report.delete()
def chargeback_report_custom(vm_ownership, assign_custom_rate, provider):
    # Create a Chargeback report based on a custom rate; Queue the report
    owner = vm_ownership
    data = {
        'menu_name': 'cb_custom_' + provider.name,
        'title': 'cb_custom' + provider.name,
        'base_report_on': 'Chargeback for Vms',
        'report_fields': ['Memory Used', 'Memory Used Cost', 'Owner',
        'CPU Used', 'CPU Used Cost',
        'Disk I/O Used', 'Disk I/O Used Cost',
        'Network I/O Used', 'Network I/O Used Cost',
        'Storage Used', 'Storage Used Cost'],
        'filter': {
            'filter_show_costs': 'Owner',
            'filter_owner': owner,
            'interval_end': 'Today (partial)'
        }
    }
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('Queuing chargeback report with custom rate for {} provider'.format(provider.name))
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data.rows)
    report.delete()
def report_vms(setup_first_provider):
    report = CustomReport(
        menu_name=generate_random_string(),
        title=generate_random_string(),
        base_report_on="Virtual Machines",
        report_fields=[
            version.pick({
                version.LOWEST: "Provider : Name",
                "5.3": "Cloud/Infrastructure Provider : Name",
            }),
            "Cluster : Name",
            "Datastore : Name",
            "Hardware : Number of CPUs",
            "Hardware : RAM",
            "Host : Name",
            "Name",
        ]
    )
    report.create()
    report.queue(wait_for_finish=True)
    yield pick(
        filter(
            lambda i: len(i[
                version.pick({
                    version.LOWEST: "Provider : Name",
                    "5.3": "Cloud/Infrastructure Provider Name",
                })
            ].strip()) > 0,
            list(report.get_saved_reports()[0].data.rows)), 2)
    report.delete()
def test_charge_report_filter_tag(setup_first_provider, request):
    """Tests creation of chargeback report that is filtered by tag

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargebacks",
        report_fields=[
            "CPU Used",
            "CPU Used Cost",
            "Memory Used",
            "Memory Used Cost",
            "Owner",
            "vCPUs Allocated Cost",
            "Total Cost",
        ],
        filter_show_costs="My Company Tag",
        filter_tag_cat="Location",
        filter_tag_value="Chicago",
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))

    flash.assert_message_match('Report "{}" was added'.format(
        report.menu_name))
    report.queue(wait_for_finish=True)
def test_charge_report_filter_owner(setup_first_provider, request):
    """Tests creation of chargeback report that is filtered by owner

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargebacks",
        report_fields=[
            "Network I/O Used",
            "Network I/O Used Cost",
            "Storage Used",
            "Storage Used Cost",
            "Disk I/O Used",
            "Disk I/O Used Cost",
            "Owner",
            "Total Cost",
        ],
        filter_show_costs="Owner",
        filter_owner="Administrator",
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))

    flash.assert_message_match('Report "{}" was added'.format(
        report.menu_name))
    report.queue(wait_for_finish=True)
Beispiel #15
0
def test_charge_report_filter_tag(infra_provider, request):
    """Tests creation of chargeback report that is filtered by tag

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargeback for Vms",
        report_fields=[
            "CPU Used",
            "CPU Used Cost",
            "Memory Used",
            "Memory Used Cost",
            "Owner",
            "vCPUs Allocated Cost",
            "Total Cost",
        ],
        filter=dict(
            filter_show_costs="My Company Tag",
            filter_tag_cat="Location",
            filter_tag_value="Chicago"
        )
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))

    report.queue(wait_for_finish=True)
Beispiel #16
0
def test_charge_report_filter_owner(infra_provider, request):
    """Tests creation of chargeback report that is filtered by owner

    """

    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Chargeback for Vms",
        report_fields=[
            "Network I/O Used",
            "Network I/O Used Cost",
            "Storage Used",
            "Storage Used Cost",
            "Disk I/O Used",
            "Disk I/O Used Cost",
            "Owner",
            "Total Cost",
        ],
        filter=dict(
            filter_show_costs="Owner",
            filter_owner="Administrator"
        )
    )
    report.create()

    def cleanup_report(report):
        return lambda: _cleanup_report(report)

    request.addfinalizer(cleanup_report(report))
    report.queue(wait_for_finish=True)
Beispiel #17
0
def report_vms(infra_provider):
    report = CustomReport(menu_name=fauxfactory.gen_alphanumeric(),
                          title=fauxfactory.gen_alphanumeric(),
                          base_report_on="Virtual Machines",
                          report_fields=[
                              "Provider : Name",
                              "Cluster / Deployment Role : Name",
                              "Datastore : Name",
                              "Hardware : Number of CPUs",
                              "Hardware : RAM",
                              "Host / Node : Name",
                              "Name",
                          ])
    report.create()
    report.queue(wait_for_finish=True)
    yield sample(
        filter(lambda i: len(i["Provider Name"].strip()) > 0,
               list(report.get_saved_reports()[0].data.rows)), 2)
    report.delete()
def report_vms(setup_first_provider):
    report = CustomReport(menu_name=fauxfactory.gen_alphanumeric(),
                          title=fauxfactory.gen_alphanumeric(),
                          base_report_on="Virtual Machines",
                          report_fields=[
                              version.pick({
                                  version.LOWEST:
                                  "Provider : Name",
                                  "5.3":
                                  "Cloud/Infrastructure Provider : Name",
                              }),
                              version.pick({
                                  version.LOWEST:
                                  "Cluster : Name",
                                  "5.4.0.0.24":
                                  "Cluster / Deployment Role : Name",
                              }),
                              "Datastore : Name",
                              "Hardware : Number of CPUs",
                              "Hardware : RAM",
                              version.pick({
                                  version.LOWEST: "Host : Name",
                                  "5.4.0.0.24": "Host / Node : Name",
                              }),
                              "Name",
                          ])
    report.create()
    report.queue(wait_for_finish=True)
    yield sample(
        filter(
            lambda i: len(i[version.
                            pick({
                                version.LOWEST: "Provider : Name",
                                "5.3": "Cloud/Infrastructure Provider Name",
                            })].strip()) > 0,
            list(report.get_saved_reports()[0].data.rows)), 2)
    report.delete()
def chargeback_report_default(vm_ownership, assign_compute_default_rate, provider):
    # Create a Chargeback report based on the default Compute rate; Queue the report.
    owner = vm_ownership
    data = {'menu_name': 'cb_' + provider.name,
            'title': 'cb_' + provider.name,
            'base_report_on': 'Chargeback for Vms',
            'report_fields': ['Memory Used', 'Memory Used Cost', 'Owner',
            'CPU Used', 'CPU Used Cost',
            'Disk I/O Used', 'Disk I/O Used Cost',
            'Network I/O Used', 'Network I/O Used Cost'],
            'filter_show_costs': 'Owner',
            'filter_owner': owner,
            'interval_end': 'Today (partial)'}
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('QUEUING DEFAULT CHARGEBACK REPORT FOR {} PROVIDER'.format(provider.name))
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data[0].rows)
    report.delete()
def report_vms(setup_first_provider):
    report = CustomReport(
        menu_name=fauxfactory.gen_alphanumeric(),
        title=fauxfactory.gen_alphanumeric(),
        base_report_on="Virtual Machines",
        report_fields=[
            "Cloud/Infrastructure Provider : Name",
            "Cluster / Deployment Role : Name",
            "Datastore : Name",
            "Hardware : Number of CPUs",
            "Hardware : RAM",
            "Host / Node : Name",
            "Name",
        ]
    )
    report.create()
    report.queue(wait_for_finish=True)
    yield sample(
        filter(
            lambda i: len(i["Cloud/Infrastructure Provider Name"].strip()) > 0,
            list(report.get_saved_reports()[0].data.rows)), 2)
    report.delete()
def chargeback_report_custom(assign_compute_custom_rate, provider):
    # Create a Chargeback report based on a custom Compute rate; Queue the report
    title = 'report_' + assign_compute_custom_rate
    data = {'menu_name': title,
            'title': title,
            'base_report_on': 'Chargeback Container Images',
            'report_fields': ['Archived', 'Chargeback Rates', 'Fixed Compute Metric',
                              'Cpu Cores Used Cost', 'Cpu Cores Used Metric',
                              'Network I/O Used', 'Network I/O Used Cost',
                              'Fixed Compute Cost 1', 'Fixed Compute Cost 2',
                              'Memory Used', 'Memory Used Cost',
                              'Provider Name', 'Fixed Total Cost', 'Total Cost'],
            'filter_show_costs': 'Container Image',
            'provider': provider.name}
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('QUEUING CUSTOM CHARGEBACK REPORT FOR CONTAINER IMAGE')
    report.queue(wait_for_finish=True)

    yield list(report.get_saved_reports()[0].data)
    report.delete()
Beispiel #22
0
def custom_report(request):
    with report_crud_dir.join(request.param).open(mode="r") as rep_yaml:
        return CustomReport(**yaml.load(rep_yaml))
def gen_report_base(obj_type, provider, rate_desc, rate_interval):
    """Base function for report generation
    Args:
        :py:type:`str` obj_type: Object being tested; only 'Project' and 'Image' are supported
        :py:class:`ContainersProvider` provider: The Containers Provider
        :py:type:`str` rate_desc: The rate description as it appears in the report
        :py:type:`str` rate_interval: The rate interval, (Hourly/Daily/Weekly/Monthly)
    """
    title = 'report_{}_{}'.format(obj_type.lower(), rate_desc)
    if obj_type == 'Project':
        data = {
            'menu_name':
            title,
            'title':
            title,
            'base_report_on':
            'Chargeback for Projects',
            'report_fields': [
                'Archived', 'Chargeback Rates', 'Fixed Compute Metric',
                'Cpu Cores Used Cost', 'Cpu Cores Used Metric',
                'Network I/O Used', 'Network I/O Used Cost',
                'Fixed Compute Cost 1', 'Fixed Compute Cost 2', 'Memory Used',
                'Memory Used Cost', 'Provider Name', 'Fixed Total Cost',
                'Total Cost'
            ],
            'filter': {
                'filter_show_costs': 'Project',
                'filter_provider': provider.name,
                'filter_project': 'All Container Projects'
            }
        }
    elif obj_type == 'Image':
        data = {
            'base_report_on':
            'Chargeback Container Images',
            'report_fields': [
                'Archived', 'Chargeback Rates', 'Fixed Compute Metric',
                'Cpu Cores Used Cost', 'Cpu Cores Used Metric',
                'Network I/O Used', 'Network I/O Used Cost',
                'Fixed Compute Cost 1', 'Fixed Compute Cost 2', 'Memory Used',
                'Memory Used Cost', 'Provider Name', 'Fixed Total Cost',
                'Total Cost'
            ],
            'filter': {
                'filter_show_costs': 'Container Image',
                'filter_provider': provider.name,
            }
        }
    else:
        raise Exception("Unknown object type: {}".format(obj_type))

    data['menu_name'] = title
    data['title'] = title
    data['provider'] = provider.name
    if rate_interval == 'Hourly':
        data['filter']['interval'] = 'Day'
        data['filter']['interval_end'] = 'Yesterday'
        data['filter']['interval_size'] = '1 Day'
    elif rate_interval == 'Daily':
        data['filter']['interval'] = 'Week',
        data['filter']['interval_end'] = 'Last Week'
        data['filter']['interval_size'] = '1 Week'
    elif rate_interval in ('Weekly', 'Monthly'):
        data['filter']['interval'] = 'Month',
        data['filter']['interval_end'] = 'Last Month'
        data['filter']['interval_size'] = '1 Month'
    else:
        raise Exception('Unsupported rate interval: "{}"; available options: '
                        '(Hourly/Daily/Weekly/Monthly)')
    report = CustomReport(is_candu=True, **data)
    report.create()

    logger.info('QUEUING CUSTOM CHARGEBACK REPORT FOR CONTAINER {}'.format(
        obj_type.upper()))
    report.queue(wait_for_finish=True)

    return report