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"]))
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"]))
def handle(self, request, data): try: body = {'attachment': {'id': '%s' % data['vif_id']}} api.quantum_attach_port(request, data['network'], data['port'], body) messages.success(request, _("Port attached.")) except: exceptions.handle(request, _('Unable to attach port.')) return shortcuts.redirect("horizon:nova:networks:detail", data['network'])
def handle(self, request, data): try: LOG.info('Attaching %s port to VIF %s' % (data['port'], data['vif_id'])) body = {'attachment': {'id': '%s' % data['vif_id']}} api.quantum_attach_port(request, data['network'], data['port'], body) except Exception, e: messages.error(request, _('Unable to attach port %(port)s to VIF %(vif)s: %(msg)s') % {"port": data['port'], "vif": data['vif_id'], "msg": e.message})
def handle(self, request, data): try: LOG.info('Attaching %s port to VIF %s' % (data['port'], data['vif_id'])) body = {'attachment': {'id': '%s' % data['vif_id']}} api.quantum_attach_port(request, data['network'], data['port'], body) except Exception, e: messages.error( request, _('Unable to attach port %(port)s to VIF %(vif)s: %(msg)s') % { "port": data['port'], "vif": data['vif_id'], "msg": e.message })
def test_port_attach(self): self.mox.StubOutWithMock(api, "quantum_attach_port") api.quantum_attach_port(IsA(http.HttpRequest), 'n1', 'p1', dict).AndReturn(True) formData = {'port': 'p1', 'network': 'n1', 'vif_id': 'v1', 'method': 'AttachPort'} self.mox.StubOutWithMock(messages, 'success') messages.success(IgnoreArg(), IsA(basestring)) res = self.client.post(reverse('horizon:nova:networks:port_attach', args=["n1", "p1"]), formData) self.assertRedirectsNoFollow(res, reverse('horizon:nova:networks:detail', args=["n1"]))