YAPF formatting
Cleanup some formatting. Change-Id: Icbe0ab0b380817169959e6b527e83320fbd702fa
This commit is contained in:
parent
daf94bdeac
commit
adbce25373
|
@ -103,15 +103,21 @@ class DrydockConfig(object):
|
||||||
cfg.IntOpt(
|
cfg.IntOpt(
|
||||||
'pool_timeout',
|
'pool_timeout',
|
||||||
default=30,
|
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(
|
cfg.IntOpt(
|
||||||
'pool_overflow',
|
'pool_overflow',
|
||||||
default=10,
|
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(
|
cfg.IntOpt(
|
||||||
'connection_recycle',
|
'connection_recycle',
|
||||||
default=-1,
|
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
|
# Options for the boot action framework
|
||||||
|
|
|
@ -31,23 +31,10 @@ class Machine(model_base.ResourceBase):
|
||||||
|
|
||||||
resource_url = 'machines/{resource_id}/'
|
resource_url = 'machines/{resource_id}/'
|
||||||
fields = [
|
fields = [
|
||||||
'resource_id',
|
'resource_id', 'hostname', 'power_type', 'power_state',
|
||||||
'hostname',
|
'power_parameters', 'interfaces', 'boot_interface', 'memory',
|
||||||
'power_type',
|
'cpu_count', 'tag_names', 'status_name', 'boot_mac', 'boot_ip',
|
||||||
'power_state',
|
'owner_data', 'block_devices', 'volume_groups', 'domain'
|
||||||
'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']
|
json_fields = ['hostname', 'power_type', 'domain']
|
||||||
|
|
||||||
|
@ -534,7 +521,10 @@ class Machines(model_base.ResourceCollectionBase):
|
||||||
|
|
||||||
return node
|
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.
|
"""Find MaaS node resource matching Drydock BaremetalNode.
|
||||||
|
|
||||||
Search all the defined MaaS Machines and attempt to match
|
Search all the defined MaaS Machines and attempt to match
|
||||||
|
|
|
@ -180,7 +180,10 @@ class DrydockSession(object):
|
||||||
|
|
||||||
class KeystoneClient(object):
|
class KeystoneClient(object):
|
||||||
@staticmethod
|
@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
|
Wraps calls to keystone for lookup of an endpoint by service type
|
||||||
:param endpoint: The endpoint to look up
|
:param endpoint: The endpoint to look up
|
||||||
|
@ -193,8 +196,7 @@ class KeystoneClient(object):
|
||||||
if ks_sess is None:
|
if ks_sess is None:
|
||||||
ks_sess = KeystoneClient.get_ks_session(**auth_info)
|
ks_sess = KeystoneClient.get_ks_session(**auth_info)
|
||||||
|
|
||||||
return ks_sess.get_endpoint(
|
return ks_sess.get_endpoint(interface=interface, service_type=endpoint)
|
||||||
interface=interface, service_type=endpoint)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_token(ks_sess=None, auth_info=None):
|
def get_token(ks_sess=None, auth_info=None):
|
||||||
|
|
|
@ -49,7 +49,10 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile):
|
||||||
|
|
||||||
# Compile the applied version of this model sourcing referenced
|
# Compile the applied version of this model sourcing referenced
|
||||||
# data from the passed site design
|
# 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.logger.debug("Applying host profile to node %s" % self.name)
|
||||||
self.apply_host_profile(site_design)
|
self.apply_host_profile(site_design)
|
||||||
self.logger.debug("Applying hardware profile to node %s" % self.name)
|
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.logger.debug("Resolving kernel parameters on node %s" % self.name)
|
||||||
self.resolve_kernel_params(site_design)
|
self.resolve_kernel_params(site_design)
|
||||||
if resolve_aliases:
|
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)
|
self.apply_logicalnames(site_design, state_manager)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -109,7 +113,9 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile):
|
||||||
self.logger.debug("Primary network not found, use domain 'local'.")
|
self.logger.debug("Primary network not found, use domain 'local'.")
|
||||||
domain = "local"
|
domain = "local"
|
||||||
except AttributeError as aex:
|
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"
|
domain = "local"
|
||||||
|
|
||||||
return domain
|
return domain
|
||||||
|
|
|
@ -299,7 +299,8 @@ class Orchestrator(object):
|
||||||
try:
|
try:
|
||||||
status, site_design = self.get_described_site(design_ref)
|
status, site_design = self.get_described_site(design_ref)
|
||||||
if status.status == hd_fields.ValidationResult.Success:
|
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.compute_bootaction_targets(site_design)
|
||||||
self.render_route_domains(site_design)
|
self.render_route_domains(site_design)
|
||||||
status = val.validate_design(site_design, result_status=status)
|
status = val.validate_design(site_design, result_status=status)
|
||||||
|
|
|
@ -24,6 +24,7 @@ from drydock_provisioner.cli.task.actions import TaskBuildData
|
||||||
|
|
||||||
import drydock_provisioner.cli.commands as cli
|
import drydock_provisioner.cli.commands as cli
|
||||||
|
|
||||||
|
|
||||||
def test_taskcli_blank_nodefilter():
|
def test_taskcli_blank_nodefilter():
|
||||||
"""If no filter values are specified, node filter should be None."""
|
"""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
|
assert action.node_filter is None
|
||||||
|
|
||||||
|
|
||||||
def test_taskcli_builddata_action(mocker):
|
def test_taskcli_builddata_action(mocker):
|
||||||
"""Test the CLI task get build data routine."""
|
"""Test the CLI task get build data routine."""
|
||||||
task_id = "aaaa-bbbb-cccc-dddd"
|
task_id = "aaaa-bbbb-cccc-dddd"
|
||||||
|
@ -57,6 +59,7 @@ def test_taskcli_builddata_action(mocker):
|
||||||
assert bd_action.invoke() == build_data
|
assert bd_action.invoke() == build_data
|
||||||
api_client.get_task_build_data.assert_called_with(task_id)
|
api_client.get_task_build_data.assert_called_with(task_id)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason='Working on mocking needed for click.testing')
|
@pytest.mark.skip(reason='Working on mocking needed for click.testing')
|
||||||
def test_taskcli_builddata_command(mocker):
|
def test_taskcli_builddata_command(mocker):
|
||||||
"""Test the CLI task get build data command."""
|
"""Test the CLI task get build data command."""
|
||||||
|
@ -73,18 +76,17 @@ def test_taskcli_builddata_command(mocker):
|
||||||
api_client = mocker.MagicMock()
|
api_client = mocker.MagicMock()
|
||||||
api_client.get_task_build_data.return_value = build_data
|
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')
|
mocker.patch('drydock_provisioner.cli.commands.KeystoneClient')
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(cli.drydock, ['-u',
|
result = runner.invoke(
|
||||||
'http://foo',
|
cli.drydock, ['-u', 'http://foo', 'task', 'builddata', '-t', task_id])
|
||||||
'task',
|
|
||||||
'builddata',
|
|
||||||
'-t',
|
|
||||||
task_id])
|
|
||||||
|
|
||||||
print(result.exc_info)
|
print(result.exc_info)
|
||||||
api_client.get_task_build_data.assert_called_with(task_id)
|
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
|
||||||
|
|
Loading…
Reference in New Issue