From 80b428698172a41fc256174e61d2a005550fb1a3 Mon Sep 17 00:00:00 2001 From: Takashi NATSUME Date: Tue, 9 Oct 2018 10:16:33 +0900 Subject: [PATCH] Replace MB with MiB Change-Id: Ie5bd325d8e0f7e9af76c1ddae1d679b0e797c84b --- doc/source/cli/nova.rst | 10 +++--- .../v2/legacy/test_readonly_nova.py | 2 +- novaclient/tests/unit/fakes.py | 4 +-- novaclient/tests/unit/fixture_data/servers.py | 6 ++-- novaclient/tests/unit/test_base.py | 2 +- novaclient/tests/unit/v2/fakes.py | 20 +++++------ novaclient/tests/unit/v2/test_flavors.py | 4 +-- novaclient/tests/unit/v2/test_servers.py | 5 +-- novaclient/tests/unit/v2/test_shell.py | 32 ++++++++--------- novaclient/v2/flavors.py | 6 ++-- novaclient/v2/shell.py | 34 +++++++++---------- 11 files changed, 63 insertions(+), 62 deletions(-) diff --git a/doc/source/cli/nova.rst b/doc/source/cli/nova.rst index e14acd5c5..b8a212d49 100644 --- a/doc/source/cli/nova.rst +++ b/doc/source/cli/nova.rst @@ -1027,7 +1027,7 @@ Boot a new server. driver chooses suitable device depending on selected bus; note the libvirt driver always uses default device names), size=size of the - block device in MB(for swap) and in GiB(for + block device in MiB(for swap) and in GiB(for other formats) (if omitted, hypervisor driver calculates size), format=device will be formatted (e.g. swap, ntfs, ...; optional), @@ -1046,7 +1046,7 @@ Boot a new server. ``--swap `` Create and attach a local swap block device of - MB. + MiB. ``--ephemeral`` size=[,format=] @@ -1334,7 +1334,7 @@ Create a new flavor. generated a UUID for the ID. ```` - Memory size in MB. + Memory size in MiB. ```` Disk size in GiB. @@ -1348,7 +1348,7 @@ Create a new flavor. Ephemeral space size in GiB (default 0). ``--swap `` - Swap space size in MB (default 0). + Swap space size in MiB (default 0). ``--rxtx-factor `` RX/TX factor (default 1). @@ -1430,7 +1430,7 @@ Print a list of available 'flavors' (sizes of servers). Filters the flavors by a minimum disk space, in GiB. ``--min-ram `` - Filters the flavors by a minimum RAM, in MB. + Filters the flavors by a minimum RAM, in MiB. ``--limit `` Maximum number of flavors to display. If limit is diff --git a/novaclient/tests/functional/v2/legacy/test_readonly_nova.py b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py index 6b9598e96..a31982e5d 100644 --- a/novaclient/tests/functional/v2/legacy/test_readonly_nova.py +++ b/novaclient/tests/functional/v2/legacy/test_readonly_nova.py @@ -49,7 +49,7 @@ class SimpleReadOnlyNovaClientTest(base.ClientTestBase): params='--flavor m1.tiny') def test_admin_flavor_list(self): - self.assertIn("Memory_MB", self.nova('flavor-list')) + self.assertIn("Memory_MiB", self.nova('flavor-list')) def test_admin_hypervisor_list(self): self.nova('hypervisor-list') diff --git a/novaclient/tests/unit/fakes.py b/novaclient/tests/unit/fakes.py index a9447f71f..312cca4fb 100644 --- a/novaclient/tests/unit/fakes.py +++ b/novaclient/tests/unit/fakes.py @@ -59,10 +59,10 @@ class FakeClient(object): self.assert_called('GET', '/flavors/aa1/os-extra_specs') 2. self.run_command(["boot", "--image", "1", - "--flavor", "512 MB Server", + "--flavor", "512 MiB Server", "--max-count", "3", "server"]) self.assert_called('GET', '/images/1', pos=0) - self.assert_called('GET', '/flavors/512 MB Server', pos=1) + self.assert_called('GET', '/flavors/512 MiB Server', pos=1) self.assert_called('GET', '/flavors?is_public=None', pos=2) self.assert_called('GET', '/flavors/2', pos=3) self.assert_called( diff --git a/novaclient/tests/unit/fixture_data/servers.py b/novaclient/tests/unit/fixture_data/servers.py index 2402cd106..6df4129bd 100644 --- a/novaclient/tests/unit/fixture_data/servers.py +++ b/novaclient/tests/unit/fixture_data/servers.py @@ -43,7 +43,7 @@ class Base(base.Fixture): }, "flavor": { "id": 1, - "name": "256 MB Server", + "name": "256 MiB Server", }, "hostId": "e4d909c290d0fb1ca068ffaddf22cbd0", "status": "BUILD", @@ -85,7 +85,7 @@ class Base(base.Fixture): }, "flavor": { "id": 1, - "name": "256 MB Server", + "name": "256 MiB Server", }, "hostId": "9e107d9d372bb6826bd81d3542a419d6", "status": "ACTIVE", @@ -127,7 +127,7 @@ class Base(base.Fixture): "image": "", "flavor": { "id": 1, - "name": "256 MB Server", + "name": "256 MiB Server", }, "hostId": "9e107d9d372bb6826bd81d3542a419d6", "status": "ACTIVE", diff --git a/novaclient/tests/unit/test_base.py b/novaclient/tests/unit/test_base.py index 0b1ee83aa..b1067cf2b 100644 --- a/novaclient/tests/unit/test_base.py +++ b/novaclient/tests/unit/test_base.py @@ -49,7 +49,7 @@ class BaseTest(utils.TestCase): def test_resource_lazy_getattr(self): cs = fakes.FakeClient(api_versions.APIVersion("2.0")) f = flavors.Flavor(cs.flavors, {'id': 1}) - self.assertEqual('256 MB Server', f.name) + self.assertEqual('256 MiB Server', f.name) cs.assert_called('GET', '/flavors/1') # Missing stuff still fails after a second get diff --git a/novaclient/tests/unit/v2/fakes.py b/novaclient/tests/unit/v2/fakes.py index 374648be3..c6f34c344 100644 --- a/novaclient/tests/unit/v2/fakes.py +++ b/novaclient/tests/unit/v2/fakes.py @@ -409,7 +409,7 @@ class FakeSessionClient(base_client.SessionClient): }, "flavor": { "id": 1, - "name": "256 MB Server", + "name": "256 MiB Server", }, "hostId": "e4d909c290d0fb1ca068ffaddf22cbd0", "status": "BUILD", @@ -450,7 +450,7 @@ class FakeSessionClient(base_client.SessionClient): }, "flavor": { "id": 1, - "name": "256 MB Server", + "name": "256 MiB Server", }, "hostId": "9e107d9d372bb6826bd81d3542a419d6", "status": "ACTIVE", @@ -491,7 +491,7 @@ class FakeSessionClient(base_client.SessionClient): "image": "", "flavor": { "id": 1, - "name": "256 MB Server", + "name": "256 MiB Server", }, "hostId": "9e107d9d372bb6826bd81d3542a419d6", "status": "ACTIVE", @@ -844,19 +844,19 @@ class FakeSessionClient(base_client.SessionClient): def get_flavors_detail(self, **kw): flavors = {'flavors': [ - {'id': 1, 'name': '256 MB Server', 'ram': 256, 'disk': 10, + {'id': 1, 'name': '256 MiB Server', 'ram': 256, 'disk': 10, 'OS-FLV-EXT-DATA:ephemeral': 10, 'os-flavor-access:is_public': True, 'links': {}}, - {'id': 2, 'name': '512 MB Server', 'ram': 512, 'disk': 20, + {'id': 2, 'name': '512 MiB Server', 'ram': 512, 'disk': 20, 'OS-FLV-EXT-DATA:ephemeral': 20, 'os-flavor-access:is_public': False, 'links': {}}, - {'id': 4, 'name': '1024 MB Server', 'ram': 1024, 'disk': 10, + {'id': 4, 'name': '1024 MiB Server', 'ram': 1024, 'disk': 10, 'OS-FLV-EXT-DATA:ephemeral': 10, 'os-flavor-access:is_public': True, 'links': {}}, - {'id': 'aa1', 'name': '128 MB Server', 'ram': 128, 'disk': 0, + {'id': 'aa1', 'name': '128 MiB Server', 'ram': 128, 'disk': 0, 'OS-FLV-EXT-DATA:ephemeral': 0, 'os-flavor-access:is_public': True, 'links': {}} @@ -925,16 +925,16 @@ class FakeSessionClient(base_client.SessionClient): FAKE_RESPONSE_HEADERS, {'flavor': { 'id': 3, - 'name': '256 MB Server', + 'name': '256 MiB Server', 'ram': 256, 'disk': 10, }}, ) - def get_flavors_512_MB_Server(self, **kw): + def get_flavors_512_MiB_Server(self, **kw): raise exceptions.NotFound('404') - def get_flavors_128_MB_Server(self, **kw): + def get_flavors_128_MiB_Server(self, **kw): raise exceptions.NotFound('404') def get_flavors_80645cf4_6ad3_410a_bbc8_6f3e1e291f51(self, **kw): diff --git a/novaclient/tests/unit/v2/test_flavors.py b/novaclient/tests/unit/v2/test_flavors.py index f05e7cddb..e536af11f 100644 --- a/novaclient/tests/unit/v2/test_flavors.py +++ b/novaclient/tests/unit/v2/test_flavors.py @@ -122,11 +122,11 @@ class FlavorsTest(utils.TestCase): f = self.cs.flavors.find(ram=256) self.assert_request_id(f, fakes.FAKE_REQUEST_ID_LIST) self.cs.assert_called('GET', '/flavors/detail') - self.assertEqual('256 MB Server', f.name) + self.assertEqual('256 MiB Server', f.name) f = self.cs.flavors.find(disk=0) self.assert_request_id(f, fakes.FAKE_REQUEST_ID_LIST) - self.assertEqual('128 MB Server', f.name) + self.assertEqual('128 MiB Server', f.name) self.assertRaises(exceptions.NotFound, self.cs.flavors.find, disk=12345) diff --git a/novaclient/tests/unit/v2/test_servers.py b/novaclient/tests/unit/v2/test_servers.py index 427a4eff8..402f50203 100644 --- a/novaclient/tests/unit/v2/test_servers.py +++ b/novaclient/tests/unit/v2/test_servers.py @@ -455,9 +455,10 @@ class ServersTest(utils.FixturedTestCase): self.assertEqual('sample-server', server.name) self.assertRaises(exceptions.NoUniqueMatch, self.cs.servers.find, - flavor={"id": 1, "name": "256 MB Server"}) + flavor={"id": 1, "name": "256 MiB Server"}) - sl = self.cs.servers.findall(flavor={"id": 1, "name": "256 MB Server"}) + sl = self.cs.servers.findall(flavor={"id": 1, + "name": "256 MiB Server"}) self.assert_request_id(sl, fakes.FAKE_REQUEST_ID_LIST) self.assertEqual([1234, 5678, 9012], [s.id for s in sl]) diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index 216241ecd..5e9b9951a 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -1165,10 +1165,10 @@ class ShellTest(utils.TestCase): def test_boot_named_flavor(self): self.run_command(["boot", "--image", FAKE_UUID_1, - "--flavor", "512 MB Server", + "--flavor", "512 MiB Server", "--max-count", "3", "server"]) self.assert_called('GET', '/v2/images/' + FAKE_UUID_1, pos=0) - self.assert_called('GET', '/flavors/512 MB Server', pos=1) + self.assert_called('GET', '/flavors/512 MiB Server', pos=1) self.assert_called('GET', '/flavors?is_public=None', pos=2) self.assert_called('GET', '/flavors/2', pos=3) self.assert_called( @@ -1404,15 +1404,15 @@ class ShellTest(utils.TestCase): self.assert_called_anytime('GET', '/flavors/aa1') def test_flavor_show_by_name(self): - self.run_command(['flavor-show', '128 MB Server']) - self.assert_called('GET', '/flavors/128 MB Server', pos=0) + self.run_command(['flavor-show', '128 MiB Server']) + self.assert_called('GET', '/flavors/128 MiB Server', pos=0) self.assert_called('GET', '/flavors?is_public=None', pos=1) self.assert_called('GET', '/flavors/aa1', pos=2) self.assert_called('GET', '/flavors/aa1/os-extra_specs', pos=3) def test_flavor_show_by_name_priv(self): - self.run_command(['flavor-show', '512 MB Server']) - self.assert_called('GET', '/flavors/512 MB Server', pos=0) + self.run_command(['flavor-show', '512 MiB Server']) + self.assert_called('GET', '/flavors/512 MiB Server', pos=0) self.assert_called('GET', '/flavors?is_public=None', pos=1) self.assert_called('GET', '/flavors/2', pos=2) self.assert_called('GET', '/flavors/2/os-extra_specs', pos=3) @@ -1444,7 +1444,7 @@ class ShellTest(utils.TestCase): {'addTenantAccess': {'tenant': 'proj2'}}) def test_flavor_access_add_by_name(self): - self.run_command(['flavor-access-add', '512 MB Server', 'proj2']) + self.run_command(['flavor-access-add', '512 MiB Server', 'proj2']) self.assert_called('POST', '/flavors/2/action', {'addTenantAccess': {'tenant': 'proj2'}}) @@ -1454,7 +1454,7 @@ class ShellTest(utils.TestCase): {'removeTenantAccess': {'tenant': 'proj2'}}) def test_flavor_access_remove_by_name(self): - self.run_command(['flavor-access-remove', '512 MB Server', 'proj2']) + self.run_command(['flavor-access-remove', '512 MiB Server', 'proj2']) self.assert_called('POST', '/flavors/2/action', {'removeTenantAccess': {'tenant': 'proj2'}}) @@ -2336,8 +2336,8 @@ class ShellTest(utils.TestCase): 'start=2000-01-20T00:00:00&' + 'end=2005-02-01T00:00:00&' + 'detailed=1') - # Servers, RAM MB-Hours, CPU Hours, Disk GiB-Hours - self.assertIn('1 | 25451.76 | 49.71 | 0.00', stdout) + # Servers, RAM MiB-Hours, CPU Hours, Disk GiB-Hours + self.assertIn('1 | 25451.76 | 49.71 | 0.00', stdout) def test_usage_list_stitch_together_next_results(self): cmd = 'usage-list --start 2000-01-20 --end 2005-02-01' @@ -2357,8 +2357,8 @@ class ShellTest(utils.TestCase): 'start=2000-01-20T00:00:00&' 'end=2005-02-01T00:00:00&' 'marker=%s&detailed=1' % (marker), pos=pos + 1) - # Servers, RAM MB-Hours, CPU Hours, Disk GiB-Hours - self.assertIn('2 | 50903.53 | 99.42 | 0.00', stdout) + # Servers, RAM MiB-Hours, CPU Hours, Disk GiB-Hours + self.assertIn('2 | 50903.53 | 99.42 | 0.00', stdout) def test_usage_list_no_args(self): timeutils.set_time_override(datetime.datetime(2005, 2, 1, 0, 0)) @@ -2377,8 +2377,8 @@ class ShellTest(utils.TestCase): '/os-simple-tenant-usage/test?' + 'start=2000-01-20T00:00:00&' + 'end=2005-02-01T00:00:00') - # Servers, RAM MB-Hours, CPU Hours, Disk GiB-Hours - self.assertIn('1 | 25451.76 | 49.71 | 0.00', stdout) + # Servers, RAM MiB-Hours, CPU Hours, Disk GiB-Hours + self.assertIn('1 | 25451.76 | 49.71 | 0.00', stdout) def test_usage_stitch_together_next_results(self): cmd = 'usage --start 2000-01-20 --end 2005-02-01' @@ -2397,8 +2397,8 @@ class ShellTest(utils.TestCase): 'start=2000-01-20T00:00:00&' 'end=2005-02-01T00:00:00&' 'marker=%s' % (marker), pos=pos + 1) - # Servers, RAM MB-Hours, CPU Hours, Disk GiB-Hours - self.assertIn('2 | 50903.53 | 99.42 | 0.00', stdout) + # Servers, RAM MiB-Hours, CPU Hours, Disk GiB-Hours + self.assertIn('2 | 50903.53 | 99.42 | 0.00', stdout) def test_usage_no_tenant(self): self.run_command('usage --start 2000-01-20 --end 2005-02-01') diff --git a/novaclient/v2/flavors.py b/novaclient/v2/flavors.py index f015a06e8..9cc2b6433 100644 --- a/novaclient/v2/flavors.py +++ b/novaclient/v2/flavors.py @@ -114,7 +114,7 @@ class FlavorManager(base.ManagerWithFind): :param marker: Begin returning flavors that appear later in the flavor list than that represented by this flavor id (optional). :param min_disk: Filters the flavors by a minimum disk space, in GiB. - :param min_ram: Filters the flavors by a minimum RAM, in MB. + :param min_ram: Filters the flavors by a minimum RAM, in MiB. :param limit: maximum number of flavors to return (optional). :param sort_key: Flavors list sort key (optional). :param sort_dir: Flavors list sort direction (optional). @@ -183,14 +183,14 @@ class FlavorManager(base.ManagerWithFind): """Create a flavor. :param name: Descriptive name of the flavor - :param ram: Memory in MB for the flavor + :param ram: Memory in MiB for the flavor :param vcpus: Number of VCPUs for the flavor :param disk: Size of local disk in GiB :param flavorid: ID for the flavor (optional). You can use the reserved value ``"auto"`` to have Nova generate a UUID for the flavor in cases where you cannot simply pass ``None``. :param ephemeral: Ephemeral disk space in GiB. - :param swap: Swap space in MB + :param swap: Swap space in MiB :param rxtx_factor: RX/TX factor :param is_public: Whether or not the flavor is public. :param description: A free form description of the flavor. diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index b993fbc0d..a67a3323d 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -644,7 +644,7 @@ def _boot(cs, args): "if omitted, hypervisor driver chooses suitable device " "depending on selected bus; note the libvirt driver always " "uses default device names), " - "size=size of the block device in MB(for swap) and in " + "size=size of the block device in MiB(for swap) and in " "GiB(for other formats) " "(if omitted, hypervisor driver calculates size), " "format=device will be formatted (e.g. swap, ntfs, ...; optional), " @@ -674,7 +674,7 @@ def _boot(cs, args): "if omitted, hypervisor driver chooses suitable device " "depending on selected bus; note the libvirt driver always " "uses default device names), " - "size=size of the block device in MB(for swap) and in " + "size=size of the block device in MiB(for swap) and in " "GiB(for other formats) " "(if omitted, hypervisor driver calculates size), " "format=device will be formatted (e.g. swap, ntfs, ...; optional), " @@ -703,7 +703,7 @@ def _boot(cs, args): "if omitted, hypervisor driver chooses suitable device " "depending on selected bus; note the libvirt driver always " "uses default device names), " - "size=size of the block device in MB(for swap) and in " + "size=size of the block device in MiB(for swap) and in " "GiB(for other formats) " "(if omitted, hypervisor driver calculates size), " "format=device will be formatted (e.g. swap, ntfs, ...; optional), " @@ -732,7 +732,7 @@ def _boot(cs, args): "if omitted, hypervisor driver chooses suitable device " "depending on selected bus; note the libvirt driver always " "uses default device names), " - "size=size of the block device in MB(for swap) and in " + "size=size of the block device in MiB(for swap) and in " "GiB(for other formats) " "(if omitted, hypervisor driver calculates size), " "format=device will be formatted (e.g. swap, ntfs, ...; optional), " @@ -761,7 +761,7 @@ def _boot(cs, args): "if omitted, hypervisor driver chooses suitable device " "depending on selected bus; note the libvirt driver always " "uses default device names), " - "size=size of the block device in MB(for swap) and in " + "size=size of the block device in MiB(for swap) and in " "GiB(for other formats) " "(if omitted, hypervisor driver calculates size), " "format=device will be formatted (e.g. swap, ntfs, ...; optional), " @@ -778,7 +778,7 @@ def _boot(cs, args): '--swap', metavar="", default=None, - help=_("Create and attach a local swap block device of MB.")) + help=_("Create and attach a local swap block device of MiB.")) @utils.arg( '--ephemeral', metavar="size=[,format=]", @@ -1060,7 +1060,7 @@ def _translate_extended_states(collection): def _translate_flavor_keys(collection): - _translate_keys(collection, [('ram', 'memory_mb')]) + _translate_keys(collection, [('ram', 'memory_mib')]) def _print_flavor_extra_specs(flavor): @@ -1076,7 +1076,7 @@ def _print_flavor_list(cs, flavors, show_extra_specs=False): headers = [ 'ID', 'Name', - 'Memory_MB', + 'Memory_MiB', 'Disk', 'Ephemeral', 'Swap', @@ -1129,7 +1129,7 @@ def _print_flavor_list(cs, flavors, show_extra_specs=False): dest='min_ram', metavar='', default=None, - help=_('Filters the flavors by a minimum RAM, in MB.')) + help=_('Filters the flavors by a minimum RAM, in MiB.')) @utils.arg( '--limit', dest='limit', @@ -1196,7 +1196,7 @@ def do_flavor_show(cs, args): @utils.arg( 'ram', metavar='', - help=_("Memory size in MB.")) + help=_("Memory size in MiB.")) @utils.arg( 'disk', metavar='', @@ -1213,7 +1213,7 @@ def do_flavor_show(cs, args): @utils.arg( '--swap', metavar='', - help=_("Additional swap space size in MB (default 0)."), + help=_("Additional swap space size in MiB (default 0)."), default=0) @utils.arg( '--rxtx-factor', @@ -3087,7 +3087,7 @@ def _merge_usage_list(usages, next_usage_list): def do_usage_list(cs, args): """List usage data for all tenants.""" dateformat = "%Y-%m-%d" - rows = ["Tenant ID", "Servers", "RAM MB-Hours", "CPU Hours", + rows = ["Tenant ID", "Servers", "RAM MiB-Hours", "CPU Hours", "Disk GiB-Hours"] now = timeutils.utcnow() @@ -3156,7 +3156,7 @@ def do_usage_list(cs, args): def do_usage(cs, args): """Show usage data for a single tenant.""" dateformat = "%Y-%m-%d" - rows = ["Servers", "RAM MB-Hours", "CPU Hours", "Disk GiB-Hours"] + rows = ["Servers", "RAM MiB-Hours", "CPU Hours", "Disk GiB-Hours"] now = timeutils.utcnow() @@ -4808,13 +4808,13 @@ def do_cell_show(cs, args): def do_cell_capacities(cs, args): """Get cell capacities for all cells or a given cell.""" cell = cs.cells.capacities(args.cell) - print(_("Ram Available: %s MB") % cell.capacities['ram_free']['total_mb']) + print(_("Ram Available: %s MiB") % cell.capacities['ram_free']['total_mb']) utils.print_dict(cell.capacities['ram_free']['units_by_mb'], - dict_property='Ram(MB)', dict_value="Units") - print(_("\nDisk Available: %s MB") % + dict_property='Ram(MiB)', dict_value="Units") + print(_("\nDisk Available: %s MiB") % cell.capacities['disk_free']['total_mb']) utils.print_dict(cell.capacities['disk_free']['units_by_mb'], - dict_property='Disk(MB)', dict_value="Units") + dict_property='Disk(MiB)', dict_value="Units") @utils.arg('server', metavar='', help='Name or ID of server.')