def create_vlan_bridge(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = CreateVlanBridgeResponse()

        if linux.is_bridge(cmd.bridgeName):
            logger.debug('%s is a bridge device, no need to create bridge' %
                         cmd.bridgeName)
            self._ifup_device_if_down('%s.%s' %
                                      (cmd.physicalInterfaceName, cmd.vlan))
            self._configure_bridge()
            linux.set_device_uuid_alias(
                '%s.%s' % (cmd.physicalInterfaceName, cmd.vlan),
                cmd.l2NetworkUuid)
            return jsonobject.dumps(rsp)

        try:
            linux.create_vlan_bridge(cmd.bridgeName, cmd.physicalInterfaceName,
                                     cmd.vlan)
            self._configure_bridge()
            linux.set_device_uuid_alias(
                '%s.%s' % (cmd.physicalInterfaceName, cmd.vlan),
                cmd.l2NetworkUuid)
            logger.debug(
                'successfully realize vlan bridge[name:%s, vlan:%s] from device[%s]'
                % (cmd.bridgeName, cmd.vlan, cmd.physicalInterfaceName))
        except Exception as e:
            logger.warning(traceback.format_exc())
            rsp.error = 'unable to create vlan bridge[name:%s, vlan:%s] from device[%s], because %s' % (
                cmd.bridgeName, cmd.vlan, cmd.physicalInterfaceName, str(e))
            rsp.success = False

        return jsonobject.dumps(rsp)
Esempio n. 2
0
    def create_single_vxlan_bridge(self, cmd):
        linux.create_vxlan_interface(cmd.vni, cmd.vtepIp)

        interf = "vxlan" + str(cmd.vni)
        linux.create_vxlan_bridge(interf, cmd.bridgeName, cmd.peers)
        linux.set_device_uuid_alias(interf, cmd.l2NetworkUuid)
        self._configure_bridge_mtu(cmd.bridgeName, interf, cmd.mtu)
Esempio n. 3
0
    def create_bridge(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = CreateBridgeResponse()

        self._ifup_device_if_down(cmd.physicalInterfaceName)

        if linux.is_vif_on_bridge(cmd.bridgeName, cmd.physicalInterfaceName):
            logger.debug('%s is a bridge device. Interface %s is attached to bridge. No need to create bridge or attach device interface' % (cmd.bridgeName, cmd.physicalInterfaceName))
            self._configure_bridge(cmd.disableIptables)
            self._configure_bridge_mtu(cmd.bridgeName, cmd.physicalInterfaceName, cmd.mtu)
            self._configure_bridge_learning(cmd.bridgeName, cmd.physicalInterfaceName)
            linux.set_bridge_alias_using_phy_nic_name(cmd.bridgeName, cmd.physicalInterfaceName)
            linux.set_device_uuid_alias(cmd.physicalInterfaceName, cmd.l2NetworkUuid)
            self._ifup_device_if_down(cmd.bridgeName)
            return jsonobject.dumps(rsp)
        
        try:
            linux.create_bridge(cmd.bridgeName, cmd.physicalInterfaceName)
            linux.set_device_uuid_alias(cmd.physicalInterfaceName, cmd.l2NetworkUuid)
            self._configure_bridge(cmd.disableIptables)
            self._configure_bridge_mtu(cmd.bridgeName, cmd.physicalInterfaceName, cmd.mtu)
            self._configure_bridge_learning(cmd.bridgeName, cmd.physicalInterfaceName)
            linux.set_bridge_alias_using_phy_nic_name(cmd.bridgeName, cmd.physicalInterfaceName)
            logger.debug('successfully realize bridge[%s] from device[%s]' % (cmd.bridgeName, cmd.physicalInterfaceName))
        except Exception as e:
            logger.warning(traceback.format_exc())
            rsp.error = 'unable to create bridge[%s] from device[%s], because %s' % (cmd.bridgeName, cmd.physicalInterfaceName, str(e))
            rsp.success = False
            
        return jsonobject.dumps(rsp)
    def create_vxlan_bridges(self, req):
        # Create VXLAN interface using vtep ip then create bridge
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = CreateVxlanBridgesResponse()
        if not (cmd.vnis and cmd.vtepIp):
            rsp.error = "vni or vtepip is none"
            rsp.success = False
            return jsonobject.dumps(rsp)

        for vni in cmd.vnis:
            linux.create_vxlan_interface(vni, cmd.vtepIp)
            interf = "vxlan" + str(vni)
            linux.create_vxlan_bridge(interf, "br_vx_%s" % vni, cmd.peers)
            linux.set_device_uuid_alias(interf, cmd.l2NetworkUuid)

        return jsonobject.dumps(rsp)
Esempio n. 5
0
    def create_vxlan_bridges(self, req):
        # Create VXLAN interface using vtep ip then create bridge
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = CreateVxlanBridgesResponse()
        if not (cmd.vnis and cmd.vtepIp):
            rsp.error = "vni or vtepip is none"
            rsp.success = False
            return jsonobject.dumps(rsp)

        for vni in cmd.vnis:
            linux.create_vxlan_interface(vni, cmd.vtepIp)
            interf = "vxlan" + str(vni)
            linux.create_vxlan_bridge(interf, "br_vx_%s" % vni, cmd.peers)
            linux.set_device_uuid_alias(interf, cmd.l2NetworkUuid)

        return jsonobject.dumps(rsp)
Esempio n. 6
0
    def create_vlan_bridge(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = CreateVlanBridgeResponse()

        if linux.is_bridge(cmd.bridgeName):
            logger.debug('%s is a bridge device, no need to create bridge' % cmd.bridgeName)
            self._ifup_device_if_down('%s.%s' % (cmd.physicalInterfaceName, cmd.vlan))
            self._configure_bridge()
            linux.set_device_uuid_alias('%s.%s' % (cmd.physicalInterfaceName, cmd.vlan), cmd.l2NetworkUuid)
            return jsonobject.dumps(rsp)
        
        try:
            linux.create_vlan_bridge(cmd.bridgeName, cmd.physicalInterfaceName, cmd.vlan)
            self._configure_bridge()
            linux.set_device_uuid_alias('%s.%s' % (cmd.physicalInterfaceName, cmd.vlan), cmd.l2NetworkUuid)
            logger.debug('successfully realize vlan bridge[name:%s, vlan:%s] from device[%s]' % (cmd.bridgeName, cmd.vlan, cmd.physicalInterfaceName))
        except Exception as e:
            logger.warning(traceback.format_exc())
            rsp.error = 'unable to create vlan bridge[name:%s, vlan:%s] from device[%s], because %s' % (cmd.bridgeName, cmd.vlan, cmd.physicalInterfaceName, str(e))
            rsp.success = False
            
        return jsonobject.dumps(rsp)