Fix deprecated code
This PS replaces deprecared module pkg_resources, also fixes the schema validation by adding specific schema draft to choose in order to prevent the processor to fall back to use the latest draft that may potentially cause issues. Also switched to quay.io/airshipit for base ubuntu image Change-Id: I687ef267ee3b027e80815e8852c8edcab5b5b727
This commit is contained in:
parent
db33bcbe73
commit
108a3c1ee4
@ -18,9 +18,9 @@
|
|||||||
# 429 Too Many Requests - Server message: too many requests:
|
# 429 Too Many Requests - Server message: too many requests:
|
||||||
# You have reached your pull rate limit.
|
# You have reached your pull rate limit.
|
||||||
# You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
|
# You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
|
||||||
ARG FROM=public.ecr.aws/docker/library/ubuntu:jammy
|
ARG FROM=quay.io/airshipit/ubuntu:jammy
|
||||||
|
|
||||||
FROM public.ecr.aws/docker/library/golang:1.23.1-bullseye as baclient_builder
|
FROM quay.io/airshipit/golang:1.23.1-bullseye as baclient_builder
|
||||||
|
|
||||||
COPY ./tools/baclient_build.sh /tmp/drydock/
|
COPY ./tools/baclient_build.sh /tmp/drydock/
|
||||||
COPY ./go /tmp/drydock/go
|
COPY ./go /tmp/drydock/go
|
||||||
|
@ -241,7 +241,7 @@ class BootactionUtils(object):
|
|||||||
challenges=['Bootaction-Key'])
|
challenges=['Bootaction-Key'])
|
||||||
|
|
||||||
if ba_ctx['identity_key'] != bytes.fromhex(identity_key):
|
if ba_ctx['identity_key'] != bytes.fromhex(identity_key):
|
||||||
logger.warn(
|
logger.warning(
|
||||||
"Forbidding boot action access - node: %s, identity_key: %s, req header: %s"
|
"Forbidding boot action access - node: %s, identity_key: %s, req header: %s"
|
||||||
% (ba_ctx['node_name'], str(
|
% (ba_ctx['node_name'], str(
|
||||||
ba_ctx['identity_key']), str(bytes.fromhex(identity_key))))
|
ba_ctx['identity_key']), str(bytes.fromhex(identity_key))))
|
||||||
|
@ -203,7 +203,7 @@ class PromenadeSession(object):
|
|||||||
elif timeout is not None:
|
elif timeout is not None:
|
||||||
raise ValueError("Non integer timeout value")
|
raise ValueError("Non integer timeout value")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.logger.warn(
|
self.logger.warning(
|
||||||
"Timeout value must be a tuple of integers or a "
|
"Timeout value must be a tuple of integers or a "
|
||||||
"single integer. Proceeding with values of "
|
"single integer. Proceeding with values of "
|
||||||
"(%s, %s)", connect_timeout, read_timeout)
|
"(%s, %s)", connect_timeout, read_timeout)
|
||||||
|
@ -631,7 +631,7 @@ class Machines(model_base.ResourceCollectionBase):
|
|||||||
node_oob_ip = node_model.get_network_address(node_oob_network)
|
node_oob_ip = node_model.get_network_address(node_oob_network)
|
||||||
|
|
||||||
if node_oob_ip is None:
|
if node_oob_ip is None:
|
||||||
self.logger.warn("Node model missing OOB IP address")
|
self.logger.warning("Node model missing OOB IP address")
|
||||||
raise ValueError('Node model missing OOB IP address')
|
raise ValueError('Node model missing OOB IP address')
|
||||||
|
|
||||||
maas_node = self.find_node_with_power_address(node_oob_ip)
|
maas_node = self.find_node_with_power_address(node_oob_ip)
|
||||||
|
@ -204,7 +204,7 @@ class DrydockSession(object):
|
|||||||
elif timeout is not None:
|
elif timeout is not None:
|
||||||
raise ValueError("Non integer timeout value")
|
raise ValueError("Non integer timeout value")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.logger.warn(
|
self.logger.warning(
|
||||||
"Timeout value must be a tuple of integers or a "
|
"Timeout value must be a tuple of integers or a "
|
||||||
"single integer. Proceeding with values of "
|
"single integer. Proceeding with values of "
|
||||||
"(%s, %s)", connect_timeout, read_timeout)
|
"(%s, %s)", connect_timeout, read_timeout)
|
||||||
|
@ -97,7 +97,7 @@ class Ingester(object):
|
|||||||
status, design_items = self.registered_plugin.ingest_data(
|
status, design_items = self.registered_plugin.ingest_data(
|
||||||
content=design_blob, **kwargs)
|
content=design_blob, **kwargs)
|
||||||
except errors.IngesterError as vex:
|
except errors.IngesterError as vex:
|
||||||
self.logger.warn(
|
self.logger.warning(
|
||||||
"Ingester:ingest_data - Unexpected error processing data - %s"
|
"Ingester:ingest_data - Unexpected error processing data - %s"
|
||||||
% (str(vex)))
|
% (str(vex)))
|
||||||
return None, None
|
return None, None
|
||||||
|
@ -17,7 +17,7 @@ import yaml
|
|||||||
import logging
|
import logging
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
from importlib.resources import files
|
||||||
import copy
|
import copy
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
@ -717,8 +717,7 @@ class DeckhandIngester(IngesterPlugin):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def _get_schema_dir(self):
|
def _get_schema_dir(self):
|
||||||
return pkg_resources.resource_filename('drydock_provisioner',
|
return str(files('drydock_provisioner') / 'schemas')
|
||||||
'schemas')
|
|
||||||
|
|
||||||
# Mapping of handlers for different document kinds
|
# Mapping of handlers for different document kinds
|
||||||
v1_doc_handlers = {
|
v1_doc_handlers = {
|
||||||
|
@ -18,7 +18,7 @@ import logging
|
|||||||
import base64
|
import base64
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
from importlib.resources import files
|
||||||
|
|
||||||
import drydock_provisioner.objects.fields as hd_fields
|
import drydock_provisioner.objects.fields as hd_fields
|
||||||
|
|
||||||
@ -648,8 +648,7 @@ class YamlIngester(IngesterPlugin):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def _get_schema_dir(self):
|
def _get_schema_dir(self):
|
||||||
return pkg_resources.resource_filename('drydock_provisioner',
|
return str(files('drydock_provisioner') / 'schemas')
|
||||||
'schemas')
|
|
||||||
|
|
||||||
# Mapping of handlers for different document kinds
|
# Mapping of handlers for different document kinds
|
||||||
v1_doc_handlers = {
|
v1_doc_handlers = {
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/baremetalNode.yaml'
|
id: 'http://att.com/att-comdev/drydock/baremetalNode.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/bootaction.yaml'
|
id: 'http://att.com/att-comdev/drydock/bootaction.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/hardwareProfile.yaml'
|
id: 'http://att.com/att-comdev/drydock/hardwareProfile.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/hostProfile.yaml'
|
id: 'http://att.com/att-comdev/drydock/hostProfile.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/network.yaml'
|
id: 'http://att.com/att-comdev/drydock/network.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/networkLink.yaml'
|
id: 'http://att.com/att-comdev/drydock/networkLink.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/rack.yaml'
|
id: 'http://att.com/att-comdev/drydock/rack.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
@ -6,7 +6,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
application: drydock
|
application: drydock
|
||||||
data:
|
data:
|
||||||
$schema: 'http://json-schema.org/schema#'
|
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||||
id: 'http://att.com/att-comdev/drydock/region.yaml'
|
id: 'http://att.com/att-comdev/drydock/region.yaml'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
@ -49,7 +49,7 @@ class DrydockState(object):
|
|||||||
max_overflow=config.config_mgr.conf.database.pool_overflow,
|
max_overflow=config.config_mgr.conf.database.pool_overflow,
|
||||||
pool_timeout=config.config_mgr.conf.database.pool_timeout,
|
pool_timeout=config.config_mgr.conf.database.pool_timeout,
|
||||||
pool_recycle=config.config_mgr.conf.database.connection_recycle)
|
pool_recycle=config.config_mgr.conf.database.connection_recycle)
|
||||||
self.db_metadata = MetaData(bind=self.db_engine)
|
self.db_metadata = MetaData()
|
||||||
|
|
||||||
self.tasks_tbl = tables.Tasks(self.db_metadata)
|
self.tasks_tbl = tables.Tasks(self.db_metadata)
|
||||||
self.result_message_tbl = tables.ResultMessage(self.db_metadata)
|
self.result_message_tbl = tables.ResultMessage(self.db_metadata)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pytest >= 3.0
|
pytest
|
||||||
pytest-cov==4.0.0
|
pytest-cov
|
||||||
pytest-mock
|
pytest-mock
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,8 @@ def mock_process_node_filter(mocker, deckhand_orchestrator):
|
|||||||
n2.site = 'test2'
|
n2.site = 'test2'
|
||||||
mock_results = [n1, n2]
|
mock_results = [n1, n2]
|
||||||
|
|
||||||
with mocker.patch(
|
mocker.patch(
|
||||||
'drydock_provisioner.orchestrator.orchestrator.Orchestrator.process_node_filter',
|
'drydock_provisioner.orchestrator.orchestrator.Orchestrator.process_node_filter',
|
||||||
mocker.MagicMock(return_value=mock_results)):
|
return_value=mock_results
|
||||||
yield
|
)
|
||||||
|
yield
|
||||||
|
@ -53,7 +53,6 @@ class TestClientSession(object):
|
|||||||
sess = DrydockSession("testdrydock")
|
sess = DrydockSession("testdrydock")
|
||||||
result = sess.get('bogus')
|
result = sess.get('bogus')
|
||||||
assert result.status_code == 200
|
assert result.status_code == 200
|
||||||
return True
|
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_get_with_timeout(self):
|
def test_get_with_timeout(self):
|
||||||
@ -62,7 +61,6 @@ class TestClientSession(object):
|
|||||||
sess = DrydockSession("testdrydock")
|
sess = DrydockSession("testdrydock")
|
||||||
result = sess.get('bogus', timeout=(60, 60))
|
result = sess.get('bogus', timeout=(60, 60))
|
||||||
assert result.status_code == 200
|
assert result.status_code == 200
|
||||||
return True
|
|
||||||
|
|
||||||
post_responses_inp = {
|
post_responses_inp = {
|
||||||
'method': 'POST',
|
'method': 'POST',
|
||||||
@ -79,7 +77,6 @@ class TestClientSession(object):
|
|||||||
sess = DrydockSession("testdrydock")
|
sess = DrydockSession("testdrydock")
|
||||||
result = sess.post('bogus')
|
result = sess.post('bogus')
|
||||||
assert result.status_code == 200
|
assert result.status_code == 200
|
||||||
return True
|
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_post_with_timeout(self):
|
def test_post_with_timeout(self):
|
||||||
@ -88,7 +85,6 @@ class TestClientSession(object):
|
|||||||
sess = DrydockSession("testdrydock")
|
sess = DrydockSession("testdrydock")
|
||||||
result = sess.post('bogus', timeout=(60, 60))
|
result = sess.post('bogus', timeout=(60, 60))
|
||||||
assert result.status_code == 200
|
assert result.status_code == 200
|
||||||
return True
|
|
||||||
|
|
||||||
def test_timeout(self):
|
def test_timeout(self):
|
||||||
"""Tests the _timeout method"""
|
"""Tests the _timeout method"""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import pylibyaml # noqa: F401 # patch pyyaml to use libyaml bindings
|
import pylibyaml # noqa: F401 # patch pyyaml to use libyaml bindings
|
||||||
import yaml
|
import yaml
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import pkg_resources
|
from importlib.resources import files
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import pytest
|
import pytest
|
||||||
@ -18,8 +18,7 @@ class BaseSchemaValidationTest(object):
|
|||||||
:param expect_failure: should the validation pass or fail.
|
:param expect_failure: should the validation pass or fail.
|
||||||
:param input_files: pytest fixture used to access the test input files
|
:param input_files: pytest fixture used to access the test input files
|
||||||
:param input: test input yaml doc filename"""
|
:param input: test input yaml doc filename"""
|
||||||
schema_dir = pkg_resources.resource_filename('drydock_provisioner',
|
schema_dir = str(files('drydock_provisioner') / 'schemas')
|
||||||
'schemas')
|
|
||||||
schema_filename = os.path.join(schema_dir, schema)
|
schema_filename = os.path.join(schema_dir, schema)
|
||||||
schema_file = open(schema_filename, 'r')
|
schema_file = open(schema_filename, 'r')
|
||||||
schema = yaml.safe_load(schema_file)
|
schema = yaml.safe_load(schema_file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user