Merge lp:~justin-fathomdb/nova/justinsb-hpsan2 into lp:~hudson-openstack/nova/trunk
- justinsb-hpsan2
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Jay Pipes |
Approved revision: | 707 |
Merge reported by: | justinsb |
Merged at revision: | not available |
Proposed branch: | lp:~justin-fathomdb/nova/justinsb-hpsan2 |
Merge into: | lp:~hudson-openstack/nova/trunk |
Prerequisite: | lp:~justin-fathomdb/nova/justinsb-metadata3 |
Diff against target: |
741 lines (+514/-60) 5 files modified
nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py (+72/-0) nova/db/sqlalchemy/models.py (+3/-0) nova/volume/driver.py (+152/-27) nova/volume/manager.py (+6/-2) nova/volume/san.py (+281/-31) |
To merge this branch: | bzr merge lp:~justin-fathomdb/nova/justinsb-hpsan2 |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Todd Willey (community) | Approve | ||
Devin Carlen (community) | Approve | ||
Jay Pipes (community) | Approve | ||
Review via email: mp+50869@code.launchpad.net |
This proposal supersedes a proposal from 2011-02-22.
Commit message
Description of the change
Support HP/LeftHand SANs. We control the SAN by SSHing and issuing CLIQ commands. Also improved the way iSCSI volumes are mounted: try to store the iSCSI connection info in the volume entity, in preference to doing discovery. Also CHAP authentication support.
CHAP support is necessary to avoid the attach-volume command require an export on the SAN device. If we had to do that, the attach command would have to hit both the volume controller and the compute controller, and that would be complex.
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal | # |
Todd Willey (xtoddx) wrote : Posted in a previous version of this proposal | # |
If we're going to do something special with the return value of driver.
I'm not well versed in iscsi, but I'd hope there would be a way to get more specific matches in _do_iscsi_
It would also be great to document what fields should be in iscsi_properties, since this is a class that is inherited other places. A central point would be better than having to look it up in _run_iscsiadmin, discover_volume, etc, getting just a few of the fields each time.
I also see in HpSanISCSIDriver you're using CHAP, but in ISCSIDriver.
Also, I think it is strange for the volume layer to have knowledge of the database schema, and have to know column names and have a variable it returns called 'db_update'. Maybe just renaming it 'state_changes' or something would assuage my fear, and make me feel that if there was a schema change that would be okay because we don't actually have to pass the return value to database calls.
All in all a very nice contribution. ☺
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal | # |
Thanks for fixing up the few nits I brought up Justin. Approved from me from a style/overview perspective. I trust Todd and some others will more thoroughly review the call sequences to the volume drivers.
Cheers!
jay
justinsb (justin-fathomdb) wrote : Posted in a previous version of this proposal | # |
I documented the return value in VolumeDriver create_volume & create_export.
I changed the name of the model state change Dictionary from db_update to model_update, based on your suggestion. The volume drivers are tightly coupled to the model definitions, so I don't think we're violating any separation of concerns. However, the naming "DB" was violating the separation, so I renamed it. Thanks for pointing this out.
The two new properties are 'provider_auth' and 'provider_
The iSCSI discovery code is inherited, though the indentation level changed (I'm probably not blameless on the original code though!) I agree that it's fragile, so I'd like to move away from it. HP SANs and Solaris 'SANs' no longer use it; I can fix OpenISCSI next but that's a behavioural change on code that is potentially in active use so probably belongs in its own patch. There's a note that discovery is deprecated, but this code path is there until I can fix it for OpeniSCSI, but it is the same code as before. If you think I should clean it up in this patch I can do that, but I think it's best not to.
The CHAP authentication issue with discovery will go away when discovery is removed. HP SANs don't use discovery, and they're also the only ones using CHAP right now. If CHAP is supported with discovery (?), we'd definitely have to pass some extra parameters which aren't being passed right now, and I don't see the point of making this chaneg if I'm going to remove this code anyway :-)
I documented the current iscsi_properties (though I really don't know how to format this so it doesn't look terrible)
justinsb (justin-fathomdb) wrote : Posted in a previous version of this proposal | # |
Fixed up code. Can't merge (or even run unit tests) until metadata patch merges though, because of numbering issues on the DB migrations.
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal | # |
> Fixed up code. Can't merge (or even run unit tests) until metadata patch
> merges though, because of numbering issues on the DB migrations.
Hi! There's a little-known feature of Launchpad's merge proposal system that allows you to set a "prerequisite branch". Edit the merge proposal and set the pre-requisite branch to your metadata branch, and Launchpad will:
* Not show any changes from the metadata branch in this merge proposal diff (this is so you can, say, merge your local metadata branch into this hpsan branch and not have the metadata changes show up in the merge diff here)
* Not allow someone to set this to Approved before the metadata branch is merged into trunk.
Cheers!
jay
justinsb (justin-fathomdb) wrote : | # |
Added metadata as prerequisite branch. But can we get that merged please? I think it's good to go...
Todd Willey (xtoddx) wrote : | # |
Looks pretty good. I'd suggest one more pass on the docstrings. Pep-257 outlines the format for multi-line docstrings, which is essentially that a short sentence goes on the first line, then you write the rest, and you end with a blank line.
You can look at nova/db/api.py to see how the flags in the database layer are documented in RST, which should be a good way to document the properties here as well.
FUJITA Tomonori (fujita-tomonori-deactivatedaccount) wrote : | # |
I'm still learning how the volume stuff works but here are some comments about iSCSI stuff:
- Avoiding discovery session sounds better. You can directly insert the target info into open-iscsi db and let open-iscsi log in it.
- iSCSI supports the mutual authentication (the initiator can verify the target too) so it might be better to make 'provider_auth' capable to handle it.
- If you will not remove the discovery session, 'provider_auth' needs to handle discovery session CHAP auth too.
justinsb (justin-fathomdb) wrote : | # |
Todd: Fixed docstrings so that they look better and comply with PEP 257. Is there an easy preview tool and PEP 257 checker?
FUJITA: The goal is to remove discovery. It's not done in this patch, but it's coming for OpeniSCSI. So I don't want to invest time in supporting CHAP at the moment for discovery, because that is hopefully going away, and CHAP isn't used with OpenISCSI at the moment anyway.
I do agree that mutual authentication would be nice, but I'd like to keep this patch as focused as is possible. It would be great if you want to add support!
Todd Willey (xtoddx) wrote : | # |
Lets get this done!
OpenStack Infra (hudson-openstack) wrote : | # |
No proposals found for merge of lp:~justin-fathomdb/nova/justinsb-metadata3 into lp:nova.
justinsb (justin-fathomdb) wrote : | # |
Ah - I accidentally pushed trunk to the (already merged) justinsb-metadata3 branch, which I think is the cause of the above error from Hudson. Nonetheless, it looks like this branch did merge clean. I'm just double-checking that, but I put it back to 'merged' to stop mergebot getting really confused!
Preview Diff
1 | === added file 'nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py' | |||
2 | --- nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py 1970-01-01 00:00:00 +0000 | |||
3 | +++ nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py 2011-02-24 06:50:14 +0000 | |||
4 | @@ -0,0 +1,72 @@ | |||
5 | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 | ||
6 | 2 | |||
7 | 3 | # Copyright 2011 Justin Santa Barbara. | ||
8 | 4 | # All Rights Reserved. | ||
9 | 5 | # | ||
10 | 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
11 | 7 | # not use this file except in compliance with the License. You may obtain | ||
12 | 8 | # a copy of the License at | ||
13 | 9 | # | ||
14 | 10 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
15 | 11 | # | ||
16 | 12 | # Unless required by applicable law or agreed to in writing, software | ||
17 | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
18 | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
19 | 15 | # License for the specific language governing permissions and limitations | ||
20 | 16 | # under the License. | ||
21 | 17 | |||
22 | 18 | from sqlalchemy import * | ||
23 | 19 | from migrate import * | ||
24 | 20 | |||
25 | 21 | from nova import log as logging | ||
26 | 22 | |||
27 | 23 | |||
28 | 24 | meta = MetaData() | ||
29 | 25 | |||
30 | 26 | |||
31 | 27 | # Table stub-definitions | ||
32 | 28 | # Just for the ForeignKey and column creation to succeed, these are not the | ||
33 | 29 | # actual definitions of instances or services. | ||
34 | 30 | # | ||
35 | 31 | volumes = Table('volumes', meta, | ||
36 | 32 | Column('id', Integer(), primary_key=True, nullable=False), | ||
37 | 33 | ) | ||
38 | 34 | |||
39 | 35 | |||
40 | 36 | # | ||
41 | 37 | # New Tables | ||
42 | 38 | # | ||
43 | 39 | # None | ||
44 | 40 | |||
45 | 41 | # | ||
46 | 42 | # Tables to alter | ||
47 | 43 | # | ||
48 | 44 | # None | ||
49 | 45 | |||
50 | 46 | # | ||
51 | 47 | # Columns to add to existing tables | ||
52 | 48 | # | ||
53 | 49 | |||
54 | 50 | volumes_provider_location = Column('provider_location', | ||
55 | 51 | String(length=256, | ||
56 | 52 | convert_unicode=False, | ||
57 | 53 | assert_unicode=None, | ||
58 | 54 | unicode_error=None, | ||
59 | 55 | _warn_on_bytestring=False)) | ||
60 | 56 | |||
61 | 57 | volumes_provider_auth = Column('provider_auth', | ||
62 | 58 | String(length=256, | ||
63 | 59 | convert_unicode=False, | ||
64 | 60 | assert_unicode=None, | ||
65 | 61 | unicode_error=None, | ||
66 | 62 | _warn_on_bytestring=False)) | ||
67 | 63 | |||
68 | 64 | |||
69 | 65 | def upgrade(migrate_engine): | ||
70 | 66 | # Upgrade operations go here. Don't create your own engine; | ||
71 | 67 | # bind migrate_engine to your metadata | ||
72 | 68 | meta.bind = migrate_engine | ||
73 | 69 | |||
74 | 70 | # Add columns to existing tables | ||
75 | 71 | volumes.create_column(volumes_provider_location) | ||
76 | 72 | volumes.create_column(volumes_provider_auth) | ||
77 | 0 | 73 | ||
78 | === modified file 'nova/db/sqlalchemy/models.py' | |||
79 | --- nova/db/sqlalchemy/models.py 2011-02-17 23:00:18 +0000 | |||
80 | +++ nova/db/sqlalchemy/models.py 2011-02-24 06:50:14 +0000 | |||
81 | @@ -243,6 +243,9 @@ | |||
82 | 243 | display_name = Column(String(255)) | 243 | display_name = Column(String(255)) |
83 | 244 | display_description = Column(String(255)) | 244 | display_description = Column(String(255)) |
84 | 245 | 245 | ||
85 | 246 | provider_location = Column(String(255)) | ||
86 | 247 | provider_auth = Column(String(255)) | ||
87 | 248 | |||
88 | 246 | 249 | ||
89 | 247 | class Quota(BASE, NovaBase): | 250 | class Quota(BASE, NovaBase): |
90 | 248 | """Represents quota overrides for a project.""" | 251 | """Represents quota overrides for a project.""" |
91 | 249 | 252 | ||
92 | === modified file 'nova/volume/driver.py' | |||
93 | --- nova/volume/driver.py 2011-02-04 17:04:55 +0000 | |||
94 | +++ nova/volume/driver.py 2011-02-24 06:50:14 +0000 | |||
95 | @@ -21,6 +21,7 @@ | |||
96 | 21 | """ | 21 | """ |
97 | 22 | 22 | ||
98 | 23 | import time | 23 | import time |
99 | 24 | import os | ||
100 | 24 | 25 | ||
101 | 25 | from nova import exception | 26 | from nova import exception |
102 | 26 | from nova import flags | 27 | from nova import flags |
103 | @@ -36,6 +37,8 @@ | |||
104 | 36 | 'Which device to export the volumes on') | 37 | 'Which device to export the volumes on') |
105 | 37 | flags.DEFINE_string('num_shell_tries', 3, | 38 | flags.DEFINE_string('num_shell_tries', 3, |
106 | 38 | 'number of times to attempt to run flakey shell commands') | 39 | 'number of times to attempt to run flakey shell commands') |
107 | 40 | flags.DEFINE_string('num_iscsi_scan_tries', 3, | ||
108 | 41 | 'number of times to rescan iSCSI target to find volume') | ||
109 | 39 | flags.DEFINE_integer('num_shelves', | 42 | flags.DEFINE_integer('num_shelves', |
110 | 40 | 100, | 43 | 100, |
111 | 41 | 'Number of vblade shelves') | 44 | 'Number of vblade shelves') |
112 | @@ -88,7 +91,8 @@ | |||
113 | 88 | % FLAGS.volume_group) | 91 | % FLAGS.volume_group) |
114 | 89 | 92 | ||
115 | 90 | def create_volume(self, volume): | 93 | def create_volume(self, volume): |
117 | 91 | """Creates a logical volume.""" | 94 | """Creates a logical volume. Can optionally return a Dictionary of |
118 | 95 | changes to the volume object to be persisted.""" | ||
119 | 92 | if int(volume['size']) == 0: | 96 | if int(volume['size']) == 0: |
120 | 93 | sizestr = '100M' | 97 | sizestr = '100M' |
121 | 94 | else: | 98 | else: |
122 | @@ -123,7 +127,8 @@ | |||
123 | 123 | raise NotImplementedError() | 127 | raise NotImplementedError() |
124 | 124 | 128 | ||
125 | 125 | def create_export(self, context, volume): | 129 | def create_export(self, context, volume): |
127 | 126 | """Exports the volume.""" | 130 | """Exports the volume. Can optionally return a Dictionary of changes |
128 | 131 | to the volume object to be persisted.""" | ||
129 | 127 | raise NotImplementedError() | 132 | raise NotImplementedError() |
130 | 128 | 133 | ||
131 | 129 | def remove_export(self, context, volume): | 134 | def remove_export(self, context, volume): |
132 | @@ -222,7 +227,18 @@ | |||
133 | 222 | 227 | ||
134 | 223 | 228 | ||
135 | 224 | class ISCSIDriver(VolumeDriver): | 229 | class ISCSIDriver(VolumeDriver): |
137 | 225 | """Executes commands relating to ISCSI volumes.""" | 230 | """Executes commands relating to ISCSI volumes. |
138 | 231 | |||
139 | 232 | We make use of model provider properties as follows: | ||
140 | 233 | |||
141 | 234 | :provider_location: if present, contains the iSCSI target information | ||
142 | 235 | in the same format as an ietadm discovery | ||
143 | 236 | i.e. '<ip>:<port>,<portal> <target IQN>' | ||
144 | 237 | |||
145 | 238 | :provider_auth: if present, contains a space-separated triple: | ||
146 | 239 | '<auth method> <auth username> <auth password>'. | ||
147 | 240 | `CHAP` is the only auth_method in use at the moment. | ||
148 | 241 | """ | ||
149 | 226 | 242 | ||
150 | 227 | def ensure_export(self, context, volume): | 243 | def ensure_export(self, context, volume): |
151 | 228 | """Synchronously recreates an export for a logical volume.""" | 244 | """Synchronously recreates an export for a logical volume.""" |
152 | @@ -294,40 +310,149 @@ | |||
153 | 294 | self._execute("sudo ietadm --op delete --tid=%s" % | 310 | self._execute("sudo ietadm --op delete --tid=%s" % |
154 | 295 | iscsi_target) | 311 | iscsi_target) |
155 | 296 | 312 | ||
158 | 297 | def _get_name_and_portal(self, volume): | 313 | def _do_iscsi_discovery(self, volume): |
159 | 298 | """Gets iscsi name and portal from volume name and host.""" | 314 | #TODO(justinsb): Deprecate discovery and use stored info |
160 | 315 | #NOTE(justinsb): Discovery won't work with CHAP-secured targets (?) | ||
161 | 316 | LOG.warn(_("ISCSI provider_location not stored, using discovery")) | ||
162 | 317 | |||
163 | 299 | volume_name = volume['name'] | 318 | volume_name = volume['name'] |
165 | 300 | host = volume['host'] | 319 | |
166 | 301 | (out, _err) = self._execute("sudo iscsiadm -m discovery -t " | 320 | (out, _err) = self._execute("sudo iscsiadm -m discovery -t " |
168 | 302 | "sendtargets -p %s" % host) | 321 | "sendtargets -p %s" % (volume['host'])) |
169 | 303 | for target in out.splitlines(): | 322 | for target in out.splitlines(): |
170 | 304 | if FLAGS.iscsi_ip_prefix in target and volume_name in target: | 323 | if FLAGS.iscsi_ip_prefix in target and volume_name in target: |
175 | 305 | (location, _sep, iscsi_name) = target.partition(" ") | 324 | return target |
176 | 306 | break | 325 | return None |
177 | 307 | iscsi_portal = location.split(",")[0] | 326 | |
178 | 308 | return (iscsi_name, iscsi_portal) | 327 | def _get_iscsi_properties(self, volume): |
179 | 328 | """Gets iscsi configuration | ||
180 | 329 | |||
181 | 330 | We ideally get saved information in the volume entity, but fall back | ||
182 | 331 | to discovery if need be. Discovery may be completely removed in future | ||
183 | 332 | The properties are: | ||
184 | 333 | |||
185 | 334 | :target_discovered: boolean indicating whether discovery was used | ||
186 | 335 | |||
187 | 336 | :target_iqn: the IQN of the iSCSI target | ||
188 | 337 | |||
189 | 338 | :target_portal: the portal of the iSCSI target | ||
190 | 339 | |||
191 | 340 | :auth_method:, :auth_username:, :auth_password: | ||
192 | 341 | |||
193 | 342 | the authentication details. Right now, either auth_method is not | ||
194 | 343 | present meaning no authentication, or auth_method == `CHAP` | ||
195 | 344 | meaning use CHAP with the specified credentials. | ||
196 | 345 | """ | ||
197 | 346 | |||
198 | 347 | properties = {} | ||
199 | 348 | |||
200 | 349 | location = volume['provider_location'] | ||
201 | 350 | |||
202 | 351 | if location: | ||
203 | 352 | # provider_location is the same format as iSCSI discovery output | ||
204 | 353 | properties['target_discovered'] = False | ||
205 | 354 | else: | ||
206 | 355 | location = self._do_iscsi_discovery(volume) | ||
207 | 356 | |||
208 | 357 | if not location: | ||
209 | 358 | raise exception.Error(_("Could not find iSCSI export " | ||
210 | 359 | " for volume %s") % | ||
211 | 360 | (volume['name'])) | ||
212 | 361 | |||
213 | 362 | LOG.debug(_("ISCSI Discovery: Found %s") % (location)) | ||
214 | 363 | properties['target_discovered'] = True | ||
215 | 364 | |||
216 | 365 | (iscsi_target, _sep, iscsi_name) = location.partition(" ") | ||
217 | 366 | |||
218 | 367 | iscsi_portal = iscsi_target.split(",")[0] | ||
219 | 368 | |||
220 | 369 | properties['target_iqn'] = iscsi_name | ||
221 | 370 | properties['target_portal'] = iscsi_portal | ||
222 | 371 | |||
223 | 372 | auth = volume['provider_auth'] | ||
224 | 373 | |||
225 | 374 | if auth: | ||
226 | 375 | (auth_method, auth_username, auth_secret) = auth.split() | ||
227 | 376 | |||
228 | 377 | properties['auth_method'] = auth_method | ||
229 | 378 | properties['auth_username'] = auth_username | ||
230 | 379 | properties['auth_password'] = auth_secret | ||
231 | 380 | |||
232 | 381 | return properties | ||
233 | 382 | |||
234 | 383 | def _run_iscsiadm(self, iscsi_properties, iscsi_command): | ||
235 | 384 | command = ("sudo iscsiadm -m node -T %s -p %s %s" % | ||
236 | 385 | (iscsi_properties['target_iqn'], | ||
237 | 386 | iscsi_properties['target_portal'], | ||
238 | 387 | iscsi_command)) | ||
239 | 388 | (out, err) = self._execute(command) | ||
240 | 389 | LOG.debug("iscsiadm %s: stdout=%s stderr=%s" % | ||
241 | 390 | (iscsi_command, out, err)) | ||
242 | 391 | return (out, err) | ||
243 | 392 | |||
244 | 393 | def _iscsiadm_update(self, iscsi_properties, property_key, property_value): | ||
245 | 394 | iscsi_command = ("--op update -n %s -v %s" % | ||
246 | 395 | (property_key, property_value)) | ||
247 | 396 | return self._run_iscsiadm(iscsi_properties, iscsi_command) | ||
248 | 309 | 397 | ||
249 | 310 | def discover_volume(self, volume): | 398 | def discover_volume(self, volume): |
250 | 311 | """Discover volume on a remote host.""" | 399 | """Discover volume on a remote host.""" |
259 | 312 | iscsi_name, iscsi_portal = self._get_name_and_portal(volume) | 400 | iscsi_properties = self._get_iscsi_properties(volume) |
260 | 313 | self._execute("sudo iscsiadm -m node -T %s -p %s --login" % | 401 | |
261 | 314 | (iscsi_name, iscsi_portal)) | 402 | if not iscsi_properties['target_discovered']: |
262 | 315 | self._execute("sudo iscsiadm -m node -T %s -p %s --op update " | 403 | self._run_iscsiadm(iscsi_properties, "--op new") |
263 | 316 | "-n node.startup -v automatic" % | 404 | |
264 | 317 | (iscsi_name, iscsi_portal)) | 405 | if iscsi_properties.get('auth_method'): |
265 | 318 | return "/dev/disk/by-path/ip-%s-iscsi-%s-lun-0" % (iscsi_portal, | 406 | self._iscsiadm_update(iscsi_properties, |
266 | 319 | iscsi_name) | 407 | "node.session.auth.authmethod", |
267 | 408 | iscsi_properties['auth_method']) | ||
268 | 409 | self._iscsiadm_update(iscsi_properties, | ||
269 | 410 | "node.session.auth.username", | ||
270 | 411 | iscsi_properties['auth_username']) | ||
271 | 412 | self._iscsiadm_update(iscsi_properties, | ||
272 | 413 | "node.session.auth.password", | ||
273 | 414 | iscsi_properties['auth_password']) | ||
274 | 415 | |||
275 | 416 | self._run_iscsiadm(iscsi_properties, "--login") | ||
276 | 417 | |||
277 | 418 | self._iscsiadm_update(iscsi_properties, "node.startup", "automatic") | ||
278 | 419 | |||
279 | 420 | mount_device = ("/dev/disk/by-path/ip-%s-iscsi-%s-lun-0" % | ||
280 | 421 | (iscsi_properties['target_portal'], | ||
281 | 422 | iscsi_properties['target_iqn'])) | ||
282 | 423 | |||
283 | 424 | # The /dev/disk/by-path/... node is not always present immediately | ||
284 | 425 | # TODO(justinsb): This retry-with-delay is a pattern, move to utils? | ||
285 | 426 | tries = 0 | ||
286 | 427 | while not os.path.exists(mount_device): | ||
287 | 428 | if tries >= FLAGS.num_iscsi_scan_tries: | ||
288 | 429 | raise exception.Error(_("iSCSI device not found at %s") % | ||
289 | 430 | (mount_device)) | ||
290 | 431 | |||
291 | 432 | LOG.warn(_("ISCSI volume not yet found at: %(mount_device)s. " | ||
292 | 433 | "Will rescan & retry. Try number: %(tries)s") % | ||
293 | 434 | locals()) | ||
294 | 435 | |||
295 | 436 | # The rescan isn't documented as being necessary(?), but it helps | ||
296 | 437 | self._run_iscsiadm(iscsi_properties, "--rescan") | ||
297 | 438 | |||
298 | 439 | tries = tries + 1 | ||
299 | 440 | if not os.path.exists(mount_device): | ||
300 | 441 | time.sleep(tries ** 2) | ||
301 | 442 | |||
302 | 443 | if tries != 0: | ||
303 | 444 | LOG.debug(_("Found iSCSI node %(mount_device)s " | ||
304 | 445 | "(after %(tries)s rescans)") % | ||
305 | 446 | locals()) | ||
306 | 447 | |||
307 | 448 | return mount_device | ||
308 | 320 | 449 | ||
309 | 321 | def undiscover_volume(self, volume): | 450 | def undiscover_volume(self, volume): |
310 | 322 | """Undiscover volume on a remote host.""" | 451 | """Undiscover volume on a remote host.""" |
319 | 323 | iscsi_name, iscsi_portal = self._get_name_and_portal(volume) | 452 | iscsi_properties = self._get_iscsi_properties(volume) |
320 | 324 | self._execute("sudo iscsiadm -m node -T %s -p %s --op update " | 453 | self._iscsiadm_update(iscsi_properties, "node.startup", "manual") |
321 | 325 | "-n node.startup -v manual" % | 454 | self._run_iscsiadm(iscsi_properties, "--logout") |
322 | 326 | (iscsi_name, iscsi_portal)) | 455 | self._run_iscsiadm(iscsi_properties, "--op delete") |
315 | 327 | self._execute("sudo iscsiadm -m node -T %s -p %s --logout " % | ||
316 | 328 | (iscsi_name, iscsi_portal)) | ||
317 | 329 | self._execute("sudo iscsiadm -m node --op delete " | ||
318 | 330 | "--targetname %s" % iscsi_name) | ||
323 | 331 | 456 | ||
324 | 332 | 457 | ||
325 | 333 | class FakeISCSIDriver(ISCSIDriver): | 458 | class FakeISCSIDriver(ISCSIDriver): |
326 | 334 | 459 | ||
327 | === modified file 'nova/volume/manager.py' | |||
328 | --- nova/volume/manager.py 2011-02-15 18:19:52 +0000 | |||
329 | +++ nova/volume/manager.py 2011-02-24 06:50:14 +0000 | |||
330 | @@ -107,10 +107,14 @@ | |||
331 | 107 | vol_size = volume_ref['size'] | 107 | vol_size = volume_ref['size'] |
332 | 108 | LOG.debug(_("volume %(vol_name)s: creating lv of" | 108 | LOG.debug(_("volume %(vol_name)s: creating lv of" |
333 | 109 | " size %(vol_size)sG") % locals()) | 109 | " size %(vol_size)sG") % locals()) |
335 | 110 | self.driver.create_volume(volume_ref) | 110 | model_update = self.driver.create_volume(volume_ref) |
336 | 111 | if model_update: | ||
337 | 112 | self.db.volume_update(context, volume_ref['id'], model_update) | ||
338 | 111 | 113 | ||
339 | 112 | LOG.debug(_("volume %s: creating export"), volume_ref['name']) | 114 | LOG.debug(_("volume %s: creating export"), volume_ref['name']) |
341 | 113 | self.driver.create_export(context, volume_ref) | 115 | model_update = self.driver.create_export(context, volume_ref) |
342 | 116 | if model_update: | ||
343 | 117 | self.db.volume_update(context, volume_ref['id'], model_update) | ||
344 | 114 | except Exception: | 118 | except Exception: |
345 | 115 | self.db.volume_update(context, | 119 | self.db.volume_update(context, |
346 | 116 | volume_ref['id'], {'status': 'error'}) | 120 | volume_ref['id'], {'status': 'error'}) |
347 | 117 | 121 | ||
348 | === modified file 'nova/volume/san.py' | |||
349 | --- nova/volume/san.py 2011-02-09 19:25:18 +0000 | |||
350 | +++ nova/volume/san.py 2011-02-24 06:50:14 +0000 | |||
351 | @@ -16,13 +16,16 @@ | |||
352 | 16 | # under the License. | 16 | # under the License. |
353 | 17 | """ | 17 | """ |
354 | 18 | Drivers for san-stored volumes. | 18 | Drivers for san-stored volumes. |
355 | 19 | |||
356 | 19 | The unique thing about a SAN is that we don't expect that we can run the volume | 20 | The unique thing about a SAN is that we don't expect that we can run the volume |
358 | 20 | controller on the SAN hardware. We expect to access it over SSH or some API. | 21 | controller on the SAN hardware. We expect to access it over SSH or some API. |
359 | 21 | """ | 22 | """ |
360 | 22 | 23 | ||
361 | 23 | import os | 24 | import os |
362 | 24 | import paramiko | 25 | import paramiko |
363 | 25 | 26 | ||
364 | 27 | from xml.etree import ElementTree | ||
365 | 28 | |||
366 | 26 | from nova import exception | 29 | from nova import exception |
367 | 27 | from nova import flags | 30 | from nova import flags |
368 | 28 | from nova import log as logging | 31 | from nova import log as logging |
369 | @@ -41,37 +44,19 @@ | |||
370 | 41 | 'Password for SAN controller') | 44 | 'Password for SAN controller') |
371 | 42 | flags.DEFINE_string('san_privatekey', '', | 45 | flags.DEFINE_string('san_privatekey', '', |
372 | 43 | 'Filename of private key to use for SSH authentication') | 46 | 'Filename of private key to use for SSH authentication') |
373 | 47 | flags.DEFINE_string('san_clustername', '', | ||
374 | 48 | 'Cluster name to use for creating volumes') | ||
375 | 49 | flags.DEFINE_integer('san_ssh_port', 22, | ||
376 | 50 | 'SSH port to use with SAN') | ||
377 | 44 | 51 | ||
378 | 45 | 52 | ||
379 | 46 | class SanISCSIDriver(ISCSIDriver): | 53 | class SanISCSIDriver(ISCSIDriver): |
380 | 47 | """ Base class for SAN-style storage volumes | 54 | """ Base class for SAN-style storage volumes |
408 | 48 | (storage providers we access over SSH)""" | 55 | |
409 | 49 | #Override because SAN ip != host ip | 56 | A SAN-style storage value is 'different' because the volume controller |
410 | 50 | def _get_name_and_portal(self, volume): | 57 | probably won't run on it, so we need to access is over SSH or another |
411 | 51 | """Gets iscsi name and portal from volume name and host.""" | 58 | remote protocol. |
412 | 52 | volume_name = volume['name'] | 59 | """ |
386 | 53 | |||
387 | 54 | # TODO(justinsb): store in volume, remerge with generic iSCSI code | ||
388 | 55 | host = FLAGS.san_ip | ||
389 | 56 | |||
390 | 57 | (out, _err) = self._execute("sudo iscsiadm -m discovery -t " | ||
391 | 58 | "sendtargets -p %s" % host) | ||
392 | 59 | |||
393 | 60 | location = None | ||
394 | 61 | find_iscsi_name = self._build_iscsi_target_name(volume) | ||
395 | 62 | for target in out.splitlines(): | ||
396 | 63 | if find_iscsi_name in target: | ||
397 | 64 | (location, _sep, iscsi_name) = target.partition(" ") | ||
398 | 65 | break | ||
399 | 66 | if not location: | ||
400 | 67 | raise exception.Error(_("Could not find iSCSI export " | ||
401 | 68 | " for volume %s") % | ||
402 | 69 | volume_name) | ||
403 | 70 | |||
404 | 71 | iscsi_portal = location.split(",")[0] | ||
405 | 72 | LOG.debug("iscsi_name=%s, iscsi_portal=%s" % | ||
406 | 73 | (iscsi_name, iscsi_portal)) | ||
407 | 74 | return (iscsi_name, iscsi_portal) | ||
413 | 75 | 60 | ||
414 | 76 | def _build_iscsi_target_name(self, volume): | 61 | def _build_iscsi_target_name(self, volume): |
415 | 77 | return "%s%s" % (FLAGS.iscsi_target_prefix, volume['name']) | 62 | return "%s%s" % (FLAGS.iscsi_target_prefix, volume['name']) |
416 | @@ -85,6 +70,7 @@ | |||
417 | 85 | ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | 70 | ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
418 | 86 | if FLAGS.san_password: | 71 | if FLAGS.san_password: |
419 | 87 | ssh.connect(FLAGS.san_ip, | 72 | ssh.connect(FLAGS.san_ip, |
420 | 73 | port=FLAGS.san_ssh_port, | ||
421 | 88 | username=FLAGS.san_login, | 74 | username=FLAGS.san_login, |
422 | 89 | password=FLAGS.san_password) | 75 | password=FLAGS.san_password) |
423 | 90 | elif FLAGS.san_privatekey: | 76 | elif FLAGS.san_privatekey: |
424 | @@ -92,10 +78,11 @@ | |||
425 | 92 | # It sucks that paramiko doesn't support DSA keys | 78 | # It sucks that paramiko doesn't support DSA keys |
426 | 93 | privatekey = paramiko.RSAKey.from_private_key_file(privatekeyfile) | 79 | privatekey = paramiko.RSAKey.from_private_key_file(privatekeyfile) |
427 | 94 | ssh.connect(FLAGS.san_ip, | 80 | ssh.connect(FLAGS.san_ip, |
428 | 81 | port=FLAGS.san_ssh_port, | ||
429 | 95 | username=FLAGS.san_login, | 82 | username=FLAGS.san_login, |
430 | 96 | pkey=privatekey) | 83 | pkey=privatekey) |
431 | 97 | else: | 84 | else: |
433 | 98 | raise exception.Error("Specify san_password or san_privatekey") | 85 | raise exception.Error(_("Specify san_password or san_privatekey")) |
434 | 99 | return ssh | 86 | return ssh |
435 | 100 | 87 | ||
436 | 101 | def _run_ssh(self, command, check_exit_code=True): | 88 | def _run_ssh(self, command, check_exit_code=True): |
437 | @@ -124,10 +111,10 @@ | |||
438 | 124 | def check_for_setup_error(self): | 111 | def check_for_setup_error(self): |
439 | 125 | """Returns an error if prerequisites aren't met""" | 112 | """Returns an error if prerequisites aren't met""" |
440 | 126 | if not (FLAGS.san_password or FLAGS.san_privatekey): | 113 | if not (FLAGS.san_password or FLAGS.san_privatekey): |
442 | 127 | raise exception.Error("Specify san_password or san_privatekey") | 114 | raise exception.Error(_("Specify san_password or san_privatekey")) |
443 | 128 | 115 | ||
444 | 129 | if not (FLAGS.san_ip): | 116 | if not (FLAGS.san_ip): |
446 | 130 | raise exception.Error("san_ip must be set") | 117 | raise exception.Error(_("san_ip must be set")) |
447 | 131 | 118 | ||
448 | 132 | 119 | ||
449 | 133 | def _collect_lines(data): | 120 | def _collect_lines(data): |
450 | @@ -155,17 +142,27 @@ | |||
451 | 155 | 142 | ||
452 | 156 | class SolarisISCSIDriver(SanISCSIDriver): | 143 | class SolarisISCSIDriver(SanISCSIDriver): |
453 | 157 | """Executes commands relating to Solaris-hosted ISCSI volumes. | 144 | """Executes commands relating to Solaris-hosted ISCSI volumes. |
454 | 145 | |||
455 | 158 | Basic setup for a Solaris iSCSI server: | 146 | Basic setup for a Solaris iSCSI server: |
456 | 147 | |||
457 | 159 | pkg install storage-server SUNWiscsit | 148 | pkg install storage-server SUNWiscsit |
458 | 149 | |||
459 | 160 | svcadm enable stmf | 150 | svcadm enable stmf |
460 | 151 | |||
461 | 161 | svcadm enable -r svc:/network/iscsi/target:default | 152 | svcadm enable -r svc:/network/iscsi/target:default |
462 | 153 | |||
463 | 162 | pfexec itadm create-tpg e1000g0 ${MYIP} | 154 | pfexec itadm create-tpg e1000g0 ${MYIP} |
464 | 155 | |||
465 | 163 | pfexec itadm create-target -t e1000g0 | 156 | pfexec itadm create-target -t e1000g0 |
466 | 164 | 157 | ||
467 | 158 | |||
468 | 165 | Then grant the user that will be logging on lots of permissions. | 159 | Then grant the user that will be logging on lots of permissions. |
469 | 166 | I'm not sure exactly which though: | 160 | I'm not sure exactly which though: |
470 | 161 | |||
471 | 167 | zfs allow justinsb create,mount,destroy rpool | 162 | zfs allow justinsb create,mount,destroy rpool |
472 | 163 | |||
473 | 168 | usermod -P'File System Management' justinsb | 164 | usermod -P'File System Management' justinsb |
474 | 165 | |||
475 | 169 | usermod -P'Primary Administrator' justinsb | 166 | usermod -P'Primary Administrator' justinsb |
476 | 170 | 167 | ||
477 | 171 | Also make sure you can login using san_login & san_password/san_privatekey | 168 | Also make sure you can login using san_login & san_password/san_privatekey |
478 | @@ -306,6 +303,17 @@ | |||
479 | 306 | self._run_ssh("pfexec /usr/sbin/stmfadm add-view -t %s %s" % | 303 | self._run_ssh("pfexec /usr/sbin/stmfadm add-view -t %s %s" % |
480 | 307 | (target_group_name, luid)) | 304 | (target_group_name, luid)) |
481 | 308 | 305 | ||
482 | 306 | #TODO(justinsb): Is this always 1? Does it matter? | ||
483 | 307 | iscsi_portal_interface = '1' | ||
484 | 308 | iscsi_portal = FLAGS.san_ip + ":3260," + iscsi_portal_interface | ||
485 | 309 | |||
486 | 310 | db_update = {} | ||
487 | 311 | db_update['provider_location'] = ("%s %s" % | ||
488 | 312 | (iscsi_portal, | ||
489 | 313 | iscsi_name)) | ||
490 | 314 | |||
491 | 315 | return db_update | ||
492 | 316 | |||
493 | 309 | def remove_export(self, context, volume): | 317 | def remove_export(self, context, volume): |
494 | 310 | """Removes an export for a logical volume.""" | 318 | """Removes an export for a logical volume.""" |
495 | 311 | 319 | ||
496 | @@ -333,3 +341,245 @@ | |||
497 | 333 | if self._is_lu_created(volume): | 341 | if self._is_lu_created(volume): |
498 | 334 | self._run_ssh("pfexec /usr/sbin/sbdadm delete-lu %s" % | 342 | self._run_ssh("pfexec /usr/sbin/sbdadm delete-lu %s" % |
499 | 335 | (luid)) | 343 | (luid)) |
500 | 344 | |||
501 | 345 | |||
502 | 346 | class HpSanISCSIDriver(SanISCSIDriver): | ||
503 | 347 | """Executes commands relating to HP/Lefthand SAN ISCSI volumes. | ||
504 | 348 | |||
505 | 349 | We use the CLIQ interface, over SSH. | ||
506 | 350 | |||
507 | 351 | Rough overview of CLIQ commands used: | ||
508 | 352 | |||
509 | 353 | :createVolume: (creates the volume) | ||
510 | 354 | |||
511 | 355 | :getVolumeInfo: (to discover the IQN etc) | ||
512 | 356 | |||
513 | 357 | :getClusterInfo: (to discover the iSCSI target IP address) | ||
514 | 358 | |||
515 | 359 | :assignVolumeChap: (exports it with CHAP security) | ||
516 | 360 | |||
517 | 361 | The 'trick' here is that the HP SAN enforces security by default, so | ||
518 | 362 | normally a volume mount would need both to configure the SAN in the volume | ||
519 | 363 | layer and do the mount on the compute layer. Multi-layer operations are | ||
520 | 364 | not catered for at the moment in the nova architecture, so instead we | ||
521 | 365 | share the volume using CHAP at volume creation time. Then the mount need | ||
522 | 366 | only use those CHAP credentials, so can take place exclusively in the | ||
523 | 367 | compute layer. | ||
524 | 368 | """ | ||
525 | 369 | |||
526 | 370 | def _cliq_run(self, verb, cliq_args): | ||
527 | 371 | """Runs a CLIQ command over SSH, without doing any result parsing""" | ||
528 | 372 | cliq_arg_strings = [] | ||
529 | 373 | for k, v in cliq_args.items(): | ||
530 | 374 | cliq_arg_strings.append(" %s=%s" % (k, v)) | ||
531 | 375 | cmd = verb + ''.join(cliq_arg_strings) | ||
532 | 376 | |||
533 | 377 | return self._run_ssh(cmd) | ||
534 | 378 | |||
535 | 379 | def _cliq_run_xml(self, verb, cliq_args, check_cliq_result=True): | ||
536 | 380 | """Runs a CLIQ command over SSH, parsing and checking the output""" | ||
537 | 381 | cliq_args['output'] = 'XML' | ||
538 | 382 | (out, _err) = self._cliq_run(verb, cliq_args) | ||
539 | 383 | |||
540 | 384 | LOG.debug(_("CLIQ command returned %s"), out) | ||
541 | 385 | |||
542 | 386 | result_xml = ElementTree.fromstring(out) | ||
543 | 387 | if check_cliq_result: | ||
544 | 388 | response_node = result_xml.find("response") | ||
545 | 389 | if response_node is None: | ||
546 | 390 | msg = (_("Malformed response to CLIQ command " | ||
547 | 391 | "%(verb)s %(cliq_args)s. Result=%(out)s") % | ||
548 | 392 | locals()) | ||
549 | 393 | raise exception.Error(msg) | ||
550 | 394 | |||
551 | 395 | result_code = response_node.attrib.get("result") | ||
552 | 396 | |||
553 | 397 | if result_code != "0": | ||
554 | 398 | msg = (_("Error running CLIQ command %(verb)s %(cliq_args)s. " | ||
555 | 399 | " Result=%(out)s") % | ||
556 | 400 | locals()) | ||
557 | 401 | raise exception.Error(msg) | ||
558 | 402 | |||
559 | 403 | return result_xml | ||
560 | 404 | |||
561 | 405 | def _cliq_get_cluster_info(self, cluster_name): | ||
562 | 406 | """Queries for info about the cluster (including IP)""" | ||
563 | 407 | cliq_args = {} | ||
564 | 408 | cliq_args['clusterName'] = cluster_name | ||
565 | 409 | cliq_args['searchDepth'] = '1' | ||
566 | 410 | cliq_args['verbose'] = '0' | ||
567 | 411 | |||
568 | 412 | result_xml = self._cliq_run_xml("getClusterInfo", cliq_args) | ||
569 | 413 | |||
570 | 414 | return result_xml | ||
571 | 415 | |||
572 | 416 | def _cliq_get_cluster_vip(self, cluster_name): | ||
573 | 417 | """Gets the IP on which a cluster shares iSCSI volumes""" | ||
574 | 418 | cluster_xml = self._cliq_get_cluster_info(cluster_name) | ||
575 | 419 | |||
576 | 420 | vips = [] | ||
577 | 421 | for vip in cluster_xml.findall("response/cluster/vip"): | ||
578 | 422 | vips.append(vip.attrib.get('ipAddress')) | ||
579 | 423 | |||
580 | 424 | if len(vips) == 1: | ||
581 | 425 | return vips[0] | ||
582 | 426 | |||
583 | 427 | _xml = ElementTree.tostring(cluster_xml) | ||
584 | 428 | msg = (_("Unexpected number of virtual ips for cluster " | ||
585 | 429 | " %(cluster_name)s. Result=%(_xml)s") % | ||
586 | 430 | locals()) | ||
587 | 431 | raise exception.Error(msg) | ||
588 | 432 | |||
589 | 433 | def _cliq_get_volume_info(self, volume_name): | ||
590 | 434 | """Gets the volume info, including IQN""" | ||
591 | 435 | cliq_args = {} | ||
592 | 436 | cliq_args['volumeName'] = volume_name | ||
593 | 437 | result_xml = self._cliq_run_xml("getVolumeInfo", cliq_args) | ||
594 | 438 | |||
595 | 439 | # Result looks like this: | ||
596 | 440 | #<gauche version="1.0"> | ||
597 | 441 | # <response description="Operation succeeded." name="CliqSuccess" | ||
598 | 442 | # processingTime="87" result="0"> | ||
599 | 443 | # <volume autogrowPages="4" availability="online" blockSize="1024" | ||
600 | 444 | # bytesWritten="0" checkSum="false" clusterName="Cluster01" | ||
601 | 445 | # created="2011-02-08T19:56:53Z" deleting="false" description="" | ||
602 | 446 | # groupName="Group01" initialQuota="536870912" isPrimary="true" | ||
603 | 447 | # iscsiIqn="iqn.2003-10.com.lefthandnetworks:group01:25366:vol-b" | ||
604 | 448 | # maxSize="6865387257856" md5="9fa5c8b2cca54b2948a63d833097e1ca" | ||
605 | 449 | # minReplication="1" name="vol-b" parity="0" replication="2" | ||
606 | 450 | # reserveQuota="536870912" scratchQuota="4194304" | ||
607 | 451 | # serialNumber="9fa5c8b2cca54b2948a63d833097e1ca0000000000006316" | ||
608 | 452 | # size="1073741824" stridePages="32" thinProvision="true"> | ||
609 | 453 | # <status description="OK" value="2"/> | ||
610 | 454 | # <permission access="rw" | ||
611 | 455 | # authGroup="api-34281B815713B78-(trimmed)51ADD4B7030853AA7" | ||
612 | 456 | # chapName="chapusername" chapRequired="true" id="25369" | ||
613 | 457 | # initiatorSecret="" iqn="" iscsiEnabled="true" | ||
614 | 458 | # loadBalance="true" targetSecret="supersecret"/> | ||
615 | 459 | # </volume> | ||
616 | 460 | # </response> | ||
617 | 461 | #</gauche> | ||
618 | 462 | |||
619 | 463 | # Flatten the nodes into a dictionary; use prefixes to avoid collisions | ||
620 | 464 | volume_attributes = {} | ||
621 | 465 | |||
622 | 466 | volume_node = result_xml.find("response/volume") | ||
623 | 467 | for k, v in volume_node.attrib.items(): | ||
624 | 468 | volume_attributes["volume." + k] = v | ||
625 | 469 | |||
626 | 470 | status_node = volume_node.find("status") | ||
627 | 471 | if not status_node is None: | ||
628 | 472 | for k, v in status_node.attrib.items(): | ||
629 | 473 | volume_attributes["status." + k] = v | ||
630 | 474 | |||
631 | 475 | # We only consider the first permission node | ||
632 | 476 | permission_node = volume_node.find("permission") | ||
633 | 477 | if not permission_node is None: | ||
634 | 478 | for k, v in status_node.attrib.items(): | ||
635 | 479 | volume_attributes["permission." + k] = v | ||
636 | 480 | |||
637 | 481 | LOG.debug(_("Volume info: %(volume_name)s => %(volume_attributes)s") % | ||
638 | 482 | locals()) | ||
639 | 483 | return volume_attributes | ||
640 | 484 | |||
641 | 485 | def create_volume(self, volume): | ||
642 | 486 | """Creates a volume.""" | ||
643 | 487 | cliq_args = {} | ||
644 | 488 | cliq_args['clusterName'] = FLAGS.san_clustername | ||
645 | 489 | #TODO(justinsb): Should we default to inheriting thinProvision? | ||
646 | 490 | cliq_args['thinProvision'] = '1' if FLAGS.san_thin_provision else '0' | ||
647 | 491 | cliq_args['volumeName'] = volume['name'] | ||
648 | 492 | if int(volume['size']) == 0: | ||
649 | 493 | cliq_args['size'] = '100MB' | ||
650 | 494 | else: | ||
651 | 495 | cliq_args['size'] = '%sGB' % volume['size'] | ||
652 | 496 | |||
653 | 497 | self._cliq_run_xml("createVolume", cliq_args) | ||
654 | 498 | |||
655 | 499 | volume_info = self._cliq_get_volume_info(volume['name']) | ||
656 | 500 | cluster_name = volume_info['volume.clusterName'] | ||
657 | 501 | iscsi_iqn = volume_info['volume.iscsiIqn'] | ||
658 | 502 | |||
659 | 503 | #TODO(justinsb): Is this always 1? Does it matter? | ||
660 | 504 | cluster_interface = '1' | ||
661 | 505 | |||
662 | 506 | cluster_vip = self._cliq_get_cluster_vip(cluster_name) | ||
663 | 507 | iscsi_portal = cluster_vip + ":3260," + cluster_interface | ||
664 | 508 | |||
665 | 509 | model_update = {} | ||
666 | 510 | model_update['provider_location'] = ("%s %s" % | ||
667 | 511 | (iscsi_portal, | ||
668 | 512 | iscsi_iqn)) | ||
669 | 513 | |||
670 | 514 | return model_update | ||
671 | 515 | |||
672 | 516 | def delete_volume(self, volume): | ||
673 | 517 | """Deletes a volume.""" | ||
674 | 518 | cliq_args = {} | ||
675 | 519 | cliq_args['volumeName'] = volume['name'] | ||
676 | 520 | cliq_args['prompt'] = 'false' # Don't confirm | ||
677 | 521 | |||
678 | 522 | self._cliq_run_xml("deleteVolume", cliq_args) | ||
679 | 523 | |||
680 | 524 | def local_path(self, volume): | ||
681 | 525 | # TODO(justinsb): Is this needed here? | ||
682 | 526 | raise exception.Error(_("local_path not supported")) | ||
683 | 527 | |||
684 | 528 | def ensure_export(self, context, volume): | ||
685 | 529 | """Synchronously recreates an export for a logical volume.""" | ||
686 | 530 | return self._do_export(context, volume, force_create=False) | ||
687 | 531 | |||
688 | 532 | def create_export(self, context, volume): | ||
689 | 533 | return self._do_export(context, volume, force_create=True) | ||
690 | 534 | |||
691 | 535 | def _do_export(self, context, volume, force_create): | ||
692 | 536 | """Supports ensure_export and create_export""" | ||
693 | 537 | volume_info = self._cliq_get_volume_info(volume['name']) | ||
694 | 538 | |||
695 | 539 | is_shared = 'permission.authGroup' in volume_info | ||
696 | 540 | |||
697 | 541 | model_update = {} | ||
698 | 542 | |||
699 | 543 | should_export = False | ||
700 | 544 | |||
701 | 545 | if force_create or not is_shared: | ||
702 | 546 | should_export = True | ||
703 | 547 | # Check that we have a project_id | ||
704 | 548 | project_id = volume['project_id'] | ||
705 | 549 | if not project_id: | ||
706 | 550 | project_id = context.project_id | ||
707 | 551 | |||
708 | 552 | if project_id: | ||
709 | 553 | #TODO(justinsb): Use a real per-project password here | ||
710 | 554 | chap_username = 'proj_' + project_id | ||
711 | 555 | # HP/Lefthand requires that the password be >= 12 characters | ||
712 | 556 | chap_password = 'project_secret_' + project_id | ||
713 | 557 | else: | ||
714 | 558 | msg = (_("Could not determine project for volume %s, " | ||
715 | 559 | "can't export") % | ||
716 | 560 | (volume['name'])) | ||
717 | 561 | if force_create: | ||
718 | 562 | raise exception.Error(msg) | ||
719 | 563 | else: | ||
720 | 564 | LOG.warn(msg) | ||
721 | 565 | should_export = False | ||
722 | 566 | |||
723 | 567 | if should_export: | ||
724 | 568 | cliq_args = {} | ||
725 | 569 | cliq_args['volumeName'] = volume['name'] | ||
726 | 570 | cliq_args['chapName'] = chap_username | ||
727 | 571 | cliq_args['targetSecret'] = chap_password | ||
728 | 572 | |||
729 | 573 | self._cliq_run_xml("assignVolumeChap", cliq_args) | ||
730 | 574 | |||
731 | 575 | model_update['provider_auth'] = ("CHAP %s %s" % | ||
732 | 576 | (chap_username, chap_password)) | ||
733 | 577 | |||
734 | 578 | return model_update | ||
735 | 579 | |||
736 | 580 | def remove_export(self, context, volume): | ||
737 | 581 | """Removes an export for a logical volume.""" | ||
738 | 582 | cliq_args = {} | ||
739 | 583 | cliq_args['volumeName'] = volume['name'] | ||
740 | 584 | |||
741 | 585 | self._cliq_run_xml("unassignVolume", cliq_args) |
Hi! As I said on IRC, not much I can review as far as the volume stuff goes, so here is some general feedback :)
1 === added file 'nova/db/ sqlalchemy/ migrate_ repo/versions/ 003_cactus. py'
As you mentioned on IRC, I think it would be best to name this something like 003_add_ provider_ columns. py instead of 003_cactus.py, to make the actual migration file more descriptive of its contents...
74 + # Create tables info(repr( table)) exception( 'Exception while creating table') c.user_ id.alter( type=String( length= 255, unicode= False, unicode= None, bytestring= False))
75 + for table in (
76 + #certificates, consoles, console_pools, instance_actions
77 + ):
78 + try:
79 + table.create()
80 + except Exception:
81 + logging.
82 + logging.
83 + raise
84 +
85 + # Alter column types
86 + # auth_tokens.
87 + # convert_
88 + # assert_
89 + # unicode_error=None,
90 + # _warn_on_
I recognize you probably commented that stuff out thinking that we are only using a single 003_cactus.py migration file, but if that migration file is renamed to something more descriptive (and we can have >1 migration file per release), obviously I think you should remove all that commented out code :)
Missed i18n in these locations:
139 + LOG.warn("ISCSI provider_location not stored, using discovery") Error(" local_path not supported")
175 + LOG.debug("ISCSI Discovery: Found %s" % (location))
552 + raise exception.
For 175 above, please use the following instead:
LOG.debug(_("ISCSI Discovery: Found %s"), location)
Not sure if you meant to i18n this or not :)
457 + message = ("Unexpected number of virtual ips for cluster %s. " tostring( cluster_ xml)))
458 + "Result=%s" %
459 + (cluster_name, ElementTree.
But if so, should be:
message = _("Unexpected number of virtual ips for cluster %(cluster)s. "
"Result= %(result) s" % {'cluster': cluster_name,
' result' : ElementTree. tostring( cluster_ xml)})
Other than those little nits above, the only other advice I could give would be to maybe sprinkle a few LOG.debug()s around HpSanISCSIDriver methods and maybe add a bit of docstring documentation to HpSanISCSIDriver that gives the rough flow of the commands executed against the volume controller?
Cheers, and thanks for a great contribution!
jay