public function populate(&$entry, $row) { parent::populate($entry, $row); $entry->setKeywords(pg_to_php_array($row->keywords)); $entry->setDisciplineID(pg_to_php_array($row->disciplineid)); $entry->setCategoryID(pg_to_php_array($row->categoryid)); }
public function populate(&$entry, $row) { parent::populate($entry, $row); $entry->setIDPTrace(pg_to_php_array($row->idptrace)); }
public static function findOSOrAlias($os) { db()->setFetchMode(Zend_Db::FETCH_OBJ); $rs = db()->query("SELECT find_os(?) AS os", array(trim($os)))->fetchAll(); $oses = array(); foreach ($rs as $r) { if ($r->os !== null) { $os = $r->os; $os = pg_to_php_array($os); if ($os[3] !== false) { $os[3] = pg_to_php_array($os[3]); } else { $os[3] = null; } $oses[] = $os; } } if (count($oses) > 0) { $os = $oses[0]; $oses = new Default_Model_OSes(); $oses->filter->id->equals($os[0]); if (count($oses->items) > 0) { return $oses->items[0]; } } else { return null; } }
public function findOS($os) { db()->setFetchMode(Zend_Db::FETCH_OBJ); $rs = db()->query("SELECT find_os('Windows RTM') AS os")->fetchAll(); $oses = array(); foreach ($rs as $r) { if ($r[0]->os !== null) { $os = $r[0]->os; $os = pg_to_php_array($os); if ($os[3] !== false) { $os[3] = pg_to_php_array($os[3]); } else { $os[3] = null; } $oses[] = $os; } } if (count($oses) > 0) { return $oses; } else { return null; } }
public function populate(&$entry, $row) { parent::populate($entry, $row); $entry->setTags(pg_to_php_array($row->tags)); }
public function populate(&$entry, $row) { parent::populate($entry, $row); $entry->setSiteID(pg_to_php_array($row->siteid)); $entry->setOrganizationID(pg_to_php_array($row->organizationid)); }
public function populate(&$entry, $row) { parent::populate($entry, $row); $entry->setRecipients(pg_to_php_array($row->recipients)); }
public function parseVAppImageInstance($xml, $parent = null) { $isupdated = false; $contextscript = null; $flavour = $this->parseVAppFlavour($xml, $parent); if ($flavour === false) { return false; } $m = $this->getItem("vmiinstance", $xml); $version = strval($xml->attributes()->version); if (Supports::singleVMIPolicy()) { //IN case of single VMI policy //set VAVersion version as VMI version //and VAVersion description as VMI description $wver = $this->getCurrentVAVersion(); if ($wver !== NULL) { $m->version = $wver->version; $m->description = $wver->notes; } } else { if ($this->validateVersion($version) === false) { return $this->_setErrorMessage("Invalid version value for VMI Instance."); } else { $m->version = $version; } } if (!$m->guid) { if (count($xml->xpath('./virtualization:identifier')) > 0) { $tmpguid = $xml->xpath('./virtualization:identifier'); $tmpguid = strval($tmpguid[0]); if (strlen(trim($tmpguid)) > 0) { $m->guid = $tmpguid; } if ($this->validateIdentifier($m->guid) === false) { return $this->_setErrorMessage("Invalid identifier value for VMI Instance"); } } } if (intval($m->vmiflavourid) !== intval($flavour->id)) { $isupdated = true; } $m->vmiflavourid = $flavour->id; //Check if existing image instance can be included in //specific vmi. (belongs in the same version, vappliance etc) $caninclude = $this->canIncludeImageInstance($m, $parent); if ($caninclude !== true) { return $this->_setErrorMessage($caninclude); } //check if urls are in valid format if (count($xml->xpath('./virtualization:url')) > 0) { $xuri = $xml->xpath('./virtualization:url'); $xuri = strval($xuri[0]); if (trim($m->uri) !== trim($xuri)) { $m->integrityStatus = ""; $m->integrityMessage = ""; } if (trim($m->uri) !== "" && trim($m->uri) != trim($xuri)) { $isupdated = true; debug_log("last updated url"); } $m->uri = $xuri; if ($this->validateUrl($m->uri) === false) { return $this->_setErrorMessage("Invalid URL value for VMI Instance."); } } if (count($xml->xpath('./virtualization:cores')) > 0) { $cores = $xml->xpath('./virtualization:cores'); $cores = $cores[0]; if (strlen(trim(strval($cores->attributes()->minimum))) > 0) { $coresmin = strval($cores->attributes()->minimum); if (is_numeric($coresmin) && intval($coresmin) >= 0) { if (trim($m->coreminimum) !== "" && intval($m->coreminimum) != intval($coresmin)) { $isupdated = true; debug_log("last updated core min"); } $m->coreminimum = intval($coresmin); } else { return $this->_setErrorMessage("Minimum cores value must be a positive number"); } } if (strlen(trim(strval($cores->attributes()->recommended))) > 0) { $coresrecom = strval($cores->attributes()->recommended); if (is_numeric($coresrecom) && intval($coresrecom) >= 0) { if (trim($m->coreRecommend) !== "" && intval($m->coreRecommend) != intval($coresrecom)) { $isupdated = true; debug_log("last updated core recom"); } $m->coreRecommend = intval($coresrecom); } else { return $this->_setErrorMessage("Recommended cores value must be a positive number"); } } } if (count($xml->xpath('./virtualization:ram')) > 0) { $ram = $xml->xpath('./virtualization:ram'); $ram = $ram[0]; if (strlen(trim(strval($ram->attributes()->minimum))) > 0) { $rammin = strval($ram->attributes()->minimum); if (is_numeric($rammin) && intval($rammin) >= 0) { if (trim($m->RAMminimum) !== "0" && intval($m->RAMminimum) != intval($rammin)) { $isupdated = true; } $m->RAMminimum = intval($rammin); } else { return $this->_setErrorMessage("Minimum RAM value must be a positive number"); } } if (strlen(trim(strval($ram->attributes()->recommended))) > 0) { $ramrecom = strval($ram->attributes()->recommended); if (is_numeric($ramrecom) && intval($ramrecom) >= 0) { if (trim($m->RAMrecommend) !== "" && intval($m->RAMrecommend) != intval($ramrecom)) { $isupdated = true; } $m->RAMrecommend = intval($ramrecom); } else { return $this->_setErrorMessage("Recommended RAM value must be a positive number"); } } } if (count($xml->xpath('./virtualization:title')) > 0) { $title = $xml->xpath('./virtualization:title'); $title = (string) $title[0]; $title = strip_tags($title); if (strlen(trim($title)) > 0) { if ($this->validateTitle($title) === false) { return $this->_setErrorMessage("Invalid title value for VMI Instance."); } else { if (trim($m->title) != trim($title)) { $isupdated = true; } $m->title = trim($title); } } } else { $m->title = ""; } if (Supports::singleVMIPolicy() === false && count($xml->xpath('./virtualization:description')) > 0) { $description = $xml->xpath('./virtualization:description'); $description = (string) $description[0]; $description = strip_tags($description); if (strlen(trim($description)) > 0) { if ($this->validateNotes($description) === false) { return $this->_setErrorMessage("Invalid description value for VMI Instance."); } } if (trim($m->description) !== trim($description)) { $isupdated = true; } $m->description = $description; } if (count($xml->xpath('./virtualization:notes')) > 0) { $notes = $xml->xpath('./virtualization:notes'); $notes = (string) $notes[0]; $notes = strip_tags($notes); if (strlen(trim($notes)) > 0) { if ($this->validateNotes($notes) === false) { return $this->_setErrorMessage("Invalid comments value for VMI Instance."); } } if (trim($m->notes) !== trim($notes)) { $isupdated = true; } $m->notes = $notes; } //Check if user disabled image file integrity checks. $checkintegrity = true; if (strlen(trim(strval($xml->attributes()->integrity))) > 0) { if (strval($xml->attributes()->integrity) == "false") { $checkintegrity = false; } else { $checkintegrity = true; } } //If integrity checks are disabled then //user must send file size and checksums //else raise error. if ($checkintegrity === false) { if (count($xml->xpath('./virtualization:size')) > 0) { $size = $xml->xpath('./virtualization:size'); $size = (string) $size[0]; if (!is_numeric($size) || intval($size) <= 0) { return $this->_setErrorMessage("Invalid image file size value for VMI Instance."); } } $checksum = ""; if (count($xml->xpath('./virtualization:checksum')) > 0) { $checksum = $xml->xpath('./virtualization:checksum'); $checksum = $checksum[0]; } if (strlen(trim(strval($checksum))) > 0) { $checksum = $xml->xpath('./virtualization:checksum'); $checksum = $checksum[0]; if ($m->checksum !== strval($checksum) || $m->size !== intval($size)) { $m->integrityStatus = ""; $m->integrityMessage = ""; } if (trim($m->size) !== "" && intval($m->size) !== intval($size)) { $isupdated = true; } $m->size = $size; if (trim($m->checksum) !== "" && trim($m->checksum) !== trim($checksum)) { $isupdated = true; } $m->checksum = strval($checksum); $m->checksumfunc = strval($checksum->attributes()->hash); $m->checksumfunc = strtolower(trim($m->checksumfunc)); if (strlen(trim($m->checksum)) == 0) { return $this->_setErrorMessage("Invalid checksum value for VMI Instance."); } if (strlen(trim($m->checksumfunc)) == 0 || in_array($m->checksumfunc, array("sha512", "sha384", "sha256", "sha224", "sha1", "md5")) === false) { $m->checksumfunc = "sha512"; } } } else { $m->size = 0; $m->checksum = ''; $m->checksumfunc = 'sha512'; } $m->autointegrity = $checkintegrity; if (!is_numeric($m->id) || intval($m->id) <= 0) { /*new instance*/ $addedby = $this->_parent->getUser(); if ($addedby && intval($addedby->id) > 0) { $m->addedbyid = $addedby->id; } $m->initialchecksum = $m->checksum; $m->initialsize = $m->size; } else { if ($isupdated === true) { $lastupdatedby = $this->_parent->getUser(); if ($lastupdatedby && intval($lastupdatedby->id) > 0) { $m->lastUpdatedByID = $lastupdatedby->id; $m->lastUpdatedOn = 'NOW()'; } } } //Save optional Ovf file url if (count($xml->xpath('./virtualization:ovf')) > 0) { $ovf = $xml->xpath('./virtualization:ovf'); $ovf = $ovf[0]; if (strlen(trim(strval($ovf->attributes()->url))) > 0) { $m->ovfurl = trim(strval($ovf->attributes()->url)); } else { $m->ovfurl = null; } } else { $m->ovfurl = ""; } //Save optional Context Script //Only in case of a new version if (trim($m->id) === "" || trim($m->id) === "-1") { if (count($xml->xpath('./virtualization:contextscript')) > 0) { $contextscript = $xml->xpath('./virtualization:contextscript'); $contextscript = $contextscript[0]; } } //Set default title in case of empty title if (trim($m->title) === "") { $os = $flavour->getOs(); $osversion = $flavour->osversion; $hypervisors = $flavour->getHypervisors(); if (is_string($hypervisors)) { $hypervisors = pg_to_php_array($hypervisors); } $hypers = implode(",", $hypervisors); $deftitle = "Image for " . $this->appname . " [" . trim($os->name) . "/" . trim($osversion) . "/" . trim($hypers) . "]"; $m->title = trim($deftitle); } $m->save(); $synccontextscript = $this->syncContextScript($contextscript, $m); if ($synccontextscript === null || $synccontextscript === false) { return $this->_setErrorMessage("Could not relate context scripts to vmi instance " . $m->id); } else { if (is_string($synccontextscript)) { return $this->_setErrorMessage($synccontextscript); } } return $m; }
public function populate(&$entry, $row) { parent::populate($entry, $row); $entry->setHypervisors(pg_to_php_array($row->hypervisors)); }