def clusters_list(): tenant_id = request.headers['X-Tenant-Id'] try: return api_u.render( clusters=[c.dict for c in api.get_clusters(tenant_id=tenant_id)]) except Exception, e: return api_u.internal_error(500, 'Exception while listing Clusters', e)
def check_cluster_template_usage(cluster_template_id, **kwargs): clusters = api.get_clusters() use_cluster_template_ids = [cluster.cluster_template_id for cluster in clusters] if cluster_template_id in use_cluster_template_ids: raise ex.InvalidException( "Cluster template %s is use" % cluster_template_id)
def check_cluster_template_usage(cluster_template_id, **kwargs): clusters = api.get_clusters() use_cluster_template_ids = [ cluster.cluster_template_id for cluster in clusters ] if cluster_template_id in use_cluster_template_ids: raise ex.InvalidException("Cluster template %s is use" % cluster_template_id)
def validate_cluster_create(cluster_values): jsonschema.validate(cluster_values, CLUSTER_CREATE_SCHEMA) values = cluster_values['cluster'] # check that requested cluster name is unique unique_names = [cluster.name for cluster in api.get_clusters()] if values['name'] in unique_names: raise ex.ClusterNameExistedException(values['name']) # check that requested templates are from already defined values node_templates = values['node_templates'] possible_node_templates = [nt.name for nt in api.get_node_templates()] for nt in node_templates: if nt not in possible_node_templates: raise ex.NodeTemplateNotFoundException(nt) # check node count is integer and non-zero value jsonschema.validate(node_templates[nt], {"type": "integer", "minimum": 1}) # check that requested cluster contains only 1 instance of NameNode # and 1 instance of JobTracker jt_count = 0 nn_count = 0 for nt_name in node_templates: processes = api.get_node_template(name=nt_name).dict['node_type'][ 'processes'] if "job_tracker" in processes: jt_count += node_templates[nt_name] if "name_node" in processes: nn_count += node_templates[nt_name] if nn_count != 1: raise ex.NotSingleNameNodeException(nn_count) if jt_count != 1: raise ex.NotSingleJobTrackerException(jt_count) if CONF.allow_cluster_ops: image_id = values['base_image_id'] nova_images = nova.get_images(request.headers) if image_id not in nova_images: LOG.debug("Could not find %s image in %s", image_id, nova_images) raise ex.ImageNotFoundException(values['base_image_id']) # check available Nova absolute limits _check_limits(nova.get_limits(request.headers), values['node_templates']) else: LOG.info("Cluster ops are disabled, use --allow-cluster-ops flag")
def check_node_group_template_usage(node_group_template_id, **kwargs): node_groups = [] for cluster in api.get_clusters(): node_groups += cluster.node_groups for cluster_template in api.get_cluster_templates(): node_groups += cluster_template.node_groups node_group_template_ids = set( [node_group.node_group_template_id for node_group in node_groups]) if node_group_template_id in node_group_template_ids: raise ex.InvalidException("Node group template %s is use" % node_group_template_id)
def check_node_group_template_usage(node_group_template_id, **kwargs): node_groups = [] for cluster in api.get_clusters(): node_groups += cluster.node_groups for cluster_template in api.get_cluster_templates(): node_groups += cluster_template.node_groups node_group_template_ids = set([node_group.node_group_template_id for node_group in node_groups]) if node_group_template_id in node_group_template_ids: raise ex.InvalidException( "Node group template %s in use" % node_group_template_id)
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)
def clusters_list(): return u.render(clusters=[c.to_dict() for c in api.get_clusters()])
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)
def clusters_list(): try: return render(clusters=[c.dict for c in api.get_clusters()]) except Exception, e: abort_and_log(500, 'Exception while listing Clusters', e)
def clusters_list(): return u.render(clusters=[c.to_dict() for c in api.get_clusters()])