How to use vg_remove method in avocado

Best Python code snippet using avocado_python

lvm.py

Source:lvm.py Github

copy

Full Screen

1#! /usr/bin/python32print("content-type: text/html")3print()4print('''<style>5pre{6 color: #654ea3;7 font-weight: bold;8 font-size: 20px;9}10span{11 color: #e5abc6;12 font-weight: bold;13 font-size: 26px;14}15</style>16''')17print('<body style="padding: 40px;">')18print('<h1 style="color:#e5abc6;" >Output</h1>')19import cgi20import subprocess as sp21fs = cgi.FieldStorage()22#---23choice = fs.getvalue("choice")24#---25show_pv = fs.getvalue("show_pv")26#---27show_vg = fs.getvalue("show_vg")28#---29show_lv = fs.getvalue("show_lv")30#---31create_pv = fs.getvalue("create_pv")32#---33create_vg = fs.getvalue("create_vg")34vg_pv1 = fs.getvalue("vg_pv1")35vg_pv2 = fs.getvalue("vg_pv2")36#---37create_lv = fs.getvalue("create_lv")38create_lv_size = fs.getvalue("create_lv_size")39create_lv_vg = fs.getvalue("create_lv_vg")40create_lv_mount = fs.getvalue("create_lv_mount")41#---42extend_lv = fs.getvalue("extend_lv")43extend_lv_vg = fs.getvalue("extend_lv_vg")44extend_lv_size = fs.getvalue("extend_lv_size")45#---46reduce_lv = fs.getvalue("reduce_lv")47reduce_lv_vg = fs.getvalue("reduce_lv_vg")48reduce_lv_size = fs.getvalue("reduce_lv_size")49reduce_lv_mount = fs.getvalue("reduce_lv_mount")50#---51extend_vg = fs.getvalue("extend_vg")52extend_vg_pv = fs.getvalue("extend_vg_pv")53#---54reduce_vg = fs.getvalue("reduce_vg")55reduce_vg_pv = fs.getvalue("reduce_vg_pv")56#---57lv_remove_path = fs.getvalue("lv_remove_path")58#---59vg_remove = fs.getvalue("vg_remove")60#---61pv_remove = fs.getvalue("pv_remove")62#---63create_file = fs.getvalue("create_file")64file_text = fs.getvalue("file_text")65file_folder = fs.getvalue("file_folder")66choice = int(choice)67if choice == 1:68 output = sp.getoutput('sudo fdisk -l')69 print("<pre>{}</pre>".format(output))70elif choice == 2:71 if show_pv == None:72 show_pv = ""73 output = sp.getoutput('sudo pvdisplay '+show_pv)74 print("<span><br>#### Physical Volume/s -> {} ####<br></span>".format(show_pv))75 print("<pre>{}</pre>".format(output))76elif choice == 3:77 if show_vg == None:78 show_vg = ""79 output = sp.getoutput('sudo vgdisplay '+show_vg)80 print("<span><br>#### Volume Group/s -> {} ####</span><br>".format(show_vg))81 print("<pre>{}</pre>".format(output))82elif choice == 4:83 if show_lv == None:84 show_lv = ""85 output = sp.getoutput('sudo lvdisplay '+show_lv)86 print("<span><br>#### Logical Volume/s -> {} ####</span><br>".format(show_lv))87 print("<pre>{}</pre>".format(output))88elif choice == 5:89 output = sp.getoutput('sudo pvcreate '+create_pv)90 print("<span><br>#### Created Physical Volume -> {} ####</span><br>".format(create_pv))91 print("<pre>{}</pre>".format(output))92elif choice == 6:93 output = sp.getoutput('sudo vgcreate '+create_vg+' '+vg_pv1+' '+vg_pv2)94 print("<span><br>#### Created Volume Group -> {} ####</span><br>".format(create_vg))95 print("<pre>{}</pre>".format(output))96elif choice == 7:97 output = sp.getoutput('sudo lvcreate --size {} --name {} {}'.format(create_lv_size,create_lv,create_lv_vg))98 output = sp.getoutput('sudo mkfs.ext4 /dev/{}/{}'.format(create_lv_vg,create_lv))99 output = sp.getoutput('sudo rm -rf {}'.format(create_lv_mount))100 output = sp.getoutput('sudo mkdir {}'.format(create_lv_mount))101 output = sp.getoutput('sudo chown apache {}'.format(create_lv_mount))102 output = sp.getoutput('sudo -u root mount /dev/{}/{} {}'.format(create_lv_vg,create_lv,create_lv_mount))103 print("</span><br>#### 'Created LV! Ready to store files. Mounted to folder {} ####</span><br>".format(create_lv_mount))104 print("<pre>{}</pre>".format(output))105elif choice == 8:106 output = sp.getoutput('sudo lvextend --size {} /dev/{}/{}'.format(extend_lv_size,extend_lv_vg,extend_lv))107 output = sp.getoutput('sudo resize2fs /dev/{}/{}'.format(extend_lv_vg,extend_lv))108 print("</span><br>#### Extended LV size -> {} ####</span><br>".format(extend_lv))109 print("<pre>{}</pre>".format(output))110elif choice == 9:111 output = sp.getoutput('sudo umount /dev/{}/{}'.format(reduce_lv_vg,reduce_lv))112 output = sp.getoutput('sudo e2fsck -f /dev/{}/{}'.format(reduce_lv_vg,reduce_lv))113 output = sp.getoutput('sudo resize2fs -f /dev/{}/{} {}'.format(reduce_lv_vg,reduce_lv,reduce_lv_size)) 114 print("<span><br>#### Reduced LV size -> {} ####</span><br>".format(reduce_lv)) 115 print("<pre>{}</pre>".format(output))116 output = sp.getoutput('sudo lvreduce -f --size {} /dev/{}/{}'.format(reduce_lv_size,reduce_lv_vg,reduce_lv))117 print("<pre>{}</pre>".format(output))118 output = sp.getoutput('sudo mount /dev/{}/{} {}'.format(reduce_lv_vg,reduce_lv,reduce_lv_mount))119 print("<pre>{}</pre>".format(output))120elif choice == 10:121 output = sp.getoutput('sudo vgextend {} {}'.format(extend_vg,extend_vg_pv))122 print("<span><br>#### Extended VG size ####</span><br>")123 print("<pre>{}</pre>".format(output))124elif choice == 11:125 output = sp.getoutput('sudo pvmove {}'.format(reduce_vg_pv))126 output = sp.getoutput('sudo vgreduce {} {}'.format(reduce_vg,reduce_vg_pv))127 print("<span><br>#### Reduced VG size ####</span><br>")128 print("<pre>{}</pre>".format(output))129elif choice == 12:130 output = sp.getoutput('sudo umount {}'.format(lv_remove_path))131 output = sp.getoutput('sudo lvremove {} -y'.format(lv_remove_path))132 print("<span><br>#### LV Removed -> {} ####</span><br>".format(lv_remove_path))133 print("<pre>{}</pre>".format(output))134elif choice == 13:135 output = sp.getoutput('sudo vgremove {} -y'.format(vg_remove))136 print("<span><br>#### VG Removed -> {} ####</span><br>".format(vg_remove))137 print("<pre>{}</pre>".format(output))138elif choice == 14:139 output = sp.getoutput('sudo pvremove {} -y'.format(pv_remove))140 print("<span><br>#### PV Removed -> {} ####</span><br>".format(pv_remove))141 print("<pre>{}</pre>".format(output))142elif choice == 15:143 output = sp.getoutput("sudo chown apache /var/www/cgi-bin")144 f = open("{}".format(create_file),'w')145 f.write(file_text)146 f.close()147 output = sp.getoutput("sudo cp {} {}".format(create_file,file_folder))148 print("<span><br>#### File Created ####</span><br>")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful