summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoe VLcek <JoeV@RedHat.com>2012-07-23 13:48:43 -0400
committerJoe VLcek <JoeV@RedHat.com>2012-07-23 13:48:43 -0400
commit3083335d2c2654e2ef0e41a35d4b1bf11f5d5c90 (patch)
treedd5b4d697154374431c127042d2f05bc6242ea55 /cloudinit
parente20958b9d775475dd77c27394d7ccba77a3575b2 (diff)
downloadvyos-cloud-init-3083335d2c2654e2ef0e41a35d4b1bf11f5d5c90.tar.gz
vyos-cloud-init-3083335d2c2654e2ef0e41a35d4b1bf11f5d5c90.zip
pep8, pylint... AltCloud source changes
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/sources/DataSourceAltCloud.py54
1 files changed, 25 insertions, 29 deletions
diff --git a/cloudinit/sources/DataSourceAltCloud.py b/cloudinit/sources/DataSourceAltCloud.py
index 53c7d8d9..27a67e6c 100644
--- a/cloudinit/sources/DataSourceAltCloud.py
+++ b/cloudinit/sources/DataSourceAltCloud.py
@@ -21,11 +21,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import errno
import time
import os
import os.path
-import subprocess
from cloudinit import log as logging
from cloudinit import sources
@@ -34,9 +32,7 @@ from cloudinit.util import ProcessExecutionError
LOG = logging.getLogger(__name__)
-'''
-Needed file paths
-'''
+# Needed file paths
CLOUD_INFO_FILE = '/etc/sysconfig/cloud-info'
MEDIA_DIR = '/media/userdata'
@@ -46,27 +42,24 @@ MEDIA_DIR = '/media/userdata'
DELTACLOUD_USER_DATA_FILE = MEDIA_DIR + '/deltacloud-user-data.txt'
USER_DATA_FILE = MEDIA_DIR + '/user-data.txt'
-'''
-Shell command lists
-'''
-CMD_DMI_SYSTEM = ['/usr/sbin/dmidecode', '--string', 'system-product-name']
+# Shell command lists
+CMD_DMI_SYSTEM = ['/usr/sbin/dmidecode', '--string', 'system-product-name']
CMD_PROBE_FLOPPY = ['/sbin/modprobe', 'floppy']
-CMD_MNT_FLOPPY = ['/bin/mount', '/dev/fd0', MEDIA_DIR]
-CMD_MNT_CDROM = ['/bin/mount', '/dev/cdrom', MEDIA_DIR]
+CMD_MNT_FLOPPY = ['/bin/mount', '/dev/fd0', MEDIA_DIR]
+CMD_MNT_CDROM = ['/bin/mount', '/dev/cdrom', MEDIA_DIR]
-'''
-Retry times and sleep secs between each try
-'''
+# Retry times and sleep secs between each try
RETRY_TIMES = 3
SLEEP_SECS = 3
-META_DATA_NOT_SUPPORTED = {
- 'block-device-mapping' : {},
- 'instance-id' : 455,
- 'local-hostname' : 'localhost',
+META_DATA_NOT_SUPPORTED = {
+ 'block-device-mapping': {},
+ 'instance-id': 455,
+ 'local-hostname': 'localhost',
'placement': {},
}
+
class DataSourceAltCloud(sources.DataSource):
def __init__(self, sys_cfg, distro, paths):
sources.DataSource.__init__(self, sys_cfg, distro, paths)
@@ -177,7 +170,7 @@ class DataSourceAltCloud(sources.DataSource):
def user_data_rhevm(self):
'''
RHEVM specific userdata read
-
+
If on RHEV-M the user data will be contained on the
floppy device in file <USER_DATA_FILE>
To access it:
@@ -187,11 +180,12 @@ class DataSourceAltCloud(sources.DataSource):
mount /dev/fd0 <MEDIA_DIR> # NOTE: -> /dev/
read <MEDIA_DIR>/<USER_DATA_FILE>
'''
-
+
# modprobe floppy
try:
cmd = CMD_PROBE_FLOPPY
(cmd_out, _err) = util.subp(cmd)
+ LOG.debug(('Command: %s\nOutput%s') % (' '.join(cmd), cmd_out))
except ProcessExecutionError, _err:
util.logexc(LOG, (('Failed command: %s\n%s') % \
(' '.join(cmd), _err.message)))
@@ -204,19 +198,20 @@ class DataSourceAltCloud(sources.DataSource):
# mkdir <MEDIA_DIR> dir just in case it isn't already.
try:
os.makedirs(MEDIA_DIR)
- except OSError, (errno, strerror):
- if errno is not 17:
+ except OSError, (_err, strerror):
+ if _err is not 17:
LOG.debug(('makedirs(<MEDIA_DIR>) failed: %s \nError: %s') % \
- (errno, strerror))
+ (_err, strerror))
return False
# mount /dev/fd0 <MEDIA_DIR>
try:
cmd = CMD_MNT_FLOPPY
(cmd_out, _err) = util.subp(cmd)
+ LOG.debug(('Command: %s\nOutput%s') % (' '.join(cmd), cmd_out))
except ProcessExecutionError, _err:
# Ignore failure: already mounted
- if 'ALREADY MOUNTED' not in _err.message.upper():
+ if 'ALREADY MOUNTED' not in str(_err.message).upper():
util.logexc(LOG, (('Failed command: %s\n%s') % \
(' '.join(cmd), _err.message)))
return False
@@ -254,7 +249,7 @@ class DataSourceAltCloud(sources.DataSource):
def user_data_vsphere(self):
'''
VSphere specific userdata read
-
+
If on vSphere the user data will be contained on the
floppy device in file <USER_DATA_FILE>
To access it:
@@ -266,19 +261,20 @@ class DataSourceAltCloud(sources.DataSource):
# mkdir <MEDIA_DIR> dir just in case it isn't already.
try:
os.makedirs(MEDIA_DIR)
- except OSError, (errno, strerror):
- if errno is not 17:
+ except OSError, (_err, strerror):
+ if _err is not 17:
LOG.debug(('makedirs(<MEDIA_DIR>) failed: %s \nError: %s') % \
- (errno, strerror))
+ (_err, strerror))
return False
# mount /dev/cdrom <MEDIA_DIR>
try:
cmd = CMD_MNT_CDROM
(cmd_out, _err) = util.subp(cmd)
+ LOG.debug(('Command: %s\nOutput%s') % (' '.join(cmd), cmd_out))
except ProcessExecutionError, _err:
# Ignore failure: already mounted
- if 'ALREADY MOUNTED' not in _err.message.upper():
+ if 'ALREADY MOUNTED' not in str(_err.message).upper():
LOG.debug(('Failed command: %s\n%s') % \
(' '.join(cmd), _err.message))
return False