def _delete_aa_server_group(self, cluster): if cluster.anti_affinity: server_group_name = g.generate_aa_group_name(cluster.name) client = nova.client().server_groups server_groups = client.findall(name=server_group_name) if len(server_groups) == 1: client.delete(server_groups[0].id)
def _delete_aa_server_group(self, cluster): if cluster.anti_affinity: server_group_name = g.generate_aa_group_name(cluster.name) client = nova.client().server_groups server_groups = b.execute_with_retries(client.findall, name=server_group_name) if len(server_groups) == 1: b.execute_with_retries(client.delete, server_groups[0].id)
def _create_aa_server_group(self, cluster): server_group_name = g.generate_aa_group_name(cluster.name) client = nova.client().server_groups if client.findall(name=server_group_name): raise exc.InvalidDataException( _("Server group with name %s is already exists") % server_group_name) server_group = client.create(name=server_group_name, policies=['anti-affinity']) return server_group.id
def _find_aa_server_group(self, cluster): server_group_name = g.generate_aa_group_name(cluster.name) server_groups = nova.client().server_groups.findall( name=server_group_name) if len(server_groups) > 1: raise exc.IncorrectStateError( _("Several server groups with name %s found") % server_group_name) if len(server_groups) == 1: return server_groups[0].id return None
def _delete_aa_server_groups(self, cluster): if cluster.anti_affinity: for i in range(1, cluster.anti_affinity_ratio): server_group_name = g.generate_aa_group_name(cluster.name, i) client = nova.client().server_groups server_groups = b.execute_with_retries(client.findall, name=server_group_name) if len(server_groups) == 1: b.execute_with_retries(client.delete, server_groups[0].id) '''In case the server group is created using mitaka or older version''' old_server_group_name = server_group_name.rsplit('-', 1)[0] server_groups_old = b.execute_with_retries( client.findall, name=old_server_group_name) if len(server_groups_old) == 1: b.execute_with_retries(client.delete, server_groups_old[0].id)
def _get_aa_group_name(cluster_name): return g.generate_aa_group_name(cluster_name)
def _get_aa_group_name(cluster, server_group_index): return g.generate_aa_group_name(cluster.name, server_group_index)