Subversion-Projekte lars-tiefland.openvz_admin

Revision

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

Revision 143 Revision 152
Zeile 1... Zeile 1...
1
<?php
1
<?php
2
	//$Id: vServer.class.php 143 2008-08-08 22:06:36Z lars $
2
	//$Id: vServer.class.php 152 2009-06-20 22:09:15Z 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
	class vServer
7
	class vServer
Zeile 197... Zeile 197...
197
			return $out_v;
197
			return $out_v;
198
		}
198
		}
Zeile 199... Zeile 199...
199
 
199
 
200
		function save($v_name, $v_dist, $v_ip, $v_r_pw)
200
		function save($v_name, $v_dist, $v_ip, $v_r_pw)
201
		{
201
		{
202
			global $db, $smarty;
202
			global $db, $smarty, $title, $tpl_file;
203
			$this->name = $v_name;
203
			$this->name = $v_name;
204
			$this->dist_id = $v_dist;
204
			$this->dist_id = $v_dist;
205
			unset($out);
205
			unset($out);
206
			$d = new Dist($v_dist);
206
			$d = new Dist($v_dist);
Zeile 212... Zeile 212...
212
			$db->beginTransaction();
212
			$db->beginTransaction();
213
			$sql = "INSERT into vservers (v_id, hn_id, v_name, v_dist) VALUES ($this->v_id, $this->hn_id, '$this->name', $this->dist_id)";
213
			$sql = "INSERT into vservers (v_id, hn_id, v_name, v_dist) VALUES ($this->v_id, $this->hn_id, '$this->name', $this->dist_id)";
214
			$res = $db->query($sql);
214
			$res = $db->query($sql);
215
			if (!PEAR::isError($res))
215
			if (!PEAR::isError($res))
216
			{
216
			{
217
				$v_id = $db->lasinsertid();
217
				$v_id = $db->lastinsertid();
218
				$sql_ip = "SELECT id FROM ips WHERE ip='$v_ip'";
-
 
219
				$res_ip = $db->query($sql_ip);
-
 
220
				if (!PEAR::isError($res_ip))
-
 
221
				{
-
 
222
					$row_ip = $res->fetchRow();
-
 
223
					$ip_id = $row_ip["id"];
-
 
224
					$sql = "INSERT INTO host_2_ip (ve_id, ip) VALUES ($v_id,$ip_id)";
218
					$sql = "INSERT INTO host_2_ip (ve_id, ip) VALUES ($v_id,$v_ip)";
225
					$res = $db->query($sql);
219
					$res = $db->query($sql);
226
					if (!PEAR::isError($res))
220
					if (!PEAR::isError($res))
227
					{
221
					{
228
						$cmd = "ssh root@mainframe vzctl create $this->v_id --hostname $v_name --ostemplate $d_template --config vps.$d_name --ipadd " .
222
						$cmd = "ssh root@mainframe vzctl create $this->v_id --hostname $v_name --ostemplate $d_template --config vps.$d_name --ipadd " .
229
							$ip["ip"];
223
							$ip["ip"];
Zeile 245... Zeile 239...
245
					else
239
					else
246
					{
240
					{
247
						$smarty->assign("error", true);
241
						$smarty->assign("error", true);
248
						$smarty->assign("meld", "Ein Fehler ist aufgetreten!");
242
						$smarty->assign("meld", "Ein Fehler ist aufgetreten!");
249
						$smarty->assign("db_meld", $res->getUserInfo());
243
						$smarty->assign("db_meld", $res->getUserInfo());
-
 
244
							$tpl_file="meld.tpl";
-
 
245
							$title="Fehler";
250
						$db->rollback();
246
						$db->rollback();
251
					}
247
					}
252
				}
-
 
253
				else
-
 
254
				{
-
 
255
					$smarty->assign("error", true);
-
 
256
					$smarty->assign("meld", "Ein Fehler ist aufgetreten!");
-
 
257
					$smarty->assign("db_meld", $res_ip->getUserInfo());
-
 
258
					$db->rollback();
-
 
259
				}
-
 
260
			}
248
			}
261
			else
249
			else
262
			{
250
			{
263
				$smarty->assign("error", true);
251
				$smarty->assign("error", true);
264
				$smarty->assign("meld", "Ein Fehler ist aufgetreten!");
252
				$smarty->assign("meld", "Ein Fehler ist aufgetreten!");