Revision 121f3bc0 image_creator/os_type/unix.py

b/image_creator/os_type/unix.py
1
# -*- coding: utf-8 -*-
2
#
1 3
# Copyright 2012 GRNET S.A. All rights reserved.
2 4
#
3 5
# Redistribution and use in source and binary forms, with or
......
31 33
# interpreted as representing official policies, either expressed
32 34
# or implied, of GRNET S.A.
33 35

  
36
"""This module hosts OS-specific code common to all Unix-like OSs."""
37

  
34 38
import re
35 39

  
36 40
from image_creator.os_type import OSBase, sysprep
......
75 79
            try:
76 80
                self.g.mount_options(mopts, dev, mp)
77 81
            except RuntimeError as msg:
78
                if mp in critical_mpoint:
82
                if mp in critical_mpoints:
79 83
                    self.out.warn('unable to mount %s. Reason: %s' % (mp, msg))
80 84
                    return False
81 85
                else:
......
90 94
        if print_header:
91 95
            self.out.output('Removing files under /var/cache')
92 96

  
93
        self.foreach_file('/var/cache', self.g.rm, ftype='r')
97
        self._foreach_file('/var/cache', self.g.rm, ftype='r')
94 98

  
95 99
    @sysprep()
96 100
    def cleanup_tmp(self, print_header=True):
......
99 103
        if print_header:
100 104
            self.out.output('Removing files under /tmp and /var/tmp')
101 105

  
102
        self.foreach_file('/tmp', self.g.rm_rf, maxdepth=1)
103
        self.foreach_file('/var/tmp', self.g.rm_rf, maxdepth=1)
106
        self._foreach_file('/tmp', self.g.rm_rf, maxdepth=1)
107
        self._foreach_file('/var/tmp', self.g.rm_rf, maxdepth=1)
104 108

  
105 109
    @sysprep()
106 110
    def cleanup_log(self, print_header=True):
......
109 113
        if print_header:
110 114
            self.out.output('Emptying all files under /var/log')
111 115

  
112
        self.foreach_file('/var/log', self.g.truncate, ftype='r')
116
        self._foreach_file('/var/log', self.g.truncate, ftype='r')
113 117

  
114 118
    @sysprep(enabled=False)
115 119
    def cleanup_mail(self, print_header=True):
......
119 123
            self.out.output('Removing files under /var/mail & /var/spool/mail')
120 124

  
121 125
        if self.g.is_dir('/var/spool/mail'):
122
            self.foreach_file('/var/spool/mail', self.g.rm_rf, maxdepth=1)
126
            self._foreach_file('/var/spool/mail', self.g.rm_rf, maxdepth=1)
123 127

  
124
        self.foreach_file('/var/mail', self.g.rm_rf, maxdepth=1)
128
        self._foreach_file('/var/mail', self.g.rm_rf, maxdepth=1)
125 129

  
126 130
    @sysprep()
127 131
    def cleanup_userdata(self, print_header=True):
......
129 133

  
130 134
        homedirs = ['/root']
131 135
        if self.g.is_dir('/home/'):
132
            homedirs += self.ls('/home/')
136
            homedirs += self._ls('/home/')
133 137

  
134 138
        if print_header:
135 139
            self.out.output("Removing sensitive user data under %s" %
......
141 145
                if self.g.is_file(fname):
142 146
                    self.g.scrub_file(fname)
143 147
                elif self.g.is_dir(fname):
144
                    self.foreach_file(fname, self.g.scrub_file, ftype='r')
148
                    self._foreach_file(fname, self.g.scrub_file, ftype='r')
145 149

  
146 150
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :

Also available in: Unified diff