/** * Returns an array with Image objects on the system * * @return array $objects An array with Image objects * */ public static function getImages($apiPort, $incDangling) { $objects = array(); $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_TIMEOUT => 30, CURLOPT_CONNECTTIMEOUT => 5)); $url = "http://localhost:" . $apiPort . "/images/json?all=0"; /* if($incDangling) { $url .= "0"; } else { $url .= "1"; } */ curl_setopt($curl, CURLOPT_URL, $url); if (!($response = curl_exec($curl))) { throw new OMVModuleDockerException('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl)); } curl_close($curl); $data = array(); foreach (json_decode($response) as $item) { $data[substr($item->Id, 0, 12)] = $item; } foreach ($data as $item) { $image = new OMVModuleDockerImage($item->Id, $data, $apiPort); $tmp = array("repository" => rtrim(ltrim($image->getRepository(), "<"), ">"), "tag" => rtrim(ltrim($image->getTag(), "<"), ">"), "id" => $image->getId(), "created" => $image->getCreated(), "size" => $image->getSize(), "ports" => $image->getPorts(), "envvars" => $image->getEnvVars()); array_push($objects, $tmp); } return $objects; }
/** * Returns an array with Image objects on the system * * @param int $apiPort Network port to use in API call * @param bool $incDangling Flag to filter dangling images (not used) * * @return array $objects An array with Image objects * */ public static function getImages($apiPort, $incDangling) { $objects = array(); $url = "http://localhost:" . $apiPort . "/images/json?all=0"; /* if ($incDangling) { $url .= "0"; } else { $url .= "1"; } */ $response = OMVModuleDockerUtil::doApiCall($url); $data = array(); foreach (json_decode($response) as $item) { $data[substr($item->Id, 0, 12)] = $item; } foreach ($data as $item) { $image = new OMVModuleDockerImage($item->Id, $data, $apiPort); $tmp = array("repository" => rtrim(ltrim($image->getRepository(), "<"), ">"), "tag" => rtrim(ltrim($image->getTag(), "<"), ">"), "id" => $image->getId(), "created" => $image->getCreated(), "size" => $image->getSize(), "ports" => $image->getPorts(), "envvars" => $image->getEnvVars(), "imagevolumes" => $image->getVolumes()); array_push($objects, $tmp); } return $objects; }