Parallels H-Sphere Documentation System Administrator Guide

 

H-Sphere VPS Scripts

(HS VPS version 1.2 and up)
 
 

Related Docs:   VPS Installation FreeVPS Docs

Last modified: 27 Dec 2007

 

WARNING: This documentation covers Parallels H-Sphere versions up to 3.1. For the latest up-to-date Parallels H-Sphere documentation, please proceed to the official Parallels site.

H-Sphere VPS is a set of scripts that serve as the backend for advanced VPS management via H-Sphere CP but they can also run from the command-line mode. The latter is the subject of this document that covers:

 

Default VPS Configuration File

The default VPS configuration file is /hsphere/local/config/vserver/vps.cfg.

WARNING:
1. Do not change location of the configuration file!
2. It is strongly recommended not to make changes to the configuration file manually!

If you need to set parameters to the configuration file, run VPS configuration script (/hsphere/shared/scripts/vps-configure.pl).

See also configuration parameters set in the VPS configuration file.

 

Other VPS Related Configuration Files

a) Template configuration files located in $HSINSTALLPKG (Default: /hsphere/local/config/vserver/<Your OS code>/):
where <Your OS code>:
RH73 - Red Hat Linux release 7.3
RHES3 - Red Hat Enterprise Linux ES release 3
RHAS3 - Red Hat Enterprise Linux AS release 3
RHWS3 - Red Hat Enterprise Linux WS release 3
WBEL3 - White Box Enterprise Linux release 3
CentOS3 - CentOS release 3

rpm_base.cfg - base and core of Linux;
rpm_development-tools.cfg - Development Tools
rpm_dns-server.cfg - DNS Name Server
rpm_ftp-server.cfg - FTP Server
rpm_kernel-vps.cfg - kernel emulator for VPS
rpm_mail-server.cfg - Mail Server
rpm_mysql-server.cfg - MySQL Database
rpm_news-server.cfg - News Server
rpm_perl-full.cfg - Perl programing language modules
rpm_pgsql-server.cfg - Postgresql SQL Database
rpm_quota.cfg - quota tools for VPS
rpm_samba-server.cfg - Windows File Server
rpm_system-tools.cfg - System Tools
rpm_web-server.cfg - Web Server

b) VPS box configuration files located in $VPSCONFIGS (Default: /hsphere/local/config/vserver/):

vps.cfg - the main configuration file for all Virtual Private Servers.
vps.cfg.bak - the main configuration file backup.
vps.cfg.default - default configuration for all Virtual Private Servers.
vps.list - the list of all known VPS and the list of Virtual Private Servers scheduled for removal.

 

VPS Scripts Location

All VPS scripts are located in the $VPSSCRIPTS directory (Default: /hsphere/shared/scripts).
Cron scripts are located in the $VPSSCRIPTS/cron (Default: /hsphere/shared/scripts/cron).

 

Perl Modules Used By VPS Scripts

Note: We provide the hsphere-vps package only for:

Red Hat Linux 7.3 with Perl 5.6.1 installed.
Red Hat Enterprise Linux release 3, CentOS 3.x, White Box Enterprise Linux release 3 with Perl 5.8.0 installed.

If you wish to install this package with other versions of Perl, you need to build your own H-Sphere VPS binaries.

Perl modules:
Red Hat Linux 7.3: Perl v5.6.1 modules are installed in [/usr/lib/perl5/site_perl/5.6.1/VServer/]
Red Hat Enterprise Linux release 3, CentOS 3.x, White Box Enterprise Linux release 3: Perl v5.8.0 modules are installed in [/usr/lib/perl5/site_perl/5.8.0/VServer]

Addon.pm
Admin.pm
Net.pm
Util.pm
Vars.pm
Vrpm.pm

 

VPS Configuration

Enter the $VPSSCRIPTS directory (Default: /hsphere/shared/scripts) to run the vps_configure.pl script.

SYNTAX:

./vps-configure.pl [-d|-r|-h]
OPTIONS:
        --defaults|-d   load default settings
        --restore|-r    restore settings you made before
        --help|-h       display this help message

Run vps_configure.pl:

# /hsphere/shared/scripts/vps-configure.pl
Do you really want to reconfigure your VPSs [y/n]?

Kernel: 2.4.21-freevps-1.2-1hugemem
FreeVPS patch build: 1080548030
Base FreeVPS tools package: freevps-tools-1.2-1
H-Sphere VPS scripts package: hsphere-vps-1.2-1
RedHat release: RH73

To perform basic configuration for all virtual servers, run the scipt and follow the instructions step by step.

 

Create VPS

To create new Virtual Private Server, run the vps-post-config.pl script:

./vps-post-config.pl VPS_HOST_NAME

And put in the following parameters to STDIN:

IP=ADDRESS:MASK:HDEV - IP to be assigned to this VPS and allowed on network interface HDEV on your VPS box;
DLIMIT=XXXX - Disk limit in Mb;
MLIMIT=XXXX - Memory Limit in Mb;
PLIMIT=XXXX - Limit on the number of running processes;
FILELIMIT=XXXX - Number of opened files limit;
TCPLIMIT=XXXX - TCP sockets limit;
ROOTPWD=**** - User root password;
CTRL+D - Press Ctrl+d to stop data input.

Example:

Create a VPS with the following configuration:

Hostname: 231.tst
IP address: 192.168.112.231, mask: 255.255.255.0
Disk limit: 3000Mb
Memory limit: 512Mb
Limit on the number of running processes: 1000
Root password: 1

[root@vps scripts]# ./vps-post-config.pl 231.tst

    IP=192.168.112.231:255.255.255.0[press Enter]
    DLIMIT=3000[press Enter]
    MLIMIT=512[press Enter]
    PLIMIT=1000[press Enter]
    ROOTPWD=1[press Enter]
    [press Ctrl+d] (end of data input)

vps-post-config.pl creates the $HSVPSFILES/231.tst/231.tst.in file (Default: /hsphere/local/config/vserver/cp/231.tst/231.tst.in) with the input parameters, and registers VPS in the list of known vservers: $VPSCONFIGS/vps.list (Default: /hsphere/local/config/vserver/vps.list)

Check the list of VPSs:

[root@vps scripts]# cat /hsphere/local/config/vserver/vps.list

You would get something like this:

DELETE=""
VSERVERS="3:231.tst"

Format:

DELETE="HOSTNAME1 HOSTNAME2 HOSTNAME3" - the list of VPSs scheduled for deletion, separated with whitespaces;
VSERVERS="CONTEXT_ID1:HOSTNAME1 CONTEXT_ID2:HOSTNAME2" - the list of known VPSs, separated with whitespaces; CONTEXT_ID is a virtual server ID

 

Migrate VPS

HS VPS 1.3-6.4 and up

VPS migration is performed by the vps-migrate.pl script that moves VPS(s) to another host. This script uses:

  • OpenSSH client:
    • for secure copying (scp remote file copy program)
    • for executing commands on a remote machine
  • tar archiving utility.

To perform a migration, access to remote servers and logging into them automatically without entering the password each time is required from the "source" box. So, the access keys should be copied from the "source" box into the destination box. If such keys are not uploaded, the script does it for you (use the --put-ssh-key option).

Preparation:

  1. Suspend the VPS server on the "source" box.
  2. Configure the destination machine to be VPS server host:
    • Install all required packages (FreeVPS kernel, FreeVPS tools, H-Sphere VPS scripts).
    • Complete all configuration tasks.

Actions performed by the script:

  • The remote host VPS servers configuration is loaded and checked
  • Platform compatibity is checked for the VPS box and the destination host. For example, a VPS under Enterprise Linux can't be moved to a host under RedHat Linux release 7.3.
  • The script checks whether a VPS with the same name as the migrated one exists on the destination box
  • Available free disk space on the destination host VPS home partition is checked as Free_space > VPS_disk_usage*1.5
  • The script checks if the VPS server virtual context number exists on the destination box:
    • if the migrated VPS server virtual context does not exist on the destination box, the VPS is created with this context
    • if it does exist, the first free virtual context is used for the migrated VPS.
  • Network interface which all the virtual network interfaces were attached to is checked. If a network interface doesn't exist on the destination host, new one is used, and the VPS network is reconfigured to be used to assign virtual network interfaces.
  • VPS home is archived using the tar utility filtered through gzip
  • MD5SUM for the source file is compared with that of the file copied to the remote host
  • VPS traffic data is migrated to the destination box
  • Post-migration:
    • Migrated VPS server(s) are scheduled for fix and configuration restore. The configuration (virtual context creation, limits comfiguration, disk usage quota check) is restored within 3 minutes by the crpn/vps-cron-fix.pl cron
    • Migrated VPS is suspended on the destination box, and should be resumed via H-Sphere or manualy.

For help, run:

# ./vps-migrate.pl --help
vps-migrate.pl         # Moves VPS(s) to another host.

Usage:
   vps-migrate.pl --host=<host> [--user=<name>] --vps=v<ps_name>|--all [--put-ssh-key] [--help]

--host            # <host> - host (DNS name/IP address) to migrate VPS(s) to.
--user            # <name> - username to be used to log into the host.
                  # If username is not specified, the name of the user executing the script will be taken.
--vps             # <vps_name> - VPS to be migrated.
--all             # Migrate all known VPSs.
--put-ssh-key     # Generate and upload public SSH keys to remote box.
--help            # Print this help information.

 

Delete VPS

vps-delete.pl

SYNTAX:
./vps-delete.pl VPS_HOST_NAME

  1. It removes existing VPS [VPS_HOST_NAME], all its configuration files, removes [VPS_HOST_NAME] from the list of known VPS.
  2. If [VPS_HOST_NAME] is being created by cron at the moment, [vps-delete.pl] posts deletion request for VPS (sets the DELETE parameter in the vps.list file)
  3. All deletion requests are processed by vps-cron-delete.pl cron every 4 minutes.

 

VPS Cron Scripts

These are VPS scripts scheduled in cron on the host server:

*/5 * * * * /hsphere/shared/scripts/cron/vps-cron.pl >/dev/null 2>&1
59 */1 * * * /hsphere/shared/scripts/cron/vps-cron-traf.pl >/dev/null 2>&1
*/4 * * * * /hsphere/shared/scripts/cron/vps-cron-delete.pl >/dev/null 2>&1
*/3 * * * * /hsphere/shared/scripts/cron/vps-cron-fix.pl >/dev/null 2>&1

1. vps-cron.pl

The $VPSSCRIPTS/cron/vps-cron.pl script (Default: /hsphere/shared/scripts/cron/vps-cron.pl) runs every 5 minutes. It is used to install and configure new Virtual Private Servers.

The script works as follows:

  1. It checks the list of known vservers and takes each VPS and processes requested tasks from the $HSVPSFILES/VPS_NAME/VPS_NAME.in file (Default: .../cp/VPS_NAME/VPS_NAME.in).
  2. If the requested task is successfully done, it creates a note in the $HSVPSFILES/VPS_NAME/VPS_NAME.out file (Default: .../cp/VPS_NAME/VPS_NAME.out)
  3. If all of the requested tasks are done, it creates the DONE file: $HSVPSFILES/VPS_NAME/VPS_NAME.done (Default: .../cp/VPS_NAME/VPS_NAME.done), and deletes the request file: $HSVPSFILES/VPS_NAME/VPS_NAME.in (Default: .../cp/VPS_NAME/VPS_NAME.in).
  4. It creates the FLAG file: $STATCRONPID (Default: /var/log/hsphere/vps_cron.pid) with its own PID, to prevent executing another copy of it.
  5. It creates all configuration files required for VPSs: $VPSCONFIGS/VPS_NAME.conf (Default: /hsphere/local/config/vserver/VPS_NAME.conf) $VPSCONFIGS/VPS_NAME.sh (Default: /hsphere/local/config/vserver/VPS_NAME.sh)
  6. It installs basic Linux RH7.3 packages and additional packages if configured, creates services, set limits, assigns IPs, and finally, starts VPS.

2. vps-cron-traf.pl

Processes VPS network traffic statistics. Creates files with VPS daily traffic statistics: /hsphere/local/var/statistic/DD.MM.YYYY.vps.txt

3. vps-cron-delete.pl

This cron script that runs every 4 minutes deletes VPS server(s) scheduled for removing.

VPS server is scheduled for removing in case it can't be deleted immediately after the removing request was sent, e.g. when other tasks need to be finished first.

Names of the VPS servers(s) scheduled for removing are listed delimited with whitespace in the DELETE parameter of the /hsphere/local/config/vserver/vps.list configuration file.

Example:

# cat /hsphere/local/config/vserver/vps.list
DELETE="vps1.psoft vps2.psoft"
VDU=""
VSERVERS="3:230.psoft 4:vps1.psoft 5:test.test 6:vps2.psoft 7:vps4.psoft 8:vps5.psoft 9:vps6.psoft 10:vps3.psoft 11:vps7.psoft 12:vps9.psoft
13:blabla.test.tst 14:vps11.psoft 15:vps12.psoft 16:vps13.psoft 17:vps-rh73-blank.psoft 18:vps14.psoft 21:newacc.test.tst
22:jumbo.jumbo23:vps200.hs.test 24:vps203.hs.test 25:vps207.hs.test 26:vps212.hs.test 27:myvps.test 28:my-server.test 29:krambambuli.test"
 

4. vps-cron-fix.pl

(HS VPS 1.3-6.4 and up)

This script fixes some VPS(s) configuration: limits, usage, etc.

For instance, it can fix VPS server(s) configuration that was "lost" when you upgraded the FreeVPS kernel after the host system (physical box) reboot.

Fixed parameters:

  • VPS server virtual context recreated
  • VPS root directory (new root for the created virtual context) set
  • VPS server files context fixed
  • VPS server inside user/group quotas for all filesystems configured in /etc/fstab checked
  • VPS disk usage calculated
  • all limits restored

The script runs as a cron job and is configured to fix corrupted configuration every 3 minutes. The script also checks and fixes VPS servers(s) daily.

If needed, you can run the script manually. Use --vps to fix a particular VPS and -f|--force to forcefully fix a virtual server(s) even if its(their) configuration is uncorrupted.

IMPORTANT:
It is recommended that you stop/suspend VPS server(s) before the fix.

For help, run:

# vps-cron-fix.pl --help
vps-cron-fix.pl   # Script for checking and fixing VPS(s) configuration: limits, usage, etc.
                  # The script is configured to check (and to fix if needed) VPS(s) configuration
                  every 3 minutes (run as a cron job).
                  # VPS(s) are fixed daily anyway.

Usage:
   vps-cron-fix.pl [--vps=<name>|-v <name>] [--force|-f]

-v|--vps    # Fixes particular VPS.
            # If not set - script will fix all known VPS servers.
-f|--force  # Run script by force (even if it was run today already).
--help      # Print this help information.

 

5. vps-cron-net-reconfig.pl (VPS Network Reconfiguration Cron)

HS VPS 1.4-1 and up

Location: $VPSSCRIPTS/cron/vps-cron-net-reconfig.pl (by default /hsphere/shared/scripts/cron/vps-cron-net-reconfig.pl)

This script runs every 5 minutes as cron to reconfigure virtual servers' network. If subnet configuration is changed, it reconfigures all affected virtual servers' configuration. If subnet default gateway or mask is changed, it reconfigures and restarts network for each virtual server. If network interface is changed on a virtual server, it restarts this virtual server.

Usage:

vps-cron-net-reconfig.pl [--vps=<name>] [--force]

--vps       # Process particular VPS.
           # If not set - script will process all registered virtual servers.
--force     # Run script by force
--help      # Print this help information.

Examples:

vps-cron-net-reconfig.pl --vps=vps.test --force
   # Process VPS server vps.test forcefully, even if the reconfig flag is not set

vps-cron-net-reconfig.pl --vps=vps.test
   # Process VPS server vps.test if the reconfig flag is set

vps-cron-net-reconfig.pl --force
   # Process all registered virtual servers, even if reconfigure flag is not set

vps-cron-net-reconfig.pl
   # Process all registered VPS server(s) if the reconfig flag is set

 

VPS Configuration Scripts

1) ./vps-addip.pl VPS_HOST_NAME IP:MASK
Assigns new IP address to the VPS_HOST_NAME virtual server.

2) ./vps-rmip.pl VPS_HOST_NAME IP[:MASK]
Removes IP from VPS_HOST_NAME.

3) ./vps-dlimit-set VPS_HOST_NAME DISK_LIMIT_VALUE
Sets disk usage limit for VPS_HOST_NAME to DISK_LIMIT_VALUE, in Mb.

4) ./vps-dlimit-get VPS_HOST_NAME
Returns disk limit and disk usage for VPS_HOST_NAME.

5) ./vps-mlimit-set VPS_HOST_NAME MEMORY_LIMIT_VALUE
Sets memory limit for the VPS_HOST_NAME server to MEMORY_LIMIT_VALUE, in Mb

6) ./vps-mlimit-get VPS_HOST_NAME
Returns memory limit and memory usage for VPS_HOST_NAME

7) ./vps-plimit-set VPS_HOST_NAME PROCESS_LIMIT_VALUE
Sets limit on the number of processes running on VPS_HOST_NAME to PROCESS_LIMIT_VALUE, in Mb

8) ./vps-plimit-get VPS_HOST_NAME
Returns the limit on and the number of processes running on VPS_HOST_NAME

9) ./vps-flimit-get VPS_HOST_NAME
Returns file handlers limit, and the number of opened at this moment files VPS_HOST_NAME

10) ./vps-flimit-set VPS_HOST_NAME
Sets file handlers limit for VPS_HOST_NAME

11) ./vps-tcplimit-get VPS_HOST_NAME
Returns the limit on socket connections and the number of established connections for VPS VPS_HOST_NAME

12) ./vps-tcplimit-set VPS_HOST_NAME
Sets limit for established socket connections for VPS VPS_HOST_NAME

13) ./vps-dev-speed.pl
Tools to get|set the speed of virtual network interface.
Note: Virtual network interface speed must be divisible by 64000.
Usage: vps-eth-speed.pl VPS_NAME [--dev=<device>|-d <device>] --get|--set <SPEED>
For more information, please run: vps-dev-speed.pl --help

14) ./vps-dev-speed-set VPS_NAME [--dev=<device>|-d <device>] <SPEED>
Sets work speed to <SPEED> Kb/sec for virtual network interface <device> on Virtual Private Server VPS_NAME
Note: Virtual network interface speed (<SPEED> value) must be divisible by 64000.
Note: If --dev=<device>|-d <device> option not specified, <SPEED> value will be set to all registered virtual network interfaces on VPS VPS_NAME

15) ./vps-dev-speed-get VPS_NAME [--dev=<device>|-d <device>]
Returns work speed for virtual network interface <device> on Virtual Private Server VPS_NAME
Note: If --dev=<device>|-d <device> option not specified, returns speed for all virtual network interfaces registered on VPS VPS_NAME, in the following format:

VDEV0 SPEED0
VDEV1 SPEED1
...

16) ./vps-start.pl [VPS_HOST_NAME | [-a|--all]]
Turns on VPS_HOST_NAME, or all known stopped VPS servers if the -a|--all option is specified.

17) ./vps-stop.pl [VPS_HOST_NAME | [-a|--all]]
Turns off VPS_HOST_NAME, or all known running VPS servers if the -a|--all option is specified.

18) ./vps-suspend.pl [VPS_HOST_NAME | [-a|--all]]
Suspends (turns off and sets ONBOOT=no) vserver [VPS_HOST_NAME], or all known VPS servers if the -a|--all option is specified.

19) ./vps-resume.pl [VPS_HOST_NAME | [-a|--all]]
Resumes (turns on and sets ONBOOT=yes) vserver [VPS_HOST_NAME], or all known VPS servers if the -a|--all option is specified.

20) ./vps-rootpwd.pl VPS_HOST_NAME
To set new password for user root, send it to STDIN.

21) ./vps-du.pl
Returns disk usage for all known VPSs on the host server in the format required by H-Sphere Control Panel.

22) ./vps-get-config.pl VPS_HOST_NAME
Returns all VPS configuration parameters in the format required by H-Sphere Control Panel.

 

View List of Installed VPS's

The ./vps-list.pl script returns brief information about all VPS installed on the host server, installed VPS packages, values of configuration variables.

Example:

# ./vps-list.pl

Kernel release: 2.4.21-freevps-1.3-22smp
FreeVPS kernel patch build: 0 [19691231]
FreeVPS tools release: 1.3-9
H-Sphere VPS release: 1.3-6.4 [20050426]
Linux release: CentOS release 3.3 (final) [CentOS3]
Free disk space on VPS home [/home/hsphere/local/vservers]: 9346 Mb

Virtual Private Servers found on the host:
----------------------------------------------------------------------------------------------------------------------------
ID NAME              STATUS VDEV:HDEV:IP/MASK+|-(UP|DOWN) DISK (Mb)     MEMORY (Mb) SWAP   PROCESSES CPU (%)    TRAFFIC
-----------------------------------------------------------------------------------------(Mb)------------s--h--used-----(Mb)
5  vps1.psoft              run. eth0:eth0:10.0.0.2/24-        0     1707.6  0    0.8    0.5    0    5    0  0  0    0.0
6  vps2.psoft              run. eth0:eth0:160.79.224.138/24+  0     425.0   0    2.2    1.4    0    8    0  0  0    0.0
----------------------------------------------------------------------------------------------------------------------------

Display all settings for VPSs on this host [y/n]? 

 

Install/Uninstall Additional Packages

  • To install an additional template or package into completely created virtual server use vps-pkg-inst.pl script.
    Run # ./vps-pkg-inst.pl --help to get help on the script options:
    vps-pkg-inst.pl   # Install template or single package into Virtual Private Server(s)
    
    Usage:
       vps-pkg-inst.pl --vps=<vps_name>|--all --package=<package_name>|--template=<template> [--help]
    
    --vps       # <vps_name> - VPS server name to install package/template
    --all       # install package/template into all registered and complately created VPS servers
    --package   # <package_name> - RPM package file to be installed full path and name
    --template  # <template> - template to be installed name.
               # rpm_<template>.cfg templete configuration file must be located in corresponding operating system
               VPS configuration directory
               # All RPM packages included in rpm_<template>.cfg file must be located in corresponding operating
               system distributive packages directory
    --help      # Print this help information.
    
    Example:
    vps-pkg-inst.pl --vps=vps.test --template=web-server
       # Install web-server template packages into VPS server named vps.test
    
    vps-pkg-inst.pl --all --template=system-tools
       # Install system-tools template packages into all registered on the host VPS servers
    
    vps-pkg-inst.pl --vps=vps.test --package=/pub/RedHat/RHES3/vim-enhanced-6.2.98-1.i386.rpm
       # Install vim-enhanced-6.2.98-1 package into VPS server named vps.test

    During template installation the script tries to start default (coresponding to installing template/package) services. Any other service should be started manualy from inside of the VPS. No services configuration is performed during the template/package installation. Please read more about virtual server template creation and management in the H-Sphere VPS Templates.

  • To unistall any template or package installed inside virtual server, use vps-pkg-remove.pl script
    Run # ./vps-pkg-remove.pl --help to get help on the script options:
    vps-pkg-remove.pl   # Uninstall template or single package from Virtual Private Server(s)
    
    Usage:
       vps-pkg-remove.pl --vps=<vps_name>|--all --package=<package_name>|--template=<template> [--help]
    
    --vps       # <vps_name> - VPS server name to uninstall package/template
    --all       # uninstall package/template from all registered and complately created VPS servers
    --package   # <package_name> - RPM package to be uninstalled name
    --template  # <template> - template to be uninstalled name.
               # rpm_<template>.cfg templete configuration file must be located in corresponding operating
               system VPS configuration directory
    --help      # Print this help information.
    
    Example:
    vps-pkg-remove.pl --vps=vps.test --template=web-server
       # Uninstall web-server template packages from VPS server named vps.test
    
    vps-pkg-remove.pl --all --template=system-tools
       # Uninstall system-tools template packages from all registered on the host VPS servers
    
    vps-pkg-remove.pl --vps=vps.test --package=vim-enhanced-6.2.98-1
       # Uninstall vim-enhanced-6.2.98-1 package from VPS server named vps.test

    Be carefull when packages are removed. We do not provide any back-ups to enable services (corresponding to a template/package removal) configuration restore. If any of the packages (single or included into the removed template) required by any other template installed , the package will be not removed.

 

Check VPS Files For Changes

HS VPS 1.3-6.4 and up

This action is performed by the vps-files-md5-check.pl script. It compares info of the package installed files with that of the package metadata stored in the rpm database. Parameters compared are size, MD5 sum, permissions, type, owner, and group of each file.

The --verify option of the RPM Package Manager is used. For reference, please turn to the rpm manual.

Example of usage: Say, the file info has been changed as a result of the box hacking. The script checks the file inside VPS for changes and proposes to copy this file from the host system.

WARNING:
We strongly recommend not to overwrite non-binary files, e.g. configs. This may cause the system malfunction.
Before copying, find out which files have been changed by running the script with the listing options.

For help info, run:

# vps-files-md5-check.pl --help
vps-files-md5-check.pl          # Check installed files information for changes.

Usage:
   vps-files-md5-check.pl --vps=<vps_name>|--root=<directory> [--list|--list-all [--detailed]] [--copy-all]

--vps           # <vps_name> - VPS name to check.
--root          # <directory> - new root directory to check (packages must be installed with the --root option).
--list          # List changed files.
--list-all      # List all changed files (config, license, readme, doc, ghost file, etc.).
--detailed      # Show file changes.
--copy-all      # Do not ask to copy modified file from the host.
--help          #Print this help information.

Example:

# ./vps-files-md5-check.pl --vps=vps4.psoft --list-all --detailed
S.5....T c /etc/pam.d/system-auth
   %config configuration file.
       file Size differs
       MD5 sum differs
       mTime differs
.......T c /etc/inittab
   %config configuration file.
       mTime differs
.......T c /etc/mail/sendmail.cf
   %config configuration file.
       mTime differs
.......T c /etc/krb5.conf
   %config configuration file.
       mTime differs
S.5....T c /etc/sysconfig/rhn/up2date-uuid
   %config configuration file.
       file Size differs
       MD5 sum differs
       mTime differs

In the above example, there are no files to overwrite because all of them are %config configuration files.

In the next example we are changing /bin/true binary:

# ./vps-files-md5-check.pl --vps=vps4.psoft --list-all --detailed
<...>
..5....T   /bin/true
       MD5 sum differs
       mTime differs
<...>

The script shows that MD5 sum for rpm database differs from that of the binary file. To copy the file from the host, run:

# ./vps-files-md5-check.pl --vps=vps4.psoft

Would you like to copy /bin/true from the host [y/n]? y

 

VPS IP Migration Tool

HS VPS 1.3-6.6 and up

vps-ip-migrate.pl is used to change virtual servers' IP addresses (in other words, IP migration).

For help, run:

# ./vps-ip-migrate.pl --help
vps-ip-migrate.pl   # VPS server IP migration script.

Usage:
   vps-ip-migrate.pl --vps=<vps_name>|--all --xml=<xml_ip_map> [--help]

--vps       # <vps_name> - VPS server name to perform IP migration
--all       # perform IP migration for all registered VPS servers
--xml       # <xml_ip_map> - XML structured IP map migration file
--help      # Print this help information.

Example:

vps-ip-migrate.pl --vps=vps.test --xml=ip_map.xml
   # Perform IP migration for vps.test according to the ip_map.xml IP map file

vps-ip-migrate.pl --all --xml=ip_map.xml
   # Perform IP migration for all registered in the host VPS servers according to the
   ip_map.xml IP map file

Options:

  • --all - when it's used, IPs will be changed for all Virtual Servers registered in the host (physical machine)
  • --vps=<vps_name> - used for IP change/migration on a single <vps_name> VPS
  • --xml=<xml_ip_map> - full name of structured IP migration map xml file

When calling the script, it's mandatory to use --all or --vps option.

IMPORTANT!
This script doesn't make any changes to H-Sphere cluster. It physicaly changes IP(s) created ONLY inside VPS server(s).
Read on IP migration (changing IPs) for the H-Sphere cluster.

 

VPS Network Configuration Tools

HS VPS 1.4-1 and up

H-Sphere VPS 1.4-1 provides adding multiple subnets and network gateways to virtual servers. The following scripts located in the $VPSSCRIPTS/ (/hsphere/shared/scripts/ by default) are responsible for managing VPS subnets:

  • vps-subnets-add.pl - add new subnet to network gateways (subnets configuration file);
  • vps-subnets-change.pl - change existing subnet configuration;
  • vps-subnets-del.pl - remove configuration for particular subnet;
  • vps-subnets-list.pl - print subnet configuration;
  • vps-subnets-xml-get.pl - print XML structured subnet configuration;
  • vps-subnets-xml-put.pl - save XML structured subnet configuration;

Run these scripts with the --help option for detailed usage info.

These scripts work with the subnet configuration XML file.

vps-subnets-add.pl

Configures subnet (IP addresses to be assigned to newly created VPS servers) with gateway, IP mask and network interface. Please turn to your data center system administrators for subnet configuration information.

Usage:

vps-subnets-add.pl --addr=<addr> --device=<device> --gateway=<gateway> --mask=<mask> [--help]

--addr      # <addr> - subnet address
--device    # <device> - Linux style name of the network interface to which subnet IPs will be assigned.
            # For example eth0 (eth1, ...)
            # To list available interfaces run: net-iface-list.pl
--gateway   # <gateway> - gateway to be used by IPs from this subnet
--mask      # <mask> - IPs mask
--help      # Print this help information.

Example:

vps-subnets-add.pl --addr 192.168.112.0 --device eth1 --gateway 192.168.112.1 --mask 255.255.255.0

Configures all 192.168.112.x IPs (subnet 192.168.112.0) to be assigned to network interface eth1 with gateway 192.168.112.1 and mask 255.255.255.0

vps-subnets-change.pl

Changes subnet configuration, such as, gateway or/and IP mask and/or network interface.

Usage:

vps-subnets-change.pl --addr=<addr> --device=<device>|--gateway=<gateway>|--mask=<mask> [--help]

--addr      # <addr> - subnet network address whose configuration is to be changed
--device    # <device> - Linux style name of the new network interface to which subnet IPs will be assigned.
            # For example eth0 (eth1, ...)
--gateway   # <gateway> - new gateway to be used by IPs from this subnet
--mask      # <mask> - new IP mask
--help      # Print this help information.

Example:

vps-subnets-change.pl --addr 192.168.112.0 --device eth2

Configures all 192.168.112.x IPs (subnet 192.168.112.0) to be assigned to new network interface eth2 (use old gateway and mask)

vps-subnets-del.pl

Deletes subnet configuration according to the XML config file.

Usage:

vps-subnets-del.pl <addr> [--help]

           # <addr> - subnet address whose configuration is to be removed
--help     # Print this help information.

Example:

vps-subnets-del.pl 192.168.112.0

Removes 192.168.112.0 subnet configuration.

vps-subnets-list.pl

Prints VPS subnet configuration from the XML config file.

Usage:

vps-subnets-list.pl [--help|-h]

--help      # Print this help information.

vps-subnets-xml-put.pl

Stores virtual servers' subnet configuration into the XML config file.

Usage:

vps-subnets-xml-put.pl [--help|-h]

--help      # Print this help information.

 

Device Management

H-Sphere VPS 1.4-4 and up

Global and per virtal context device management is available in command-line mode starting with kernel-freevps-1.5-6 and freevps-tools-1.4-3.
Low level management is provided with vaccess tool that comes in FreeVPS tools package. To get more info on the vaccess tool, run:

# man vaccess

Virtual device management isn't yet available in H-Sphere control panel interface.

 

Global VPS Device Management

Global VPS device management is realized through two scripts: vps-dev-global-add.pl and vps-dev-global-del.pl.

By default only these character devices requried for basic virtual servers functionality are enabled:
    1.3, 1.5, 1.7, 1.8, 1.9, 5.0, 5.2, 136.all, 200.all (null, zero, full, random, urandom, tty, ptmx, tun)

Block devices are not enabled by default and if needed, must be enabled additionally.

To check what devices are enabled on your host virtual servers, run the following command:
  • character devices:
    # vserver_ctl --ctx 1 --exec cat /proc/vservers/access/chardev
  • block devices:
    # vserver_ctl --ctx 1 --exec cat /proc/vservers/access/blockdev

 

vps-dev-global-add.pl enables device for all virtual servers and has the following syntax:

# ./vps-dev-global-add.pl --help
vps-dev-global-add.pl         # Enables device globally (for all virtual servers)

Usage:
  vps-dev-global-add.pl  --dev=<dev_name>|(--ftype=<file_type> --dtype=<device_type>) [--help]

--dev       # <dev_name> - device name
--ftype     # <file_type> - device file type:
          # c - a character special file
          # b - a block special file
--dtype     # <device_type> - device type in the MAJOR.MINOR format
          # for example: 1.3
--help      # Print this help information.

Example:
vps-dev-global-add.pl --dev="tun"
  # Enable /dev/tun for all virtual servers
vps-dev-global-add.pl --ftype=c --dtype="10.200"
  # Enable character device type 10.200 (/dev/tun) for all virtual servers

 

vps-dev-global-del.pl disables device globally for all registered virtual servers and its syntax is the same as for script vps-dev-global-add.pl

To get more info on the script, run:

# ./vps-dev-global-del.pl --help

 

Per Virtual Server Device Management

Per virtual server device management is realized through two scripts: vps-dev-add.pl and vps-dev-del.pl.

You can check devices enabled for individual virtual context by the following command:

  • character devices:
    # vserver_ctl --ctx 1 --exec cat /proc/vservers/<ID> | grep Char
  • block devices:
    # vserver_ctl --ctx 1 --exec cat /proc/vservers/<ID> | grep Block

where, <ID> is a virtual context ID, for example 3, 4, etc.

H-Sphere VPS device management tools enable usage of virtual servers names instead of virtual contexts IDs.

 

vps-dev-add.pl enables individual device for all virtual servers and has the following syntax:
vps-dev-add.pl --vps=<vps_name>--dev=<dev_name>|(--ftype=<file_type>--dtype=<device_type>) [--help], where --vps # <vps_name> is a virtual server name and other parameters are the same as for vps-dev-global-add.pl.

For example:
vps-dev-add.pl --vps=vps.tst --dev="tun" will enable /dev/tun for virtual server vps.tst;
vps-dev-add.pl --vps=vps.tst --ftype=c --dtype="10.200" will enable character device type 10.200 (/dev/tun) for virtual server vps.tst

To get more info on the script, run:

# ./vps-dev-add.pl --help

 

vps-dev-del.pl disables device for virtual server and its syntax is the same as for script vps-dev-add.pl

To get more info on the script, run:

# ./vps-dev-del.pl --help

For example:
vps-dev-del.pl --vps=vps.tst --dev="tun" will disable /dev/tun for virtual server vps.tst; vps-dev-del.pl --ftype=c --dtype="10.200" will disable character device of the 10.200 type (which is /dev/tun) for virtual server vps.tst.

To get more info on the script, run:

# ./vps-dev-del.pl --help

Related Docs:   VPS Installation FreeVPS Docs



© Copyright 2017. Parallels Holdings. All rights reserved.