标签:dir app utf-8 mod pen can -- open fun
#!/usr/bin/env pythonprint(‘echo "- - -" > /sys/class/scsi_host/host0/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host1/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host2/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host3/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host4/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host5/scan‘)
f = open(‘a.txt‘,‘r+‘)
l = []
for i in f.readlines():
l.append(i.split())
f.close()
#print(l)
l1 =[]
for i in l:
l1.append(i[1])
l2 = [‘sdc‘,‘sdd‘,‘sde‘,‘sdf‘,‘sdg‘,‘sdh‘]
def func(n):
s = ‘ ‘
for i in range(n):
s = s + ‘/dev/‘+ l2[0] + ‘ ‘
l2.remove(l2[0])
return s
#print(l1)
#for i in l1:
#a = ‘pvcreate --dataalignment +1M ‘ + i[1]
#print(a)
for i in l:
sd = func(int(i[2]))
print(‘vgcreate ‘ + ‘ ‘ + i[0] + ‘ -s 32M ‘ + sd)
c = ‘lvcreate -L ‘ + i[5] + ‘G ‘ + ‘ -n ‘ + i[4] + ‘ ‘ + ‘-i‘ + ‘ ‘+ i[2] + ‘ ‘ + "-I 64" + ‘ ‘+ i[0]
print(c)
d = ‘mkfs.‘ + i[6] + ‘ ‘ + ‘/dev/‘ + i[0] + ‘/‘ + i[4]
print(d)
e = ‘mkdir -p‘ + ‘ ‘ + i[7] + i[9]
print(e)
print(‘echo ‘ + ‘/dev/‘ + i[0] + ‘/‘ + i[4] + ‘ ‘ + i[7] + ‘ ‘ + ‘ ‘ + i[6] + ‘ defaults 0 0 ‘ + ‘>>/etc/fstab‘)
f = ‘chmod 755 -R ‘ + i[9]
print(f)
g = ‘chown -R‘ + ‘ ‘ + i[8] + ‘ ‘ +i[9]
print(g)
print(‘mount -a‘)
a.txt
vgname pvcreate lvsize pesize lvname
vgdata /dev/sdb 2 32 lvdata 1 ext4 /data root:root /data
vgdata1 /dev/sdc 2 32 lvdata1 2 ext4 /data1 root:root /data1
vgdata2 /dev/sdd 1 32 lvdata2 3 ext4 /data2 root:root /data2
标签:dir app utf-8 mod pen can -- open fun
原文地址:http://blog.51cto.com/11592403/2176656