zoukankan      html  css  js  c++  java
  • 挂载磁盘脚本

    1. #!/usr/bin/python
    2. #coding=utf-8
    3. '''
    4. Created on Nov 4, 2015
    5. install basic system [c2]
    6. @author: Galbraith
    7. '''
    8. from subprocess import call
    9. from os.path import basename
    10. import os
    11. import sys
    12. import commands
    13. def scall(cmd_line):
    14. '''linux shell '''
    15. return call(cmd_line,shell=True)
    16. def findstrinfile(filename, lookup):
    17. '''file str differ check'''
    18. return lookup in open(filename,'rt').read()
    19. def file_check(file_sl):
    20. '''file differ check'''
    21. return os.path.isfile(file_sl)
    22. def dir_check(dir_sl):
    23. '''dir differ check'''
    24. return os.path.exists(dir_sl)
    25. def srun(comm):
    26. '''system command'''
    27. return os.system(comm)
    28. def mount_disk():
    29. '''mount new disk'''
    30. srun('mkdir /data')
    31. srun('mkfs -t ext4 /dev/vdb')
    32. srun('mount /dev/vdb /data')
    33. srun('echo "/dev/vdb /data ext4 defaults 0 0" >> /etc/fstab')
    34. def cat_mount():
    35. mount = commands.getoutput('mount -v')
    36. lines = mount.split(' ')
    37. points = map(lambda line: line.split()[2], lines)
    38. srun('df -h')
    39. print points
    40. def handle():
    41. mount_disk()
    42. cat_mount()
    43. if __name__ == '__main__':
    44. handle()
  • 相关阅读:
    svn命令
    Lambda 表达式
    JAVA 探究NIO
    JAVA I/O系统
    MySQL 锁
    spring boot 集成 zookeeper 搭建微服务架构
    架构演化
    JAVA 集合
    spring boot 发送邮件
    MySQL 隔离级别
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/13329827.html
Copyright © 2011-2022 走看看