# Path: image_creator/util.py
# class FatalError(Exception):
#     """Fatal Error exception of snf-image-creator"""
#     pass
# 
# Path: image_creator/bootloader.py
# def vbr_bootinfo(vbr):
#     """Inspect a Volume Boot Record and return the installed bootloader"""
#     if vbr[0x80:0x82] in VBR_SIG2_NONE:
#         return "none"
# 
#     try:
#         ret = VBR_SIG2[vbr[0x80:0x82]]
#     except KeyError:
#         try:
#             ret = VBR_SIG4[vbr[0x80:0x84]]
#         except KeyError:
#             return "unknown"
# 
#     return MBR_LDR[ret]
# 
# Path: image_creator/distro/unix.py
# DESKTOPSESSIONS = {
#     # Put the most popular GUIs first
#     ('startkde',): 'KDE',
#     ('gnome-session', 'gnomesession'): 'GNOME',
#     ('unity',): 'Unity',
#     ('xfce4-session', 'startxfce4', 'xfwm4'): 'Xfce',
#     ('startlxde', 'lxsession'): 'LXDE',
#     ('mate-session',): 'MATE',
#     ('cinnamon', 'gnome-session-cinnamon', 'cinnamon-session'): 'Cinnamon',
#     ('enlightenment',): 'Enlightenment',
# 
#     ('aewm',): 'aewm',
#     ('afterstep',): 'AfterStep',
#     ('amiwm',): 'amiwm',
#     ('awesome',): 'awesome',
#     ('blackbox',): 'Blackbox',
#     ('ctwm',): 'CTWM',
#     ('dwm',): 'dwm',
#     ('epiwm',): 'EPIwm',
#     ('fluxbox', 'startfluxbox'): 'Fluxbox',
#     ('flwm',): 'flvm',
#     ('fvwm',): 'FVWM',
#     ('fvwm2',): 'FVWM',
#     ('fvwm95',): 'FVWM95',
#     ('golem',): 'Golem',
#     ('i3',): 'i3',
#     ('icewm', 'icewm-session'): 'IceVM',
#     ('ion', 'ion2', 'ion3'): 'Ion',
#     ('jwm',): "JWM",
#     ('kahakai',): 'Kahakai',
#     ('larswm',): 'larswm',
#     ('mlvwm',): 'MLVWM',
#     ('mwm',): 'Motif Window Manager',
#     ('olvwm',): 'OLVWM',
#     ('olwm',): 'OLWM',
#     ('openbox', 'openbox-session'): 'Openbox',
#     ('particleman', ): 'ParticleMan',
#     ('pekwm',): 'PeKWM',
#     ('pwm', 'pwm2', 'pwm3'): 'PWM',
#     ('qvwm',): 'qvwm',
#     ('rasor-session',): 'Razor-qt',
#     ('ratpoison',): 'Ratpoison',
#     ('sapphire',): 'Sapphire',
#     ('sawfish',): 'Sawfish',
#     ('sithwm',): 'SithWM',
#     ('startede',): 'EDE',
#     ('startstump',): 'StumpWM',
#     ('starttrinity',): 'TDE',
#     ('twm',): 'twm',
#     ('uwm',): 'UDE',
#     ('w9wm',): 'w9wm',
#     ('wmaker',): 'WindowMaker',
#     ('wmx',): 'wmx',
#     ('wmi', 'wmii'): 'wmii',
#     ('windowlab',): 'WindowLab',
#     ('xmonad',): 'xmonad',
# }
# X11_EXECUTABLE = 'startx'
# SENSITIVE_USERDATA = [
#     '.history',
#     '.sh_history',
#     '.bash_history',
#     '.zsh_history',
#     '.gnupg',
#     '.ssh',
#     '.kamakirc',
#     '.kamaki.history',
#     '.kamaki.log'
# ]
# def check_sensitive_userdata(value):
#     def __init__(self, image, **kwargs):
#     def _mountpoints(self):
#         def compare(a, b):
#     def _do_mount(self, readonly):
#     def _do_collect_metadata(self):
#     def ssh_connection_options(self, users):
#         def sshd_config():
#     def _cleanup_cache(self):
#     def _cleanup_tmp(self):
#     def _cleanup_log(self):
#     def _cleanup_mail(self):
#     def _cleanup_userdata(self):
# class Unix(OSBase):


import os
import os.path
import re
import tempfile
import yaml
import pkg_resources
from collections import namedtuple
from functools import wraps
from image_creator.util import FatalError
from image_creator.bootloader import vbr_bootinfo
from image_creator.distro.unix import Unix, sysprep, add_sysprep_param
    "mandriva": 19,
    "cirros": 15,
    "pardus": 10
}

CLOUDINIT_FILE_PRIORITY = 60

GRUB1_CONFIG = ['/boot/grub/menu.lst']
GRUB2_CONFIG = ['/boot/grub/grub.cfg',
                '/boot/grub2/grub.cfg']


def cloudinit(method):
    """Decorator that adds a check to run only on cloud-init enabled images"""
    @wraps(method)
    def inner(self):
        if not self.cloud_init:
            self.out.warn("Not a cloud-init enabled image")
            return
        return method(self)
    return inner


class Linux(Unix):
    """OS class for Linux"""
    @add_sysprep_param(
        'bootmenu_timeout', 'posint', 10, "Boot menu timeout in seconds")
    @add_sysprep_param(
        'powerbtn_action', 'string', '/sbin/shutdown -h now',
        "The action that should be executed if the power button is pressed")

# Path: image_creator/util.py
# class FatalError(Exception):
#     """Fatal Error exception of snf-image-creator"""
#     pass
# 
# Path: image_creator/bootloader.py
# def vbr_bootinfo(vbr):
#     """Inspect a Volume Boot Record and return the installed bootloader"""
#     if vbr[0x80:0x82] in VBR_SIG2_NONE:
#         return "none"
# 
#     try:
#         ret = VBR_SIG2[vbr[0x80:0x82]]
#     except KeyError:
#         try:
#             ret = VBR_SIG4[vbr[0x80:0x84]]
#         except KeyError:
#             return "unknown"
# 
#     return MBR_LDR[ret]
# 
# Path: image_creator/distro/unix.py
# DESKTOPSESSIONS = {
#     # Put the most popular GUIs first
#     ('startkde',): 'KDE',
#     ('gnome-session', 'gnomesession'): 'GNOME',
#     ('unity',): 'Unity',
#     ('xfce4-session', 'startxfce4', 'xfwm4'): 'Xfce',
#     ('startlxde', 'lxsession'): 'LXDE',
#     ('mate-session',): 'MATE',
#     ('cinnamon', 'gnome-session-cinnamon', 'cinnamon-session'): 'Cinnamon',
#     ('enlightenment',): 'Enlightenment',
# 
#     ('aewm',): 'aewm',
#     ('afterstep',): 'AfterStep',
#     ('amiwm',): 'amiwm',
#     ('awesome',): 'awesome',
#     ('blackbox',): 'Blackbox',
#     ('ctwm',): 'CTWM',
#     ('dwm',): 'dwm',
#     ('epiwm',): 'EPIwm',
#     ('fluxbox', 'startfluxbox'): 'Fluxbox',
#     ('flwm',): 'flvm',
#     ('fvwm',): 'FVWM',
#     ('fvwm2',): 'FVWM',
#     ('fvwm95',): 'FVWM95',
#     ('golem',): 'Golem',
#     ('i3',): 'i3',
#     ('icewm', 'icewm-session'): 'IceVM',
#     ('ion', 'ion2', 'ion3'): 'Ion',
#     ('jwm',): "JWM",
#     ('kahakai',): 'Kahakai',
#     ('larswm',): 'larswm',
#     ('mlvwm',): 'MLVWM',
#     ('mwm',): 'Motif Window Manager',
#     ('olvwm',): 'OLVWM',
#     ('olwm',): 'OLWM',
#     ('openbox', 'openbox-session'): 'Openbox',
#     ('particleman', ): 'ParticleMan',
#     ('pekwm',): 'PeKWM',
#     ('pwm', 'pwm2', 'pwm3'): 'PWM',
#     ('qvwm',): 'qvwm',
#     ('rasor-session',): 'Razor-qt',
#     ('ratpoison',): 'Ratpoison',
#     ('sapphire',): 'Sapphire',
#     ('sawfish',): 'Sawfish',
#     ('sithwm',): 'SithWM',
#     ('startede',): 'EDE',
#     ('startstump',): 'StumpWM',
#     ('starttrinity',): 'TDE',
#     ('twm',): 'twm',
#     ('uwm',): 'UDE',
#     ('w9wm',): 'w9wm',
#     ('wmaker',): 'WindowMaker',
#     ('wmx',): 'wmx',
#     ('wmi', 'wmii'): 'wmii',
#     ('windowlab',): 'WindowLab',
#     ('xmonad',): 'xmonad',
# }
# X11_EXECUTABLE = 'startx'
# SENSITIVE_USERDATA = [
#     '.history',
#     '.sh_history',
#     '.bash_history',
#     '.zsh_history',
#     '.gnupg',
#     '.ssh',
#     '.kamakirc',
#     '.kamaki.history',
#     '.kamaki.log'
# ]
# def check_sensitive_userdata(value):
#     def __init__(self, image, **kwargs):
#     def _mountpoints(self):
#         def compare(a, b):
#     def _do_mount(self, readonly):
#     def _do_collect_metadata(self):
#     def ssh_connection_options(self, users):
#         def sshd_config():
#     def _cleanup_cache(self):
#     def _cleanup_tmp(self):
#     def _cleanup_log(self):
#     def _cleanup_mail(self):
#     def _cleanup_userdata(self):
# class Unix(OSBase):


# Path: image_creator/distro/linux.py
import os
import os.path
import re
import tempfile
import yaml
import pkg_resources
from collections import namedtuple
from functools import wraps
from image_creator.util import FatalError
from image_creator.bootloader import vbr_bootinfo
from image_creator.distro.unix import Unix, sysprep, add_sysprep_param

    "mandriva": 19,
    "cirros": 15,
    "pardus": 10
}

CLOUDINIT_FILE_PRIORITY = 60

GRUB1_CONFIG = ['/boot/grub/menu.lst']
GRUB2_CONFIG = ['/boot/grub/grub.cfg',
                '/boot/grub2/grub.cfg']


def cloudinit(method):
    """Decorator that adds a check to run only on cloud-init enabled images"""
    @wraps(method)
    def inner(self):
        if not self.cloud_init:
            self.out.warn("Not a cloud-init enabled image")
            return
        return method(self)
    return inner


class Linux(Unix):
    """OS class for Linux"""
    @add_sysprep_param(
        'bootmenu_timeout', 'posint', 10, "Boot menu timeout in seconds")
    @add_sysprep_param(
        'powerbtn_action', 'string', '/sbin/shutdown -h now',
        "The action that should be executed if the power button is pressed")

    @add_sysprep_param(