diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-01-28 01:17:00 -0800 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-02-04 11:35:16 -0800 |
| commit | 94d8553201e50e3e9e25992bfe4735addae4ffda (patch) | |
| tree | 881809bbeeb441ad70fe6abc139712f9486458a5 /nova/volume | |
| parent | 65e233133e801439caaa8265b0de68c70a04ccd2 (diff) | |
Add initiator to initialize_connection
Some volumes need to know the name of the initiator that will be
connecting to the iscsi volume. This adds a call down to the hypervisor
driver to get the ip and the initiator name for the vm before calling
initialize connection. This connection is passed down to the volume
driver so that it can be used to authenticate when the hypervisor
tries to connect to the volume.
* Adds initiator initialize_connection
* Makes a call to driver to get initiator name and ip address
* Gets initiator from openiscsi for libvirt
* Gets initiator from config for xenapi
* Add tests for the driver calls
* Fixes bug 924461
Change-Id: I5b6a2dd84560c7f7b447571e0abf0993e5512ca0
Diffstat (limited to 'nova/volume')
| -rw-r--r-- | nova/volume/api.py | 8 | ||||
| -rw-r--r-- | nova/volume/driver.py | 28 | ||||
| -rw-r--r-- | nova/volume/manager.py | 40 | ||||
| -rw-r--r-- | nova/volume/xensm.py | 4 |
4 files changed, 50 insertions, 30 deletions
diff --git a/nova/volume/api.py b/nova/volume/api.py index cc9cac019..d5042833e 100644 --- a/nova/volume/api.py +++ b/nova/volume/api.py @@ -244,22 +244,22 @@ class API(base.Base): "args": {"volume_id": volume['id']}}) @wrap_check_policy - def initialize_connection(self, context, volume, address): + def initialize_connection(self, context, volume, connector): host = volume['host'] queue = self.db.queue_get_for(context, FLAGS.volume_topic, host) return rpc.call(context, queue, {"method": "initialize_connection", "args": {"volume_id": volume['id'], - "address": address}}) + "connector": connector}}) @wrap_check_policy - def terminate_connection(self, context, volume, address): + def terminate_connection(self, context, volume, connector): host = volume['host'] queue = self.db.queue_get_for(context, FLAGS.volume_topic, host) return rpc.call(context, queue, {"method": "terminate_connection", "args": {"volume_id": volume['id'], - "address": address}}) + "connector": connector}}) def _create_snapshot(self, context, volume, name, description, force=False): diff --git a/nova/volume/driver.py b/nova/volume/driver.py index fa2893737..f00eb0800 100644 --- a/nova/volume/driver.py +++ b/nova/volume/driver.py @@ -215,12 +215,12 @@ class VolumeDriver(object): """Make sure volume is exported.""" raise NotImplementedError() - def initialize_connection(self, volume, address): - """Allow connection to ip and return connection info.""" + def initialize_connection(self, volume, connector): + """Allow connection to connector and return connection info.""" raise NotImplementedError() - def terminate_connection(self, volume, address): - """Disallow connection from ip""" + def terminate_connection(self, volume, connector): + """Disallow connection from connector""" raise NotImplementedError() def get_volume_stats(self, refresh=False): @@ -409,7 +409,7 @@ class ISCSIDriver(VolumeDriver): '-v', property_value) return self._run_iscsiadm(iscsi_properties, iscsi_command) - def initialize_connection(self, volume, address): + def initialize_connection(self, volume, connector): """Initializes the connection and returns connection info. The iscsi driver returns a driver_volume_type of 'iscsi'. @@ -433,7 +433,7 @@ class ISCSIDriver(VolumeDriver): 'data': iscsi_properties } - def terminate_connection(self, volume, address): + def terminate_connection(self, volume, connector): pass def check_for_export(self, context, volume_id): @@ -461,13 +461,13 @@ class FakeISCSIDriver(ISCSIDriver): """No setup necessary in fake mode.""" pass - def initialize_connection(self, volume, address): + def initialize_connection(self, volume, connector): return { 'driver_volume_type': 'iscsi', 'data': {} } - def terminate_connection(self, volume, address): + def terminate_connection(self, volume, connector): pass @staticmethod @@ -532,7 +532,7 @@ class RBDDriver(VolumeDriver): """Removes an export for a logical volume""" pass - def initialize_connection(self, volume, address): + def initialize_connection(self, volume, connector): return { 'driver_volume_type': 'rbd', 'data': { @@ -540,7 +540,7 @@ class RBDDriver(VolumeDriver): } } - def terminate_connection(self, volume, address): + def terminate_connection(self, volume, connector): pass @@ -601,7 +601,7 @@ class SheepdogDriver(VolumeDriver): """Removes an export for a logical volume""" pass - def initialize_connection(self, volume, address): + def initialize_connection(self, volume, connector): return { 'driver_volume_type': 'sheepdog', 'data': { @@ -609,7 +609,7 @@ class SheepdogDriver(VolumeDriver): } } - def terminate_connection(self, volume, address): + def terminate_connection(self, volume, connector): pass @@ -638,10 +638,10 @@ class LoggingVolumeDriver(VolumeDriver): def remove_export(self, context, volume): self.log_action('remove_export', volume) - def initialize_connection(self, volume, address): + def initialize_connection(self, volume, connector): self.log_action('initialize_connection', volume) - def terminate_connection(self, volume, address): + def terminate_connection(self, volume, connector): self.log_action('terminate_connection', volume) def check_for_export(self, context, volume_id): diff --git a/nova/volume/manager.py b/nova/volume/manager.py index 7e739031b..15f26f79e 100644 --- a/nova/volume/manager.py +++ b/nova/volume/manager.py @@ -254,31 +254,51 @@ class VolumeManager(manager.SchedulerDependentManager): # TODO(vish): refactor this into a more general "unreserve" self.db.volume_detached(context, volume_id) - def initialize_connection(self, context, volume_id, address): - """Initialize volume to be connected from address. + def initialize_connection(self, context, volume_id, connector): + """Prepare volume for connection from host represented by connector. This method calls the driver initialize_connection and returns - it to the caller. The driver is responsible for doing any - necessary security setup and returning a connection_info dictionary - in the following format: - {'driver_volume_type': driver_volume_type - 'data': data} + it to the caller. The connector parameter is a dictionary with + information about the host that will connect to the volume in the + following format: + { + 'ip': ip, + 'initiator': initiator, + } + + ip: the ip address of the connecting machine + + initiator: the iscsi initiator name of the connecting machine. + This can be None if the connecting machine does not support iscsi + connections. + + driver is responsible for doing any necessary security setup and + returning a connection_info dictionary in the following format: + { + 'driver_volume_type': driver_volume_type, + 'data': data, + } driver_volume_type: a string to identify the type of volume. This can be used by the calling code to determine the strategy for connecting to the volume. This could be 'iscsi', 'rbd', 'sheepdog', etc. + data: this is the data that the calling code will use to connect to the volume. Keep in mind that this will be serialized to json in various places, so it should not contain any non-json data types. """ volume_ref = self.db.volume_get(context, volume_id) - return self.driver.initialize_connection(volume_ref, address) + return self.driver.initialize_connection(volume_ref, connector) + + def terminate_connection(self, context, volume_id, connector): + """Cleanup connection from host represented by connector. - def terminate_connection(self, context, volume_id, address): + The format of connector is the same as for initialize_connection. + """ volume_ref = self.db.volume_get(context, volume_id) - self.driver.terminate_connection(volume_ref, address) + self.driver.terminate_connection(volume_ref, connector) def check_for_export(self, context, instance_id): """Make sure whether volume is exported.""" diff --git a/nova/volume/xensm.py b/nova/volume/xensm.py index bf219f273..a706b10be 100644 --- a/nova/volume/xensm.py +++ b/nova/volume/xensm.py @@ -203,7 +203,7 @@ class XenSMDriver(VolumeDriver): """Safely, synchronously recreates an export for a logical volume.""" pass - def initialize_connection(self, volume, address): + def initialize_connection(self, volume, connector): try: xensm_properties = dict(self.db.sm_volume_get(self.ctxt, volume['id'])) @@ -236,5 +236,5 @@ class XenSMDriver(VolumeDriver): 'data': xensm_properties } - def terminate_connection(self, volume, address): + def terminate_connection(self, volume, connector): pass |
