xcat2 / xcat-extensions

Repos to store scripts for special user cases
4 stars 8 forks source link

combine xcatha-setup and xcatha-failover into xcatha.py #6

Closed bybai closed 6 years ago

bybai commented 6 years ago

For https://github.com/xcat2/xcat2-task-management/issues/137

  1. enhace log format
  2. combine xcatha_setup.py and xcatha_failover.py into xcatha.py

UT: 1, help:

[root@bybc0605 ~]# python xcatha.py -h
usage: xcatha.py [-h] (-s | -a | -d) [-p PATH] -v VIRTUAL_IP -i NIC
                 [-n HOST_NAME] [-m NETMASK] [-t {postgresql,sqlite,mysql}]

Setup/Activate/Deactivate shared data based xCAT HA MN node

optional arguments:
  -h, --help            show this help message and exit
  -s, --setup           setup node to be xCAT MN
  -a, --activate        activate node to be xCAT MN
  -d, --deactivate      deactivate node to be xCAT MN
  -p PATH               shared data directory path
  -v VIRTUAL_IP         virtual IP
  -i NIC                virtual IP network interface
  -n HOST_NAME          virtual IP hostname
  -m NETMASK            virtual IP network mask
  -t {postgresql,sqlite,mysql}
                        database type

2, positive UT, this is partial output:

[root@bybc0605 ~]# python xcatha.py -s -p /HA -v 10.5.106.50 -i eth0:0 -n hamn -m 255.0.0.0 -t postgresql
============================================================================================
2018-05-31 22:49:36,208 - INFO - Check virtual ip stage
2018-05-31 22:49:36,208 - INFO - ping -c 1 -w 10 10.5.106.50
PING 10.5.106.50 (10.5.106.50) 56(84) bytes of data.
From 10.5.106.5 icmp_seq=1 Destination Host Unreachable
From 10.5.106.5 icmp_seq=2 Destination Host Unreachable
From 10.5.106.5 icmp_seq=3 Destination Host Unreachable
From 10.5.106.5 icmp_seq=4 Destination Host Unreachable

--- 10.5.106.50 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 2999ms
pipe 4
2018-05-31 22:49:39,219 - INFO - virtual ip can be used.
============================================================================================
2018-05-31 22:49:39,219 - INFO - Check if xCAT data is in shared data directory
2018-05-31 22:49:39,219 - ERROR - There is no xCAT data /HA/install in shared data /HA
============================================================================================
2018-05-31 22:49:39,220 - INFO - Start configure virtual ip as alias ip stage
2018-05-31 22:49:39,220 - INFO - Running ifconfig eth0:0 10.5.106.50  netmask 255.0.0.0
2018-05-31 22:49:39,239 - INFO - ifconfig eth0:0 10.5.106.50  netmask 255.0.0.0
2018-05-31 22:49:39,240 - INFO - Configure virtual IP [Passed].
============================================================================================
2018-05-31 22:49:39,240 - INFO - add virtual ip 10.5.106.50 into /etc/resolv.conf
nameserver 10.5.106.50
============================================================================================
2018-05-31 22:49:39,240 - INFO - Save physical hostname and ip
============================================================================================
2018-05-31 22:49:39,246 - INFO - Start configure hostname stage
2018-05-31 22:49:39,246 - INFO - Running hostname hamn
2018-05-31 22:49:39,248 - INFO - hostname hamn
2018-05-31 22:49:39,248 - INFO - hostname hamn [Passed]
============================================================================================
2018-05-31 22:49:39,248 - INFO - Check xcatd service status
Unit xcatd.service could not be found.
============================================================================================
2018-05-31 22:49:39,254 - INFO - Install xCAT stage
2018-05-31 22:49:39,254 - INFO - Running wget https://raw.githubusercontent.com/xcat2/xcat-core/master/xCAT-server/share/xcat/tools/go-xcat -O - >/tmp/go-xcat
--2018-05-31 22:49:39--  https://raw.githubusercontent.com/xcat2/xcat-core/master/xCAT-server/share/xcat/tools/go-xcat
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.68.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.68.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 46541 (45K) [text/plain]
Saving to: 'STDOUT'

100%[======================================>] 46,541      --.-K/s   in 0.1s

2018-05-31 22:49:39 (467 KB/s) - written to stdout [46541/46541]

2018-05-31 22:49:39,817 - INFO - wget https://raw.githubusercontent.com/xcat2/xcat-core/master/xCAT-server/share/xcat/tools/go-xcat -O - >/tmp/go-xcat
2018-05-31 22:49:39,817 - INFO - Running chmod +x /tmp/go-xcat
2018-05-31 22:49:39,820 - INFO - chmod +x /tmp/go-xcat
2018-05-31 22:49:39,820 - INFO - Running /tmp/go-xcat --yes install
Operating system:   linux
Architecture:       x86_64
Linux Distribution: rhel
Version:            7.4

Reading repositories ...... done
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package conserver-xcat.x86_64 0:8.2.1-1 will be installed
---> Package elilo-xcat.noarch 0:3.14-4 will be installed
---> Package grub2-xcat.noarch 0:2.02-0.16.el7.snap201506090204 will be installed
... ...
Complete!
2018-05-31 22:55:21,016 - INFO - yum -y install postgresql* perl-DBD-Pg
2018-05-31 22:55:21,017 - INFO - install postgresql* perl-DBD-Pg  package [Passed]
============================================================================================
2018-05-31 22:55:21,017 - INFO - Switch to target database stage
2018-05-31 22:55:21,017 - INFO - export XCATPGPW=xxxxxx;pgsqlsetup -i -a 10.5.106.50 -a 10.5.106.5
Backing up xCAT Database to /root/xcat-dbback.
This could take several minutes.
... ...
Starting the PosgreSQL Server
Starting the PosgreSQL Server
Restoring the xCAT Database with /root/xcat-dbback to PostgreSQL database.
This could take several minutes.
Starting xcatd (via systemctl):                            [  OK  ]
xCAT is running on the PostgreSQL database.

2018-05-31 22:59:19,279 - INFO - Switch to postgresql [Passed]
2018-05-31 22:59:19,283 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-05-31 22:59:19,286 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
============================================================================================
2018-05-31 22:59:19,289 - INFO - Configure shared data directory stage
2018-05-31 22:59:19,290 - INFO - Copy /install to /HA/install
2018-05-31 22:59:24,024 - INFO - Running chown -R root:root /HA/install
2018-05-31 22:59:24,859 - INFO - chown -R root:root /HA/install
2018-05-31 22:59:24,859 - INFO - Copy /etc/xcat to /HA/etc/xcat
2018-05-31 22:59:28,358 - INFO - Running chown -R root:root /HA/etc/xcat
2018-05-31 22:59:29,043 - INFO - chown -R root:root /HA/etc/xcat
2018-05-31 22:59:29,043 - INFO - Copy /root/.xcat to /HA/root/.xcat
2018-05-31 22:59:29,260 - INFO - Running chown -R root:root /HA/root/.xcat
2018-05-31 22:59:29,296 - INFO - chown -R root:root /HA/root/.xcat
2018-05-31 22:59:29,297 - INFO - Copy /var/lib/pgsql to /HA/var/lib/pgsql
2018-05-31 23:00:13,832 - INFO - Running chown -R postgres:postgres /HA/var/lib/pgsql
2018-05-31 23:00:21,751 - INFO - chown -R postgres:postgres /HA/var/lib/pgsql
2018-05-31 23:00:21,751 - INFO - Copy /tftpboot to /HA/tftpboot
2018-05-31 23:00:45,409 - INFO - Running chown -R root:root /HA/tftpboot
2018-05-31 23:00:47,054 - INFO - chown -R root:root /HA/tftpboot
2018-05-31 23:00:47,054 - INFO - Creating symlink .../install
2018-05-31 23:00:47,054 - INFO - Creating symlink .../etc/xcat
2018-05-31 23:00:47,054 - INFO - Creating symlink .../root/.xcat
2018-05-31 23:00:47,055 - INFO - Creating symlink .../var/lib/pgsql
2018-05-31 23:00:47,055 - INFO - Creating symlink .../tftpboot
2018-05-31 23:00:47,055 - INFO - Running cat /tmp/ha_mn >> /etc/xcat/ha_mn
2018-05-31 23:00:47,072 - INFO - cat /tmp/ha_mn >> /etc/xcat/ha_mn
============================================================================================
2018-05-31 23:00:47,072 - INFO - Check xcatd service status
2018-05-31 23:00:47,078 - INFO - xCAT service has started [Passed]
============================================================================================
2018-05-31 23:00:47,078 - INFO - Configure xCAT policy table stage
2018-05-31 23:00:47,080 - INFO - Running lsdef -t policy -i name|grep hamn
    name=hamn
2018-05-31 23:00:47,488 - INFO - lsdef -t policy -i name|grep hamn
2018-05-31 23:00:47,488 - INFO - hamn exists in policy table.
============================================================================================
2018-05-31 23:00:47,488 - INFO - Deactivate stage
2018-05-31 23:00:47,503 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-05-31 23:00:47,507 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
2018-05-31 23:00:47,515 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-05-31 23:00:47,519 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
2018-05-31 23:00:47,523 - INFO - Restoring original hostname: bybc0605
============================================================================================
2018-05-31 23:00:47,524 - INFO - Start configure hostname stage
2018-05-31 23:00:47,524 - INFO - Running hostname bybc0605
2018-05-31 23:00:47,526 - INFO - hostname bybc0605
2018-05-31 23:00:47,526 - INFO - hostname bybc0605 [Passed]
============================================================================================
2018-05-31 23:00:47,526 - INFO - Remove virtual IP
2018-05-31 23:00:47,526 - INFO - Running ifconfig eth0:0 0.0.0.0 0.0.0.0 &>/dev/null
2018-05-31 23:00:47,528 - INFO - ifconfig eth0:0 0.0.0.0 0.0.0.0 &>/dev/null [Failed, OK to ignore]
2018-05-31 23:00:47,528 - INFO - Running ip addr show |grep 10.5.106.50 &>/dev/null
2018-05-31 23:00:47,532 - INFO - ip addr show |grep 10.5.106.50 &>/dev/null [Failed, OK to ignore]
2018-05-31 23:00:47,532 - INFO - Remove virtual IP [Passed]
============================================================================================
2018-05-31 23:00:47,532 - INFO - Unconfigure shared data directory stage
2018-05-31 23:00:47,532 - INFO - Removing symlink .../install
2018-05-31 23:00:47,532 - INFO - Removing symlink .../etc/xcat
2018-05-31 23:00:47,532 - INFO - Removing symlink .../root/.xcat
2018-05-31 23:00:47,532 - INFO - Removing symlink .../var/lib/pgsql
2018-05-31 23:00:47,533 - INFO - Removing symlink .../tftpboot
2018-05-31 23:00:47,533 - INFO - Running systemctl disable goconserver
2018-05-31 23:00:47,599 - INFO - systemctl disable goconserver
2018-05-31 23:00:47,599 - INFO - Running systemctl disable conserver
conserver.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig conserver off
2018-05-31 23:00:47,661 - INFO - systemctl disable conserver
2018-05-31 23:00:47,661 - INFO - Running systemctl disable ntpd
2018-05-31 23:00:47,704 - INFO - systemctl disable ntpd
2018-05-31 23:00:47,704 - INFO - Running systemctl disable dhcpd
Removed symlink /etc/systemd/system/multi-user.target.wants/dhcpd.service.
2018-05-31 23:00:47,746 - INFO - systemctl disable dhcpd
2018-05-31 23:00:47,746 - INFO - Running systemctl disable named
Removed symlink /etc/systemd/system/multi-user.target.wants/named.service.
2018-05-31 23:00:47,789 - INFO - systemctl disable named
2018-05-31 23:00:47,790 - INFO - Running systemctl disable xcatd
xcatd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig xcatd off
2018-05-31 23:00:47,839 - INFO - systemctl disable xcatd
2018-05-31 23:00:47,839 - INFO - Running systemctl disable postgresql
Removed symlink /etc/systemd/system/multi-user.target.wants/postgresql.service.
2018-05-31 23:00:47,883 - INFO - systemctl disable postgresql
2018-05-31 23:00:47,893 - INFO - Running systemctl stop goconserver
2018-05-31 23:00:47,905 - INFO - systemctl stop goconserver
2018-05-31 23:00:47,905 - INFO - Running systemctl stop conserver
2018-05-31 23:00:47,916 - INFO - systemctl stop conserver
2018-05-31 23:00:47,917 - INFO - Running systemctl stop ntpd
2018-05-31 23:00:47,927 - INFO - systemctl stop ntpd
2018-05-31 23:00:47,927 - INFO - Running systemctl stop dhcpd
2018-05-31 23:00:47,939 - INFO - systemctl stop dhcpd
2018-05-31 23:00:47,939 - INFO - Running systemctl stop named
2018-05-31 23:00:47,949 - INFO - systemctl stop named
2018-05-31 23:00:47,949 - INFO - Running systemctl stop xcatd
2018-05-31 23:00:51,232 - INFO - systemctl stop xcatd
2018-05-31 23:00:51,232 - INFO - Running systemctl stop postgresql
2018-05-31 23:00:51,962 - INFO - systemctl stop postgresql
2018-05-31 23:00:51,962 - INFO - This machine is set to standby management node successfully...
[root@bybc0605 ~]#
whowutwut commented 6 years ago

@bybai General comments, Should fix some of the messages to be consistnte.

ip -> IP xcat -> xCAT

This is an error but printed as an INFO...

2018-05-30 11:07:23,276 - INFO - Error: Can not restore original hostname

Should capitalize the beginning of the message: removing symlink -> Removing symlink

Why are we doing xCAT install in this script? Shouldn't this script focus on deactivating and activating xCAT only related services on the MN? Seems like scope creep...

whowutwut commented 6 years ago

@gurevichmark Thanks for addressing those comments above! 👍

robin2008 commented 6 years ago

@bybai , not log the passwd into log file.

2018-05-30 10:51:27,427 - INFO - Running export XCATPGPW=cluster;pgsqlsetup
bybai commented 6 years ago

Hi @whowutwut Mark and me created new commits based on comments and fixed some defects for the first stage xcatha.py script. Please review it.

whowutwut commented 6 years ago

@bybai We should consider for future to be creating "feature branches" so that changes can be added into the project without affecting the master branch. And then once it's tested, we can merge it into master.

Can we update the output examples based on the latest code? I'm ok with merging if you want this in, but since we are GA 2.14.1 on friday, we should wait to merge this for 2.14.2.

Another comment that I have, like discussed on the conf call, is it possible to have a --dryrun option and then also have some tags that we can get a single line output of what is being done...

xcatha.py --dryrun .... | grep INFO but seems like this generates too many messages

For example:

2018-05-30 10:55:25,367 - INFO - Running cp -f /tmp/ha_mn /etc/xcat/ha_mn
2018-05-30 10:55:25,404 - INFO - cp -f /tmp/ha_mn /etc/xcat/ha_mn

Seems like one is INFO, but another should be DEBUG ...

If we can reduce the output so that grep INFO will essentially give us a high level "steps", it would be beneficial to be more "self documenting"

bybai commented 6 years ago

Hi @whowutwut,

  1. after this pull request is merged, it is in xcat-extensions, it is not in xcat-core, and xcatha.py will not be included in xcat-core tar ball. So whether merging it or not today will not affect GA 2.14.1.

  2. We can add --dryrun option, I opened this task https://github.com/xcat2/xcat2-task-management/issues/172. Current output is long, I think print each stage output in screen is better than just wait for the script. When reducing the output, the script sometime like hang.

  3. xcatha.py also create a log file in its current directory named xcatha.log, the output like:

    05/31/2018 03:14:46 AM - INFO - systemctl stop named
    05/31/2018 03:14:46 AM - INFO - Running systemctl stop xcatd
    05/31/2018 03:14:49 AM - INFO - systemctl stop xcatd
    05/31/2018 03:14:49 AM - INFO - Running systemctl stop postgresql
    05/31/2018 03:14:50 AM - INFO - systemctl stop postgresql
bybai commented 6 years ago

Hi @whowutwut , New output is following: 1, setup:

[root@bybc0605 ~]# python xcatha.py -s -p /HA -v 10.5.106.50 -i eth0:0 -n hamn -m 255.0.0.0 -t postgresql
============================================================================================
2018-05-31 22:49:36,208 - INFO - Check virtual ip stage
2018-05-31 22:49:36,208 - INFO - ping -c 1 -w 10 10.5.106.50
PING 10.5.106.50 (10.5.106.50) 56(84) bytes of data.
From 10.5.106.5 icmp_seq=1 Destination Host Unreachable
From 10.5.106.5 icmp_seq=2 Destination Host Unreachable
From 10.5.106.5 icmp_seq=3 Destination Host Unreachable
From 10.5.106.5 icmp_seq=4 Destination Host Unreachable

--- 10.5.106.50 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 2999ms
pipe 4
2018-05-31 22:49:39,219 - INFO - virtual ip can be used.
============================================================================================
2018-05-31 22:49:39,219 - INFO - Check if xCAT data is in shared data directory
2018-05-31 22:49:39,219 - ERROR - There is no xCAT data /HA/install in shared data /HA
============================================================================================
2018-05-31 22:49:39,220 - INFO - Start configure virtual ip as alias ip stage
2018-05-31 22:49:39,220 - INFO - Running ifconfig eth0:0 10.5.106.50  netmask 255.0.0.0
2018-05-31 22:49:39,239 - INFO - ifconfig eth0:0 10.5.106.50  netmask 255.0.0.0
2018-05-31 22:49:39,240 - INFO - Configure virtual IP [Passed].
============================================================================================
2018-05-31 22:49:39,240 - INFO - add virtual ip 10.5.106.50 into /etc/resolv.conf
nameserver 10.5.106.50
============================================================================================
2018-05-31 22:49:39,240 - INFO - Save physical hostname and ip
============================================================================================
2018-05-31 22:49:39,246 - INFO - Start configure hostname stage
2018-05-31 22:49:39,246 - INFO - Running hostname hamn
2018-05-31 22:49:39,248 - INFO - hostname hamn
2018-05-31 22:49:39,248 - INFO - hostname hamn [Passed]
============================================================================================
2018-05-31 22:49:39,248 - INFO - Check xcatd service status
Unit xcatd.service could not be found.
============================================================================================
2018-05-31 22:49:39,254 - INFO - Install xCAT stage
2018-05-31 22:49:39,254 - INFO - Running wget https://raw.githubusercontent.com/xcat2/xcat-core/master/xCAT-server/share/xcat/tools/go-xcat -O - >/tmp/go-xcat
--2018-05-31 22:49:39--  https://raw.githubusercontent.com/xcat2/xcat-core/master/xCAT-server/share/xcat/tools/go-xcat
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.68.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.68.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 46541 (45K) [text/plain]
Saving to: 'STDOUT'

100%[======================================>] 46,541      --.-K/s   in 0.1s

2018-05-31 22:49:39 (467 KB/s) - written to stdout [46541/46541]

2018-05-31 22:49:39,817 - INFO - wget https://raw.githubusercontent.com/xcat2/xcat-core/master/xCAT-server/share/xcat/tools/go-xcat -O - >/tmp/go-xcat
2018-05-31 22:49:39,817 - INFO - Running chmod +x /tmp/go-xcat
2018-05-31 22:49:39,820 - INFO - chmod +x /tmp/go-xcat
2018-05-31 22:49:39,820 - INFO - Running /tmp/go-xcat --yes install
Operating system:   linux
Architecture:       x86_64
Linux Distribution: rhel
Version:            7.4

Reading repositories ...... done
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package conserver-xcat.x86_64 0:8.2.1-1 will be installed
---> Package elilo-xcat.noarch 0:3.14-4 will be installed
---> Package grub2-xcat.noarch 0:2.02-0.16.el7.snap201506090204 will be installed
... ...
Complete!
2018-05-31 22:55:21,016 - INFO - yum -y install postgresql* perl-DBD-Pg
2018-05-31 22:55:21,017 - INFO - install postgresql* perl-DBD-Pg  package [Passed]
============================================================================================
2018-05-31 22:55:21,017 - INFO - Switch to target database stage
2018-05-31 22:55:21,017 - INFO - export XCATPGPW=xxxxxx;pgsqlsetup -i -a 10.5.106.50 -a 10.5.106.5
Backing up xCAT Database to /root/xcat-dbback.
This could take several minutes.
... ...
Starting the PosgreSQL Server
Starting the PosgreSQL Server
Restoring the xCAT Database with /root/xcat-dbback to PostgreSQL database.
This could take several minutes.
Starting xcatd (via systemctl):                            [  OK  ]
xCAT is running on the PostgreSQL database.

2018-05-31 22:59:19,279 - INFO - Switch to postgresql [Passed]
2018-05-31 22:59:19,283 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-05-31 22:59:19,286 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
============================================================================================
2018-05-31 22:59:19,289 - INFO - Configure shared data directory stage
2018-05-31 22:59:19,290 - INFO - Copy /install to /HA/install
2018-05-31 22:59:24,024 - INFO - Running chown -R root:root /HA/install
2018-05-31 22:59:24,859 - INFO - chown -R root:root /HA/install
2018-05-31 22:59:24,859 - INFO - Copy /etc/xcat to /HA/etc/xcat
2018-05-31 22:59:28,358 - INFO - Running chown -R root:root /HA/etc/xcat
2018-05-31 22:59:29,043 - INFO - chown -R root:root /HA/etc/xcat
2018-05-31 22:59:29,043 - INFO - Copy /root/.xcat to /HA/root/.xcat
2018-05-31 22:59:29,260 - INFO - Running chown -R root:root /HA/root/.xcat
2018-05-31 22:59:29,296 - INFO - chown -R root:root /HA/root/.xcat
2018-05-31 22:59:29,297 - INFO - Copy /var/lib/pgsql to /HA/var/lib/pgsql
2018-05-31 23:00:13,832 - INFO - Running chown -R postgres:postgres /HA/var/lib/pgsql
2018-05-31 23:00:21,751 - INFO - chown -R postgres:postgres /HA/var/lib/pgsql
2018-05-31 23:00:21,751 - INFO - Copy /tftpboot to /HA/tftpboot
2018-05-31 23:00:45,409 - INFO - Running chown -R root:root /HA/tftpboot
2018-05-31 23:00:47,054 - INFO - chown -R root:root /HA/tftpboot
2018-05-31 23:00:47,054 - INFO - Creating symlink .../install
2018-05-31 23:00:47,054 - INFO - Creating symlink .../etc/xcat
2018-05-31 23:00:47,054 - INFO - Creating symlink .../root/.xcat
2018-05-31 23:00:47,055 - INFO - Creating symlink .../var/lib/pgsql
2018-05-31 23:00:47,055 - INFO - Creating symlink .../tftpboot
2018-05-31 23:00:47,055 - INFO - Running cat /tmp/ha_mn >> /etc/xcat/ha_mn
2018-05-31 23:00:47,072 - INFO - cat /tmp/ha_mn >> /etc/xcat/ha_mn
============================================================================================
2018-05-31 23:00:47,072 - INFO - Check xcatd service status
2018-05-31 23:00:47,078 - INFO - xCAT service has started [Passed]
============================================================================================
2018-05-31 23:00:47,078 - INFO - Configure xCAT policy table stage
2018-05-31 23:00:47,080 - INFO - Running lsdef -t policy -i name|grep hamn
    name=hamn
2018-05-31 23:00:47,488 - INFO - lsdef -t policy -i name|grep hamn
2018-05-31 23:00:47,488 - INFO - hamn exists in policy table.
============================================================================================
2018-05-31 23:00:47,488 - INFO - Deactivate stage
2018-05-31 23:00:47,503 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-05-31 23:00:47,507 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
2018-05-31 23:00:47,515 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-05-31 23:00:47,519 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
2018-05-31 23:00:47,523 - INFO - Restoring original hostname: bybc0605
============================================================================================
2018-05-31 23:00:47,524 - INFO - Start configure hostname stage
2018-05-31 23:00:47,524 - INFO - Running hostname bybc0605
2018-05-31 23:00:47,526 - INFO - hostname bybc0605
2018-05-31 23:00:47,526 - INFO - hostname bybc0605 [Passed]
============================================================================================
2018-05-31 23:00:47,526 - INFO - Remove virtual IP
2018-05-31 23:00:47,526 - INFO - Running ifconfig eth0:0 0.0.0.0 0.0.0.0 &>/dev/null
2018-05-31 23:00:47,528 - INFO - ifconfig eth0:0 0.0.0.0 0.0.0.0 &>/dev/null [Failed, OK to ignore]
2018-05-31 23:00:47,528 - INFO - Running ip addr show |grep 10.5.106.50 &>/dev/null
2018-05-31 23:00:47,532 - INFO - ip addr show |grep 10.5.106.50 &>/dev/null [Failed, OK to ignore]
2018-05-31 23:00:47,532 - INFO - Remove virtual IP [Passed]
============================================================================================
2018-05-31 23:00:47,532 - INFO - Unconfigure shared data directory stage
2018-05-31 23:00:47,532 - INFO - Removing symlink .../install
2018-05-31 23:00:47,532 - INFO - Removing symlink .../etc/xcat
2018-05-31 23:00:47,532 - INFO - Removing symlink .../root/.xcat
2018-05-31 23:00:47,532 - INFO - Removing symlink .../var/lib/pgsql
2018-05-31 23:00:47,533 - INFO - Removing symlink .../tftpboot
2018-05-31 23:00:47,533 - INFO - Running systemctl disable goconserver
2018-05-31 23:00:47,599 - INFO - systemctl disable goconserver
2018-05-31 23:00:47,599 - INFO - Running systemctl disable conserver
conserver.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig conserver off
2018-05-31 23:00:47,661 - INFO - systemctl disable conserver
2018-05-31 23:00:47,661 - INFO - Running systemctl disable ntpd
2018-05-31 23:00:47,704 - INFO - systemctl disable ntpd
2018-05-31 23:00:47,704 - INFO - Running systemctl disable dhcpd
Removed symlink /etc/systemd/system/multi-user.target.wants/dhcpd.service.
2018-05-31 23:00:47,746 - INFO - systemctl disable dhcpd
2018-05-31 23:00:47,746 - INFO - Running systemctl disable named
Removed symlink /etc/systemd/system/multi-user.target.wants/named.service.
2018-05-31 23:00:47,789 - INFO - systemctl disable named
2018-05-31 23:00:47,790 - INFO - Running systemctl disable xcatd
xcatd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig xcatd off
2018-05-31 23:00:47,839 - INFO - systemctl disable xcatd
2018-05-31 23:00:47,839 - INFO - Running systemctl disable postgresql
Removed symlink /etc/systemd/system/multi-user.target.wants/postgresql.service.
2018-05-31 23:00:47,883 - INFO - systemctl disable postgresql
2018-05-31 23:00:47,893 - INFO - Running systemctl stop goconserver
2018-05-31 23:00:47,905 - INFO - systemctl stop goconserver
2018-05-31 23:00:47,905 - INFO - Running systemctl stop conserver
2018-05-31 23:00:47,916 - INFO - systemctl stop conserver
2018-05-31 23:00:47,917 - INFO - Running systemctl stop ntpd
2018-05-31 23:00:47,927 - INFO - systemctl stop ntpd
2018-05-31 23:00:47,927 - INFO - Running systemctl stop dhcpd
2018-05-31 23:00:47,939 - INFO - systemctl stop dhcpd
2018-05-31 23:00:47,939 - INFO - Running systemctl stop named
2018-05-31 23:00:47,949 - INFO - systemctl stop named
2018-05-31 23:00:47,949 - INFO - Running systemctl stop xcatd
2018-05-31 23:00:51,232 - INFO - systemctl stop xcatd
2018-05-31 23:00:51,232 - INFO - Running systemctl stop postgresql
2018-05-31 23:00:51,962 - INFO - systemctl stop postgresql
2018-05-31 23:00:51,962 - INFO - This machine is set to standby management node successfully...
[root@bybc0605 ~]#

2, deactivate:

[root@bybc0605 ~]#  python xcatha.py -d -i eth0:0 -v 10.5.106.50
============================================================================================
2018-06-01 00:52:31,720 - INFO - Deactivating this node as xCAT MN
============================================================================================
2018-06-01 00:52:31,722 - INFO - Deactivate stage
2018-06-01 00:52:31,726 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-06-01 00:52:31,730 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
2018-06-01 00:52:31,735 - INFO - Running ifconfig|grep "inet 10.5.106.5  netmask"
        inet 10.5.106.5  netmask 255.0.0.0  broadcast 10.255.255.255
2018-06-01 00:52:31,738 - INFO - ifconfig|grep "inet 10.5.106.5  netmask"
2018-06-01 00:52:31,741 - INFO - Restoring original hostname: bybc0605
============================================================================================
2018-06-01 00:52:31,741 - INFO - Start configure hostname stage
2018-06-01 00:52:31,741 - INFO - Running hostname bybc0605
2018-06-01 00:52:31,743 - INFO - hostname bybc0605
2018-06-01 00:52:31,743 - INFO - hostname bybc0605 [Passed]
============================================================================================
2018-06-01 00:52:31,744 - INFO - Remove virtual IP
2018-06-01 00:52:31,744 - INFO - Running ifconfig eth0:0 0.0.0.0 0.0.0.0 &>/dev/null
2018-06-01 00:52:31,746 - INFO - ifconfig eth0:0 0.0.0.0 0.0.0.0 &>/dev/null [Failed, OK to ignore]
2018-06-01 00:52:31,746 - INFO - Running ip addr show |grep 10.5.106.50 &>/dev/null
2018-06-01 00:52:31,749 - INFO - ip addr show |grep 10.5.106.50 &>/dev/null [Failed, OK to ignore]
2018-06-01 00:52:31,749 - INFO - Remove virtual IP [Passed]
============================================================================================
2018-06-01 00:52:31,749 - INFO - Unconfigure shared data directory stage
2018-06-01 00:52:31,750 - INFO - Removing symlink .../install
2018-06-01 00:52:31,750 - INFO - Removing symlink .../etc/xcat
2018-06-01 00:52:31,750 - INFO - Removing symlink .../root/.xcat
2018-06-01 00:52:31,750 - INFO - Removing symlink .../var/lib/pgsql
2018-06-01 00:52:31,750 - INFO - Removing symlink .../tftpboot
2018-06-01 00:52:31,750 - INFO - Running systemctl disable goconserver
2018-06-01 00:52:31,802 - INFO - systemctl disable goconserver
2018-06-01 00:52:31,803 - INFO - Running systemctl disable conserver
conserver.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig conserver off
2018-06-01 00:52:31,855 - INFO - systemctl disable conserver
2018-06-01 00:52:31,855 - INFO - Running systemctl disable ntpd
2018-06-01 00:52:31,899 - INFO - systemctl disable ntpd
2018-06-01 00:52:31,899 - INFO - Running systemctl disable dhcpd
2018-06-01 00:52:31,942 - INFO - systemctl disable dhcpd
2018-06-01 00:52:31,942 - INFO - Running systemctl disable named
2018-06-01 00:52:31,984 - INFO - systemctl disable named
2018-06-01 00:52:31,984 - INFO - Running systemctl disable xcatd
xcatd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig xcatd off
2018-06-01 00:52:32,032 - INFO - systemctl disable xcatd
2018-06-01 00:52:32,032 - INFO - Running systemctl disable postgresql
2018-06-01 00:52:32,080 - INFO - systemctl disable postgresql
2018-06-01 00:52:32,092 - INFO - Running systemctl stop goconserver
2018-06-01 00:52:32,103 - INFO - systemctl stop goconserver
2018-06-01 00:52:32,103 - INFO - Running systemctl stop conserver
2018-06-01 00:52:32,113 - INFO - systemctl stop conserver
2018-06-01 00:52:32,113 - INFO - Running systemctl stop ntpd
2018-06-01 00:52:32,129 - INFO - systemctl stop ntpd
2018-06-01 00:52:32,130 - INFO - Running systemctl stop dhcpd
2018-06-01 00:52:32,154 - INFO - systemctl stop dhcpd
2018-06-01 00:52:32,155 - INFO - Running systemctl stop named
2018-06-01 00:52:32,196 - INFO - systemctl stop named
2018-06-01 00:52:32,197 - INFO - Running systemctl stop xcatd
2018-06-01 00:52:35,548 - INFO - systemctl stop xcatd
2018-06-01 00:52:35,548 - INFO - Running systemctl stop postgresql
2018-06-01 00:52:35,736 - INFO - systemctl stop postgresql
2018-06-01 00:52:35,736 - INFO - This machine is set to standby management node successfully...

3, activate:

[root@bybc0605 ~]# python xcatha.py -a -p /HA -v 10.5.106.50 -i eth0:0 -n hamn -m 255.0.0.0 -t postgresql
============================================================================================
2018-06-01 00:53:50,404 - INFO - Activating this node as xCAT MN
============================================================================================
2018-06-01 00:53:50,404 - INFO - Activate stage
============================================================================================
2018-06-01 00:53:50,404 - INFO - Check virtual ip stage
2018-06-01 00:53:50,404 - INFO - ping -c 1 -w 10 10.5.106.50
PING 10.5.106.50 (10.5.106.50) 56(84) bytes of data.
From 10.5.106.5 icmp_seq=1 Destination Host Unreachable

--- 10.5.106.50 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

2018-06-01 00:53:50,537 - INFO - virtual ip can be used.
============================================================================================
2018-06-01 00:53:50,537 - INFO - Start configure virtual ip as alias ip stage
2018-06-01 00:53:50,537 - INFO - Running ifconfig eth0:0 10.5.106.50  netmask 255.0.0.0
2018-06-01 00:53:50,539 - INFO - ifconfig eth0:0 10.5.106.50  netmask 255.0.0.0
2018-06-01 00:53:50,540 - INFO - Configure virtual IP [Passed].
============================================================================================
2018-06-01 00:53:50,540 - INFO - add virtual ip 10.5.106.50 into /etc/resolv.conf
============================================================================================
2018-06-01 00:53:50,543 - INFO - Start configure hostname stage
2018-06-01 00:53:50,543 - INFO - Running hostname hamn

2018-06-01 00:53:50,545 - INFO - hostname hamn

2018-06-01 00:53:50,545 - INFO - hostname hamn
 [Passed]
============================================================================================
2018-06-01 00:53:50,546 - INFO - Check if xCAT data is in shared data directory
2018-06-01 00:53:50,546 - INFO - There is xCAT data /HA/install in shared data /HA
============================================================================================
2018-06-01 00:53:50,546 - INFO - Configure shared data directory stage
2018-06-01 00:53:50,547 - INFO - Creating symlink .../install
2018-06-01 00:53:50,547 - INFO - Creating symlink .../etc/xcat
2018-06-01 00:53:50,547 - INFO - Creating symlink .../root/.xcat
2018-06-01 00:53:50,547 - INFO - Creating symlink .../var/lib/pgsql
2018-06-01 00:53:50,548 - INFO - Creating symlink .../tftpboot
2018-06-01 00:53:50,548 - INFO - Running cat /tmp/ha_mn >> /etc/xcat/ha_mn
2018-06-01 00:53:50,570 - INFO - cat /tmp/ha_mn >> /etc/xcat/ha_mn
============================================================================================
2018-06-01 00:53:50,571 - INFO - Start all services stage
2018-06-01 00:53:50,571 - INFO - Running systemctl start postgresql
2018-06-01 00:53:51,680 - INFO - systemctl start postgresql
2018-06-01 00:53:51,680 - INFO - Running systemctl start xcatd
2018-06-01 00:53:54,195 - INFO - systemctl start xcatd
2018-06-01 00:53:54,195 - INFO - Running source /etc/profile.d/xcat.sh
2018-06-01 00:53:54,197 - INFO - source /etc/profile.d/xcat.sh
2018-06-01 00:53:54,197 - INFO - Running lsdef -t site -i domain|grep domain
    domain=cluster.com
2018-06-01 00:53:54,527 - INFO - lsdef -t site -i domain|grep domain
2018-06-01 00:53:54,527 - INFO - Running makedns -n
Handling localhost in /etc/hosts.
Handling bybc0605 in /etc/hosts.
Handling localhost in /etc/hosts.
Handling hamn in /etc/hosts.
Getting reverse zones, this may take several minutes for a large cluster.
Completed getting reverse zones.
Updating zones.
Completed updating zones.
Restarting named
Restarting named complete
Updating DNS records, this may take several minutes for a large cluster.
Completed updating DNS records.
DNS setup is completed
2018-06-01 00:53:57,899 - INFO - Running systemctl start named
2018-06-01 00:53:57,931 - INFO - systemctl start named
2018-06-01 00:53:57,931 - INFO - Running makedhcp -n
Renamed existing dhcp configuration file to  /etc/dhcp/dhcpd.conf.xcatbak

Warning: No dynamic range specified for 10.0.0.0. If hardware discovery is being used, a dynamic range is required.
2018-06-01 00:53:58,276 - INFO - makedhcp -n
2018-06-01 00:53:58,276 - INFO - Running makedhcp -a
2018-06-01 00:53:58,464 - INFO - makedhcp -a
2018-06-01 00:53:58,464 - INFO - Running systemctl start dhcpd
2018-06-01 00:53:58,479 - INFO - systemctl start dhcpd
2018-06-01 00:53:58,479 - INFO - Running systemctl start ntpd
2018-06-01 00:53:58,499 - INFO - systemctl start ntpd
2018-06-01 00:53:58,499 - INFO - This machine is set to primary management node successfully...
whowutwut commented 6 years ago

Let's merge this in first and continue to improve it.