コード例 #1
0
    def test02_add_nfs_mount(self):
        logs.info(" ***** Add NFS mount point ****")
        self.assertEqual(fit_common.remote_shell(PROXYVARS + "apt-get -y install nfs-kernel-server")['exitcode'],
                         0, "nfs-kernel-server install failure.")
        nfsexports = open("nfsexports", 'w')
        nfsexports.write('/nfs               *(rw,sync,no_subtree_check,no_root_squash,no_all_squash)\n')
        nfsexports.close()
        fit_common.scp_file_to_ora("nfsexports")

        # Making a backup copy of /etc/exports file
        rc = fit_common.remote_shell('test -e /etc/microservices_exports.bak')

        if rc['exitcode'] == 0:
            fit_common.remote_shell('cp /etc/microservices_exports.bak /etc/exports')
        else:
            fit_common.remote_shell('cp /etc/exports /etc/microservices_exports.bak')

        self.assertEqual(fit_common.remote_shell('cat nfsexports >> /etc/exports'
                                                 )['exitcode'], 0, "nfsexports config failure.")

        # Make an nfs mount point
        self.assertEqual(fit_common.remote_shell('sudo mkdir -p /nfs'
                                                 )['exitcode'], 0, "Failed to mkdir /nfs")
        # Ubuntu 14.04 nfs services
        self.assertEqual(fit_common.remote_shell('sudo service nfs-kernel-server start'
                                                 )['exitcode'], 0, "Failed to start nfs-kernel-server")
        # export file system
        self.assertEqual(fit_common.remote_shell('sudo exportfs -a'
                                                 )['exitcode'], 0, "Failed on command exportfs -a")
        # check mount point
        self.assertEqual(fit_common.remote_shell('sudo showmount -e 172.31.128.1'
                                                 )['exitcode'], 0, "Display exported fs")
コード例 #2
0
 def test01_install_rackhd_dependencies(self):
     print "**** Installing RackHD dependencies."
     # update sudoers to preserve proxy environment
     sudoersproxy = open("sudoersproxy", 'w')
     sudoersproxy.write(
         'Defaults env_keep="HOME no_proxy http_proxy https_proxy"\n')
     sudoersproxy.close()
     fit_common.remote_shell('pwd')
     fit_common.scp_file_to_ora("sudoersproxy")
     self.assertEqual(
         fit_common.remote_shell('cp sudoersproxy /etc/sudoers.d/')
         ['exitcode'], 0, "sudoersproxy config failure.")
     os.remove('sudoersproxy')
     # install git
     self.assertEqual(
         fit_common.remote_shell(ENVVARS +
                                 "apt-get -y install git")['exitcode'], 0,
         "Git install failure.")
     self.assertEqual(
         fit_common.remote_shell(ENVVARS + "apt-get -y update")['exitcode'],
         0, "update failure.")
     self.assertEqual(
         fit_common.remote_shell(ENVVARS +
                                 "apt-get -y dist-upgrade")['exitcode'], 0,
         "upgrade failure.")
     self.assertEqual(
         fit_common.remote_shell("git config --global http.sslverify false")
         ['exitcode'], 0, "Git config failure.")
     self.assertEqual(
         fit_common.remote_shell("git config --global http.proxy " +
                                 fit_common.GLOBAL_CONFIG['repos']['proxy'])
         ['exitcode'], 0, "Git proxy config failure.")
コード例 #3
0
ファイル: onrack_stack_init.py プロジェクト: johren/fit_tests
 def test00_update_config(self):
     # this will add proxy settings to default OnRack Config file
     monorail_config = fit_common.rackhdapi('/api/2.0/config')['json']
     monorail_config.update({
         "httpProxies": [{
             "localPath":
             "/mirror",
             "remotePath":
             "/",
             "server":
             fit_common.GLOBAL_CONFIG['repos']['mirror']
         }]
     })
     monorail_json = open('monorail.json', 'w')
     monorail_json.write(
         fit_common.json.dumps(monorail_config, sort_keys=True, indent=4))
     monorail_json.close()
     fit_common.scp_file_to_ora('monorail.json')
     self.assertEqual(
         fit_common.remote_shell('cp monorail.json /opt/onrack/etc/')
         ['exitcode'], 0, "RackHD Config file failure.")
     os.remove('monorail.json')
     print "**** Restart services..."
     fit_common.remote_shell("/opt/onrack/bin/monorail restart")
     fit_common.countdown(30)
     self.assertEqual(
         fit_common.rackhdapi("/api/2.0/config")['status'], 200,
         "Unable to contact Onrack.")
コード例 #4
0
 def test05_install_rackhd_config_files(self):
     print "**** Installing RackHD config files."
     # create RackHD config
     hdconfig = fit_common.fitcfg()['rackhd-config']
     config_json = open('config.json', 'w')
     config_json.write(
         fit_common.json.dumps(hdconfig, sort_keys=True, indent=4))
     config_json.close()
     # AMQP config files
     rabbitmq_config = open('rabbitmq.config', 'w')
     rabbitmq_config.write(
         '[{rabbit,[{tcp_listeners, [5672]},{loopback_users, []}]},{rabbitmq_management,[{listener, [{port,  15672},{ip,"127.0.0.1"}]}]}].'
     )
     rabbitmq_config.close()
     # copy files to ORA
     fit_common.scp_file_to_ora('config.json')
     fit_common.scp_file_to_ora('rabbitmq.config')
     self.assertEqual(
         fit_common.remote_shell('cp config.json /opt/monorail/')
         ['exitcode'], 0, "RackHD Config file failure.")
     self.assertEqual(
         fit_common.remote_shell('cp rabbitmq.config /etc/rabbitmq/')
         ['exitcode'], 0, "AMQP Config file failure.")
     os.remove('config.json')
     os.remove('rabbitmq.config')
     self.assertEqual(
         fit_common.remote_shell(PROXYVARS +
                                 "cd ~/src/on-http && ./install-web-ui.sh")
         ['exitcode'], 0, "web-ui install failure.")
     self.assertEqual(
         fit_common.remote_shell(
             PROXYVARS +
             "cd ~/src/on-http && ./install-swagger-ui.sh")['exitcode'], 0,
         "swagger-ui install failure.")
コード例 #5
0
 def test00_set_auth_user(self):
     print '**** Installing default admin user'
     fit_common.remote_shell('rm auth.json')
     auth_json = open('auth.json', 'w')
     auth_json.write('{"username":"******"api"]["admin_user"] + '", "password":"******"api"]["admin_pass"] + '", "role":"Administrator"}')
     auth_json.close()
     fit_common.scp_file_to_ora('auth.json')
     rc = fit_common.remote_shell("curl -ks -X POST -H 'Content-Type:application/json' https://localhost:" + str(fit_common.GLOBAL_CONFIG['ports']['https']) + "/api/2.0/users -d @auth.json" )
     if rc['exitcode'] != 0:
         print "ALERT: Auth admin user not set! Please manually set the admin user account if https access is desired."
コード例 #6
0
 def test01_set_auth_user(self):
     fit_common.remote_shell('rm auth.json')
     auth_json = open('auth.json', 'w')
     auth_json.write('{"username":"******"api"][0]["admin_user"] + '", "password":"******"api"][0]["admin_pass"] + '", "role":"Administrator"}')
     auth_json.close()
     fit_common.scp_file_to_ora('auth.json')
     rc = fit_common.remote_shell("curl -ks -X POST -H 'Content-Type:application/json' https://localhost:" +
                                  str(fit_common.fitports()['https']) + "/api/2.0/users -d @auth.json")
     if rc['exitcode'] != 0:
         log.info_5("ALERT: Auth admin user not set! Please manually set the admin user account if required.")
コード例 #7
0
 def test01_update_sudoers_info(self):
     # update sudoers to preserve proxy environment
     logs.info(" ***** Update sudoers proxy env ****")
     sudoersproxy = open("sudoersproxy", 'w')
     sudoersproxy.write('Defaults env_keep="HOME http_proxy https_proxy ftp_proxy"\n')
     sudoersproxy.close()
     fit_common.remote_shell('pwd')
     fit_common.scp_file_to_ora("sudoersproxy")
     self.assertEqual(fit_common.remote_shell('cp sudoersproxy /etc/sudoers.d/'
                                              )['exitcode'], 0, "sudoersproxy config failure.")
     os.remove('sudoersproxy')
コード例 #8
0
    def test03_install_docker(self):
        # Check if docker-compose is already installed
        rsp = fit_common.remote_shell("docker -v")
        if rsp['exitcode'] == 0:
            logs.info(" Docker already installed")
            if "Docker version" in rsp['stdout']:
                logs.info(" Docker installed: %s", rsp['stdout'])
        else:
            logs.info(" Install Docker")

            # apt-get update
            command = PROXYVARS + "sudo apt-get update"
            self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "get-update failed.")

            # Getting the docker installation file from docker.com
            command = PROXYVARS + "sudo wget -qO- https://get.docker.com/ | sh"
            self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "Getting docker file from docker.com failed.")

            # Checking the users with whoami command
            command = "sudo usermod -aG docker $(whoami)"
            self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "whoami command failed.")

        # Check if docker-compose is already installed
        rsp = fit_common.remote_shell("docker-compose -v")
        if rsp['exitcode'] == 0:
            logs.info(" docker-compose already installed")
            if "docker-compose version" in rsp['stdout']:
                logs.info(" Docker installed: %s", rsp['stdout'])
        else:
            # Installing python pip
            command = PROXYVARS + "sudo apt-get -y install python-pip"
            self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "Pip install failed.")

            # Installing docker compose
            logs.info(" Install docker-compose")
            command = PROXYVARS + "sudo pip install docker-compose"
            self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "Docker compose install failed.")

        # Setup docker proxy environment
        logs.info(" Setup Docker Proxy")
        dockerproxy = open("dockerproxy", 'w')
        # dockerproxy.write('export http_proxy="http://web.hwimo.lab.emc.com:3128/"\n')
        dockerproxy.write(PROXYVARS)
        dockerproxy.close()
        fit_common.scp_file_to_ora("dockerproxy")
        self.assertEqual(fit_common.remote_shell('cat dockerproxy >> /etc/default/docker'
                                                 )['exitcode'], 0, "adding docker proxy config failed.")
        os.remove('dockerproxy')

        # Restart the docker service
        command = PROXYVARS + "sudo service docker restart"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "Docker service restart failed.")
        time.sleep(60)
コード例 #9
0
 def test03_set_auth_user(self):
     print '**** Installing default admin user'
     fit_common.remote_shell('rm auth.json')
     auth_json = open('auth.json', 'w')
     auth_json.write('{"username":"******"api"]["admin_user"] + '", "password":"******"api"]["admin_pass"] + '", "role":"Administrator"}')
     auth_json.close()
     fit_common.scp_file_to_ora('auth.json')
     rc = fit_common.remote_shell("curl -ks -X POST -H 'Content-Type:application/json' https://localhost:" \
                                  + str(fit_common.GLOBAL_CONFIG['ports']['https']) + "/api/2.0/users -d @auth.json")
     if rc['exitcode'] != 0:
         print "ALERT: Auth admin user not set! Please manually set the admin user account if https access is desired."
コード例 #10
0
 def test01_update_sudoers_info(self):
     # update sudoers to preserve proxy environment
     logs.info(" ***** Update sudoers proxy env ****")
     sudoersproxy = open("sudoersproxy", 'w')
     sudoersproxy.write(
         'Defaults env_keep="HOME http_proxy https_proxy ftp_proxy"\n')
     sudoersproxy.close()
     fit_common.remote_shell('pwd')
     fit_common.scp_file_to_ora("sudoersproxy")
     self.assertEqual(
         fit_common.remote_shell('cp sudoersproxy /etc/sudoers.d/')
         ['exitcode'], 0, "sudoersproxy config failure.")
     os.remove('sudoersproxy')
コード例 #11
0
    def test04_setup_rackhd_docker_services(self):
        # add the .env variables for HOST IP into the ".env" file
        envfile = open("envfile", 'w')
        envfile.write("TAG=latest\n")
        envfile.write("REGISTRY_IP=172.31.128.1\n")
        host_ip = "HOST_IP=" + socket.gethostbyname(fit_common.fitcfg()['rackhd_host']) + "\n"
        envfile.write(host_ip)
        envfile.close()
        fit_common.scp_file_to_ora("envfile")
        self.assertEqual(fit_common.remote_shell('cp envfile /home/onrack/.env'
                                                 )['exitcode'], 0, "copy of env file failed.")
        os.remove('envfile')

        # Get the username and password from config-mn/credentials.json
        username = fit_common.fitcreds()['docker_hub'][0]['username']
        password = fit_common.fitcreds()['docker_hub'][0]['password']
        command = 'cd rackhd/docker/dell; sudo docker login --username='******' --password='******'exitcode'], 0, "Docker login failed.")

        # Docker up consul
        command = "cd rackhd/docker/dell; sudo docker-compose up -d consul"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "Docker up consul failed.")
        time.sleep(30)

        command = "cd rackhd/docker/dell; sudo chmod +x set_config.sh; sudo ./set_config.sh"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "set_config.sh failed.")

        # Docker up the rest of micro service containers
        command = "cd rackhd/docker/dell; sudo docker-compose up -d"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "docker-compose up failed.")
        time.sleep(180)

        # Set port to 8080 in smi config file
        port_var = fit_common.fitports()['http']
        command = "cd rackhd/docker/dell; sudo sed -i 's/9090/" + str(port_var) + "/g' set_rackhd_smi_config.sh"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "set_rackhd_smi_config.sh failed.")

        # Populates smi config file
        command = "cd rackhd/docker/dell; sudo ./set_rackhd_smi_config.sh"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "set_rackhd_smi_config.sh failed.")

        # Replace  callback Uri port from 9988 to 9080 in smi config file
        command = "cd /opt/monorail; sudo sed -i 's/9988/9080/g' smiConfig.json"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "Change port from 9988 to 9080 in smiConfig failed.")

        # Restart on-http service
        command = "sudo service on-http restart"
        self.assertEqual(fit_common.remote_shell(command)['exitcode'], 0, "failed to start on-http service.")
コード例 #12
0
 def test01_install_rackhd_dependencies(self):
     print "**** Installing RackHD dependencies."
     # update sudoers to preserve proxy environment
     sudoersproxy = open("sudoersproxy", 'w')
     sudoersproxy.write('Defaults env_keep="HOME no_proxy http_proxy https_proxy"\n')
     sudoersproxy.close()
     fit_common.scp_file_to_ora("sudoersproxy")
     self.assertEqual(fit_common.remote_shell('cp sudoersproxy /etc/sudoers.d/'
                                               )['exitcode'], 0, "sudoersproxy config failure.")
     os.remove('sudoersproxy')
     # install git
     self.assertEqual(fit_common.remote_shell("apt-get -y install git")['exitcode'], 0, "Git install failure.")
     self.assertEqual(fit_common.remote_shell("apt-get -y update")['exitcode'], 0, "update failure.")
     self.assertEqual(fit_common.remote_shell("apt-get -y dist-upgrade")['exitcode'], 0, "upgrade failure.")
     self.assertEqual(fit_common.remote_shell("git config --global http.proxy " + fit_common.GLOBAL_CONFIG['repos']['proxy']
                                               )['exitcode'], 0, "Git proxy config failure.")
コード例 #13
0
 def test06_startup(self):
     print "Start services."
     startup = open('startup.sh', 'w')
     startup.write('cd ~/;nf start&\n')
     startup.close()
     fit_common.scp_file_to_ora('startup.sh')
     self.assertEqual(fit_common.remote_shell("chmod 777 startup.sh;/etc/init.d/isc-dhcp-server restart")['exitcode'], 0, "dhcp startup failure.")
     self.assertEqual(fit_common.remote_shell("nohup ./startup.sh")['exitcode'], 0, "RackHD startup failure.")
     print "**** Check installation."
     for dummy in range(0, 10):
         try:
             fit_common.rackhdapi("/api/2.0/config")
         except:
             fit_common.time.sleep(10)
         else:
             break
     self.assertEqual(fit_common.rackhdapi("/api/2.0/config")['status'], 200, "Unable to contact RackHD.")
コード例 #14
0
 def test06_startup(self):
     print "Start services."
     startup = open('startup.sh', 'w')
     startup.write('cd ~/;nf start&\n')
     startup.close()
     fit_common.scp_file_to_ora('startup.sh')
     self.assertEqual(fit_common.remote_shell("chmod 777 startup.sh;/etc/init.d/isc-dhcp-server restart")['exitcode'], 0, "dhcp startup failure.")
     self.assertEqual(fit_common.remote_shell("nohup ./startup.sh")['exitcode'], 0, "RackHD startup failure.")
     print "**** Check installation."
     for dummy in range(0, 10):
         try:
             fit_common.rackhdapi("/api/2.0/config")
         except:
             fit_common.time.sleep(10)
         else:
             break
     self.assertEqual(fit_common.rackhdapi("/api/2.0/config")['status'], 200, "Unable to contact RackHD.")
コード例 #15
0
 def test05_install_rackhd_config_files(self):
     print "**** Installing RackHD config files."
     # create RackHD config
     hdconfig = fit_common.fitcfg()['rackhd-config']
     config_json = open('config.json', 'w')
     config_json.write(fit_common.json.dumps(hdconfig, sort_keys=True, indent=4))
     config_json.close()
     # AMQP config files
     rabbitmq_config = open('rabbitmq.config', 'w')
     rabbitmq_config.write('[{rabbit,[{tcp_listeners, [5672]},{loopback_users, []}]},{rabbitmq_management,[{listener, [{port,  15672},{ip,"127.0.0.1"}]}]}].')
     rabbitmq_config.close()
     # copy files to ORA
     fit_common.scp_file_to_ora('config.json')
     fit_common.scp_file_to_ora('rabbitmq.config')
     self.assertEqual(fit_common.remote_shell('cp config.json /opt/monorail/')['exitcode'], 0, "RackHD Config file failure.")
     self.assertEqual(fit_common.remote_shell('cp rabbitmq.config /etc/rabbitmq/')['exitcode'], 0, "AMQP Config file failure.")
     os.remove('config.json')
     os.remove('rabbitmq.config')
コード例 #16
0
    def test02_add_nfs_mount(self):
        logs.info(" ***** Add NFS mount point ****")
        self.assertEqual(
            fit_common.remote_shell(PROXYVARS +
                                    "apt-get -y install nfs-kernel-server")
            ['exitcode'], 0, "nfs-kernel-server install failure.")
        nfsexports = open("nfsexports", 'w')
        nfsexports.write(
            '/nfs               *(rw,sync,no_subtree_check,no_root_squash,no_all_squash)\n'
        )
        nfsexports.close()
        fit_common.scp_file_to_ora("nfsexports")

        # Making a backup copy of /etc/exports file
        rc = fit_common.remote_shell('test -e /etc/microservices_exports.bak')

        if rc['exitcode'] == 0:
            fit_common.remote_shell(
                'cp /etc/microservices_exports.bak /etc/exports')
        else:
            fit_common.remote_shell(
                'cp /etc/exports /etc/microservices_exports.bak')

        self.assertEqual(
            fit_common.remote_shell('cat nfsexports >> /etc/exports')
            ['exitcode'], 0, "nfsexports config failure.")

        # Make an nfs mount point
        self.assertEqual(
            fit_common.remote_shell('sudo mkdir -p /nfs')['exitcode'], 0,
            "Failed to mkdir /nfs")
        # Ubuntu 14.04 nfs services
        self.assertEqual(
            fit_common.remote_shell('sudo service nfs-kernel-server start')
            ['exitcode'], 0, "Failed to start nfs-kernel-server")
        # export file system
        self.assertEqual(
            fit_common.remote_shell('sudo exportfs -a')['exitcode'], 0,
            "Failed on command exportfs -a")
        # check mount point
        self.assertEqual(
            fit_common.remote_shell('sudo showmount -e 172.31.128.1')
            ['exitcode'], 0, "Display exported fs")
コード例 #17
0
 def test01_install_rackhd_dependencies(self):
     print "**** Installing RackHD dependencies."
     # update sudoers to preserve proxy environment
     sudoersproxy = open("sudoersproxy", "w")
     sudoersproxy.write('Defaults env_keep="HOME no_proxy http_proxy https_proxy"\n')
     sudoersproxy.close()
     fit_common.remote_shell("pwd")
     fit_common.scp_file_to_ora("sudoersproxy")
     self.assertEqual(
         fit_common.remote_shell("cp sudoersproxy /etc/sudoers.d/")["exitcode"], 0, "sudoersproxy config failure."
     )
     os.remove("sudoersproxy")
     # install git
     self.assertEqual(
         fit_common.remote_shell(PROXYVARS + "apt-get -y install git")["exitcode"], 0, "Git install failure."
     )
     self.assertEqual(
         fit_common.remote_shell("git config --global http.sslverify false")["exitcode"], 0, "Git config failure."
     )
     if "proxy" in fit_common.GLOBAL_CONFIG["repos"] and fit_common.GLOBAL_CONFIG["repos"]["proxy"] != "":
         self.assertEqual(
             fit_common.remote_shell("git config --global http.proxy " + fit_common.GLOBAL_CONFIG["repos"]["proxy"])[
                 "exitcode"
             ],
             0,
             "Git proxy config failure.",
         )
     # install Ansible
     self.assertEqual(fit_common.remote_shell(PROXYVARS + "apt-get -y update")["exitcode"], 0, "Update failure.")
     self.assertEqual(
         fit_common.remote_shell(PROXYVARS + "cd ~;apt-get -y install ansible")["exitcode"],
         0,
         "Ansible Install failure.",
     )
     # create startup files
     self.assertEqual(
         fit_common.remote_shell(
             "touch /etc/default/on-dhcp-proxy /etc/default/on-http /etc/default/on-tftp /etc/default/on-syslog /etc/default/on-taskgraph"
         )["exitcode"],
         0,
         "Startup files failure.",
     )
コード例 #18
0
 def test01_install_rackhd_dependencies(self):
     print "**** Installing RackHD dependencies."
     # update sudoers to preserve proxy environment
     sudoersproxy = open("sudoersproxy", 'w')
     sudoersproxy.write(
         'Defaults env_keep="HOME no_proxy http_proxy https_proxy"\n')
     sudoersproxy.close()
     fit_common.remote_shell('pwd')
     fit_common.scp_file_to_ora("sudoersproxy")
     self.assertEqual(
         fit_common.remote_shell('cp sudoersproxy /etc/sudoers.d/')
         ['exitcode'], 0, "sudoersproxy config failure.")
     os.remove('sudoersproxy')
     # install git
     self.assertEqual(
         fit_common.remote_shell(PROXYVARS +
                                 "apt-get -y install git")['exitcode'], 0,
         "Git install failure.")
     self.assertEqual(
         fit_common.remote_shell("git config --global http.sslverify false")
         ['exitcode'], 0, "Git config failure.")
     if 'proxy' in fit_common.GLOBAL_CONFIG[
             'repos'] and fit_common.GLOBAL_CONFIG['repos']['proxy'] != '':
         self.assertEqual(
             fit_common.remote_shell(
                 "git config --global http.proxy " +
                 fit_common.GLOBAL_CONFIG['repos']['proxy'])['exitcode'], 0,
             "Git proxy config failure.")
     # install Ansible
     self.assertEqual(
         fit_common.remote_shell(PROXYVARS +
                                 "apt-get -y update")['exitcode'], 0,
         "Update failure.")
     self.assertEqual(
         fit_common.remote_shell(
             PROXYVARS + "cd ~;apt-get -y install ansible")['exitcode'], 0,
         "Ansible Install failure.")
     # create startup files
     self.assertEqual(
         fit_common.remote_shell(
             "touch /etc/default/on-dhcp-proxy /etc/default/on-http /etc/default/on-tftp /etc/default/on-syslog /etc/default/on-taskgraph"
         )['exitcode'], 0, "Startup files failure.")
コード例 #19
0
 def test01_set_auth_user(self):
     auth_json = open('auth.json', 'w')
     auth_json.write('{"username":"******"api"][0]["admin_user"] + '", "password":"******"api"][0]["admin_pass"] + '", "role":"Administrator"}')
     auth_json.close()
     try:
         # add first user to remote rackhd directly
         return_code = ""
         rackhd_hostname = fit_common.fitargs()['rackhd_host']
         set_auth_url = "https://" + rackhd_hostname + ":" + str(fit_common.fitports()['https']) + "/api/2.0/users"
         rc = fit_common.restful(url_command=set_auth_url, rest_action="post", rest_payload=json.load(open('auth.json')))
         return_code = str(rc['status'])
     except Exception as e:
         log.info_5("ALERT: RackHD is not in localhost, will set first user through ssh{0}".format(e))
     if return_code != '201':
         log.info_5("ALERT: Can't set first user to RackHD https port directly, will set it through ssh")
         # ssh login to rackhd and add first user to localhost rackhd
         fit_common.remote_shell('rm auth.json')
         fit_common.scp_file_to_ora('auth.json')
         rc = fit_common.remote_shell("curl -ks -X POST -H 'Content-Type:application/json' https://localhost:" +
                                      str(fit_common.fitports()['https']) + "/api/2.0/users -d @auth.json")
         if rc['exitcode'] != 0:
             log.info_5("ALERT: Auth admin user not set! Please manually set the admin user account if required.")
コード例 #20
0
 def test01_install_rackhd_dependencies(self):
     print "**** Installing RackHD dependencies."
     # update sudoers to preserve proxy environment
     sudoersproxy = open("sudoersproxy", 'w')
     sudoersproxy.write('Defaults env_keep="HOME no_proxy http_proxy https_proxy"\n')
     sudoersproxy.close()
     fit_common.remote_shell('pwd')
     fit_common.scp_file_to_ora("sudoersproxy")
     self.assertEqual(fit_common.remote_shell('cp sudoersproxy /etc/sudoers.d/'
                                               )['exitcode'], 0, "sudoersproxy config failure.")
     os.remove('sudoersproxy')
     # install git
     self.assertEqual(fit_common.remote_shell(PROXYVARS + "apt-get -y install git")['exitcode'], 0, "Git install failure.")
     self.assertEqual(fit_common.remote_shell("git config --global http.sslverify false")['exitcode'], 0, "Git config failure.")
     if fit_common.fitproxy()['host'] != '':
         self.assertEqual(fit_common.remote_shell("git config --global http.proxy http://" + fit_common.fitproxy()['host'] + ':' + fit_common.fitproxy()['port']
                                               )['exitcode'], 0, "Git proxy config failure.")
     # install Ansible
     self.assertEqual(fit_common.remote_shell(PROXYVARS + "apt-get -y update")['exitcode'], 0, "Update failure.")
     self.assertEqual(fit_common.remote_shell(PROXYVARS + "cd ~;apt-get -y install ansible")['exitcode'], 0, "Ansible Install failure.")
     # create startup files
     self.assertEqual(fit_common.remote_shell(
         "touch /etc/default/on-dhcp-proxy /etc/default/on-http /etc/default/on-tftp /etc/default/on-syslog /etc/default/on-taskgraph"
         )['exitcode'], 0, "Startup files failure.")
コード例 #21
0
 def test04_update_config(self):
     print "**** Updating OnRack config."
     hdconfig = fit_common.rackhdapi("/api/2.0/config")['json']
     hdconfig["httpProxies"] = [{
                     "localPath": "/mirror",
                     "remotePath": "/",
                     "server": fit_common.GLOBAL_CONFIG['repos']['mirror']
                 }]
     config_json = open('config.json', 'w')
     config_json.write(fit_common.json.dumps(hdconfig, sort_keys=True, indent=4))
     config_json.close()
     # copy files to ORA
     fit_common.scp_file_to_ora('config.json')
     self.assertEqual(fit_common.remote_shell('cp config.json /opt/onrack/etc/monorail.json')['exitcode'], 0, "OnRack Config file failure.")
     os.remove('config.json')
     shell_data = fit_common.remote_shell("/opt/onrack/bin/monorail restart")
     #retry 100 seconds for monorail up
     for dummy in range(0, 10):
         if fit_common.remote_shell("/opt/onrack/bin/monorail status")['exitcode'] == 0:
             fit_common.time.sleep(10)
             break
         else:
             fit_common.time.sleep(10)
     self.assertEqual(hdconfig, fit_common.rackhdapi("/api/2.0/config")['json'], "OnRack Config file failure.")
コード例 #22
0
 def test05_install_rackhd_config_files(self):
     print "**** Installing RackHD config files."
     #create DHCP config
     fit_common.remote_shell('echo INTERFACES=' + IFLIST[7] +
                             ' > /etc/default/isc-dhcp-server')
     dhcp_conf = open('dhcpd.conf', 'w')
     dhcp_conf.write(
         'ddns-update-style none;\n'
         'option domain-name "example.org";\n'
         'option domain-name-servers ns1.example.org, ns2.example.org;\n'
         'default-lease-time 600;\n'
         'max-lease-time 7200;\n'
         'log-facility local7;\n'
         'deny duplicates;\n'
         'ignore-client-uids true;\n'
         'subnet 172.31.128.0 netmask 255.255.252.0 {\n'
         '  range 172.31.128.2 172.31.131.254;\n'
         '  option vendor-class-identifier "PXEClient";\n'
         '}\n')
     dhcp_conf.close()
     # create RackHD config
     hdconfig = {
         "CIDRNet":
         "172.31.128.0/22",
         "amqp":
         "amqp://localhost",
         "apiServerAddress":
         "172.31.128.1",
         "apiServerPort":
         9080,
         "broadcastaddr":
         "172.31.131.255",
         "dhcpGateway":
         "172.31.128.1",
         "dhcpProxyBindAddress":
         "172.31.128.1",
         "dhcpProxyBindPort":
         4011,
         "dhcpSubnetMask":
         "255.255.252.0",
         "gatewayaddr":
         "172.31.128.1",
         "httpEndpoints": [{
             "address": "0.0.0.0",
             "port": fit_common.GLOBAL_CONFIG['ports']['http'],
             "httpsEnabled": False,
             "proxiesEnabled": True,
             "authEnabled": False,
             "routers": "northbound-api-router"
         }, {
             "address":
             "0.0.0.0",
             "port":
             fit_common.GLOBAL_CONFIG['ports']['https'],
             "httpsEnabled":
             True,
             "proxiesEnabled":
             True,
             "authEnabled":
             True,
             "routers":
             "northbound-api-router"
         }, {
             "address": "172.31.128.1",
             "port": 9080,
             "httpsEnabled": False,
             "proxiesEnabled": True,
             "authEnabled": False,
             "routers": "southbound-api-router"
         }],
         "httpDocsRoot":
         "./build/apidoc",
         "httpFileServiceRoot":
         "./static/files",
         "httpFileServiceType":
         "FileSystem",
         "httpProxies": [{
             "localPath":
             "/mirror",
             "remotePath":
             "/",
             "server":
             fit_common.GLOBAL_CONFIG['repos']['mirror']
         }],
         "httpStaticRoot":
         "/opt/monorail/static/http",
         "minLogLevel":
         3,
         "authUsername":
         "******",
         "authPasswordHash":
         "KcBN9YobNV0wdux8h0fKNqi4uoKCgGl/j8c6YGlG7iA0PB3P9ojbmANGhDlcSBE0iOTIsYsGbtSsbqP4wvsVcw==",
         "authPasswordSalt":
         "zlxkgxjvcFwm0M8sWaGojh25qNYO8tuNWUMN4xKPH93PidwkCAvaX2JItLA3p7BSCWIzkw4GwWuezoMvKf3UXg==",
         "authTokenSecret":
         "RackHDRocks!",
         "authTokenExpireIn":
         86400,
         "mongo":
         "mongodb://localhost/pxe",
         "sharedKey":
         "qxfO2D3tIJsZACu7UA6Fbw0avowo8r79ALzn+WeuC8M=",
         "statsd":
         "127.0.0.1:8125",
         "subnetmask":
         "255.255.252.0",
         "syslogBindAddress":
         "172.31.128.1",
         "syslogBindPort":
         514,
         "tftpBindAddress":
         "172.31.128.1",
         "tftpBindPort":
         69,
         "tftpRoot":
         "./static/tftp",
     }
     config_json = open('config.json', 'w')
     config_json.write(
         fit_common.json.dumps(hdconfig, sort_keys=True, indent=4))
     config_json.close()
     # AMQP config files
     rabbitmq_config = open('rabbitmq.config', 'w')
     rabbitmq_config.write('[{rabbit, [{tcp_listeners, [5672]}]}].')
     rabbitmq_config.close()
     # copy files to ORA
     fit_common.scp_file_to_ora('config.json')
     fit_common.scp_file_to_ora('dhcpd.conf')
     fit_common.scp_file_to_ora('rabbitmq.config')
     self.assertEqual(
         fit_common.remote_shell('cp dhcpd.conf /etc/dhcp/')['exitcode'], 0,
         "DHCP Config failure.")
     self.assertEqual(
         fit_common.remote_shell('cp config.json /opt/monorail/')
         ['exitcode'], 0, "RackHD Config file failure.")
     self.assertEqual(
         fit_common.remote_shell('cp rabbitmq.config /etc/rabbitmq/')
         ['exitcode'], 0, "AMQP Config file failure.")
     os.remove('dhcpd.conf')
     os.remove('config.json')
     os.remove('rabbitmq.config')
コード例 #23
0
    def test03_install_docker(self):
        # Check if docker-compose is already installed
        rsp = fit_common.remote_shell("docker -v")
        if rsp['exitcode'] == 0:
            logs.info(" Docker already installed")
            if "Docker version" in rsp['stdout']:
                logs.info(" Docker installed: %s", rsp['stdout'])
        else:
            logs.info(" Install Docker")

            # apt-get update
            command = PROXYVARS + "sudo apt-get update"
            self.assertEqual(
                fit_common.remote_shell(command)['exitcode'], 0,
                "get-update failed.")

            # Getting the docker installation file from docker.com
            command = PROXYVARS + "sudo wget -qO- https://get.docker.com/ | sh"
            self.assertEqual(
                fit_common.remote_shell(command)['exitcode'], 0,
                "Getting docker file from docker.com failed.")

            # Checking the users with whoami command
            command = "sudo usermod -aG docker $(whoami)"
            self.assertEqual(
                fit_common.remote_shell(command)['exitcode'], 0,
                "whoami command failed.")

        # Check if docker-compose is already installed
        rsp = fit_common.remote_shell("docker-compose -v")
        if rsp['exitcode'] == 0:
            logs.info(" docker-compose already installed")
            if "docker-compose version" in rsp['stdout']:
                logs.info(" Docker installed: %s", rsp['stdout'])
        else:
            # Installing python pip
            command = PROXYVARS + "sudo apt-get -y install python-pip"
            self.assertEqual(
                fit_common.remote_shell(command)['exitcode'], 0,
                "Pip install failed.")

            # Installing docker compose
            logs.info(" Install docker-compose")
            command = PROXYVARS + "sudo pip install docker-compose"
            self.assertEqual(
                fit_common.remote_shell(command)['exitcode'], 0,
                "Docker compose install failed.")

        # Setup docker proxy environment
        logs.info(" Setup Docker Proxy")
        dockerproxy = open("dockerproxy", 'w')
        # dockerproxy.write('export http_proxy="http://web.hwimo.lab.emc.com:3128/"\n')
        dockerproxy.write(PROXYVARS)
        dockerproxy.close()
        fit_common.scp_file_to_ora("dockerproxy")
        self.assertEqual(
            fit_common.remote_shell('cat dockerproxy >> /etc/default/docker')
            ['exitcode'], 0, "adding docker proxy config failed.")
        os.remove('dockerproxy')

        # Restart the docker service
        command = PROXYVARS + "sudo service docker restart"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "Docker service restart failed.")
        time.sleep(60)
コード例 #24
0
    def test04_setup_rackhd_docker_services(self):
        # add the .env variables for HOST IP into the ".env" file
        envfile = open("envfile", 'w')
        envfile.write("TAG=latest\n")
        envfile.write("REGISTRY_IP=172.31.128.1\n")
        host_ip = "HOST_IP=" + socket.gethostbyname(
            fit_common.fitcfg()['rackhd_host']) + "\n"
        envfile.write(host_ip)
        envfile.close()
        fit_common.scp_file_to_ora("envfile")
        self.assertEqual(
            fit_common.remote_shell('cp envfile /home/onrack/.env')
            ['exitcode'], 0, "copy of env file failed.")
        os.remove('envfile')

        # Get the username and password from config-mn/credentials.json
        username = fit_common.fitcreds()['docker_hub'][0]['username']
        password = fit_common.fitcreds()['docker_hub'][0]['password']
        command = 'cd rackhd/docker/dell; sudo docker login --username='******' --password='******'exitcode'], 0,
            "Docker login failed.")

        # Docker up consul
        command = "cd rackhd/docker/dell; sudo docker-compose up -d consul"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "Docker up consul failed.")
        time.sleep(30)

        command = "cd rackhd/docker/dell; sudo chmod +x set_config.sh; sudo ./set_config.sh"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "set_config.sh failed.")

        # Docker up the rest of micro service containers
        command = "cd rackhd/docker/dell; sudo docker-compose up -d"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "docker-compose up failed.")
        time.sleep(180)

        # Set port to 8080 in smi config file
        port_var = fit_common.fitports()['http']
        command = "cd rackhd/docker/dell; sudo sed -i 's/9090/" + str(
            port_var) + "/g' set_rackhd_smi_config.sh"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "set_rackhd_smi_config.sh failed.")

        # Populates smi config file
        command = "cd rackhd/docker/dell; sudo ./set_rackhd_smi_config.sh"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "set_rackhd_smi_config.sh failed.")

        # Replace  callback Uri port from 9988 to 9080 in smi config file
        command = "cd /opt/monorail; sudo sed -i 's/9988/9080/g' smiConfig.json"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "Change port from 9988 to 9080 in smiConfig failed.")

        # Restart on-http service
        command = "sudo service on-http restart"
        self.assertEqual(
            fit_common.remote_shell(command)['exitcode'], 0,
            "failed to start on-http service.")
コード例 #25
0
    def test04_install_network_config(self):
        print "**** Installing RackHD network config."
        # collect nic names
        getifs = fit_common.remote_shell("ifconfig -s -a |tail -n +2 |grep -v -e Iface -e lo -e docker")
        # clean out login stuff
        splitifs = getifs['stdout'].split('\n')
        ifslit = [] # array of valid eth ports
        for item in splitifs:
            if "assword" not in item and item.split(" ")[0]:
                ifslit.append(item.split(" ")[0])

        # install control network config
        control_cfg = open('control.cfg', 'w')
        control_cfg.write(
                            'auto ' + ifslit[1] + '\n'
                            'iface ' + ifslit[1] + ' inet static\n'
                            'address 172.31.128.1\n'
                            'netmask 255.255.252.0\n'
                        )
        control_cfg.close()
        # copy file to ORA
        fit_common.scp_file_to_ora('control.cfg')
        self.assertEqual(fit_common.remote_shell('cp control.cfg /etc/network/interfaces.d/')['exitcode'], 0, "Control network config failure.")
        os.remove('control.cfg')
        # startup NIC
        fit_common.remote_shell('ip addr add 172.31.128.1/22 dev ' + ifslit[1])
        fit_common.remote_shell('ip link set ' + ifslit[1] + ' up')
        self.assertEqual(fit_common.remote_shell('ping -c 1 -w 5 172.31.128.1')['exitcode'], 0, 'Control NIC failure.')

        # If PDU network adapter is present, configure
        try:
            ifslit[2]
        except IndexError:
            print "**** No PDU network will be configured"
        else:
            pdudirect_cfg = open('pdudirect.cfg', 'w')
            pdudirect_cfg.write(
                                'auto ' + ifslit[2] + '\n'
                                'iface ' + ifslit[2] + ' inet static\n'
                                'address 192.168.1.1\n'
                                'netmask 255.255.255.0\n'
                                )
            pdudirect_cfg.close()
            # copy file to ORA
            fit_common.scp_file_to_ora('pdudirect.cfg')
            self.assertEqual(fit_common.remote_shell('cp pdudirect.cfg /etc/network/interfaces.d/')['exitcode'], 0, "DHCP Config failure.")
            os.remove('pdudirect.cfg')
            # startup NIC
            fit_common.remote_shell('ip addr add 192.168.1.1/24 dev ' + ifslit[2])
            fit_common.remote_shell('ip link set ' + ifslit[2] + ' up')
            self.assertEqual(fit_common.remote_shell('ping -c 1 -w 5 192.168.1.1')['exitcode'], 0, 'PDU NIC failure.')

        #create DHCP config
        fit_common.remote_shell('echo INTERFACES=' + ifslit[1] + ' > /etc/default/isc-dhcp-server')
        dhcp_conf = open('dhcpd.conf', 'w')
        dhcp_conf.write(
                        'ddns-update-style none;\n'
                        'option domain-name "example.org";\n'
                        'option domain-name-servers ns1.example.org, ns2.example.org;\n'
                        'default-lease-time 600;\n'
                        'max-lease-time 7200;\n'
                        'log-facility local7;\n'
                        'deny duplicates;\n'
                        'ignore-client-uids true;\n'
                        'subnet 172.31.128.0 netmask 255.255.252.0 {\n'
                        '  range 172.31.128.2 172.31.131.254;\n'
                        '  option vendor-class-identifier "PXEClient";\n'
                        '}\n'
                         )
        dhcp_conf.close()
        # copy file to ORA
        fit_common.scp_file_to_ora('dhcpd.conf')
        self.assertEqual(fit_common.remote_shell('cp dhcpd.conf /etc/dhcp/')['exitcode'], 0, "DHCP Config failure.")
        os.remove('dhcpd.conf')
コード例 #26
0
      'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
      'xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 '
      'http://maven.apache.org/xsd/settings-1.0.0.xsd">'
          '<proxies>'
              '<proxy>'
              '<id>mavenproxy</id>'
              '<active>true</active>'
              '<protocol>https</protocol>'
              '<host>' + fit_common.fitproxy()['host'] + '</host>'
              '<port>' + fit_common.fitproxy()['port'] + '</port>'
              '<nonProxyHosts>localhost</nonProxyHosts>'
            '</proxy>'
          '</proxies>'
      '</settings>')
    maven_proxy.close()
    fit_common.scp_file_to_ora('settings.xml')
    fit_common.remote_shell('mkdir -p ~/.m2;cp settings.xml ~/.m2;mkdir -p /root/.m2;cp settings.xml /root/.m2')
    os.remove('settings.xml')

class rackhd_source_install(fit_common.unittest.TestCase):
    def test01_install_rackhd_dependencies(self):
        print "**** Installing RackHD dependencies."
        # update sudoers to preserve proxy environment
        sudoersproxy = open("sudoersproxy", 'w')
        sudoersproxy.write('Defaults env_keep="HOME no_proxy http_proxy https_proxy"\n')
        sudoersproxy.close()
        fit_common.remote_shell('pwd')
        fit_common.scp_file_to_ora("sudoersproxy")
        self.assertEqual(fit_common.remote_shell('cp sudoersproxy /etc/sudoers.d/'
                                                  )['exitcode'], 0, "sudoersproxy config failure.")
        os.remove('sudoersproxy')
コード例 #27
0
    def test04_install_network_config(self):
        print "**** Installing RackHD network config."
        # collect nic names
        getifs = fit_common.remote_shell("ifconfig -s -a |tail -n +2 |grep -v -e Iface -e lo")
        # clean out login stuff
        splitifs = getifs["stdout"].split("\n")
        ifslit = []  # array of valid eth ports
        for item in splitifs:
            if "assword" not in item and item.split(" ")[0]:
                ifslit.append(item.split(" ")[0])

        # install control network config
        control_cfg = open("control.cfg", "w")
        control_cfg.write(
            "auto " + ifslit[1] + "\n"
            "iface " + ifslit[1] + " inet static\n"
            "address 172.31.128.1\n"
            "netmask 255.255.252.0\n"
        )
        control_cfg.close()
        # copy file to ORA
        fit_common.scp_file_to_ora("control.cfg")
        self.assertEqual(
            fit_common.remote_shell("cp control.cfg /etc/network/interfaces.d/")["exitcode"],
            0,
            "Control network config failure.",
        )
        os.remove("control.cfg")
        # startup NIC
        fit_common.remote_shell("ip addr add 172.31.128.1/22 dev " + ifslit[1])
        fit_common.remote_shell("ip link set " + ifslit[1] + " up")
        self.assertEqual(fit_common.remote_shell("ping -c 1 -w 5 172.31.128.1")["exitcode"], 0, "Control NIC failure.")

        # If PDU network adapter is present, configure
        try:
            ifslit[2]
        except IndexError:
            print "**** No PDU network will be configured"
        else:
            pdudirect_cfg = open("pdudirect.cfg", "w")
            pdudirect_cfg.write(
                "auto " + ifslit[2] + "\n"
                "iface " + ifslit[2] + " inet static\n"
                "address 192.168.1.1\n"
                "netmask 255.255.255.0\n"
            )
            pdudirect_cfg.close()
            # copy file to ORA
            fit_common.scp_file_to_ora("pdudirect.cfg")
            self.assertEqual(
                fit_common.remote_shell("cp pdudirect.cfg /etc/network/interfaces.d/")["exitcode"],
                0,
                "DHCP Config failure.",
            )
            os.remove("pdudirect.cfg")
            # startup NIC
            fit_common.remote_shell("ip addr add 192.168.1.1/24 dev " + ifslit[2])
            fit_common.remote_shell("ip link set " + ifslit[2] + " up")
            self.assertEqual(fit_common.remote_shell("ping -c 1 -w 5 192.168.1.1")["exitcode"], 0, "PDU NIC failure.")

        # create DHCP config
        fit_common.remote_shell("echo INTERFACES=" + ifslit[1] + " > /etc/default/isc-dhcp-server")
        dhcp_conf = open("dhcpd.conf", "w")
        dhcp_conf.write(
            "ddns-update-style none;\n"
            'option domain-name "example.org";\n'
            "option domain-name-servers ns1.example.org, ns2.example.org;\n"
            "default-lease-time 600;\n"
            "max-lease-time 7200;\n"
            "log-facility local7;\n"
            "deny duplicates;\n"
            "ignore-client-uids true;\n"
            "subnet 172.31.128.0 netmask 255.255.252.0 {\n"
            "  range 172.31.128.2 172.31.131.254;\n"
            '  option vendor-class-identifier "PXEClient";\n'
            "}\n"
        )
        dhcp_conf.close()
        # copy file to ORA
        fit_common.scp_file_to_ora("dhcpd.conf")
        self.assertEqual(fit_common.remote_shell("cp dhcpd.conf /etc/dhcp/")["exitcode"], 0, "DHCP Config failure.")
        os.remove("dhcpd.conf")
コード例 #28
0
 def test03_install_rackhd_config_files(self):
     print "**** Installing RackHD config files."
     #create DHCP config
     dhcp_conf = open("dhcpd.conf", 'w')
     dhcp_conf.write(
                     'ddns-update-style none;\n'
                     'option domain-name "example.org";\n'
                     'option domain-name-servers ns1.example.org, ns2.example.org;\n'
                     'default-lease-time 600;\n'
                     'max-lease-time 7200;\n'
                     'log-facility local7;\n'
                     'deny duplicates;\n'
                     'ignore-client-uids true;\n'
                     'subnet 172.31.128.0 netmask 255.255.252.0 {\n'
                     '  range 172.31.128.2 172.31.131.254;\n'
                     '  option vendor-class-identifier "PXEClient";\n'
                     '}\n'
                      )
     dhcp_conf.close()
     # create RackHD config
     hdconfig = {
                 "CIDRNet": "172.31.128.0/22",
                 "amqp": "amqp://localhost",
                 "apiServerAddress": "172.31.128.1",
                 "apiServerPort": 9080,
                 "broadcastaddr": "172.31.131.255",
                 "dhcpGateway": "172.31.128.1",
                 "dhcpProxyBindAddress": "172.31.128.1",
                 "dhcpProxyBindPort": 4011,
                 "dhcpSubnetMask": "255.255.252.0",
                 "gatewayaddr": "172.31.128.1",
                 "httpEndpoints": [
                     {
                         "address": "0.0.0.0",
                         "port": fit_common.GLOBAL_CONFIG['ports']['http'],
                         "httpsEnabled": False,
                         "proxiesEnabled": True,
                         "authEnabled": False,
                         "routers": "northbound-api-router"
                     },
                     {
                         "address": "0.0.0.0",
                         "port": fit_common.GLOBAL_CONFIG['ports']['https'],
                         "httpsEnabled": True,
                         "proxiesEnabled": True,
                         "authEnabled": True,
                         "routers": "northbound-api-router"
                     },
                     {
                         "address": "172.31.128.1",
                         "port": 9080,
                         "httpsEnabled": False,
                         "proxiesEnabled": True,
                         "authEnabled": False,
                         "routers": "southbound-api-router"
                     }
                 ],
                 "httpDocsRoot": "./build/apidoc",
                 "httpFileServiceRoot": "./static/files",
                 "httpFileServiceType": "FileSystem",
                 "httpProxies": [{
                     "localPath": "/mirror",
                     "remotePath": "/",
                     "server": fit_common.GLOBAL_CONFIG['repos']['mirror']
                 }],
                 "httpStaticRoot": "/opt/monorail/static/http",
                 "minLogLevel": 3,
                 "authUsername": "******",
                 "authPasswordHash": "KcBN9YobNV0wdux8h0fKNqi4uoKCgGl/j8c6YGlG7iA0PB3P9ojbmANGhDlcSBE0iOTIsYsGbtSsbqP4wvsVcw==",
                 "authPasswordSalt": "zlxkgxjvcFwm0M8sWaGojh25qNYO8tuNWUMN4xKPH93PidwkCAvaX2JItLA3p7BSCWIzkw4GwWuezoMvKf3UXg==",
                 "authTokenSecret": "RackHDRocks!",
                 "authTokenExpireIn": 86400,
                 "mongo": "mongodb://localhost/pxe",
                 "sharedKey": "qxfO2D3tIJsZACu7UA6Fbw0avowo8r79ALzn+WeuC8M=",
                 "statsd": "127.0.0.1:8125",
                 "subnetmask": "255.255.252.0",
                 "syslogBindAddress": "172.31.128.1",
                 "syslogBindPort": 514,
                 "tftpBindAddress": "172.31.128.1",
                 "tftpBindPort": 69,
                 "tftpRoot": "./static/tftp",
                 "minLogLevel": 2
             }
     config_json = open("config.json", 'w')
     config_json.write(fit_common.json.dumps(hdconfig, sort_keys=True, indent=4))
     config_json.close()
     # copy files to ORA
     fit_common.scp_file_to_ora("config.json")
     fit_common.scp_file_to_ora("dhcpd.conf")
     self.assertEqual(fit_common.remote_shell('cp dhcpd.conf /etc/dhcp/')['exitcode'], 0, "DHCP Config failure.")
     self.assertEqual(fit_common.remote_shell('cp config.json /opt/monorail/')['exitcode'], 0, "RackHD Config file failure.")
     os.remove('dhcpd.conf')
     os.remove('config.json')
コード例 #29
0
 def test05_install_rackhd_config_files(self):
     print "**** Installing RackHD config files."
     # create RackHD config
     hdconfig = {
                 "CIDRNet": "172.31.128.0/22",
                 "amqp": "amqp://localhost",
                 "apiServerAddress": "172.31.128.1",
                 "apiServerPort": 9080,
                 "arpCacheEnabled": True,
                 "broadcastaddr": "172.31.131.255",
                 "dhcpGateway": "172.31.128.1",
                 "dhcpProxyBindAddress": "172.31.128.1",
                 "dhcpProxyBindPort": 4011,
                 "dhcpSubnetMask": "255.255.252.0",
                 "gatewayaddr": "172.31.128.1",
                 "httpEndpoints": [
                     {
                         "address": "0.0.0.0",
                         "port": fit_common.GLOBAL_CONFIG['ports']['http'],
                         "httpsEnabled": False,
                         "proxiesEnabled": True,
                         "authEnabled": False,
                         "routers": "northbound-api-router"
                     },
                     {
                         "address": "0.0.0.0",
                         "port": fit_common.GLOBAL_CONFIG['ports']['https'],
                         "httpsEnabled": True,
                         "proxiesEnabled": True,
                         "authEnabled": True,
                         "routers": "northbound-api-router"
                     },
                     {
                         "address": "172.31.128.1",
                         "port": 9080,
                         "httpsEnabled": False,
                         "proxiesEnabled": True,
                         "authEnabled": False,
                         "routers": "southbound-api-router"
                     }
                 ],
                 "httpDocsRoot": "./build/apidoc",
                 "httpFileServiceRoot": "./static/files",
                 "httpFileServiceType": "FileSystem",
                 "httpProxies": [{
                     "localPath": "/mirror",
                     "remotePath": "/",
                     "server": fit_common.GLOBAL_CONFIG['repos']['mirror']
                 }],
                 "httpStaticRoot": "/opt/monorail/static/http",
                 "minLogLevel": 3,
                 "authUsername": "******",
                 "authPasswordHash": "KcBN9YobNV0wdux8h0fKNqi4uoKCgGl/j8c6YGlG7iA0PB3P9ojbmANGhDlcSBE0iOTIsYsGbtSsbqP4wvsVcw==",
                 "authPasswordSalt": "zlxkgxjvcFwm0M8sWaGojh25qNYO8tuNWUMN4xKPH93PidwkCAvaX2JItLA3p7BSCWIzkw4GwWuezoMvKf3UXg==",
                 "authTokenSecret": "RackHDRocks!",
                 "authTokenExpireIn": 86400,
                 "mongo": "mongodb://localhost/pxe",
                 "sharedKey": "qxfO2D3tIJsZACu7UA6Fbw0avowo8r79ALzn+WeuC8M=",
                 "statsd": "127.0.0.1:8125",
                 "subnetmask": "255.255.252.0",
                 "syslogBindAddress": "172.31.128.1",
                 "syslogBindPort": 514,
                 "tftpBindAddress": "172.31.128.1",
                 "tftpBindPort": 69,
                 "tftpRoot": "./static/tftp",
             }
     config_json = open('config.json', 'w')
     config_json.write(fit_common.json.dumps(hdconfig, sort_keys=True, indent=4))
     config_json.close()
     # AMQP config files
     rabbitmq_config = open('rabbitmq.config', 'w')
     rabbitmq_config.write('[{rabbit,[{tcp_listeners, [5672]},{loopback_users, []}]},{rabbitmq_management,[{listener, [{port,  15672},{ip,"127.0.0.1"}]}]}].')
     rabbitmq_config.close()
     # copy files to ORA
     fit_common.scp_file_to_ora('config.json')
     fit_common.scp_file_to_ora('rabbitmq.config')
     self.assertEqual(fit_common.remote_shell('cp config.json /opt/monorail/')['exitcode'], 0, "RackHD Config file failure.")
     self.assertEqual(fit_common.remote_shell('cp rabbitmq.config /etc/rabbitmq/')['exitcode'], 0, "AMQP Config file failure.")
     os.remove('config.json')
     os.remove('rabbitmq.config')
コード例 #30
0
 def test05_install_rackhd_config_files(self):
     print "**** Installing RackHD config files."
     # create RackHD config
     hdconfig = {
         "CIDRNet":
         "172.31.128.0/22",
         "amqp":
         "amqp://localhost",
         "apiServerAddress":
         "172.31.128.1",
         "apiServerPort":
         9080,
         "arpCacheEnabled":
         True,
         "broadcastaddr":
         "172.31.131.255",
         "dhcpGateway":
         "172.31.128.1",
         "dhcpProxyBindAddress":
         "172.31.128.1",
         "dhcpProxyBindPort":
         4011,
         "dhcpSubnetMask":
         "255.255.252.0",
         "gatewayaddr":
         "172.31.128.1",
         "httpEndpoints": [{
             "address": "0.0.0.0",
             "port": fit_common.GLOBAL_CONFIG['ports']['http'],
             "httpsEnabled": False,
             "proxiesEnabled": True,
             "authEnabled": False,
             "routers": "northbound-api-router"
         }, {
             "address":
             "0.0.0.0",
             "port":
             fit_common.GLOBAL_CONFIG['ports']['https'],
             "httpsEnabled":
             True,
             "proxiesEnabled":
             True,
             "authEnabled":
             True,
             "routers":
             "northbound-api-router"
         }, {
             "address": "172.31.128.1",
             "port": 9080,
             "httpsEnabled": False,
             "proxiesEnabled": True,
             "authEnabled": False,
             "routers": "southbound-api-router"
         }],
         "httpDocsRoot":
         "./build/apidoc",
         "httpFileServiceRoot":
         "./static/files",
         "httpFileServiceType":
         "FileSystem",
         "httpProxies": [{
             "localPath":
             "/mirror",
             "remotePath":
             "/",
             "server":
             fit_common.GLOBAL_CONFIG['repos']['mirror']
         }],
         "httpStaticRoot":
         "/opt/monorail/static/http",
         "minLogLevel":
         3,
         "authUsername":
         "******",
         "authPasswordHash":
         "KcBN9YobNV0wdux8h0fKNqi4uoKCgGl/j8c6YGlG7iA0PB3P9ojbmANGhDlcSBE0iOTIsYsGbtSsbqP4wvsVcw==",
         "authPasswordSalt":
         "zlxkgxjvcFwm0M8sWaGojh25qNYO8tuNWUMN4xKPH93PidwkCAvaX2JItLA3p7BSCWIzkw4GwWuezoMvKf3UXg==",
         "authTokenSecret":
         "RackHDRocks!",
         "authTokenExpireIn":
         86400,
         "mongo":
         "mongodb://localhost/pxe",
         "sharedKey":
         "qxfO2D3tIJsZACu7UA6Fbw0avowo8r79ALzn+WeuC8M=",
         "statsd":
         "127.0.0.1:8125",
         "subnetmask":
         "255.255.252.0",
         "syslogBindAddress":
         "172.31.128.1",
         "syslogBindPort":
         514,
         "tftpBindAddress":
         "172.31.128.1",
         "tftpBindPort":
         69,
         "tftpRoot":
         "./static/tftp",
     }
     config_json = open('config.json', 'w')
     config_json.write(
         fit_common.json.dumps(hdconfig, sort_keys=True, indent=4))
     config_json.close()
     # AMQP config files
     rabbitmq_config = open('rabbitmq.config', 'w')
     rabbitmq_config.write(
         '[{rabbit,[{tcp_listeners, [5672]},{loopback_users, []}]},{rabbitmq_management,[{listener, [{port,  15672},{ip,"127.0.0.1"}]}]}].'
     )
     rabbitmq_config.close()
     # copy files to ORA
     fit_common.scp_file_to_ora('config.json')
     fit_common.scp_file_to_ora('rabbitmq.config')
     self.assertEqual(
         fit_common.remote_shell('cp config.json /opt/monorail/')
         ['exitcode'], 0, "RackHD Config file failure.")
     self.assertEqual(
         fit_common.remote_shell('cp rabbitmq.config /etc/rabbitmq/')
         ['exitcode'], 0, "AMQP Config file failure.")
     os.remove('config.json')
     os.remove('rabbitmq.config')
コード例 #31
0
        'xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 '
        'http://maven.apache.org/xsd/settings-1.0.0.xsd">'
        "<proxies>"
        "<proxy>"
        "<id>mavenproxy</id>"
        "<active>true</active>"
        "<protocol>https</protocol>"
        "<host>" + fit_common.GLOBAL_CONFIG["repos"]["proxyhost"] + "</host>"
        "<port>" + fit_common.GLOBAL_CONFIG["repos"]["proxyport"] + "</port>"
        "<nonProxyHosts>localhost</nonProxyHosts>"
        "</proxy>"
        "</proxies>"
        "</settings>"
    )
    maven_proxy.close()
    fit_common.scp_file_to_ora("settings.xml")
    fit_common.remote_shell("mkdir -p ~/.m2;cp settings.xml ~/.m2;mkdir -p /root/.m2;cp settings.xml /root/.m2")
    os.remove("settings.xml")


class rackhd_source_install(fit_common.unittest.TestCase):
    def test01_install_rackhd_dependencies(self):
        print "**** Installing RackHD dependencies."
        # update sudoers to preserve proxy environment
        sudoersproxy = open("sudoersproxy", "w")
        sudoersproxy.write('Defaults env_keep="HOME no_proxy http_proxy https_proxy"\n')
        sudoersproxy.close()
        fit_common.remote_shell("pwd")
        fit_common.scp_file_to_ora("sudoersproxy")
        self.assertEqual(
            fit_common.remote_shell("cp sudoersproxy /etc/sudoers.d/")["exitcode"], 0, "sudoersproxy config failure."