Scalr\Modules\Platforms\Openstack\OpenstackPlatformModule::RemoveServerSnapshot PHP Method

RemoveServerSnapshot() public method

See also: Scalr\Modules\PlatformModuleInterface::RemoveServerSnapshot()
public RemoveServerSnapshot ( Image $image )
$image Scalr\Model\Entity\Image
    public function RemoveServerSnapshot(Image $image)
    {
        if (!$image->getEnvironment()) {
            return true;
        }
        try {
            $cloudLocation = $image->cloudLocation;
            if ($image->cloudLocation == '') {
                $locations = $this->getLocations($image->getEnvironment());
                $cloudLocation = array_keys($locations)[0];
            }
            $osClient = $image->getEnvironment()->openstack($image->platform, $cloudLocation);
            $osClient->servers->images->delete($image->id);
        } catch (\Exception $e) {
            if (!stristr($e->getMessage(), "Image not found") && !stristr($e->getMessage(), "Cannot destroy a destroyed snapshot")) {
                throw $e;
            }
        }
        return true;
    }