Exemple #1
0
def run(provider_type, options):
    """Run nise."""
    LOG.info("Creating reports...")
    if provider_type == "aws":
        aws_create_report(options)
    elif provider_type == "azure":
        azure_create_report(options)
    elif provider_type == "ocp":
        ocp_create_report(options)
    elif provider_type == "gcp":
        gcp_create_report(options)
Exemple #2
0
 def generate(self):
     options = {
         "start_date": self.start_date,
         "end_date": self.end_date,
         "gcp_dataset_name": self.dataset,
         "gcp_report_prefix": self.report_prefix,
         "gcp_bucket_name": self.bucket,
         "gcp_etag": self.etag,
     }
     if self.static_file:
         static_file_data = Source.obtain_static_file_data(
             self.static_file, self.start_date, self.end_date)
         options["static_report_data"] = static_file_data
     gcp_create_report(options)
Exemple #3
0
def run(provider_type, options):
    """Run nise."""
    static_data_bool = _load_static_report_data(options)
    if not options.get("start_date"):
        raise NiseError("'start_date' is required in static files.")
    if not static_data_bool:
        fix_dates(options, provider_type)

    LOG.info("Creating reports...")
    if provider_type == "aws":
        aws_create_report(options)
    elif provider_type == "azure":
        azure_create_report(options)
    elif provider_type == "ocp":
        ocp_create_report(options)
    elif provider_type == "gcp":
        gcp_create_report(options)
Exemple #4
0
def main():
    """Run data generation program."""
    parser = create_parser()
    args = parser.parse_args()
    options = vars(args)
    _load_static_report_data(options)
    _, provider_type = _validate_provider_inputs(parser, options)
    if not options.get('start_date'):
        parser.error('the following arguments are required: --start-date')
    if provider_type == 'aws':
        aws_create_report(options)
    elif provider_type == 'azure':
        azure_create_report(options)
    elif provider_type == 'ocp':
        ocp_create_report(options)
    elif provider_type == 'gcp':
        gcp_create_report(options)
Exemple #5
0
    def test_gcp_create_report(self):
        """Test the gcp report creation method."""
        now = datetime.datetime.now().replace(microsecond=0,
                                              second=0,
                                              minute=0,
                                              hour=0)
        one_day = datetime.timedelta(days=1)
        yesterday = now - one_day
        report_prefix = 'test_report'
        gcp_create_report({
            'start_date': yesterday,
            'end_date': now,
            'gcp_report_prefix': report_prefix
        })
        output_file_name = '{}-{}.csv'.format(report_prefix,
                                              yesterday.strftime('%Y-%m-%d'))
        expected_output_file_path = '{}/{}'.format(os.getcwd(),
                                                   output_file_name)

        self.assertTrue(os.path.isfile(expected_output_file_path))
        os.remove(expected_output_file_path)