~zulcss/nova/nova-precise-g3

« back to all changes in this revision

Viewing changes to nova/tests/fake_volume.py

  • Committer: Chuck Short
  • Date: 2013-02-25 12:48:57 UTC
  • mfrom: (94.1.5 raring-proposed)
  • Revision ID: zulcss@ubuntu.com-20130225124857-iiz7w0zqhjo1sbs3
* New upstream release for the Ubuntu Cloud Archive. 
* New usptream release. 
* debian/patches/debian/patches/fix-ubuntu-tests.patch: Refreshed.
* debian/nova-baremetal.logrotate: Fix logfile path.
* debian/control, debian/nova-spiceproxy.{install, logrotate, upstart}:
  Add spice html5 proxy support.
* debian/nova-novncproxy.upstart: Start on runlevel [2345]
* debian/rules: Call testr directly since run_tests.sh -N gives weird return
  value when tests pass.
* debian/pyddist-overrides: Add websockify.
* debian/nova-common.postinst: Removed config file conversion, since
  the option is no longer available. (LP: #1110567)
* debian/control: Add python-pyasn1 as a dependency.
* debian/control: Add python-oslo-config as a dependency.
* debian/control: Suggest sysfsutils, sg3-utils, multipath-tools for fibre
  channel support.
* debian/control: Fix typo (websocikfy -> websockify).
* SECURITY UPDATE: fix lack of authentication on block device used for
  os-volume_boot
  - debian/patches/CVE-2013-0208.patch: adjust nova/compute/api.py to
    validate we can access the volumes
  - CVE-2013-0208

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#    License for the specific language governing permissions and limitations
13
13
#    under the License.
14
14
 
15
 
"""Implementation of a fake volume API"""
 
15
"""Implementation of a fake volume API."""
16
16
 
17
17
import uuid
18
18
 
 
19
from oslo.config import cfg
 
20
 
19
21
from nova import exception
20
22
from nova.openstack.common import log as logging
21
23
from nova.openstack.common import timeutils
23
25
 
24
26
LOG = logging.getLogger(__name__)
25
27
 
 
28
CONF = cfg.CONF
 
29
CONF.import_opt('cinder_cross_az_attach',
 
30
                'nova.volume.cinder')
 
31
 
26
32
 
27
33
class fake_volume():
28
34
    user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66'
136
142
 
137
143
    def create_with_kwargs(self, context, **kwargs):
138
144
        volume_id = kwargs.get('volume_id', None)
139
 
        print volume_id
140
145
        v = fake_volume(kwargs['size'],
141
146
                        kwargs['name'],
142
147
                        kwargs['description'],
145
150
                        None,
146
151
                        None,
147
152
                        None)
148
 
        print v.vol['id']
149
153
        if kwargs.get('status', None) is not None:
150
154
            v.vol['status'] = kwargs['status']
151
155
        if kwargs['host'] is not None:
177
181
        LOG.info('deleting volume %s', volume['id'])
178
182
        self.volume_list = [v for v in self.volume_list if v != volume]
179
183
 
180
 
    def check_attach(self, context, volume):
 
184
    def check_attach(self, context, volume, instance=None):
181
185
        if volume['status'] != 'available':
182
186
            msg = _("status must be available")
183
187
            msg = "%s" % volume
185
189
        if volume['attach_status'] == 'attached':
186
190
            msg = _("already attached")
187
191
            raise exception.InvalidVolume(reason=msg)
 
192
        if instance and not CONF.cinder_cross_az_attach:
 
193
            if instance['availability_zone'] != volume['availability_zone']:
 
194
                msg = _("Instance and volume not in same availability_zone")
 
195
                raise exception.InvalidVolume(reason=msg)
188
196
 
189
197
    def check_detach(self, context, volume):
190
198
        if volume['status'] == "available":