integralstor / integralstor_gridcell

Gluster/ZFS based open source scale-out storage system
1 stars 3 forks source link

Input validation and need to parse only single input from user while configuring first_time_setup(94 option) in gridcell #187

Open gugupy opened 6 years ago

gugupy commented 6 years ago

Gridcell version: release-g2.1

Issue: While configuring first_time_setup(94 option) It's not validating user input. Due to this, the whole setup going to mess up. Need to take only single input from the user and should validate the value from the user.

raamsri commented 6 years ago

@GuGu910 @purushotham-s Would you like to give it a try? The fix is fairly simple.

You will probably need to start looking from here https://github.com/integralstor/integralstor_gridcell/blob/151b51785b7ad9543fd4c10c1c51feacdc3a6b40/scripts/python/first_time_setup.py#L559

        # Create the gluster trusted storage pool
        do = raw_input("Create the distributed storage pool?")
        if do == 'y':
            print 'Creating the distributed storage pool.'
            for admin_gridcell in admin_gridcells:
                if admin_gridcell != me:
                    d, err = gluster_trusted_pools.add_a_gridcell_to_gluster_pool(
                        admin_gridcell)
                    if err:
                        raise Exception(err)
            print 'Creating the distributed storage pool.. Done.'
            print

The if block is not handled well here and few more places following this code block.

gugupy commented 6 years ago

@six-k I will check.

gugupy commented 6 years ago

@RamSri Is new code available on the PXE server?


Thanks & Regards Gughanathan M Technical Support Engineer +91-9886634271

Datalifecycle.com Pvt.Ltd., E Mail: support@datalifecycle.com | URL: www.datalifecycle.com Bangalore: +91-80-2334 4986

On Wed, Jan 10, 2018 at 1:31 PM, Raamsri notifications@github.com wrote:

@GuGu910 https://github.com/gugu910 @purushotham-s https://github.com/purushotham-s Would you like to give it a try? The fix is fairly simple.

You will probably need to start looking from here https://github.com/ integralstor/integralstor_gridcell/blob/151b51785b7ad9543fd4c10c1c51fe acdc3a6b40/scripts/python/first_time_setup.py#L559

    # Create the gluster trusted storage pool
    do = raw_input("Create the distributed storage pool?")
    if do == 'y':
        print 'Creating the distributed storage pool.'
        for admin_gridcell in admin_gridcells:
            if admin_gridcell != me:
                d, err = gluster_trusted_pools.add_a_gridcell_to_gluster_pool(
                    admin_gridcell)
                if err:
                    raise Exception(err)
        print 'Creating the distributed storage pool.. Done.'
        print

The if block is not handled well here and few more places following this code block.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/integralstor/integralstor_gridcell/issues/187#issuecomment-356527955, or mute the thread https://github.com/notifications/unsubscribe-auth/Aa1S4nIC60UNbJJlOU41nxi4kVdS07i-ks5tJG5MgaJpZM4RY6-U .

raamsri commented 6 years ago

Yes, it should be.

On Wed, Jan 10, 2018 at 4:20 PM, GuGu910 notifications@github.com wrote:

@RamSri Is new code available on the PXE server?


Thanks & Regards Gughanathan M Technical Support Engineer +91-9886634271

Datalifecycle.com Pvt.Ltd., E Mail: support@datalifecycle.com | URL: www.datalifecycle.com Bangalore: +91-80-2334 4986

On Wed, Jan 10, 2018 at 1:31 PM, Raamsri notifications@github.com wrote:

@GuGu910 https://github.com/gugu910 @purushotham-s https://github.com/purushotham-s Would you like to give it a try? The fix is fairly simple.

You will probably need to start looking from here https://github.com/ integralstor/integralstor_gridcell/blob/151b51785b7ad9543fd4c10c1c51fe acdc3a6b40/scripts/python/first_time_setup.py#L559

Create the gluster trusted storage pool

do = raw_input("Create the distributed storage pool?") if do == 'y': print 'Creating the distributed storage pool.' for admin_gridcell in admin_gridcells: if admin_gridcell != me: d, err = gluster_trusted_pools.add_a_gridcell_to_gluster_pool( admin_gridcell) if err: raise Exception(err) print 'Creating the distributed storage pool.. Done.' print

The if block is not handled well here and few more places following this code block.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/integralstor/integralstor_gridcell/issues/187# issuecomment-356527955, or mute the thread https://github.com/notifications/unsubscribe-auth/ Aa1S4nIC60UNbJJlOU41nxi4kVdS07i-ks5tJG5MgaJpZM4RY6-U .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/integralstor/integralstor_gridcell/issues/187#issuecomment-356567106, or mute the thread https://github.com/notifications/unsubscribe-auth/AUICX7uw1zlDYZGm2SwrN0apxUzv2hSIks5tJJYJgaJpZM4RY6-U .

gugupy commented 6 years ago
    # Create the gluster trusted storage pool
    dis_strg = False
    while dis_strg is False:
        do = raw_input("Create the distributed storage pool?(y/n)")
        if do == 'y':
            print 'Creating the distributed storage pool.'
            for admin_gridcell in admin_gridcells:
                if admin_gridcell != me:
                    d, err = gluster_trusted_pools.add_a_gridcell_to_gluster_pool(admin_gridcell)
                    if err:
                        raise Exception(err)
            print 'Creating the distributed storage pool.. Done.'
            print
            break
        elif do == 'n':
            undo_setup()
        else:
            print 'Please enter a valid input?'
            dis_strg = False

@six-k I hope above code will validate the user input. RamSri can you check the code?

raamsri commented 6 years ago

@GuGu910 We can make it a little more cleaner. Try something of this sort:

        # Create the gluster trusted storage pool

        while (True):
            do = raw_input("Create the distributed storage pool?(y/n)")
            if do.lower() == 'y':
                print 'Creating the distributed storage pool.'
                for admin_gridcell in admin_gridcells:
                    if admin_gridcell != me:
                        d, err = gluster_trusted_pools.add_a_gridcell_to_gluster_pool(admin_gridcell)
                        if err:
                            raise Exception(err)
                print 'Creating the distributed storage pool.. Done.'
                print
                break
            elif do.lower() == 'n':
                break
            print 'Valid inputs are "Y/y" and "N/n"'
raamsri commented 6 years ago

It would be nice if you fork this repo, push the changes to a new branch on your forked repo and send a PR. It's easier to review code on a PR than here.

gugupy commented 6 years ago

Yeah, I will try.


Thanks & Regards Gughanathan M Technical Support Engineer +91-9886634271

Datalifecycle.com Pvt.Ltd., E Mail: support@datalifecycle.com | URL: www.datalifecycle.com Bangalore: +91-80-2334 4986

On Thu, Jan 11, 2018 at 11:23 AM, Raamsri notifications@github.com wrote:

@GuGu910 https://github.com/gugu910 We can make it a little more cleaner. Try something of this sort:

    # Create the gluster trusted storage pool

    while (True):
        do = raw_input("Create the distributed storage pool?(y/n)")
        if do.lower() == 'y':
            print 'Creating the distributed storage pool.'
            for admin_gridcell in admin_gridcells:
                if admin_gridcell != me:
                    d, err = gluster_trusted_pools.add_a_gridcell_to_gluster_pool(admin_gridcell)
                    if err:
                        raise Exception(err)
            print 'Creating the distributed storage pool.. Done.'
            print
            break
        elif do.lower() == 'n':
            break
        print 'Valid inputs are "Y/y" and "N/n"'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/integralstor/integralstor_gridcell/issues/187#issuecomment-356833926, or mute the thread https://github.com/notifications/unsubscribe-auth/Aa1S4pSM3acuiwYeBot794iDVYbZ2nugks5tJaHggaJpZM4RY6-U .