示例#1
0
def check_node_group_template_usage(node_group_template_id, **kwargs):
    cluster_users = []
    template_users = []

    for cluster in api.get_clusters():
        if (node_group_template_id in [
                node_group.node_group_template_id
                for node_group in cluster.node_groups
        ]):
            cluster_users += [cluster.name]

    for cluster_template in api.get_cluster_templates():
        if (node_group_template_id in [
                node_group.node_group_template_id
                for node_group in cluster_template.node_groups
        ]):
            template_users += [cluster_template.name]

    if cluster_users or template_users:
        raise ex.InvalidException(
            _("Node group template %(template)s is in use by "
              "cluster templates: %(users)s; and clusters: %(clusters)s") %
            {
                'template': node_group_template_id,
                'users': template_users and ', '.join(template_users) or 'N/A',
                'clusters': cluster_users and ', '.join(cluster_users) or 'N/A'
            })
示例#2
0
 def test_create_multiple_clusters_failed(self, check_cluster):
     MULTIPLE_CLUSTERS = SAMPLE_CLUSTER.copy()
     MULTIPLE_CLUSTERS['count'] = 2
     check_cluster.side_effect = exc.QuotaException(
         'resource', 'requested', 'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
示例#3
0
文件: test_api.py 项目: rsaha/sahara
 def test_create_multiple_clusters_failed(self, check_cluster):
     MULTIPLE_CLUSTERS = SAMPLE_CLUSTER.copy()
     MULTIPLE_CLUSTERS['count'] = 2
     check_cluster.side_effect = exc.QuotaException(
         'resource', 'requested', 'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
示例#4
0
def check_cluster_template_usage(cluster_template_id, **kwargs):
    users = []

    for cluster in api.get_clusters():
        if cluster_template_id == cluster.cluster_template_id:
            users.append(cluster.name)

    if users:
        raise ex.InvalidException(
            "Cluster template %s in use by %s" %
            (cluster_template_id, ', '.join(users)))
示例#5
0
def check_cluster_template_usage(cluster_template_id, **kwargs):
    users = []

    for cluster in api.get_clusters():
        if cluster_template_id == cluster.cluster_template_id:
            users.append(cluster.name)

    if users:
        raise ex.InvalidException(
            _("Cluster template %(id)s in use by %(clusters)s") %
            {'id': cluster_template_id,
             'clusters':  ', '.join(users)})
示例#6
0
def check_cluster_template_usage(cluster_template_id, **kwargs):
    users = []

    for cluster in api.get_clusters():
        if cluster_template_id == cluster.cluster_template_id:
            users.append(cluster.name)

    if users:
        raise ex.InvalidReferenceException(
            _("Cluster template %(id)s in use by %(clusters)s")
            % {"id": cluster_template_id, "clusters": ", ".join(users)}
        )
示例#7
0
def check_node_group_template_usage(node_group_template_id, **kwargs):
    cluster_users = []
    template_users = []

    for cluster in api.get_clusters():
        if (node_group_template_id in
            [node_group.node_group_template_id
             for node_group in cluster.node_groups]):
            cluster_users += [cluster.name]

    for cluster_template in api.get_cluster_templates():
        if (node_group_template_id in
            [node_group.node_group_template_id
             for node_group in cluster_template.node_groups]):
            template_users += [cluster_template.name]

    if cluster_users or template_users:
        raise ex.InvalidException(
            _("Node group template %(template)s is in use by "
              "cluster templates: %(users)s; and clusters: %(clusters)s") %
            {'template': node_group_template_id,
             'users': template_users and ', '.join(template_users) or 'N/A',
             'clusters': cluster_users and ', '.join(cluster_users) or 'N/A'})
示例#8
0
文件: base.py 项目: B-Rich/sahara
def check_cluster_unique_name(name):
    if name in [cluster.name for cluster in api.get_clusters()]:
        raise ex.NameAlreadyExistsException("Cluster with name '%s' already"
                                            " exists" % name)
    check_heat_stack_name(name)
示例#9
0
def clusters_list():
    return u.render(clusters=[c.to_dict() for c in api.get_clusters(
        **u.get_request_args().to_dict())])
示例#10
0
文件: base.py 项目: savi-dev/sahara
def check_cluster_unique_name(name):
    if name in [cluster.name for cluster in api.get_clusters()]:
        raise ex.NameAlreadyExistsException("Cluster with name '%s' already"
                                            " exists" % name)
    check_heat_stack_name(name)
示例#11
0
文件: v10.py 项目: qinweiwei/sahara
def clusters_list(**kwargs):
    all_tenants = kwargs.get('all_tenants', None)
    return u.render(clusters=[c.to_dict() for c in api.get_clusters(all_tenants)])
示例#12
0
 def test_create_cluster_failed(self, check_cluster):
     check_cluster.side_effect = exc.QuotaException(
         'resource', 'requested', 'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
示例#13
0
def clusters_list():
    return u.render(clusters=[
        c.to_dict() for c in api.get_clusters(**u.get_request_args().to_dict())
    ])
示例#14
0
文件: v10.py 项目: qinweiwei/sahara
def clusters_list(**kwargs):
    all_tenants = kwargs.get('all_tenants', None)
    return u.render(
        clusters=[c.to_dict() for c in api.get_clusters(all_tenants)])
示例#15
0
文件: v10.py 项目: B-Rich/sahara
def clusters_list():
    return u.render(clusters=[c.to_dict() for c in api.get_clusters()])
示例#16
0
文件: test_api.py 项目: rsaha/sahara
 def test_create_cluster_failed(self, check_cluster):
     check_cluster.side_effect = exc.QuotaException(
         'resource', 'requested', 'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
示例#17
0
def clusters_list():
    return u.render(clusters=[c.to_dict() for c in api.get_clusters()])