#coding:utf-8
import textwrap
class Modules(object):
    """
    Configure node install pxeboot.
    """
    def __init__(self, command):
        self.cmd = command

    @property
    def __help__(self):
        info = """
        #==============================================================
        # %s
        #
        # module_path: %s
        # module_name: %s
        #==============================================================
        """ % (self.__doc__.strip(), self.__module__.strip(), self.__repr__())
        return info
        
    def run(self, args):

        content = []
        content.append(self.__help__)
        addr = self.cmd.db.getHostAttr('localhost', 'Kickstart_PrivateAddress')
        base = self.cmd.db.getHostAttr('localhost', 'Kickstart_BaseDir')
        http = "http://%s/%s/%s/%s" % (addr, base, 'sbin', 'setPxeboot.cgi')

        setPxeboot = "wget --no-check-certificate -O /dev/null %s" % http
        content.append(setPxeboot)

        makegrub = "grub2-mkconfig > /boot/grub2/grub.cfg"
        content.append(makegrub)

        self.cmd.ks.addPost(content)
        
    def __repr__(self):
        return "kickstart-pxeboot"
