def cluster_create(context, values): values = values.copy() cluster = m.Cluster() node_groups = values.pop("node_groups", []) cluster.update(values) session = get_session() with session.begin(): try: cluster.save(session=session) except db_exc.DBDuplicateEntry as e: raise ex.DBDuplicateEntry("Duplicate entry for Cluster: %s" % e.columns) try: for ng in node_groups: node_group = m.NodeGroup() node_group.update({"cluster_id": cluster.id}) node_group.update(ng) node_group.save(session=session) except db_exc.DBDuplicateEntry as e: raise ex.DBDuplicateEntry("Duplicate entry for NodeGroup: %s" % e.columns) return cluster_get(context, cluster.id)
def node_group_add(context, cluster_id, values): session = get_session() with session.begin(): node_group = m.NodeGroup() node_group.update({"cluster_id": cluster_id}) node_group.update(values) node_group.save(session=session) return node_group.id
def node_group_add(context, cluster_id, values): session = get_session() with session.begin(): cluster = _cluster_get(context, session, cluster_id) if not cluster: raise ex.NotFoundException(cluster_id, "Cluster id '%s' not found!") node_group = m.NodeGroup() node_group.update({"cluster_id": cluster_id}) node_group.update(values) session.add(node_group) return node_group.id
def cluster_create(context, values): values = values.copy() cluster = m.Cluster() node_groups = values.pop("node_groups", []) cluster.update(values) session = get_session() with session.begin(): try: cluster.save(session=session) for ng in node_groups: node_group = m.NodeGroup() node_group.update({"cluster_id": cluster.id}) node_group.update(ng) node_group.save(session=session) except db_exc.DBDuplicateEntry as e: # raise exception about duplicated columns (e.columns) raise RuntimeError("DBDuplicateEntry: %s" % e.columns) return cluster_get(context, cluster.id)