Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 155 | Revision 158 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 155 Revision 157
Zeile 1... Zeile 1...
1
<?php
1
<?php
2
	//$Id: load.php 155 2009-06-21 13:34:11Z lars $
2
    //$Id: load.php 157 2009-11-07 21:43:00Z lars $
3
	/**
3
    /**
4
	 * 	@package	openvz_admin
4
     * 	@package	openvz_admin
5
	 * 	@author		Lars Tiefland <ltiefland@gmail.com> 
5
     * 	@author		Lars Tiefland <ltiefland@gmail.com> 
6
	 **/
6
     **/
7
	require ("include/common.php");
7
    require ( "include/common.php" );
8
	$hns = HN::getHNs();
8
    $hns = HN::getHNs();
9
	unset($hns[-1]);
9
    unset( $hns[-1] );
10
	foreach ($hns as $hn_id => $hn_name)
10
    foreach ( $hns as $hn_id => $hn_name )
11
	{
11
    {
12
		$configs = load_configs($hn_id, $hn_name);
12
        $configs = load_configs( $hn_id, $hn_name );
13
		foreach ($configs as $conf_id => $config)
13
        foreach ( $configs as $conf_id => $config )
14
		{
14
        {
15
			$cfg = read_config($hn_id, $hn_name, $config);
15
            $cfg = read_config( $hn_id, $hn_name, $config );
16
			update_db($hn_id, $cfg);
16
            update_db( $hn_id, $cfg );
17
		}
17
        }
18
	}
18
    }
Zeile 19... Zeile 19...
19
 
19
 
20
	function load_configs($hn_id, $hn_name)
20
    function load_configs( $hn_id, $hn_name )
21
	{
21
    {
22
		unset($out);
22
        unset( $out );
23
		$cmd = "ping $hn_name -w1";
23
        $cmd = "ping $hn_name -w1";
24
		exec($cmd, $out, $ret);
24
        exec( $cmd, $out, $ret );
25
		if(!$ret)
25
        if ( !$ret )
26
		{
26
        {
27
			echo "Hole Konfigurationen von $hn_name\n";
27
            echo "Hole Konfigurationen von $hn_name\n";
28
			unset( $out );
28
            unset( $out );
29
			$cmd = "ssh root@$hn_name ls /etc/vz/conf/*.conf";
29
            $cmd = "ssh root@$hn_name ls /etc/vz/conf/*.conf";
30
			exec($cmd, $out, $ret);
30
            exec( $cmd, $out, $ret );
31
			return $out;
31
            return $out;
32
		}
32
        }
Zeile 33... Zeile 33...
33
	}
33
    }
34
 
34
 
35
	function read_config($hn_id, $hn_name, $config)
35
    function read_config( $hn_id, $hn_name, $config )
36
	{
36
    {
37
		$config = basename($config);
37
        $config = basename( $config );
38
		$cmd = "scp root@$hn_name:/etc/vz/conf/$config cfgs/$hn_id";
38
        $cmd = "scp root@$hn_name:/etc/vz/conf/$config cfgs/$hn_id";
39
		exec($cmd, $out, $ret);
39
        exec( $cmd, $out, $ret );
40
		$conf = file("cfgs/$hn_id/$config");
40
        $conf = file( "cfgs/$hn_id/$config" );
41
		$conf[] = "v_id=\"" . substr($config, 0, strpos($config, '.')) . "\"";
41
        $conf[] = "v_id=\"" . substr( $config, 0, strpos($config, '.') ) . "\"";
42
		foreach ($conf as $value)
42
        foreach ( $conf as $value )
43
		{
43
        {
44
			if ($value)
44
            if ( $value )
45
			{
45
            {
46
				$value = rtrim($value);
46
                $value = rtrim( $value );
47
				if ($value[0] == " " || $value[0] == "#")
47
                if ( $value[0] == " " || $value[0] == "#" )
48
				{
48
                {
49
					continue;
49
                    continue;
50
				}
50
                }
51
				$cfg_v = explode("=", $value);
51
                $cfg_v = explode( "=", $value );
52
				$cfg_val[$cfg_v[0]] = trim($cfg_v[1], '"');
52
                $cfg_val[$cfg_v[0]] = trim( $cfg_v[1], '"' );
53
			}
53
            }
54
			else
54
            else
55
			{
55
            {
56
				continue;
56
                continue;
57
			}
57
            }
58
		}
58
        }
59
		$cfgs[] = $cfg_val;
59
        $cfgs[] = $cfg_val;
Zeile 60... Zeile 60...
60
		return $cfgs;
60
        return $cfgs;
61
	}
61
    }
62
 
62
 
Zeile 172... Zeile 269...
172
				}
269
                }