#coding:utf-8

import os
import sys
import sunhpc
import shutil
import textwrap
import subprocess
class Command(sunhpc.commands.pxelinux.build.command):
    """
    Build the nodes configure for the sunhpc cluster.

    <arg type='string' name='hosts'>
    supply an host and execute the nodes configure.
    </arg>

    <param type='Bool' name='Quiet'>
    Whether to output detailed information, default: no
    </param>
    
    <example cmd='pxelinux build nodes cluster'>
    Example Modify the configuration of an "cluster" node.
    </example>
    """
    def run(self, params, args):

        (quiet, ) = self.fillParams([('quiet', 'no')])
        q = self.str2bool(quiet)

        if not len(args):
            self.msg('must supply one host.', 'a')

        host = args[0]
        control = self.db.getHostAttr('localhost', 'Kickstart_PrivateHostname')
        if host == control:
            # build the cluster node
            self.msg('Starting build the %s node configure...' % host)
            self.loadModules('control')
        else:
            # build the compute node
            self.msg('Starting build the %s node configure...' % host)
            self.loadModules('compute')

RollName = "base"



























