Exemple #1
0
 def test_manage_volume(self):
     metadata = {"key": u"k1", "value": u"v1"}
     formData = {
         "host": "host-1",
         "identifier": "vol-1",
         "id_type": u"source-name",
         "name": "name-1",
         "description": "manage a volume",
         "volume_type": "vol_type_1",
         "availability_zone": "nova",
         "metadata": metadata["key"] + "=" + metadata["value"],
         "bootable": False,
     }
     cinder.volume_type_list(IsA(http.HttpRequest)).AndReturn(self.cinder_volume_types.list())
     cinder.availability_zone_list(IsA(http.HttpRequest)).AndReturn(self.availability_zones.list())
     cinder.extension_supported(IsA(http.HttpRequest), "AvailabilityZones").AndReturn(True)
     cinder.volume_manage(
         IsA(http.HttpRequest),
         host=formData["host"],
         identifier=formData["identifier"],
         id_type=formData["id_type"],
         name=formData["name"],
         description=formData["description"],
         volume_type=formData["volume_type"],
         availability_zone=formData["availability_zone"],
         metadata={metadata["key"]: metadata["value"]},
         bootable=formData["bootable"],
     )
     self.mox.ReplayAll()
     res = self.client.post(reverse("horizon:admin:volumes:volumes:manage"), formData)
     self.assertNoFormErrors(res)
Exemple #2
0
    def handle(self, request, data):
        try:
            az = data.get('availability_zone')

            # assume user enters metadata with "key1=val1,key2=val2"
            # convert to dictionary
            metadataDict = {}
            metadata = data.get('metadata')
            if metadata:
                metadata.replace(" ", "")
                for item in metadata.split(','):
                    key, value = item.split('=')
                    metadataDict[key] = value

            cinder.volume_manage(request,
                                 host=data['host'],
                                 identifier=data['identifier'],
                                 id_type=data['id_type'],
                                 name=data['name'],
                                 description=data['description'],
                                 volume_type=data['volume_type'],
                                 availability_zone=az,
                                 metadata=metadataDict,
                                 bootable=data['bootable'])

            # for success message, use identifier if user does not
            # provide a volume name
            volume_name = data['name']
            if not volume_name:
                volume_name = data['identifier']

            messages.success(
                request,
                _('Successfully sent the request to manage volume: %s') %
                volume_name)
            return True
        except Exception:
            redirect = reverse("horizon:admin:volumes:index")
            exceptions.handle(request,
                              _("Unable to manage volume."),
                              redirect=redirect)
Exemple #3
0
    def handle(self, request, data):
        try:
            az = data.get('availability_zone')

            # assume user enters metadata with "key1=val1,key2=val2"
            # convert to dictionary
            metadataDict = {}
            metadata = data.get('metadata')
            if metadata:
                metadata.replace(" ", "")
                for item in metadata.split(','):
                    key, value = item.split('=')
                    metadataDict[key] = value

            cinder.volume_manage(request,
                                 host=data['host'],
                                 identifier=data['identifier'],
                                 id_type=data['id_type'],
                                 name=data['name'],
                                 description=data['description'],
                                 volume_type=data['volume_type'],
                                 availability_zone=az,
                                 metadata=metadataDict,
                                 bootable=data['bootable'])

            # for success message, use identifier if user does not
            # provide a volume name
            volume_name = data['name']
            if not volume_name:
                volume_name = data['identifier']

            messages.success(
                request,
                _('Successfully sent the request to manage volume: %s')
                % volume_name)
            return True
        except Exception:
            redirect = reverse("horizon:admin:volumes:index")
            exceptions.handle(request, _("Unable to manage volume."),
                              redirect=redirect)
 def test_manage_volume(self):
     metadata = {'key': u'k1',
                 'value': u'v1'}
     formData = {'host': 'host-1',
                 'identifier': 'vol-1',
                 'id_type': u'source-name',
                 'name': 'name-1',
                 'description': 'manage a volume',
                 'volume_type': 'vol_type_1',
                 'availability_zone': 'nova',
                 'metadata': metadata['key'] + '=' + metadata['value'],
                 'bootable': False}
     cinder.volume_type_list(
         IsA(http.HttpRequest)).\
         AndReturn(self.cinder_volume_types.list())
     cinder.availability_zone_list(
         IsA(http.HttpRequest)).\
         AndReturn(self.availability_zones.list())
     cinder.extension_supported(
         IsA(http.HttpRequest),
         'AvailabilityZones').\
         AndReturn(True)
     cinder.volume_manage(
         IsA(http.HttpRequest),
         host=formData['host'],
         identifier=formData['identifier'],
         id_type=formData['id_type'],
         name=formData['name'],
         description=formData['description'],
         volume_type=formData['volume_type'],
         availability_zone=formData['availability_zone'],
         metadata={metadata['key']: metadata['value']},
         bootable=formData['bootable'])
     self.mox.ReplayAll()
     res = self.client.post(
         reverse('horizon:admin:volumes:volumes:manage'),
         formData)
     self.assertNoFormErrors(res)
Exemple #5
0
 def test_manage_volume(self):
     metadata = {'key': u'k1',
                 'value': u'v1'}
     formData = {'host': 'host-1',
                 'identifier': 'vol-1',
                 'id_type': u'source-name',
                 'name': 'name-1',
                 'description': 'manage a volume',
                 'volume_type': 'vol_type_1',
                 'availability_zone': 'nova',
                 'metadata': metadata['key'] + '=' + metadata['value'],
                 'bootable': False}
     cinder.volume_type_list(
         IsA(http.HttpRequest)). \
         AndReturn(self.cinder_volume_types.list())
     cinder.availability_zone_list(
         IsA(http.HttpRequest)). \
         AndReturn(self.availability_zones.list())
     cinder.extension_supported(
         IsA(http.HttpRequest),
         'AvailabilityZones'). \
         AndReturn(True)
     cinder.volume_manage(
         IsA(http.HttpRequest),
         host=formData['host'],
         identifier=formData['identifier'],
         id_type=formData['id_type'],
         name=formData['name'],
         description=formData['description'],
         volume_type=formData['volume_type'],
         availability_zone=formData['availability_zone'],
         metadata={metadata['key']: metadata['value']},
         bootable=formData['bootable'])
     self.mox.ReplayAll()
     res = self.client.post(
         reverse('horizon:admin:volumes:manage'),
         formData)
     self.assertNoFormErrors(res)