''' created on 2013/17/5 @author: [email protected] ''' import sys import basefunction import yaml import os import shutil from models import Host logger = basefunction.initlog("deploy") dirr = "/opt/openstack" class set_cobbler(): def __init__(self , yamlfile="%s/config/cb.yaml"%dirr): f = open(yamlfile, 'r') self.ya = yaml.load(f) self.os_type = self.ya['deploy_os_type'] f.close() def mount_file(self,os_file): cmd = "umount /mnt" basefunction.run_command(cmd, None, logger) cmd = "mount -o loop %s /mnt" %os_file re = basefunction.run_command(cmd, None, logger) if re == False: cmd = "mount %s /mnt" %os_file re = basefunction.run_command(cmd, None, logger)
baseurl=file://%s/source/%s/install enabled=1 gpgcheck=0"""%(dirr,os_type) f = open("/etc/yum.repos.d/install.repo","w") f.write(strr) f.close() if __name__ == '__main__': if os.path.exists(log_dir) == False: os.mkdir(log_dir) if os.path.exists("%s/nodes" %log_dir) == False: os.mkdir("%s/nodes" %log_dir) logger = basefunction.initlog("install") errorMessage = "" create_repo() rpm_name="telnet telnet-server syslinux cobbler puppet-server Django14 python-celery django-celery rabbitmq-server python-amqplib django-picklefield dhcp vsftpd ntpd" basefunction.install_rpm(rpm_name, None, logger) rpm_name=["telnet","telnet-server","syslinux","cobbler","puppet-server","Django14","python-celery","django-celery","rabbitmq-server","python-amqplib","django-picklefield","vsftpd"] for i in rpm_name: re = basefunction.check_rpm(i, None, logger) if re == False: print "rpm %s not installed" %i sys.exit() cmd = "sed -i \"/server 127.127.1.0/d\" /etc/ntp.conf" basefunction.run_command(cmd, None, logger)
import shutil import logmonitor #import MySQLdb f = open("local.yaml",'r') ya = yaml.load(f) server_ip = ya['cobbler_server']['ip'] f.close() f = open("role.yaml",'r') ya1 = yaml.load(f) f.close() logger = basefunction.initlog() def nc_message(message): ip = ya['cobbler_server']['ip'] name = ya['my_cfg']['hostname'] cmd = ["telnet %s 3336 & " %ip, "sleep 2 ", "echo \"%s:%s\" | nc %s 6666 " %(name,message,ip) ] for i in cmd: basefunction.run_command(i,None,logger) def log_message(message): ip = ya['cobbler_server']['ip'] name = ya['my_cfg']['hostname'] cmd = "telnet %s 3337 & ;sleep 2 ;echo \"%s:%s\" | nc %s 9999" %(ip,name,message,ip)