def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity
        compute_client = self.app.client_manager.compute
        dateformat = "%Y-%m-%d"
        now = datetime.datetime.utcnow()

        if parsed_args.start:
            start = datetime.datetime.strptime(parsed_args.start, dateformat)
        else:
            start = now - datetime.timedelta(weeks=4)

        if parsed_args.end:
            end = datetime.datetime.strptime(parsed_args.end, dateformat)
        else:
            end = now + datetime.timedelta(days=1)

        if parsed_args.project:
            project = utils.find_resource(
                identity_client.projects,
                parsed_args.project,
            ).id
        else:
            # Get the project from the current auth
            project = self.app.client_manager.auth_ref.project_id

        usage = compute_client.usage.get(project, start, end)

        if parsed_args.formatter == 'table':
            sys.stdout.write("Usage from %s to %s on project %s: \n" % (
                start.strftime(dateformat),
                end.strftime(dateformat),
                project
            ))

        info = {}
        info['Servers'] = (
            len(usage.server_usages)
            if hasattr(usage, "server_usages") else None)
        info['RAM MB-Hours'] = (
            float("%.2f" % usage.total_memory_mb_usage)
            if hasattr(usage, "total_memory_mb_usage") else None)
        info['CPU Hours'] = (
            float("%.2f" % usage.total_vcpus_usage)
            if hasattr(usage, "total_vcpus_usage") else None)
        info['Disk GB-Hours'] = (
            float("%.2f" % usage.total_local_gb_usage)
            if hasattr(usage, "total_local_gb_usage") else None)
        return zip(*sorted(six.iteritems(info)))
dataset/ETHPy150Open dtroyer/python-openstackclient/openstackclient/compute/v2/usage.py/ShowUsage.take_action/original