def _update_slurm_size_attrs(self, nodename, size):
self._update_slurm_node(nodename, [
'Weight=%i' % int(size.price * 1000),
- 'Features=instancetype=' + size.name,
+ 'Features=instancetype=' + size.id,
])
def _get_slurm_state(self, nodename):
"""Keep SLURM's node properties up to date."""
hostname = arvados_node.get("hostname")
features = arvados_node.get("slurm_node_features", "").split(",")
- sizefeature = "instancetype=" + cloud_node.size.name
+ sizefeature = "instancetype=" + cloud_node.size.id
if hostname and sizefeature not in features:
# This probably means SLURM has restarted and lost our
# dynamically configured node weights and features.
super(ComputeNodeDriver, self).__init__(
auth_kwargs, list_kwargs, create_kwargs,
driver_class)
- self._sizes_by_name = {sz.name: sz for sz in self.sizes.itervalues()}
+ self._sizes_by_id = {sz.id: sz for sz in self.sizes.itervalues()}
self._disktype_links = {dt.name: self._object_link(dt)
for dt in self.real.ex_list_disktypes()}
# and monkeypatch the results when that's the case.
if nodelist and not hasattr(nodelist[0].size, 'id'):
for node in nodelist:
- node.size = self._sizes_by_name[node.size]
+ node.size = self._sizes_by_id[node.size]
return nodelist
@classmethod
return fallback
def cloud_size_for_constraints(self, constraints):
- specified_name = constraints.get('instance_type')
+ specified_size = constraints.get('instance_type')
want_value = lambda key: self.coerce_int(constraints.get(key), 0)
wants = {'cores': want_value('min_cores_per_node'),
'ram': want_value('min_ram_mb_per_node'),
'scratch': want_value('min_scratch_mb_per_node')}
for size in self.cloud_sizes:
if (size.meets_constraints(**wants) and
- (specified_name is None or size.name == specified_name)):
+ (specified_size is None or size.id == specified_size)):
return size
return None
# patches that up in listings.
size = testutil.MockSize(2)
node = testutil.cloud_node_mock(size=size)
- node.size = size.name
+ node.size = size.id
self.driver_mock().list_sizes.return_value = [size]
self.driver_mock().list_nodes.return_value = [node]
driver = self.new_driver()
class MockSize(object):
def __init__(self, factor):
self.id = 'z{}.test'.format(factor)
- self.name = self.id
+ self.name = 'test size '+self.id
self.ram = 128 * factor
self.disk = factor # GB
self.scratch = 1000 * factor # MB