YAPF formatting

Cleanup some formatting.

Change-Id: Icbe0ab0b380817169959e6b527e83320fbd702fa
This commit is contained in:
Scott Hussey 2018-08-06 08:52:01 -05:00
parent daf94bdeac
commit adbce25373
6 changed files with 43 additions and 36 deletions

View File

@ -103,15 +103,21 @@ class DrydockConfig(object):
cfg.IntOpt(
'pool_timeout',
default=30,
help='How long a request for a connection should wait before one becomes available.'),
help=
'How long a request for a connection should wait before one becomes available.'
),
cfg.IntOpt(
'pool_overflow',
default=10,
help='How many connections above pool_size are allowed to be open during high usage.'),
help=
'How many connections above pool_size are allowed to be open during high usage.'
),
cfg.IntOpt(
'connection_recycle',
default=-1,
help='Time, in seconds, when a connection should be closed and re-established. -1 for no recycling.'),
help=
'Time, in seconds, when a connection should be closed and re-established. -1 for no recycling.'
),
]
# Options for the boot action framework

View File

@ -31,23 +31,10 @@ class Machine(model_base.ResourceBase):
resource_url = 'machines/{resource_id}/'
fields = [
'resource_id',
'hostname',
'power_type',
'power_state',
'power_parameters',
'interfaces',
'boot_interface',
'memory',
'cpu_count',
'tag_names',
'status_name',
'boot_mac',
'boot_ip',
'owner_data',
'block_devices',
'volume_groups',
'domain'
'resource_id', 'hostname', 'power_type', 'power_state',
'power_parameters', 'interfaces', 'boot_interface', 'memory',
'cpu_count', 'tag_names', 'status_name', 'boot_mac', 'boot_ip',
'owner_data', 'block_devices', 'volume_groups', 'domain'
]
json_fields = ['hostname', 'power_type', 'domain']
@ -534,7 +521,10 @@ class Machines(model_base.ResourceCollectionBase):
return node
def identify_baremetal_node(self, node_model, update_name=True, domain="local"):
def identify_baremetal_node(self,
node_model,
update_name=True,
domain="local"):
"""Find MaaS node resource matching Drydock BaremetalNode.
Search all the defined MaaS Machines and attempt to match

View File

@ -180,7 +180,10 @@ class DrydockSession(object):
class KeystoneClient(object):
@staticmethod
def get_endpoint(endpoint, ks_sess=None, auth_info=None, interface='internal'):
def get_endpoint(endpoint,
ks_sess=None,
auth_info=None,
interface='internal'):
"""
Wraps calls to keystone for lookup of an endpoint by service type
:param endpoint: The endpoint to look up
@ -193,8 +196,7 @@ class KeystoneClient(object):
if ks_sess is None:
ks_sess = KeystoneClient.get_ks_session(**auth_info)
return ks_sess.get_endpoint(
interface=interface, service_type=endpoint)
return ks_sess.get_endpoint(interface=interface, service_type=endpoint)
@staticmethod
def get_token(ks_sess=None, auth_info=None):

View File

@ -49,7 +49,10 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile):
# Compile the applied version of this model sourcing referenced
# data from the passed site design
def compile_applied_model(self, site_design, state_manager, resolve_aliases=False):
def compile_applied_model(self,
site_design,
state_manager,
resolve_aliases=False):
self.logger.debug("Applying host profile to node %s" % self.name)
self.apply_host_profile(site_design)
self.logger.debug("Applying hardware profile to node %s" % self.name)
@ -58,7 +61,8 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile):
self.logger.debug("Resolving kernel parameters on node %s" % self.name)
self.resolve_kernel_params(site_design)
if resolve_aliases:
self.logger.debug("Resolving device aliases on node %s" % self.name)
self.logger.debug(
"Resolving device aliases on node %s" % self.name)
self.apply_logicalnames(site_design, state_manager)
return
@ -109,7 +113,9 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile):
self.logger.debug("Primary network not found, use domain 'local'.")
domain = "local"
except AttributeError as aex:
self.logger.debug("Primary network does not define a domain, use domain 'local'.")
self.logger.debug(
"Primary network does not define a domain, use domain 'local'."
)
domain = "local"
return domain

View File

@ -299,7 +299,8 @@ class Orchestrator(object):
try:
status, site_design = self.get_described_site(design_ref)
if status.status == hd_fields.ValidationResult.Success:
self.compute_model_inheritance(site_design, resolve_aliases=resolve_aliases)
self.compute_model_inheritance(
site_design, resolve_aliases=resolve_aliases)
self.compute_bootaction_targets(site_design)
self.render_route_domains(site_design)
status = val.validate_design(site_design, result_status=status)

View File

@ -24,6 +24,7 @@ from drydock_provisioner.cli.task.actions import TaskBuildData
import drydock_provisioner.cli.commands as cli
def test_taskcli_blank_nodefilter():
"""If no filter values are specified, node filter should be None."""
@ -37,6 +38,7 @@ def test_taskcli_blank_nodefilter():
assert action.node_filter is None
def test_taskcli_builddata_action(mocker):
"""Test the CLI task get build data routine."""
task_id = "aaaa-bbbb-cccc-dddd"
@ -57,6 +59,7 @@ def test_taskcli_builddata_action(mocker):
assert bd_action.invoke() == build_data
api_client.get_task_build_data.assert_called_with(task_id)
@pytest.mark.skip(reason='Working on mocking needed for click.testing')
def test_taskcli_builddata_command(mocker):
"""Test the CLI task get build data command."""
@ -73,18 +76,17 @@ def test_taskcli_builddata_command(mocker):
api_client = mocker.MagicMock()
api_client.get_task_build_data.return_value = build_data
mocker.patch('drydock_provisioner.cli.commands.DrydockClient', new=api_client)
mocker.patch(
'drydock_provisioner.cli.commands.DrydockClient', new=api_client)
mocker.patch('drydock_provisioner.cli.commands.KeystoneClient')
runner = CliRunner()
result = runner.invoke(cli.drydock, ['-u',
'http://foo',
'task',
'builddata',
'-t',
task_id])
result = runner.invoke(
cli.drydock, ['-u', 'http://foo', 'task', 'builddata', '-t', task_id])
print(result.exc_info)
api_client.get_task_build_data.assert_called_with(task_id)
assert yaml.safe_dump(build_data, allow_unicode=True, default_flow_style=False) in result.output
assert yaml.safe_dump(
build_data, allow_unicode=True,
default_flow_style=False) in result.output