Exemple #1
0
 def handle(self, request, data):
     try:
         LOG.info('Renaming network %s to %s' %
                  (data['network'], data['new_name']))
         send_data = {'network': {'name': '%s' % data['new_name']}}
         api.quantum_update_network(request, data['network'], send_data)
     except Exception, e:
         if not hasattr(e, 'message'):
             e.message = str(e)
         messages.error(request,
                 _('Unable to rename network %(network)s: %(msg)s') %
                 {"network": data['network'], "msg": e.message})
Exemple #2
0
    def test_network_rename(self):
        self.mox.StubOutWithMock(api, 'quantum_network_details')
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(self.network_details)

        self.mox.StubOutWithMock(api, 'quantum_update_network')
        api.quantum_update_network(IsA(http.HttpRequest), 'n1',
                                   {'network': {'name': "Test1"}})

        self.mox.ReplayAll()

        formData = {'network': 'n1',
                    'new_name': 'Test1',
                    'method': 'RenameNetwork'}

        res = self.client.post(reverse('steer:engine:networks:rename',
                                       args=["n1"]),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('steer:engine:networks:index'))