码迷,mamicode.com
首页 > 其他好文 > 详细

请忽略我这个弱智写的py3的创建文件系统不会写日后看情况改

时间:2018-09-18 16:11:00      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:dir   app   utf-8   mod   pen   can   --   open   fun   

#!/usr/bin/env python

coding=utf-8

print(‘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

请忽略我这个弱智写的py3的创建文件系统不会写日后看情况改

标签:dir   app   utf-8   mod   pen   can   --   open   fun   

原文地址:http://blog.51cto.com/11592403/2176656

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!