(format): yapf reformat
- Run yapf to correct formatting - Update one variable typo Change-Id: Ic756ce4f9811cdf2726907c54299f4740fca9ce5
This commit is contained in:
parent
b53a3ff0ea
commit
eb996c27f4
@ -26,4 +26,3 @@ def upgrade():
|
|||||||
def downgrade():
|
def downgrade():
|
||||||
for c in tables.Tasks.__add_result_links__:
|
for c in tables.Tasks.__add_result_links__:
|
||||||
op.drop_column(tables.Tasks.__tablename__, c.name)
|
op.drop_column(tables.Tasks.__tablename__, c.name)
|
||||||
|
|
||||||
|
@ -109,15 +109,21 @@ class DrydockConfig(object):
|
|||||||
cfg.IntOpt(
|
cfg.IntOpt(
|
||||||
'http_client_connect_timeout',
|
'http_client_connect_timeout',
|
||||||
default=16,
|
default=16,
|
||||||
help='Timeout for initial read of outgoing HTTP calls from Drydock in seconds.'),
|
help=
|
||||||
|
'Timeout for initial read of outgoing HTTP calls from Drydock in seconds.'
|
||||||
|
),
|
||||||
cfg.IntOpt(
|
cfg.IntOpt(
|
||||||
'http_client_read_timeout',
|
'http_client_read_timeout',
|
||||||
default=300,
|
default=300,
|
||||||
help='Timeout for initial read of outgoing HTTP calls from Drydock in seconds.'),
|
help=
|
||||||
|
'Timeout for initial read of outgoing HTTP calls from Drydock in seconds.'
|
||||||
|
),
|
||||||
cfg.IntOpt(
|
cfg.IntOpt(
|
||||||
'http_client_retries',
|
'http_client_retries',
|
||||||
default=3,
|
default=3,
|
||||||
help='Number of retries for transient errors of outgoing HTTP calls from Drydock.'),
|
help=
|
||||||
|
'Number of retries for transient errors of outgoing HTTP calls from Drydock.'
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Enabled plugins
|
# Enabled plugins
|
||||||
|
@ -941,7 +941,9 @@ class ConfigureHardware(BaseMaasAction):
|
|||||||
n, update_name=False)
|
n, update_name=False)
|
||||||
if machine is not None:
|
if machine is not None:
|
||||||
if machine.status_name in [
|
if machine.status_name in [
|
||||||
'New', 'Broken', 'Failed commissioning', 'Failed testing']:
|
'New', 'Broken', 'Failed commissioning',
|
||||||
|
'Failed testing'
|
||||||
|
]:
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"Located node %s in MaaS, starting commissioning" %
|
"Located node %s in MaaS, starting commissioning" %
|
||||||
(n.name))
|
(n.name))
|
||||||
@ -988,7 +990,9 @@ class ConfigureHardware(BaseMaasAction):
|
|||||||
self.task.add_status_msg(
|
self.task.add_status_msg(
|
||||||
msg=msg, error=False, ctx=n.name, ctx_type='node')
|
msg=msg, error=False, ctx=n.name, ctx_type='node')
|
||||||
self.task.success(focus=n.get_id())
|
self.task.success(focus=n.get_id())
|
||||||
elif machine.status_name in ['Ready', 'Deploying', 'Allocated', 'Deployed']:
|
elif machine.status_name in [
|
||||||
|
'Ready', 'Deploying', 'Allocated', 'Deployed'
|
||||||
|
]:
|
||||||
msg = "Located node %s in MaaS, node commissioned. Skipping..." % (
|
msg = "Located node %s in MaaS, node commissioned. Skipping..." % (
|
||||||
n.name)
|
n.name)
|
||||||
self.logger.info(msg)
|
self.logger.info(msg)
|
||||||
|
@ -303,7 +303,8 @@ class Machine(model_base.ResourceBase):
|
|||||||
:param str result_type: the type of results to return. One of
|
:param str result_type: the type of results to return. One of
|
||||||
``all``, ``commissioning``, ``testing``, ``deploy``
|
``all``, ``commissioning``, ``testing``, ``deploy``
|
||||||
"""
|
"""
|
||||||
node_results = maas_nr.NodeResults(system_id_list=[self.resource_id], result_type=result_type)
|
node_results = maas_nr.NodeResults(
|
||||||
|
system_id_list=[self.resource_id], result_type=result_type)
|
||||||
node_results.refresh()
|
node_results.refresh()
|
||||||
|
|
||||||
return node_results
|
return node_results
|
||||||
|
@ -21,7 +21,10 @@ import drydock_provisioner.drivers.node.maasdriver.models.base as model_base
|
|||||||
class NodeResult(model_base.ResourceBase):
|
class NodeResult(model_base.ResourceBase):
|
||||||
|
|
||||||
resource_url = 'commissioning-results/'
|
resource_url = 'commissioning-results/'
|
||||||
fields = ['resource_id', 'name', 'result_type', 'updated', 'data', 'script_result']
|
fields = [
|
||||||
|
'resource_id', 'name', 'result_type', 'updated', 'data',
|
||||||
|
'script_result'
|
||||||
|
]
|
||||||
json_fields = []
|
json_fields = []
|
||||||
|
|
||||||
type_map = {
|
type_map = {
|
||||||
@ -57,6 +60,7 @@ class NodeResult(model_base.ResourceBase):
|
|||||||
def get_type_desc(self):
|
def get_type_desc(self):
|
||||||
return NodeResult.type_rev_map.get(self.result_type)
|
return NodeResult.type_rev_map.get(self.result_type)
|
||||||
|
|
||||||
|
|
||||||
class NodeResults(model_base.ResourceCollectionBase):
|
class NodeResults(model_base.ResourceCollectionBase):
|
||||||
|
|
||||||
collection_url = 'commissioning-results/'
|
collection_url = 'commissioning-results/'
|
||||||
@ -90,4 +94,5 @@ class NodeResults(model_base.ResourceCollectionBase):
|
|||||||
if isinstance(o, dict):
|
if isinstance(o, dict):
|
||||||
i = self.collection_resource.from_dict(self.api_client, o)
|
i = self.collection_resource.from_dict(self.api_client, o)
|
||||||
self.resources[i.resource_id] = i
|
self.resources[i.resource_id] = i
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -214,5 +214,6 @@ class BootactionAssetType(BaseDrydockEnum):
|
|||||||
|
|
||||||
ALL = (PackageList, Unit, File)
|
ALL = (PackageList, Unit, File)
|
||||||
|
|
||||||
|
|
||||||
class BootactionAssetTypeField(fields.BaseEnumField):
|
class BootactionAssetTypeField(fields.BaseEnumField):
|
||||||
AUTO_TYPE = BootactionAssetType()
|
AUTO_TYPE = BootactionAssetType()
|
||||||
|
@ -33,10 +33,10 @@ class BootactionDefined(Validators):
|
|||||||
|
|
||||||
for n in nodes_wo_ba:
|
for n in nodes_wo_ba:
|
||||||
msg = "Node %s is not in scope for any bootactions." % n.name
|
msg = "Node %s is not in scope for any bootactions." % n.name
|
||||||
self.report_warn(msg, [
|
self.report_warn(
|
||||||
n.doc_ref
|
msg, [n.doc_ref],
|
||||||
], "It is expected all nodes have at least one post-deploy action."
|
"It is expected all nodes have at least one post-deploy action."
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@ -57,20 +57,20 @@ class BootactionPackageListValid(Validators):
|
|||||||
if a.type == 'pkg_list':
|
if a.type == 'pkg_list':
|
||||||
if not a.location and not a.package_list:
|
if not a.location and not a.package_list:
|
||||||
msg = "Bootaction has asset of type 'pkg_list' but no valid package data"
|
msg = "Bootaction has asset of type 'pkg_list' but no valid package data"
|
||||||
self.report_error(msg, [
|
self.report_error(
|
||||||
ba.doc_ref
|
msg, [ba.doc_ref],
|
||||||
], "pkg_list bootaction assets must specify a list of packages."
|
"pkg_list bootaction assets must specify a list of packages."
|
||||||
)
|
)
|
||||||
elif a.package_list:
|
elif a.package_list:
|
||||||
for p, v in a.package_list.items():
|
for p, v in a.package_list.items():
|
||||||
try:
|
try:
|
||||||
self.validate_package_version(v)
|
self.validate_package_version(v)
|
||||||
except errors.InvalidPackageListFormat as ex:
|
except errors.InvalidPackageListFormat as ex:
|
||||||
msg = str(ex)
|
msg = str(ex)
|
||||||
self.report_error(msg, [
|
self.report_error(
|
||||||
ba.doc_ref
|
msg, [ba.doc_ref],
|
||||||
], "pkg_list version specifications must be in a valid format."
|
"pkg_list version specifications must be in a valid format."
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
def validate_package_version(self, v):
|
def validate_package_version(self, v):
|
||||||
|
@ -62,6 +62,7 @@ class Tasks(ExtendTable):
|
|||||||
__schema__ = copy.copy(__baseschema__)
|
__schema__ = copy.copy(__baseschema__)
|
||||||
__schema__.extend(__add_result_links__)
|
__schema__.extend(__add_result_links__)
|
||||||
|
|
||||||
|
|
||||||
class ResultMessage(ExtendTable):
|
class ResultMessage(ExtendTable):
|
||||||
"""Table for tracking result/status messages."""
|
"""Table for tracking result/status messages."""
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ cache_opts = {
|
|||||||
cache = CacheManager(**parse_cache_config_options(cache_opts))
|
cache = CacheManager(**parse_cache_config_options(cache_opts))
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ReferenceResolver(object):
|
class ReferenceResolver(object):
|
||||||
"""Class for handling different data references to resolve them data."""
|
"""Class for handling different data references to resolve them data."""
|
||||||
|
|
||||||
@ -65,8 +66,9 @@ class ReferenceResolver(object):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
tries = tries + 1
|
tries = tries + 1
|
||||||
if tries < config_mgr.conf.network.http_client_retries:
|
if tries < config_mgr.conf.network.http_client_retries:
|
||||||
LOG.debug("Retrying reference after failure: %s" % str(ex))
|
LOG.debug("Retrying reference after failure: %s" %
|
||||||
time.sleep(5 ** tries)
|
str(ex))
|
||||||
|
time.sleep(5**tries)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise errors.InvalidDesignReference(
|
raise errors.InvalidDesignReference(
|
||||||
"Cannot resolve design reference %s: unable to parse as valid URI."
|
"Cannot resolve design reference %s: unable to parse as valid URI."
|
||||||
@ -87,7 +89,8 @@ class ReferenceResolver(object):
|
|||||||
auth=(design_uri.username, design_uri.password),
|
auth=(design_uri.username, design_uri.password),
|
||||||
timeout=get_client_timeouts())
|
timeout=get_client_timeouts())
|
||||||
else:
|
else:
|
||||||
response = requests.get(design_uri.geturl(), timeout=get_client_timeouts())
|
response = requests.get(
|
||||||
|
design_uri.geturl(), timeout=get_client_timeouts())
|
||||||
|
|
||||||
return response.content
|
return response.content
|
||||||
|
|
||||||
@ -134,6 +137,7 @@ class ReferenceResolver(object):
|
|||||||
'promenade+http': resolve_reference_ucp,
|
'promenade+http': resolve_reference_ucp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_client_timeouts():
|
def get_client_timeouts():
|
||||||
"""Return a tuple of timeouts for the request library."""
|
"""Return a tuple of timeouts for the request library."""
|
||||||
return (config_mgr.conf.network.http_client_connect_timeout,
|
return (config_mgr.conf.network.http_client_connect_timeout,
|
||||||
|
@ -272,8 +272,8 @@ class DrydockState(object):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with self.db_engine.connect() as conn:
|
with self.db_engine.connect() as conn:
|
||||||
query = self.tasks_tbl.insert().values(**(
|
query = self.tasks_tbl.insert().values(
|
||||||
task.to_db(include_id=True)))
|
**(task.to_db(include_id=True)))
|
||||||
conn.execute(query)
|
conn.execute(query)
|
||||||
return True
|
return True
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@ -289,8 +289,8 @@ class DrydockState(object):
|
|||||||
try:
|
try:
|
||||||
with self.db_engine.connect() as conn:
|
with self.db_engine.connect() as conn:
|
||||||
query = self.tasks_tbl.update().where(
|
query = self.tasks_tbl.update().where(
|
||||||
self.tasks_tbl.c.task_id == task.task_id.bytes).values(**(
|
self.tasks_tbl.c.task_id == task.task_id.bytes).values(
|
||||||
task.to_db(include_id=False)))
|
**(task.to_db(include_id=False)))
|
||||||
rs = conn.execute(query)
|
rs = conn.execute(query)
|
||||||
if rs.rowcount == 1:
|
if rs.rowcount == 1:
|
||||||
return True
|
return True
|
||||||
@ -336,8 +336,8 @@ class DrydockState(object):
|
|||||||
try:
|
try:
|
||||||
with self.db_engine.connect() as conn:
|
with self.db_engine.connect() as conn:
|
||||||
query = self.active_instance_tbl.update().where(
|
query = self.active_instance_tbl.update().where(
|
||||||
self.active_instance_tbl.c.identity == leader_id.bytes).values(
|
self.active_instance_tbl.c.identity ==
|
||||||
last_ping=datetime.utcnow())
|
leader_id.bytes).values(last_ping=datetime.utcnow())
|
||||||
rs = conn.execute(query)
|
rs = conn.execute(query)
|
||||||
rc = rs.rowcount
|
rc = rs.rowcount
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from drydock_provisioner.drivers.node.maasdriver.actions.node import ConfigureNo
|
|||||||
|
|
||||||
|
|
||||||
class TestActionConfigureNodeProvisioner(object):
|
class TestActionConfigureNodeProvisioner(object):
|
||||||
def test_create_maas_repo(selfi, mocker):
|
def test_create_maas_repo(self, mocker):
|
||||||
distribution_list = ['xenial', 'xenial-updates']
|
distribution_list = ['xenial', 'xenial-updates']
|
||||||
|
|
||||||
repo_obj = objects.Repository(
|
repo_obj = objects.Repository(
|
||||||
|
Loading…
Reference in New Issue
Block a user