def build_dir_server(dir_server): # We dont support 389 yet, so exit if it is not ldap if results.dir_version != 'openldap': print "%s as a directory service is not yet supported...exiting" % results.dir_version sys.exit(1) # Build directory service node dir_node = Node(dir_server) ip = dir_node['ipaddress'] root_pass = razor.get_active_model_pass(dir_node['razor_metadata'].to_dict()['razor_active_model_uuid'])['password'] dir_node['in_use'] = 'directory-server' dir_node.run_list = ["role[qa-%s-%s]" % (results.dir_version, results.os)] dir_node.save() print "Updating server...this may take some time" update_node(dir_node) # if redhat platform, disable iptables if dir_node['platform_family'] == 'rhel': print "Platform is RHEL family, disabling iptables" disable_iptables(dir_node) # Run chef-client twice print "Running chef-client for directory service node...this may take some time..." run1 = run_chef_client(dir_node) if run1['success']: print "First chef-client run successful...starting second run..." run2 = run_chef_client(dir_node) if run2['success']: print "Second chef-client run successful..." else: print "Error running chef-client for directory node %s" % dir_node print run2 sys.exit(1) else: print "Error running chef-client for directory node %s" % dir_node print run1 sys.exit(1) # Directory service is set up, need to import config if run1['success'] and run2['success']: if results.dir_version == 'openldap': scp_run = run_remote_scp_cmd(ip, 'root', root_pass, '/var/lib/jenkins/source_files/ldif/*.ldif') if scp_run['success']: ssh_run = run_remote_ssh_cmd(ip, 'root', root_pass, 'ldapadd -x -D \"cn=admin,dc=dev,dc=rcbops,dc=me\" -f base.ldif -w@privatecloud') elif results.dir_version == '389': # Once we support 389, code here to import needed config files print "389 is not yet supported..." sys.exit(1) else: print "%s is not supported...exiting" % results.dir_version sys.exit(1) if scp_run['success'] and ssh_run['success']: print "Directory Service: %s successfully set up..." % results.dir_version else: print "Failed to set-up Directory Service: %s..." % results.dir_version sys.exit(1)
def erase_node(name): """ @param name """ print "Deleting: %s" % (name) node = Node(name) am_uuid = node['razor_metadata'].to_dict()['razor_active_model_uuid'] run = run_remote_ssh_cmd(node['ipaddress'], 'root', razor.get_active_model_pass(am_uuid)['password'], "reboot 0") if not run['success']: print "Error rebooting server %s " % node['ipaddress'] # TODO: return failure sys.exit(1) #Knife node remove; knife client remove Client(name).delete() Node(name).delete() #Remove active model razor.remove_active_model(am_uuid) time.sleep(15)
print "Error writing file" print e sys.exit(1) # Get password for OpenCenter server server_node = Node(server[0]) opencenter_server_ip = server_node["ipaddress"] am_uuid = server_node.attributes["razor_metadata"]["razor_active_model_uuid"] opencenter_server_password = razor.get_active_model_pass(am_uuid)["password"] # Build Commands to run commands = [] pip = "" if results.os == "centos": command = "yum install openssh-clients -y" run_remote_ssh_cmd(opencenter_server_ip, "root", opencenter_server_password, command) commands.append("yum install git python-pip -y") pip = "pip-python" elif results.os == "ubuntu": commands.append("apt-get install git python-pip -y -q") pip = "pip" commands += [ "rm -rf /root/opencenter-testerator", "git clone %s" % results.opencenter_test_repo, "%s install -q -r /root/opencenter-testerator/tools/pip-requires" % pip, "mv /root/%s /root/opencenter-testerator/etc/" % (config_file), ] for test in results.opencenter_tests.split(","): commands.append(
sys.exit(1) # Get password for OpenCenter server server_node = Node(server[0]) opencenter_server_ip = server_node['ipaddress'] am_uuid = server_node.attributes['razor_metadata'][ 'razor_active_model_uuid'] opencenter_server_password = razor.get_active_model_pass( am_uuid)['password'] # Build Commands to run commands = [] pip = "" if results.os == "centos": command = "yum install openssh-clients -y" run_remote_ssh_cmd(opencenter_server_ip, 'root', opencenter_server_password, command) commands.append("yum install git python-pip -y") pip = "pip-python" elif results.os == "ubuntu": commands.append("apt-get install git python-pip -y -q") pip = "pip" commands += [ "rm -rf /root/opencenter-testerator", "git clone %s" % results.opencenter_test_repo, "%s install -q -r /root/opencenter-testerator/tools/pip-requires" % pip, "mv /root/%s /root/opencenter-testerator/etc/" % (config_file) ] for test in results.opencenter_tests.split(","):