Esempio n. 1
0
    def plug(self, instance, network, mapping, vm_ref=None, device=None):
        if not vm_ref:
            vm_ref = VMHelper.lookup(self._session, instance.name)
        if not device:
            device = 0

        if mapping.get('should_create_vlan'):
            network_ref = self._ensure_vlan_bridge(network)
        else:
            network_ref = NetworkHelper.find_network_with_bridge(
                                        self._session, network['bridge'])
        vif_rec = {}
        vif_rec['device'] = str(device)
        vif_rec['network'] = network_ref
        vif_rec['VM'] = vm_ref
        vif_rec['MAC'] = mapping['mac']
        vif_rec['MTU'] = '1500'
        vif_rec['other_config'] = {}
        if "rxtx_cap" in mapping:
            vif_rec['qos_algorithm_type'] = "ratelimit"
            vif_rec['qos_algorithm_params'] = \
                {"kbps": str(mapping['rxtx_cap'] * 1024)}
        else:
            vif_rec['qos_algorithm_type'] = ""
            vif_rec['qos_algorithm_params'] = {}
        return vif_rec
Esempio n. 2
0
    def plug(self, instance, network, mapping, vm_ref=None, device=None):
        if not vm_ref:
            vm_ref = VMHelper.lookup(self._session, instance.name)

        if not device:
            device = 0

        # with OVS model, always plug into an OVS integration bridge
        # that is already created
        network_ref = NetworkHelper.find_network_with_bridge(self._session,
                                        FLAGS.xenapi_ovs_integration_bridge)
        vif_rec = {}
        vif_rec['device'] = str(device)
        vif_rec['network'] = network_ref
        vif_rec['VM'] = vm_ref
        vif_rec['MAC'] = mapping['mac']
        vif_rec['MTU'] = '1500'
        vif_rec['qos_algorithm_type'] = ""
        vif_rec['qos_algorithm_params'] = {}
        # OVS on the hypervisor monitors this key and uses it to
        # set the iface-id attribute
        vif_rec['other_config'] = \
                {"nicira-iface-id": mapping['vif_uuid']}
        return vif_rec