~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/tests/test_iscsi.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright 2011 Red Hat, Inc.
4
 
#
5
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
6
 
#    not use this file except in compliance with the License. You may obtain
7
 
#    a copy of the License at
8
 
#
9
 
#         http://www.apache.org/licenses/LICENSE-2.0
10
 
#
11
 
#    Unless required by applicable law or agreed to in writing, software
12
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
 
#    License for the specific language governing permissions and limitations
15
 
#    under the License.
16
 
 
17
 
import os.path
18
 
import shutil
19
 
import string
20
 
import tempfile
21
 
 
22
 
from nova import test
23
 
from nova.volume import iscsi
24
 
 
25
 
 
26
 
class TargetAdminTestCase(object):
27
 
 
28
 
    def setUp(self):
29
 
        self.cmds = []
30
 
 
31
 
        self.tid = 1
32
 
        self.target_name = 'iqn.2011-09.org.foo.bar:blaa'
33
 
        self.lun = 10
34
 
        self.path = '/foo'
35
 
        self.vol_id = 'blaa'
36
 
 
37
 
        self.script_template = None
38
 
        self.stubs.Set(os.path, 'isfile', lambda _: True)
39
 
        self.stubs.Set(os, 'unlink', lambda _: '')
40
 
        self.stubs.Set(iscsi.TgtAdm, '_get_target', self.fake_get_target)
41
 
 
42
 
    def fake_get_target(obj, iqn):
43
 
        return 1
44
 
 
45
 
    def get_script_params(self):
46
 
        return {'tid': self.tid,
47
 
                'target_name': self.target_name,
48
 
                'lun': self.lun,
49
 
                'path': self.path}
50
 
 
51
 
    def get_script(self):
52
 
        return self.script_template % self.get_script_params()
53
 
 
54
 
    def fake_execute(self, *cmd, **kwargs):
55
 
        self.cmds.append(string.join(cmd))
56
 
        return "", None
57
 
 
58
 
    def clear_cmds(self):
59
 
        cmds = []
60
 
 
61
 
    def verify_cmds(self, cmds):
62
 
        self.assertEqual(len(cmds), len(self.cmds))
63
 
        for a, b in zip(cmds, self.cmds):
64
 
            self.assertEqual(a, b)
65
 
 
66
 
    def verify(self):
67
 
        script = self.get_script()
68
 
        cmds = []
69
 
        for line in script.split('\n'):
70
 
            if not line.strip():
71
 
                continue
72
 
            cmds.append(line)
73
 
        self.verify_cmds(cmds)
74
 
 
75
 
    def run_commands(self):
76
 
        tgtadm = iscsi.get_target_admin()
77
 
        tgtadm.set_execute(self.fake_execute)
78
 
        tgtadm.create_iscsi_target(self.target_name, self.tid,
79
 
                self.lun, self.path)
80
 
        tgtadm.show_target(self.tid, iqn=self.target_name)
81
 
        tgtadm.remove_iscsi_target(self.tid, self.lun, self.vol_id)
82
 
 
83
 
    def test_target_admin(self):
84
 
        self.clear_cmds()
85
 
        self.run_commands()
86
 
        self.verify()
87
 
 
88
 
 
89
 
class TgtAdmTestCase(test.TestCase, TargetAdminTestCase):
90
 
 
91
 
    def setUp(self):
92
 
        super(TgtAdmTestCase, self).setUp()
93
 
        TargetAdminTestCase.setUp(self)
94
 
        self.persist_tempdir = tempfile.mkdtemp()
95
 
        self.flags(iscsi_helper='tgtadm')
96
 
        self.flags(volumes_dir=self.persist_tempdir)
97
 
        self.script_template = "\n".join([
98
 
        'tgt-admin --update iqn.2011-09.org.foo.bar:blaa',
99
 
        'tgt-admin --delete iqn.2010-10.org.openstack:volume-blaa'])
100
 
 
101
 
    def tearDown(self):
102
 
        try:
103
 
            shutil.rmtree(self.persist_tempdir)
104
 
        except OSError:
105
 
            pass
106
 
        super(TgtAdmTestCase, self).tearDown()
107
 
 
108
 
 
109
 
class IetAdmTestCase(test.TestCase, TargetAdminTestCase):
110
 
 
111
 
    def setUp(self):
112
 
        super(IetAdmTestCase, self).setUp()
113
 
        TargetAdminTestCase.setUp(self)
114
 
        self.flags(iscsi_helper='ietadm')
115
 
        self.script_template = "\n".join([
116
 
        'ietadm --op new --tid=%(tid)s --params Name=%(target_name)s',
117
 
        'ietadm --op new --tid=%(tid)s --lun=%(lun)s '
118
 
                '--params Path=%(path)s,Type=fileio',
119
 
        'ietadm --op show --tid=%(tid)s',
120
 
        'ietadm --op delete --tid=%(tid)s --lun=%(lun)s',
121
 
        'ietadm --op delete --tid=%(tid)s'])