Rename secscan_endpoint where required, fix index and indentation

This commit is contained in:
Quentin Machu 2015-11-09 15:14:25 -05:00
parent fa0897faae
commit 16c364a90c
2 changed files with 12 additions and 12 deletions

View file

@ -5,7 +5,7 @@ import features
import json
import requests
from app import sec_endpoint
from app import secscan_endpoint
from data import model
from endpoints.api import (require_repo_read, NotFound, DownstreamIssue, path_param,
RepositoryParamResource, resource, nickname, show_if, parse_args,
@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
def _call_security_api(relative_url, *args, **kwargs):
""" Issues an HTTP call to the sec API at the given relative URL. """
try:
response = sec_endpoint.call_api(relative_url, *args, **kwargs)
response = secscan_endpoint.call_api(relative_url, *args, **kwargs)
except requests.exceptions.Timeout:
raise DownstreamIssue(payload=dict(message='API call timed out'))
except requests.exceptions.ConnectionError:

View file

@ -12,7 +12,7 @@ from endpoints.notificationhelper import spawn_notification
from collections import defaultdict
from sys import exc_info
from peewee import JOIN_LEFT_OUTER
from app import app, storage, OVERRIDE_CONFIG_DIRECTORY, sec_endpoint
from app import app, storage, OVERRIDE_CONFIG_DIRECTORY, secscan_endpoint
from workers.worker import Worker
from data.database import (Image, ImageStorage, ImageStorageLocation, ImageStoragePlacement,
db_random_func, UseThenDisconnect, RepositoryTag, Repository,
@ -49,8 +49,8 @@ def _get_image_to_export(version):
for image in images:
rimages.append({'image_id': image[0],
'docker_image_id': image[0],
'storage_uuid': image[1],
'docker_image_id': image[1],
'storage_uuid': image[2],
'parent_docker_image_id': None,
'parent_storage_uuid': None})
@ -102,7 +102,7 @@ def _get_storage_locations(uuid):
.switch(ImageStoragePlacement)
.join(ImageStorage, JOIN_LEFT_OUTER)
.where(ImageStorage.uuid == uuid))
return query.get()
locations = list()
for location in query:
locations.append(location.location.name)
@ -189,11 +189,11 @@ class SecurityWorker(Worker):
if not storage.exists(locations, path):
locations = _get_storage_locations(img['storage_uuid'])
if not storage.exists(locations, path):
logger.warning('Could not find a valid location to download layer %s',
img['docker_image_id']+'.'+img['storage_uuid'])
_update_image(img, False, self._target_version)
continue
if not storage.exists(locations, path):
logger.warning('Could not find a valid location to download layer %s',
img['docker_image_id']+'.'+img['storage_uuid'])
_update_image(img, False, self._target_version)
continue
uri = storage.get_direct_download_url(locations, path)
if uri == None:
@ -256,7 +256,7 @@ class SecurityWorker(Worker):
# callback code, etc.
try:
logger.debug('Loading vulnerabilities for layer %s', img['image_id'])
response = sec_endpoint.call_api('layers/%s/vulnerabilities', request['ID'])
response = secscan_endpoint.call_api('layers/%s/vulnerabilities', request['ID'])
except requests.exceptions.Timeout:
logger.debug('Timeout when calling Sec')
continue