def set_host_roles(self, num_masters: int=None, num_workers: int=None, requested_roles=None):
    if (requested_roles is None):
        requested_roles = Counter(master=(num_masters or self.nodes.masters_count), worker=(num_workers or self.nodes.workers_count))
    assigned_roles = self._get_matching_hosts(host_type=consts.NodeRoles.MASTER, count=requested_roles['master'])
    assigned_roles.extend(self._get_matching_hosts(host_type=consts.NodeRoles.WORKER, count=requested_roles['worker']))
    for role in assigned_roles:
        self._infra_env.update_host(host_id=role['id'], host_role=role['role'])
    return assigned_roles
def set_host_roles(self, num_masters: int=None, num_workers: int=None, requested_roles=None):
    if (requested_roles is None):
        requested_roles = Counter(master=(num_masters or self.nodes.masters_count), worker=(num_workers or self.nodes.workers_count))
    assigned_roles = self._get_matching_hosts(host_type=consts.NodeRoles.MASTER, count=requested_roles['master'])
    assigned_roles.extend(self._get_matching_hosts(host_type=consts.NodeRoles.WORKER, count=requested_roles['worker']))
    for role in assigned_roles:
        self._infra_env.update_host(host_id=role['id'], host_role=role['role'])
    return assigned_roles