示例#1
0
    def test_network_index(self):
        self.mox.StubOutWithMock(api, 'quantum_list_networks')
        api.quantum_list_networks(IsA(http.HttpRequest)).\
                                            AndReturn(self.network)

        self.mox.StubOutWithMock(api, 'quantum_network_details')
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(self.network_details)

        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:networks:index'))

        self.assertTemplateUsed(res, 'nova/networks/index.html')
        networks = res.context['table'].data

        self.assertEqual(len(networks), 1)
        self.assertEqual(networks[0]['name'], 'test_network')
        self.assertEqual(networks[0]['id'], 'n1')
        self.assertEqual(networks[0]['total'], 1)
        self.assertEqual(networks[0]['used'], 1)
        self.assertEqual(networks[0]['available'], 0)
示例#2
0
文件: tests.py 项目: katzj/horizon
    def test_network_rename(self):
        self.mox.StubOutWithMock(api, "quantum_update_network")
        api.quantum_update_network(IsA(http.HttpRequest),
                                   'n1', dict).AndReturn(True)

        self.mox.StubOutWithMock(api, 'quantum_list_networks')
        api.quantum_list_networks(IsA(http.HttpRequest)).\
                                        AndReturn(self.network)

        self.mox.StubOutWithMock(api, 'quantum_network_details')
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(self.network_details)

        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        self.mox.ReplayAll()

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

        res = self.client.post(reverse('horizon:nova:networks:rename',
                                       args=["n1"]),
                               formData)
示例#3
0
文件: tests.py 项目: jakedahn/horizon
    def test_port_detach(self):
        self.mox.StubOutWithMock(api, 'quantum_network_details')
        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        self.mox.StubOutWithMock(api, 'quantum_port_details')
        self.mox.StubOutWithMock(api, 'get_vif_ids')
        self.mox.StubOutWithMock(api, "quantum_set_port_state")
        network_details = {'network': {'id': 'n1', 'name': 'network1'}}
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(network_details)

        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        api.quantum_port_details(IsA(http.HttpRequest),
                                 'n1', 'p1').AndReturn(self.port_details)

        api.get_vif_ids(IsA(http.HttpRequest)).AndReturn(self.vifs)

        api.quantum_set_port_state(IsA(http.HttpRequest),
                                   'n1',
                                   'p1',
                                   {'port': {'state': 'DOWN'}}).AndReturn(True)

        formData = {'action': "network_details__detach_port__p1"}

        self.mox.ReplayAll()

        detail_url = reverse('horizon:nova:networks:detail', args=["n1"])
        res = self.client.post(detail_url, formData)

        self.assertRedirectsNoFollow(res, detail_url)
示例#4
0
    def test_port_delete(self):
        self.mox.StubOutWithMock(api, 'quantum_network_details')
        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        self.mox.StubOutWithMock(api, 'quantum_port_details')
        self.mox.StubOutWithMock(api, 'get_vif_ids')
        self.mox.StubOutWithMock(api, "quantum_delete_port")
        network_details = {'network': {'id': 'n1', 'name': 'network1'}}
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(network_details)

        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        api.quantum_port_details(IsA(http.HttpRequest),
                                 'n1', 'p1').AndReturn(self.port_details)

        api.get_vif_ids(IsA(http.HttpRequest)).AndReturn(self.vifs)

        api.quantum_delete_port(IsA(http.HttpRequest),
                                'n1', 'p1').AndReturn(True)

        formData = {'action': 'network_details__delete__p1'}

        self.mox.StubOutWithMock(messages, 'success')
        messages.success(IgnoreArg(), IsA(basestring))

        self.mox.ReplayAll()

        detail_url = reverse('horizon:nova:networks:detail', args=["n1"])
        self.client.post(detail_url, formData)
示例#5
0
    def test_network_delete(self):
        self.mox.StubOutWithMock(api, "quantum_delete_network")
        api.quantum_delete_network(IsA(http.HttpRequest), 'n1').AndReturn(True)

        self.mox.StubOutWithMock(api, 'quantum_list_networks')
        api.quantum_list_networks(IsA(http.HttpRequest)).\
                                            AndReturn(self.network)

        self.mox.StubOutWithMock(api, 'quantum_network_details')
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(self.network_details)

        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        self.mox.ReplayAll()

        formData = {'network': 'n1',
                    'method': 'DeleteNetwork'}

        res = self.client.post(reverse('horizon:nova:networks:index'),
                               formData)
示例#6
0
    def test_port_attach(self):
        self.mox.StubOutWithMock(api, "quantum_network_details")
        self.mox.StubOutWithMock(api, "quantum_attach_port")
        self.mox.StubOutWithMock(api, "get_vif_ids")
        network_details = {'network': {'id': 'n1'}}
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(network_details)
        api.quantum_attach_port(IsA(http.HttpRequest),
                                'n1', 'p1', IsA(dict)).AndReturn(True)
        api.get_vif_ids(IsA(http.HttpRequest)).AndReturn([{
                'id': 'v1',
                'instance_name': 'instance1',
                'available': True}])

        formData = {'port': 'p1',
                    'network': 'n1',
                    'vif_id': 'v1',
                    'method': 'AttachPort'}

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:networks:port_attach',
                                       args=["n1", "p1"]),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:networks:detail',
                                             args=["n1"]))
示例#7
0
    def test_network_details(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_list_ports')
        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        self.mox.StubOutWithMock(api, 'quantum_port_details')
        api.quantum_port_details(IsA(http.HttpRequest),
                                 'n1', 'p1').AndReturn(self.port_details)

        self.mox.StubOutWithMock(api, 'get_vif_ids')
        api.get_vif_ids(IsA(http.HttpRequest)).AndReturn(self.vifs)

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:networks:detail',
                                      args=['n1']))

        self.assertTemplateUsed(res, 'nova/networks/detail.html')
        self.assertIn('network', res.context)

        network = res.context['network']

        self.assertEqual(network['name'], 'test_network')
        self.assertEqual(network['id'], 'n1')
示例#8
0
    def test_network_index(self):
        self.mox.StubOutWithMock(api, 'quantum_list_networks')
        api.quantum_list_networks(IsA(http.HttpRequest)).\
                                            AndReturn(self.network)

        self.mox.StubOutWithMock(api, 'quantum_network_details')
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(self.network_details)

        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:networks:index'))

        self.assertTemplateUsed(res, 'nova/networks/index.html')
        self.assertIn('networks', res.context)
        networks = res.context['networks']

        self.assertEqual(len(networks), 1)
        self.assertEqual(networks[0]['name'], 'test_network')
        self.assertEqual(networks[0]['id'], 'n1')
        self.assertEqual(networks[0]['total'], 1)
        self.assertEqual(networks[0]['used'], 1)
        self.assertEqual(networks[0]['available'], 0)
示例#9
0
    def test_port_attach(self):
        self.mox.StubOutWithMock(api, "quantum_network_details")
        self.mox.StubOutWithMock(api, "quantum_attach_port")
        self.mox.StubOutWithMock(api, "get_vif_ids")
        network_details = {'network': {'id': 'n1'}}
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(network_details)
        api.quantum_attach_port(IsA(http.HttpRequest), 'n1', 'p1',
                                IsA(dict)).AndReturn(True)
        api.get_vif_ids(IsA(http.HttpRequest)).AndReturn([{
            'id': 'v1',
            'instance_name': 'instance1',
            'available': True
        }])

        formData = {
            'port': 'p1',
            'network': 'n1',
            'vif_id': 'v1',
            'method': 'AttachPort'
        }

        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:nova:networks:port_attach', args=["n1", "p1"]),
            formData)

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:networks:detail', args=["n1"]))
示例#10
0
    def test_port_delete(self):
        self.mox.StubOutWithMock(api, 'quantum_network_details')
        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        self.mox.StubOutWithMock(api, 'quantum_port_details')
        self.mox.StubOutWithMock(api, 'get_vif_ids')
        self.mox.StubOutWithMock(api, "quantum_delete_port")
        network_details = {'network': {'id': 'n1', 'name': 'network1'}}
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(network_details)

        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        api.quantum_port_attachment(IsA(http.HttpRequest), 'n1',
                                    'p1').AndReturn(self.port_attachment)

        api.quantum_port_details(IsA(http.HttpRequest), 'n1',
                                 'p1').AndReturn(self.port_details)

        api.get_vif_ids(IsA(http.HttpRequest)).AndReturn(self.vifs)

        api.quantum_delete_port(IsA(http.HttpRequest), 'n1',
                                'p1').AndReturn(True)

        formData = {'action': 'network_details__delete__p1'}

        self.mox.StubOutWithMock(messages, 'success')
        messages.success(IgnoreArg(), IsA(basestring))

        self.mox.ReplayAll()

        detail_url = reverse('horizon:nova:networks:detail', args=["n1"])
        self.client.post(detail_url, formData)
示例#11
0
    def test_network_delete(self):
        self.mox.StubOutWithMock(api, "quantum_delete_network")
        api.quantum_delete_network(IsA(http.HttpRequest), 'n1').AndReturn(True)

        self.mox.StubOutWithMock(api, 'quantum_list_networks')
        api.quantum_list_networks(IsA(http.HttpRequest)).\
                                            AndReturn(self.network)

        self.mox.StubOutWithMock(api, 'quantum_network_details')
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(self.network_details)

        self.mox.StubOutWithMock(api, 'quantum_list_ports')
        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        self.mox.ReplayAll()

        formData = {'action': 'networks__delete__n1'}

        self.client.post(reverse('horizon:nova:networks:index'), formData)
示例#12
0
    def test_network_details(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_list_ports')
        api.quantum_list_ports(IsA(http.HttpRequest),
                               'n1').AndReturn(self.ports)

        self.mox.StubOutWithMock(api, 'quantum_port_attachment')
        api.quantum_port_attachment(IsA(http.HttpRequest),
                                    'n1', 'p1').AndReturn(self.port_attachment)

        self.mox.StubOutWithMock(api, 'quantum_port_details')
        api.quantum_port_details(IsA(http.HttpRequest),
                                 'n1', 'p1').AndReturn(self.port_details)

        self.mox.StubOutWithMock(api, 'get_vif_ids')
        api.get_vif_ids(IsA(http.HttpRequest)).AndReturn(self.vifs)

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:networks:detail',
                                      args=['n1']))

        self.assertTemplateUsed(res, 'nova/networks/detail.html')
        self.assertIn('network', res.context)

        network = res.context['network']

        self.assertEqual(network['name'], 'test_network')
        self.assertEqual(network['id'], 'n1')
示例#13
0
文件: views.py 项目: katzj/horizon
def index(request):
    tenant_id = request.user.tenant_id
    delete_form, delete_handled = DeleteNetwork.maybe_handle(request)

    networks = []
    instances = []

    try:
        networks_list = api.quantum_list_networks(request)
        details = []
        for network in networks_list['networks']:
            net_stats = _calc_network_stats(request, network['id'])
            # Get network details like name and id
            details = api.quantum_network_details(request, network['id'])
            networks.append({
                'name': details['network']['name'],
                'id': network['id'],
                'total': net_stats['total'],
                'available': net_stats['available'],
                'used': net_stats['used'],
                'tenant': tenant_id})

    except Exception, e:
        LOG.exception("Unable to get network list.")
        messages.error(request,
                       _('Unable to get network list: %s') % e.message)
示例#14
0
文件: views.py 项目: jakedahn/horizon
 def get_data(self):
     network_id = self.kwargs['network_id']
     network_details = api.quantum_network_details(self.request, network_id)
     self.network = {'id': network_id,
                     'name': network_details['network']['name'],
                     'ports': _get_port_states(self.request, network_id)}
     return self.network['ports']
示例#15
0
 def get_object(self, *args, **kwargs):
     network_id = kwargs["network_id"]
     try:
         return api.quantum_network_details(self.request, network_id)["network"]
     except:
         redirect = reverse("horizon:nova:networks:detail", args=(network_id,))
         exceptions.handle(self.request, _("Unable to retrieve network information."), redirect=redirect)
示例#16
0
    def get_data(self):
        tenant_id = self.request.user.tenant_id
        networks = []

        try:
            networks_list = api.quantum_list_networks(self.request)
            details = []
            for network in networks_list["networks"]:
                net_stats = _calc_network_stats(self.request, network["id"])
                # Get network details like name and id
                details = api.quantum_network_details(self.request, network["id"])
                networks.append(
                    {
                        "name": details["network"]["name"],
                        "id": network["id"],
                        "total": net_stats["total"],
                        "available": net_stats["available"],
                        "used": net_stats["used"],
                        "tenant": tenant_id,
                    }
                )
        except Exception, e:
            LOG.exception("Unable to get network list.")
            if not hasattr(e, "message"):
                e.message = str(e)
            messages.error(self.request, _("Unable to get network list: %s") % e.message)
示例#17
0
    def get_data(self):
        tenant_id = self.request.user.tenant_id
        networks = []

        try:
            networks_list = api.quantum_list_networks(self.request)
            details = []
            for network in networks_list['networks']:
                net_stats = _calc_network_stats(self.request, network['id'])
                # Get network details like name and id
                details = api.quantum_network_details(self.request,
                                                      network['id'])
                networks.append({
                    'name': details['network']['name'],
                    'id': network['id'],
                    'total': net_stats['total'],
                    'available': net_stats['available'],
                    'used': net_stats['used'],
                    'tenant': tenant_id
                })
        except Exception, e:
            LOG.exception("Unable to get network list.")
            if not hasattr(e, 'message'):
                e.message = str(e)
            messages.error(self.request,
                           _('Unable to get network list: %s') % e.message)
示例#18
0
文件: views.py 项目: jakedahn/horizon
    def get_data(self):
        tenant_id = self.request.user.tenant_id
        networks = []

        try:
            networks_list = api.quantum_list_networks(self.request)
            details = []
            for network in networks_list['networks']:
                net_stats = _calc_network_stats(self.request, network['id'])
                # Get network details like name and id
                details = api.quantum_network_details(self.request,
                                                      network['id'])
                networks.append({
                        'name': details['network']['name'],
                        'id': network['id'],
                        'total': net_stats['total'],
                        'available': net_stats['available'],
                        'used': net_stats['used'],
                        'tenant': tenant_id})
        except Exception, e:
            LOG.exception("Unable to get network list.")
            if not hasattr(e, 'message'):
                e.message = str(e)
            messages.error(self.request,
                           _('Unable to get network list: %s') % e.message)
示例#19
0
文件: views.py 项目: termie/horizon
def index(request):
    tenant_id = request.user.tenant_id
    delete_form, delete_handled = DeleteNetwork.maybe_handle(request)

    networks = []
    instances = []

    try:
        networks_list = api.quantum_list_networks(request)
        details = []
        for network in networks_list['networks']:
            net_stats = _calc_network_stats(request, network['id'])
            # Get network details like name and id
            details = api.quantum_network_details(request, network['id'])
            networks.append({
                'name': details['network']['name'],
                'id': network['id'],
                'total': net_stats['total'],
                'available': net_stats['available'],
                'used': net_stats['used'],
                'tenant': tenant_id
            })

    except Exception, e:
        LOG.exception("Unable to get network list.")
        messages.error(request,
                       _('Unable to get network list: %s') % e.message)
示例#20
0
 def get_data(self):
     network_id = self.kwargs["network_id"]
     network_details = api.quantum_network_details(self.request, network_id)
     self.network = {
         "id": network_id,
         "name": network_details["network"]["name"],
         "ports": _get_port_states(self.request, network_id),
     }
     return self.network["ports"]
示例#21
0
 def get_data(self):
     network_id = self.kwargs['network_id']
     network_details = api.quantum_network_details(self.request, network_id)
     self.network = {
         'id': network_id,
         'name': network_details['network']['name'],
         'ports': _get_port_states(self.request, network_id)
     }
     return self.network['ports']
示例#22
0
文件: views.py 项目: katzj/horizon
def rename(request, network_id):
    rename_form, handled = RenameNetwork.maybe_handle(request)
    network_details = api.quantum_network_details(request, network_id)

    if handled:
        return shortcuts.redirect('horizon:nova:networks:index')

    return shortcuts.render(request,
                            'nova/networks/rename.html', {
                                'network': network_details,
                                'rename_form': rename_form})
示例#23
0
 def get_object(self, *args, **kwargs):
     network_id = kwargs['network_id']
     try:
         return api.quantum_network_details(self.request,
                                            network_id)['network']
     except:
         redirect = reverse("horizon:nova:networks:detail",
                            args=(network_id, ))
         exceptions.handle(self.request,
                           _('Unable to retrieve network information.'),
                           redirect=redirect)
示例#24
0
文件: views.py 项目: jakedahn/horizon
 def get_object(self, *args, **kwargs):
     network_id = kwargs['network_id']
     try:
         return api.quantum_network_details(self.request,
                                            network_id)['network']
     except:
         redirect = reverse("horizon:nova:networks:detail",
                            args=(network_id,))
         exceptions.handle(self.request,
                           _('Unable to attach port.'),
                           redirect=redirect)
示例#25
0
    def test_port_create(self):
        self.mox.StubOutWithMock(api, "quantum_network_details")
        self.mox.StubOutWithMock(api, "quantum_create_port")
        network_details = {'network': {'id': 'n1'}}
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(network_details)
        api.quantum_create_port(IsA(http.HttpRequest), 'n1').AndReturn(True)

        formData = {'ports_num': 1, 'network': 'n1', 'method': 'CreatePort'}

        self.mox.StubOutWithMock(messages, 'success')
        messages.success(IgnoreArg(), IsA(basestring))

        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:nova:networks:port_create', args=["n1"]),
            formData)

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:networks:detail', args=["n1"]))
示例#26
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('horizon:nova:networks:rename',
                                       args=["n1"]),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:networks:index'))
示例#27
0
文件: tests.py 项目: jakedahn/horizon
    def test_port_create(self):
        self.mox.StubOutWithMock(api, "quantum_network_details")
        self.mox.StubOutWithMock(api, "quantum_create_port")
        network_details = {'network': {'id': 'n1'}}
        api.quantum_network_details(IsA(http.HttpRequest),
                                    'n1').AndReturn(network_details)
        api.quantum_create_port(IsA(http.HttpRequest), 'n1').AndReturn(True)

        formData = {'ports_num': 1,
                    'network': 'n1',
                    'method': 'CreatePort'}

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:networks:port_create',
                                       args=["n1"]),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:networks:detail',
                                             args=["n1"]))
示例#28
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('horizon:nova:networks:rename',
                                       args=["n1"]),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:networks:index'))
示例#29
0
文件: views.py 项目: ehazlett/horizon
def rename(request, network_id):
    network_details = api.quantum_network_details(request, network_id)
    network = network_details['network']

    rename_form, handled = RenameNetwork.maybe_handle(request, initial={
                                                'network': network['id'],
                                                'new_name': network['name']})

    if handled:
        return shortcuts.redirect('horizon:nova:networks:index')

    return shortcuts.render(request,
                            'nova/networks/rename.html', {
                                'network': network,
                                'rename_form': rename_form})
示例#30
0
文件: views.py 项目: katzj/horizon
def detail(request, network_id):
    tenant_id = request.user.tenant_id
    delete_port_form, delete_handled = DeletePort.maybe_handle(request)
    detach_port_form, detach_handled = DetachPort.maybe_handle(request)
    toggle_port_form, port_toggle_handled = TogglePort.maybe_handle(request)

    network = {}

    try:
        network_details = api.quantum_network_details(request, network_id)
        network['name'] = network_details['network']['name']
        network['id'] = network_id
        network['ports'] = _get_port_states(request, network_id)
    except Exception, e:
        LOG.exception("Unable to get network details.")
        messages.error(request,
                       _('Unable to get network details: %s') % e.message)
示例#31
0
文件: views.py 项目: termie/horizon
def rename(request, network_id):
    network_details = api.quantum_network_details(request, network_id)
    network = network_details['network']

    rename_form, handled = RenameNetwork.maybe_handle(request,
                                                      initial={
                                                          'network':
                                                          network['id'],
                                                          'new_name':
                                                          network['name']
                                                      })

    if handled:
        return shortcuts.redirect('horizon:nova:networks:index')

    return shortcuts.render(request, 'nova/networks/rename.html', {
        'network': network,
        'rename_form': rename_form
    })
示例#32
0
文件: views.py 项目: termie/horizon
def detail(request, network_id):
    tenant_id = request.user.tenant_id
    delete_port_form, delete_handled = DeletePort.maybe_handle(
        request, initial={"network": network_id})
    detach_port_form, detach_handled = DetachPort.maybe_handle(
        request, initial={"network": network_id})
    toggle_port_form, port_toggle_handled = TogglePort.maybe_handle(
        request, initial={"network": network_id})

    network = {}
    network['id'] = network_id

    try:
        network_details = api.quantum_network_details(request, network_id)
        network['name'] = network_details['network']['name']
        network['ports'] = _get_port_states(request, network_id)
    except Exception, e:
        LOG.exception("Unable to get network details.")
        messages.error(request,
                       _('Unable to get network details: %s') % e.message)
        return shortcuts.redirect("horizon:nova:networks:index")
示例#33
0
def detail(request, network_id):
    tenant_id = request.user.tenant_id
    delete_port_form, delete_handled = DeletePort.maybe_handle(request,
                                            initial={"network": network_id})
    detach_port_form, detach_handled = DetachPort.maybe_handle(request,
                                            initial={"network": network_id})
    toggle_port_form, port_toggle_handled = TogglePort.maybe_handle(request,
                                            initial={"network": network_id})

    network = {}
    network['id'] = network_id

    try:
        network_details = api.quantum_network_details(request, network_id)
        network['name'] = network_details['network']['name']
        network['ports'] = _get_port_states(request, network_id)
    except Exception, e:
        LOG.exception("Unable to get network details.")
        messages.error(request,
                       _('Unable to get network details: %s') % e.message)
        return shortcuts.redirect("horizon:nova:networks:index")