Add option to configure passes in erase_devices

Today, there is no option to configure number of iterations to be
done for shred block device erasing and defaults it to 1. This patch
adds a configuration option to change the number of passes to be done
to erase a block device.

Change-Id: Ia870862f2abe830dee5e19a1c247e3f9399c6db2
Depends-On: I1921d33a6b364c4682b6c9baaf61ac092cfa11d7
Closes-Bug:#1465130
This commit is contained in:
Anusha Ramineni 2015-06-15 20:44:09 +05:30
parent 47c17edc71
commit 7c1824c883
7 changed files with 137 additions and 81 deletions

View File

@ -1,75 +1,5 @@
[DEFAULT]
#
# Options defined in oslo.messaging
#
# ZeroMQ bind address. Should be a wildcard (*), an ethernet
# interface, or IP. The "host" option should point or resolve
# to this address. (string value)
#rpc_zmq_bind_address=*
# MatchMaker driver. (string value)
#rpc_zmq_matchmaker=local
# ZeroMQ receiver listening port. (integer value)
#rpc_zmq_port=9501
# Number of ZeroMQ contexts, defaults to 1. (integer value)
#rpc_zmq_contexts=1
# Maximum number of ingress messages to locally buffer per
# topic. Default is unlimited. (integer value)
#rpc_zmq_topic_backlog=<None>
# Directory for holding IPC sockets. (string value)
#rpc_zmq_ipc_dir=/var/run/openstack
# Name of this node. Must be a valid hostname, FQDN, or IP
# address. Must match "host" option, if running Nova. (string
# value)
#rpc_zmq_host=ironic
# Seconds to wait before a cast expires (TTL). Only supported
# by impl_zmq. (integer value)
#rpc_cast_timeout=30
# Heartbeat frequency. (integer value)
#matchmaker_heartbeat_freq=300
# Heartbeat time-to-live. (integer value)
#matchmaker_heartbeat_ttl=600
# Size of RPC thread pool. (integer value)
#rpc_thread_pool_size=64
# The Drivers(s) to handle sending notifications. Possible
# values are messaging, messagingv2, routing,log, test, noop
# (multi valued)
#notification_driver=
# AMQP topic used for OpenStack notifications. (list value)
# Deprecated group/name - [rpc_notifier2]/topics
#notification_topics=notifications
# Seconds to wait for a response from a call. (integer value)
#rpc_response_timeout=60
# A URL representing the messaging driver to use and its full
# configuration. If not set, we fall back to the rpc_backend
# option and driver specific configuration. (string value)
#transport_url=<None>
# The messaging driver to use, defaults to rabbit. Other
# drivers include qpid and zmq. (string value)
#rpc_backend=rabbit
# The default exchange under which topics are scoped. May be
# overridden by an exchange name specified in the
# transport_url option. (string value)
#control_exchange=openstack
#
# Options defined in oslo.log
#
@ -164,6 +94,76 @@
#instance_uuid_format="[instance: %(uuid)s] "
#
# Options defined in oslo.messaging
#
# ZeroMQ bind address. Should be a wildcard (*), an ethernet
# interface, or IP. The "host" option should point or resolve
# to this address. (string value)
#rpc_zmq_bind_address=*
# MatchMaker driver. (string value)
#rpc_zmq_matchmaker=local
# ZeroMQ receiver listening port. (integer value)
#rpc_zmq_port=9501
# Number of ZeroMQ contexts, defaults to 1. (integer value)
#rpc_zmq_contexts=1
# Maximum number of ingress messages to locally buffer per
# topic. Default is unlimited. (integer value)
#rpc_zmq_topic_backlog=<None>
# Directory for holding IPC sockets. (string value)
#rpc_zmq_ipc_dir=/var/run/openstack
# Name of this node. Must be a valid hostname, FQDN, or IP
# address. Must match "host" option, if running Nova. (string
# value)
#rpc_zmq_host=ironic
# Seconds to wait before a cast expires (TTL). Only supported
# by impl_zmq. (integer value)
#rpc_cast_timeout=30
# Heartbeat frequency. (integer value)
#matchmaker_heartbeat_freq=300
# Heartbeat time-to-live. (integer value)
#matchmaker_heartbeat_ttl=600
# Size of RPC thread pool. (integer value)
#rpc_thread_pool_size=64
# The Drivers(s) to handle sending notifications. Possible
# values are messaging, messagingv2, routing,log, test, noop
# (multi valued)
#notification_driver=
# AMQP topic used for OpenStack notifications. (list value)
# Deprecated group/name - [rpc_notifier2]/topics
#notification_topics=notifications
# Seconds to wait for a response from a call. (integer value)
#rpc_response_timeout=60
# A URL representing the messaging driver to use and its full
# configuration. If not set, we fall back to the rpc_backend
# option and driver specific configuration. (string value)
#transport_url=<None>
# The messaging driver to use, defaults to rabbit. Other
# drivers include qpid and zmq. (string value)
#rpc_backend=rabbit
# The default exchange under which topics are scoped. May be
# overridden by an exchange name specified in the
# transport_url option. (string value)
#control_exchange=openstack
#
# Options defined in ironic.netconf
#
@ -370,6 +370,10 @@
# set to 0, will not run during cleaning. (integer value)
#agent_erase_devices_priority=<None>
# Number of iterations to be run for erasing devices. (integer
# value)
#agent_erase_devices_iterations=1
# Whether Ironic will manage TFTP files for the deploy
# ramdisks. If set to False, you will need to configure your
# own TFTP server that allows booting the deploy ramdisks.
@ -385,6 +389,15 @@
# value)
#heartbeat_timeout=300
# Number of times to retry getting power state to check if
# bare metal node has been powered off after a soft power off.
# (integer value)
#post_deploy_get_power_state_retries=6
# Amount of time (in seconds) to wait between polling power
# state after trigger soft poweroff. (integer value)
#post_deploy_get_power_state_retry_interval=5
#
# Options defined in ironic.drivers.modules.agent_client
@ -436,6 +449,21 @@
#max_limit=1000
[cisco_ucs]
#
# Options defined in ironic.drivers.modules.ucs.power
#
# Number of times a power operation needs to be retried
# (integer value)
#max_retry=6
# Amount of time in seconds to wait in between power
# operations (integer value)
#action_interval=5
[conductor]
#
@ -1600,14 +1628,3 @@
#port=18083
[cisco_ucs]
#
# Options defined in ironic.drivers.modules.ucs.power
#
# Number of times a power operation needs to be retried.
#max_retry=6
# Amount of time in seconds to wait in between power operations.
#action_interval=5

View File

@ -58,6 +58,9 @@ agent_opts = [
'set in the ramdisk (defaults to 10 for the '
'GenericHardwareManager). If set to 0, will not run '
'during cleaning.'),
cfg.IntOpt('agent_erase_devices_iterations',
default=1,
help='Number of iterations to be run for erasing devices.'),
cfg.BoolOpt('manage_tftp',
default=True,
help='Whether Ironic will manage TFTP files for the deploy '
@ -408,6 +411,10 @@ class AgentDeploy(base.DeployInterface):
# Allow to raise if it fails, is caught and handled in conductor
ports = provider.provider.create_cleaning_ports(task)
# Append required config parameters to node's driver_internal_info
# to pass to IPA.
deploy_utils.agent_add_clean_params(task)
_prepare_pxe_boot(task)
_do_pxe_boot(task, ports)
# Tell the conductor we are waiting for the agent to boot.

View File

@ -959,6 +959,22 @@ def agent_execute_clean_step(task, step):
return states.CLEANING
def agent_add_clean_params(task):
"""Add required config parameters to node's driver_interal_info.
Adds the required conf options to node's driver_internal_info.
It is Required to pass the information to IPA.
:param task: a TaskManager instance.
"""
agent_params = CONF.agent
info = task.node.driver_internal_info
passes = agent_params.agent_erase_devices_iterations
info['agent_erase_devices_iterations'] = passes
task.node.driver_internal_info = info
task.node.save()
def try_set_boot_device(task, device, persistent=True):
"""Tries to set the boot device on the node.

View File

@ -595,6 +595,10 @@ class IloVirtualMediaAgentDeploy(base.DeployInterface):
if getattr(provider, 'create_cleaning_ports', None):
provider.create_cleaning_ports(task)
# Append required config parameters to node's driver_internal_info
# to pass to IPA.
deploy_utils.agent_add_clean_params(task)
_prepare_agent_vmedia_boot(task)
# Tell the conductor we are waiting for the agent to boot.
return states.CLEANING

View File

@ -768,6 +768,8 @@ class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
self.assertEqual(states.CLEANING, returned_state)
create_port_mock.assert_called_once_with(mock.ANY, task)
delete_mock.assert_called_once_with(mock.ANY, task)
self.assertEqual(task.node.driver_internal_info.get(
'agent_erase_devices_iterations'), 1)
@mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.delete_cleaning_ports',
spec_set=True, autospec=True)

View File

@ -317,6 +317,8 @@ class TestAgentDeploy(db_base.DbTestCase):
boot_mock.assert_called_once_with(task, ports)
create_mock.assert_called_once_with(mock.ANY, task)
delete_mock.assert_called_once_with(mock.ANY, task)
self.assertEqual(task.node.driver_internal_info.get(
'agent_erase_devices_iterations'), 1)
@mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.delete_cleaning_ports',
autospec=True)

View File

@ -1740,6 +1740,14 @@ class AgentCleaningTestCase(db_base.DbTestCase):
self.clean_steps['clean_steps']['GenericHardwareManager'][0])
self.assertEqual(states.CLEANING, response)
def test_agent_add_clean_params(self):
cfg.CONF.agent.agent_erase_devices_iterations = 2
with task_manager.acquire(
self.context, self.node['uuid'], shared=False) as task:
utils.agent_add_clean_params(task)
self.assertEqual(task.node.driver_internal_info.get(
'agent_erase_devices_iterations'), 2)
@mock.patch.object(utils, 'is_block_device', autospec=True)
@mock.patch.object(utils, 'login_iscsi', lambda *_: None)