Skip to content

Commit

Permalink
Fix XiB units
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Nov 28, 2024
1 parent 3fc36d7 commit 98de187
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions IM/connectors/OSCAR.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _get_service_json(radl_system):
if radl_system.getValue("name"):
service["name"] = radl_system.getValue("name")
if radl_system.getValue("memory.size"):
service["memory"] = "%dMi" % radl_system.getFeature('memory.size').getValue('M')
service["memory"] = "%dMi" % radl_system.getFeature('memory.size').getValue('Mi')
if radl_system.getValue("cpu.count"):
service["cpu"] = "%g" % radl_system.getValue("cpu.count")
if radl_system.getValue("gpu.count"):
Expand Down Expand Up @@ -260,7 +260,7 @@ def update_system_info_from_service_info(self, system, service_info):
conflict="other", missing="other")
if "memory" in service_info and service_info["memory"]:
memory = self.convert_memory_unit(service_info["memory"], "Mi")
system.addFeature(Feature("memory.size", "=", memory, "M"),
system.addFeature(Feature("memory.size", "=", memory, "Mi"),
conflict="other", missing="other")
if "script" in service_info and service_info["script"]:
system.addFeature(Feature("script", "=", service_info["script"]),
Expand Down
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PyYAML
cheroot
boto3
apache-libcloud >= 3.3.1
RADL >= 1.3.3
RADL >= 1.3.4
flask
werkzeug
netaddr
Expand Down
2 changes: 1 addition & 1 deletion test/unit/connectors/Fogbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_30_updateVMInfo(self, sleep, requests):
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertEqual(vm.info.systems[0].getValue("net_interface.0.ip"), "8.8.8.8")
self.assertEqual(vm.info.systems[0].getValue("memory.size"), 1073741824)
self.assertEqual(vm.info.systems[0].getValue("memory.size"), 1024000000)
self.assertEqual(vm.info.systems[0].getValue("disk.1.device"), "/dev/sdb")

data = json.loads(requests.call_args_list[1][1]["data"])
Expand Down
2 changes: 1 addition & 1 deletion test/unit/connectors/GCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_10_concrete(self, get_driver):

concrete = gce_cloud.concreteSystem(radl_system, auth)
self.assertEqual(len(concrete), 1)
self.assertEqual(concrete[0].getValue("memory.size"), 2147483648)
self.assertEqual(concrete[0].getValue("memory.size"), 2048000000)
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

@patch('libcloud.compute.drivers.gce.GCENodeDriver')
Expand Down
6 changes: 3 additions & 3 deletions test/unit/connectors/Kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_20_launch(self, save_data, requests):
'labels': {'name': 'test-1'}},
"spec": {
"accessModes": ["ReadWriteOnce"],
"resources": {"requests": {"storage": 10737418240}},
"resources": {"requests": {"storage": 10000000000}},
},
}
self.assertEqual(requests.call_args_list[1][0][1],
Expand Down Expand Up @@ -237,8 +237,8 @@ def test_20_launch(self, save_data, requests):
"imagePullPolicy": "Always",
"ports": [{"containerPort": 8080, "protocol": "TCP"}],
"resources": {
"limits": {"cpu": "1", "memory": "536870912"},
"requests": {"cpu": "1", "memory": "536870912"},
"limits": {"cpu": "1", "memory": "512000000"},
"requests": {"cpu": "1", "memory": "512000000"},
},
"env": [{"name": "var", "value": "some_val"},
{"name": "var2", "value": "some,val2"}],
Expand Down
2 changes: 1 addition & 1 deletion test/unit/connectors/OCCI.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_30_updateVMInfo(self, get_keystone_uri, requests):
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

memory = vm.info.systems[0].getValue("memory.size")
self.assertEqual(memory, 1824522240)
self.assertEqual(memory, 1740000000)

@patch('requests.request')
@patch('IM.connectors.OCCI.KeyStoneAuth.get_keystone_uri')
Expand Down
6 changes: 3 additions & 3 deletions test/unit/connectors/OSCAR.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_20_launch(self, save_data, requests):
radl_data = """
system test (
name = 'plants' and
memory.size = 2G and
memory.size = 2GI and
cpu.count = 1.0 and
cpu.sgx = 1 and
gpu.count = 1 and
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_55_alter(self, requests):
new_radl_data = """
system test (
cpu.count>=2 and
memory.size>=4G
memory.size>=4GI
)"""
new_radl = radl_parse.parse_radl(new_radl_data)

Expand All @@ -306,7 +306,7 @@ def test_55_alter(self, requests):
self.assertTrue(success, msg="ERROR: modifying VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEqual(new_vm.info.systems[0].getValue("cpu.count"), 2)
self.assertEqual(new_vm.info.systems[0].getFeature("memory.size").getValue("M"), 4096)
self.assertEqual(new_vm.info.systems[0].getFeature("memory.size").getValue("M"), 4295)
self.assertEqual(requests.call_args_list[0][0][0], "PUT")
self.assertEqual(requests.call_args_list[0][0][1], "http://oscar.com:80/system/services/fname")
self.assertEqual(json.loads(requests.call_args_list[0][1]['data']), {'memory': '4096Mi', 'cpu': '2'})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/connectors/OpenNebula.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_20_launch(self, save_data, getONEVersion, server_proxy):
OS = [ ARCH = "x86_64" ]
DISK = [ IMAGE_ID = "1" ]
DISK = [ SAVE = no, TYPE = fs , FORMAT = qcow2, SIZE = 1024, TARGET = hdb ]
DISK = [ SAVE = no, TYPE = fs , FORMAT = qcow2, SIZE = 1000, TARGET = hdb ]
SCHED_REQUIREMENTS = "CLUSTER_ID=\\"0\\""\n"""
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_im_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1552,8 +1552,8 @@ def test_estimate_resources(self):
'cloud0': {
'cloudType': 'Dummy',
'cloudEndpoint': 'http://server.com:80/path',
'compute': [{'cpuCores': 2, 'memoryInMegabytes': 4096, 'diskSizeInGigabytes': 40},
{'cpuCores': 1, 'memoryInMegabytes': 2048, 'diskSizeInGigabytes': 10}],
'compute': [{'cpuCores': 2, 'memoryInMegabytes': 4000, 'diskSizeInGigabytes': 40},
{'cpuCores': 1, 'memoryInMegabytes': 2000, 'diskSizeInGigabytes': 10}],
'storage': [{'sizeInGigabytes': 100}]
}})

Expand Down

0 comments on commit 98de187

Please sign in to comment.