예제 #1
0
 def action(self, request, obj_id):
     LOG.error("CEPH_LOG PRESENTPOOL: ACTION")
     LOG.error(obj_id)
     data = self.table.get_object_by_id(obj_id)
     LOG.error(data)
     LOG.error("CEPH_LOG PRESENTPOOL: ACTION >")
     vsmapi.present_pool(request, [obj_id,])
     messages.success(request, "Present Pool %s Success" % data['name'])
예제 #2
0
 def action(self, request, obj_id):
     LOG.error("CEPH_LOG PRESENTPOOL: ACTION")
     LOG.error(obj_id)
     data = self.table.get_object_by_id(obj_id)
     LOG.error(data)
     LOG.error("CEPH_LOG PRESENTPOOL: ACTION >")
     vsmapi.present_pool(request, [obj_id,])
     messages.success(request, "Present Pool %s Success" % data['name'])
예제 #3
0
def PoolsAction(request, action):

    post_data = request.raw_post_data
    data = json.loads(post_data)
    # TODO add cluster_id in data
    if not len(data):
        status = "error"
        msg = "No pool selected"
    else:
        # TODO add cluster_id in data
        for i in range(0, len(data)):
            data[i]['cluster_id'] = 1
        # TODO add cluster_id in data

        if action == "present":
            vsmapi.present_pool(request, [x['id'] for x in data])
            status = "info"
            msg = "Begin to Present Pools!"

    resp = dict(message=msg, status=status, data="")
    resp = json.dumps(resp)
    return HttpResponse(resp)
예제 #4
0
def PoolsAction(request, action):

    post_data = request.raw_post_data
    data = json.loads(post_data)
    # TODO add cluster_id in data
    if not len(data):
        status = "error"
        msg = "No pool selected"
    else:
        # TODO add cluster_id in data
        for i in range(0, len(data)):
            data[i]['cluster_id'] = 1
        # TODO add cluster_id in data

        if action == "present":
            vsmapi.present_pool(request, [x['id'] for x in data])
            status = "info"
            msg = "Begin to Present Pools!"

    resp = dict(message=msg, status=status, data="")
    resp = json.dumps(resp)
    return HttpResponse(resp)
예제 #5
0
def PoolsAction(request, action):
    data = json.loads(request.body)
    msg = ""
    status = ""
    if not len(data):
        status = "error"
        msg = "No pool selected"
    else:
        # TODO add cluster_id in data
        # for i in range(0, len(data)):
        #     data[i]['cluster_id'] = 1

        if action == "present":
            print data
            pools = []
            for x in data:
                cinder_volume_host = x['cinder_volume_host']
                if cinder_volume_host == "" or cinder_volume_host == None:
                    status = "error"
                    msg = "The Cinder Volume Host is null"
                pools.append({
                    'pool_id': x['id'],
                    'cinder_volume_host': cinder_volume_host,
                    'appnode_id': x['appnode_id']
                })
            if msg == "" and status == "":
                print "========Start Present Pools==========="
                result = vsmapi.present_pool(request, pools)
                print result
                host_list = ""
                for host in result['host']:
                    host_list = host + "," + host_list
                if result['status'] == "bad":
                    status = "warning"
                    msg = "Not found crudini commmand in host: %s" % host_list
                elif result['status'] == "unreachable":
                    status = "warning"
                    msg = "Please check ssh with no password between vsm controller and host: %s" % host_list
                else:
                    status = "info"
                    msg = "Begin to Present Pools!"
                print "========End Present Pools==========="

    resp = dict(message=msg, status=status, data="")
    resp = json.dumps(resp)
    return HttpResponse(resp)
예제 #6
0
def PoolsAction(request, action):
    data = json.loads(request.body)
    msg = ""
    status = ""
    if not len(data):
        status = "error"
        msg = "No pool selected"
    else:
        # TODO add cluster_id in data
        # for i in range(0, len(data)):
        #     data[i]['cluster_id'] = 1

        if action == "present":
            print data
            pools = []
            for x in data:
                cinder_volume_host = x['cinder_volume_host']
                if cinder_volume_host == "" or cinder_volume_host == None:
                    status = "error"
                    msg = "The Cinder Volume Host is null"
                pools.append({'pool_id': x['id'], 'cinder_volume_host': cinder_volume_host, 'appnode_id': x['appnode_id']})
            if msg == "" and status == "":
                print "========Start Present Pools==========="
                result = vsmapi.present_pool(request, pools)
                print result
                host_list = ""
                for host in result['host']:
                    host_list = host + "," + host_list
                if result['status'] == "bad":
                    status = "warning"
                    msg = "Not found crudini commmand in host: %s" % host_list
                elif result['status'] == "unreachable":
                    status = "warning"
                    msg = "Please check ssh with no password between vsm controller and host: %s" % host_list
                else:
                    status = "info"
                    msg = "Begin to Present Pools!"
                print "========End Present Pools==========="

    resp = dict(message=msg, status=status, data="")
    resp = json.dumps(resp)
    return HttpResponse(resp)
예제 #7
0
def PoolsAction(request, action):
    data = json.loads(request.body)
    msg = ""
    status = ""
    # glance only need to present one pool
    as_glance_store_pool_num = 0
    for info in data:
        if info["as_glance_store_pool"] == True:
            as_glance_store_pool_num += 1
    if as_glance_store_pool_num > 1:
        msg = "more than one pool as glance backend"
        status = "error"
        resp = dict(message=msg, status=status, data="")
        resp = json.dumps(resp)
        return HttpResponse(resp)

    if as_glance_store_pool_num:
        pool_usages = vsmapi.pool_usages(request)
        for pool_usage in pool_usages:
            print pool_usage.as_glance_store_pool
            if pool_usage.as_glance_store_pool:
                msg = "there is one pool as glance backend now"
                status = "error"
                resp = dict(message=msg, status=status, data="")
                resp = json.dumps(resp)
                return HttpResponse(resp)

    if not len(data):
        status = "error"
        msg = "No pool selected"
    else:
        # TODO add cluster_id in data

        if action == "present":
            print data
            pools = []
            for x in data:
                cinder_volume_host = x['cinder_volume_host']
                if (cinder_volume_host == "" or cinder_volume_host == None) and \
                        (x['as_glance_store_pool'] == "" or x['as_glance_store_pool'] == None):
                    status = "error"
                    msg = "The Cinder Volume Host and As Glance Store Pool are all null"
                pools.append({'pool_id': x['id'],
                              'cinder_volume_host': cinder_volume_host,
                              'appnode_id': x['appnode_id'],
                              'as_glance_store_pool': x['as_glance_store_pool']})
            if msg == "" and status == "":
                print "========Start Present Pools==========="
                result = vsmapi.present_pool(request, pools)
                print result
                host_list = ""
                for host in result['host']:
                    host_list = host + "," + host_list
                if result['status'] == "bad":
                    status = "warning"
                    msg = "Not found crudini commmand in host: %s" % host_list
                elif result['status'] == "unreachable":
                    status = "warning"
                    msg = "Please check ssh with no password between vsm controller and host: %s" % host_list
                else:
                    status = "info"
                    msg = "Begin to Present Pools!"
                print "========End Present Pools==========="

    resp = dict(message=msg, status=status, data="")
    resp = json.dumps(resp)
    return HttpResponse(resp)