DREN/Kickstart/scripts

From DER's LLC
Revision as of 19:23, 2 June 2023 by Admin (talk | contribs) (Created page with "==initiateKickstart== #!/usr/bin/python import xmlrpclib import subprocess import sys SATELLITE_URL = "http://localhost/rpc/api" SATELLITE_LOGIN = "daniel.roessner.adm" SATELLITE_PASSWORD = SYSTEM = "rdhpwngmp-09.711hpw.afrl-wrs.hpc.mil" PROFILE_NAME = "DCOS-Slave" def kickstart(key, SYSTEM, PROFILE_NAME): list = client.system.listSystems(key) for sys in list: if sys['name'] == SYSTEM: system_id = sys['id'] #print client.kickstart.lis...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

initiateKickstart

#!/usr/bin/python
import xmlrpclib
import subprocess
import sys

SATELLITE_URL = "http://localhost/rpc/api"
SATELLITE_LOGIN = "daniel.roessner.adm"
SATELLITE_PASSWORD = 
SYSTEM = "rdhpwngmp-09.711hpw.afrl-wrs.hpc.mil"
PROFILE_NAME = "DCOS-Slave"

def kickstart(key, SYSTEM, PROFILE_NAME):
  list  = client.system.listSystems(key)
  for sys in list:
    if sys['name'] == SYSTEM:
      system_id = sys['id']
  #print client.kickstart.listKickstarts(key)
  print client.system.provisionSystem(key, system_id, PROFILE_NAME)

def rhn_check(SYSTEM):
  COMMAND="rhn_check"
  SYSTEM = SYSTEM.split('.')[0]

  ssh = subprocess.Popen(["ssh", "-oStrictHostKeyChecking=no", "%s" % SYSTEM, COMMAND],
                       shell=False,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.PIPE)
  result = ssh.stdout.readlines()
  if result == []:
    error = ssh.stderr.readlines()
    print >>sys.stderr, "ERROR: %s" % error
  else:
    print result 

def login(SATELLITE_URL, SATELLITE_LOGIN, SATELLITE_PASSWORD):
  client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
  key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
  return key, client

def logout(key):
  client.auth.logout(key)

###################################################################### 

key, client = login(SATELLITE_URL, SATELLITE_LOGIN, SATELLITE_PASSWORD)

#kickstart(key, SYSTEM, PROFILE_NAME)
rhn_check(SYSTEM) 

logout(key)

reposync

mkdir -p /var/log/scripts/
date > /var/log/scripts/spacewalk-repo-sync.log
echo ##################################################### >> /var/log/scripts/spacewalk-repo-sync.log
CENT7LATEST=`curl --silent http://mirror.centos.org/centos/ | grep folder | grep ">7\." | cut -d '"' -f 8 | cut -d '/' -f 1 | sort -g | tail -1`
#CENT6LATEST=`curl --silent http://mirror.centos.org/centos/ | grep folder | grep ">6\." | cut -d '"' -f 8 | cut -d '/' -f 1 | sort -g | tail -1`

spacewalk-repo-sync -u http://mirror.centos.org/centos/$CENT7LATEST/os/x86_64/ -c centos7  >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u http://mirror.centos.org/centos/$CENT7LATEST/extras/x86_64/ -c centos7  >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u http://mirror.centos.org/centos/$CENT7LATEST/updates/x86_64/ -c centos7 >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u http://dl.fedoraproject.org/pub/epel/7/x86_64/ -c centos7-latest-epel >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u https://yum.dockerproject.org/repo/main/centos/7/ -c centos7-latest-docker >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u https://yum.puppetlabs.com/el/7/PC1/x86_64/ -c centos7-latest-puppet >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u http://download.zfsonlinux.org/epel/7/x86_64/ -c centos-latest-zfs >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u http://download.zfsonlinux.org/epel/7/kmod/x86_64/ -c centos-latest-zfs >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u http://yum.spacewalkproject.org/latest/RHEL/7/x86_64/ -c centos7-latest-spacewalk-server  >> /var/log/scripts/spacewalk-repo-sync.log
spacewalk-repo-sync -u http://yum.spacewalkproject.org/latest-client/RHEL/7/x86_64/ -c centos7-latest-spacewalk-server  >> /var/log/scripts/spacewalk-repo-sync.log

#spacewalk-repo-sync -u http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/ -c 7-postgres94  >> /var/log/scripts/spacewalk-repo-sync.log
#spacewalk-repo-sync -u http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/ -c 7-postgres95 >> /var/log/scripts/spacewalk-repo-sync.log
#spacewalk-repo-sync -u http://download.ceph.com/rpm/el7/x86_64/ -c ceph-centos7  >> /var/log/scripts/spacewalk-repo-sync.log

chmod -R 777 /var/satellite/redhat/1/
echo #################################################### >> /var/log/scripts/spacewalk-repo-sync.log
date >> /var/log/scripts/spacewalk-repo-sync.log