Пример #1
0
def manage_disk_add_disk(name):
    manage_disk = ManageDisk()
    disk_meta = DiskMeta()
    disk_meta.disk_name = "sanatech" + str(name)
    disk_meta.size = 1
    #disk_meta.password="******"
    #disk_meta.user="******"
    status = manage_disk.add_disk(disk_meta, None, PathType.both, 2)
    logger.info(status)
Пример #2
0
def add_disk(args):
    md = ManageDisk()
    for i in range(0, int(args.n)):
        disk_meta = DiskMeta()
        disk_meta.disk_name = "auto " + str(uuid.uuid4()).replace("-", " ")
        disk_meta.size = int(args.s)
        status = md.add_disk(disk_meta, None, PathType.both, int(args.p))
        if status > 0:
            print "Disk number {} is created".format(i)
        else:
            print "Disk number {} can not create, status error is {}.".format(
                i, status)
Пример #3
0
def manage_disk_add_disk_ips(name):
    manage_disk = ManageDisk()
    disk_meta = DiskMeta()
    disk_meta.disk_name = "sanatech" + str(name)
    disk_meta.size = 1
    disk_meta.password = "******"
    disk_meta.user = "******"
    ips = []
    ips.append("192.168.57.200")
    ips.append("192.168.57.201")
    status = manage_disk.add_disk(disk_meta, ips, PathType.both, 2, False,
                                  False)
    logger.info(status)
Пример #4
0
def save_disk():
    if request.method == 'POST':
        try:
            failed_pools = int(request.form['failed_pools'])
            activePaths = int(request.form['ActivePaths'])
            if activePaths >= 3:
                automatic_ip = "Yes"
            else:
                automatic_ip = request.form['orpUseFirstRange']
            if automatic_ip == "Yes" and failed_pools > 0:
                session['err'] = "ui_admin_add_disk_while_pool_inactive"
                return redirect(url_for('disk_controller.add_disk'), 307)
            disk = DiskMeta()
            disk.size = int(request.form['diskSize'])
            disk.disk_name = request.form['diskName']
            disk.pool = request.form['pool']
            if request.form['pool_type'] == "erasure":
                disk.data_pool = request.form['erasure_pool']
            else:
                disk.data_pool = ""

            if 'orpUseFirstRange' not in request.values:
                isAutomaticIp = "Yes"
            else:
                isAutomaticIp = request.form['orpUseFirstRange']

            activePathsCount = int(request.form['ActivePaths'])
            if activePathsCount >= 3:
                isAutomaticIp = "Yes"
            path_type = int(request.form['ISCSISubnet'])
            if path_type == 1:
                path_type = PathType.iscsi_subnet1
            elif path_type == 2:
                path_type = PathType.iscsi_subnet2
            elif path_type == 3:
                path_type = PathType.both
            manual_ips = []

            if isAutomaticIp != "Yes":
                manual_ips.append(request.form['path1'])
                isAutomaticIp = False
                if activePathsCount == 2:
                    manual_ips.append(request.form['path2'])
            else:
                isAutomaticIp = True

            disk.orpUseFirstRange = isAutomaticIp
            disk.ISCSISubnet = int(request.form['ISCSISubnet'])

            usedACL = request.form['orpACL']
            if usedACL == "Iqn":
                disk.acl = request.form['IqnVal']
            else:
                disk.acl = ""

            usedAutentication = request.form['orpAuth']
            if usedAutentication == "Yes":
                auth_auto = False
                disk.user = request.form['UserName']
                disk.password = request.form['Password']
            else:
                auth_auto = True

            enable_rep = request.form['replication']
            if enable_rep == "yes":
                disk.is_replication_target = True
            manage_config = ManageConfig()
            subnet1_info = manage_config.get_iscsi1_subnet()
            subnet2_info = manage_config.get_iscsi2_subnet()
            disk.subnet1 = subnet1_info.subnet_mask
            manageDisk = ManageDisk()
            status = manageDisk.add_disk(disk, manual_ips, path_type,
                                         activePathsCount, auth_auto,
                                         isAutomaticIp, disk.pool)
            if status == ManageDiskStatus.done:
                # session['success'] = "ui_admin_add_disk_success"
                return redirect(url_for('disk_controller.disk_list'))

            elif status == ManageDiskStatus.done_metaNo:
                session[
                    'success'] = "ui_admin_add_disk_created_with_no_metadata"
                return redirect(url_for('disk_controller.disk_list'))

            elif status == ManageDiskStatus.error:
                session['err'] = "ui_admin_add_disk_error"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.disk_created_cant_start:
                session['warning'] = "ui_admin_add_disk_created_not_start"
                return redirect(url_for('disk_controller.disk_list'))

            elif status == ManageDiskStatus.data_missing:
                session['err'] = "ui_admin_manage_disk_data_missing"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.disk_meta_cant_read:
                session[
                    'warning'] = "ui_admin_add_disk_error_created_not_read_metadata"
                return redirect(url_for('disk_controller.disk_list'))

            elif status == ManageDiskStatus.disk_exists:
                session['err'] = "ui_admin_manage_disk_exist"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.disk_name_exists:
                session['err'] = "ui_admin_manage_disk_name_exist"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.ip_out_of_range:
                session['err'] = "ui_admin_manage_disk_no_auto_ip"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.wrong_subnet:
                session['err'] = "ui_admin_manage_disk_wrong_subnet"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.wrong_data:
                session['err'] = "ui_admin_manage_disk_subnet_count"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.used_already:
                session['err'] = "ui_admin_manage_disk_used_already"
                return redirect(url_for('disk_controller.add_disk'), 307)

            elif status == ManageDiskStatus.disk_get__list_error:
                session['err'] = "ui_admin_manage_disk_disk_get_list_error"
                return redirect(url_for('disk_controller.add_disk'), 307)

        except Exception as e:
            session['err'] = "ui_admin_add_disk_error"
            logger.error(e)
            return redirect(url_for('disk_controller.add_disk'), 307)