예제 #1
0
def get_hypervutils():
    # V1 virtualization namespace features are supported up to
    # Windows Server / Hyper-V Server 2012
    # V2 virtualization namespace features are supported starting with
    # Windows Server / Hyper-V Server 2012
    # Windows Server / Hyper-V Server 2012 R2 uses the V2 namespace and
    # introduces additional features

    force_v1_flag = CONF.hyperv.force_hyperv_utils_v1
    if _check_min_windows_version(6, 3):
        if force_v1_flag:
            LOG.warning(
                _LW('V1 virtualization namespace no longer supported '
                    'on Windows Server / Hyper-V Server 2012 R2 or '
                    'above.'))
        cls = utilsv2.HyperVUtilsV2R2
    elif not force_v1_flag and _check_min_windows_version(6, 2):
        cls = utilsv2.HyperVUtilsV2
    else:
        cls = utils.HyperVUtils
    LOG.debug("Loading class: %(module_name)s.%(class_name)s", {
        'module_name': cls.__module__,
        'class_name': cls.__name__
    })
    return cls()
예제 #2
0
    def bind_nvgre_port(self, segmentation_id, network_name, port_id):
        mac_addr = self._hyperv_utils.get_vnic_mac_address(port_id)
        provider_addr = self._nvgre_utils.get_network_iface_ip(network_name)[0]
        customer_addr = self._n_client.get_port_ip_address(port_id)

        if not provider_addr or not customer_addr:
            LOG.warning(_LW('Cannot bind NVGRE port. Could not determine '
                            'provider address (%(prov_addr)s) or customer '
                            'address (%(cust_addr)s).'),
                        {'prov_addr': provider_addr,
                         'cust_addr': customer_addr})
            return

        LOG.info(_LI('Binding VirtualSubnetID %(segmentation_id)s '
                     'to switch port %(port_id)s'),
                 dict(segmentation_id=segmentation_id, port_id=port_id))
        self._hyperv_utils.set_vswitch_port_vsid(segmentation_id, port_id)

        # normal lookup record.
        self._register_lookup_record(
            provider_addr, customer_addr, mac_addr, segmentation_id)

        # lookup record for dhcp requests.
        self._register_lookup_record(
            self._vswitch_ips[network_name], constants.IPV4_DEFAULT,
            mac_addr, segmentation_id)

        LOG.info('Fanning out LookupRecord...')
        self._notifier.lookup_update(self.context,
                                     provider_addr,
                                     {'customer_addr': customer_addr,
                                      'mac_addr': mac_addr,
                                      'customer_vsid': segmentation_id})
예제 #3
0
    def _get_policy_values(self, qos_policy):
        result = {}
        for qos_rule in qos_policy.rules:
            if qos_rule.rule_type not in self._SUPPORTED_QOS_RULES:
                LOG.warning(_LW("Unsupported QoS rule: %(qos_rule)s"),
                            dict(qos_rule=qos_rule))
                continue
            result['min_kbps'] = getattr(qos_rule, 'min_kbps',
                                         result.get('min_kbps'))
            result['max_kbps'] = getattr(qos_rule, 'max_kbps',
                                         result.get('max_kbps'))
            result['max_burst_kbps'] = getattr(qos_rule, 'max_burst_kbps',
                                               result.get('max_burst_kbps'))

        return result
예제 #4
0
    def bind_nvgre_network(self, segmentation_id, net_uuid, vswitch_name):
        subnets = self._n_client.get_network_subnets(net_uuid)
        if len(subnets) > 1:
            LOG.warning(_LW("Multiple subnets in the same network is not "
                            "supported."))
        subnet = subnets[0]
        try:
            cidr, gw = self._n_client.get_network_subnet_cidr_and_gateway(
                subnet)
            self._nvgre_utils.create_customer_routes(
                segmentation_id, vswitch_name, cidr, gw)
        except Exception as ex:
            LOG.error(_LE("Exception caught: %s"), ex)

        self._network_vsids[net_uuid] = segmentation_id
        self.refresh_nvgre_records(network_id=net_uuid)
        self._notifier.tunnel_update(
            self.context, CONF.NVGRE.provider_tunnel_ip, segmentation_id)
    def bind_nvgre_network(self, segmentation_id, net_uuid, vswitch_name):
        subnets = self._n_client.get_network_subnets(net_uuid)
        if len(subnets) > 1:
            LOG.warning(
                _LW("Multiple subnets in the same network is not "
                    "supported."))
        subnet = subnets[0]
        try:
            cidr, gw = self._n_client.get_network_subnet_cidr_and_gateway(
                subnet)
            self._nvgre_utils.create_customer_routes(segmentation_id,
                                                     vswitch_name, cidr, gw)
        except Exception as ex:
            LOG.error(_LE("Exception caught: %s"), ex)

        self._network_vsids[net_uuid] = segmentation_id
        self.refresh_nvgre_records(network_id=net_uuid)
        self._notifier.tunnel_update(self.context,
                                     CONF.NVGRE.provider_tunnel_ip,
                                     segmentation_id)
예제 #6
0
    def get_tunneling_agents(self):
        try:
            agents = self._client.list_agents()
            tunneling_agents = [
                a for a in agents['agents'] if constants.TYPE_NVGRE in
                a.get('configurations', {}).get('tunnel_types', [])]

            tunneling_ip_agents = [
                a for a in tunneling_agents if
                a.get('configurations', {}).get('tunneling_ip')]

            if len(tunneling_ip_agents) < len(tunneling_agents):
                LOG.warning(_LW('Some agents have NVGRE tunneling enabled, but'
                                ' do not provide tunneling_ip. Ignoring those '
                                'agents.'))

            return dict([(a['host'], a['configurations']['tunneling_ip'])
                         for a in tunneling_ip_agents])
        except Exception as ex:
            LOG.error(_LE("Could not get tunneling agents. Error: %s"), ex)
            return {}
def get_hypervutils():
    # V1 virtualization namespace features are supported up to
    # Windows Server / Hyper-V Server 2012
    # V2 virtualization namespace features are supported starting with
    # Windows Server / Hyper-V Server 2012
    # Windows Server / Hyper-V Server 2012 R2 uses the V2 namespace and
    # introduces additional features

    force_v1_flag = CONF.hyperv.force_hyperv_utils_v1
    if _check_min_windows_version(6, 3):
        if force_v1_flag:
            LOG.warning(_LW('V1 virtualization namespace no longer supported '
                            'on Windows Server / Hyper-V Server 2012 R2 or '
                            'above.'))
        cls = utilsv2.HyperVUtilsV2R2
    elif not force_v1_flag and _check_min_windows_version(6, 2):
        cls = utilsv2.HyperVUtilsV2
    else:
        cls = utils.HyperVUtils
    LOG.debug("Loading class: %(module_name)s.%(class_name)s",
              {'module_name': cls.__module__, 'class_name': cls.__name__})
    return cls()
    def _port_enable_control_metrics(self):
        if not self.enable_metrics_collection:
            return

        for port_id in list(self._port_metric_retries.keys()):
            try:
                if self._utils.is_metrics_collection_allowed(port_id):
                    self._metricsutils.enable_port_metrics_collection(port_id)
                    LOG.info(_LI('Port metrics enabled for port: %s'), port_id)
                    del self._port_metric_retries[port_id]
                elif self._port_metric_retries[port_id] < 1:
                    self._metricsutils.enable_port_metrics_collection(port_id)
                    LOG.error(_LE('Port metrics raw enabling for port: %s'),
                              port_id)
                    del self._port_metric_retries[port_id]
                else:
                    self._port_metric_retries[port_id] -= 1
            except exceptions.NotFound:
                # the vNIC no longer exists. it might have been removed or
                # the VM it was attached to was destroyed.
                LOG.warning(_LW("Port %s no longer exists. Cannot enable "
                                "metrics."), port_id)
                del self._port_metric_retries[port_id]
예제 #9
0
    def _port_enable_control_metrics(self):
        if not self.enable_metrics_collection:
            return

        for port_id in list(self._port_metric_retries.keys()):
            try:
                if self._utils.is_metrics_collection_allowed(port_id):
                    self._metricsutils.enable_port_metrics_collection(port_id)
                    LOG.info(_LI('Port metrics enabled for port: %s'), port_id)
                    del self._port_metric_retries[port_id]
                elif self._port_metric_retries[port_id] < 1:
                    self._metricsutils.enable_port_metrics_collection(port_id)
                    LOG.error(_LE('Port metrics raw enabling for port: %s'),
                              port_id)
                    del self._port_metric_retries[port_id]
                else:
                    self._port_metric_retries[port_id] -= 1
            except exceptions.NotFound:
                # the vNIC no longer exists. it might have been removed or
                # the VM it was attached to was destroyed.
                LOG.warning(_LW("Port %s no longer exists. Cannot enable "
                                "metrics."), port_id)
                del self._port_metric_retries[port_id]
예제 #10
0
    def bind_nvgre_port(self, segmentation_id, network_name, port_id):
        mac_addr = self._hyperv_utils.get_vnic_mac_address(port_id)
        provider_addr = self._nvgre_utils.get_network_iface_ip(network_name)[0]
        customer_addr = self._n_client.get_port_ip_address(port_id)

        if not provider_addr or not customer_addr:
            LOG.warning(
                _LW('Cannot bind NVGRE port. Could not determine '
                    'provider address (%(prov_addr)s) or customer '
                    'address (%(cust_addr)s).'), {
                        'prov_addr': provider_addr,
                        'cust_addr': customer_addr
                    })
            return

        LOG.info(
            _LI('Binding VirtualSubnetID %(segmentation_id)s '
                'to switch port %(port_id)s'),
            dict(segmentation_id=segmentation_id, port_id=port_id))
        self._hyperv_utils.set_vswitch_port_vsid(segmentation_id, port_id)

        # normal lookup record.
        self._register_lookup_record(provider_addr, customer_addr, mac_addr,
                                     segmentation_id)

        # lookup record for dhcp requests.
        self._register_lookup_record(self._vswitch_ips[network_name],
                                     constants.IPV4_DEFAULT, mac_addr,
                                     segmentation_id)

        LOG.info('Fanning out LookupRecord...')
        self._notifier.lookup_update(
            self.context, provider_addr, {
                'customer_addr': customer_addr,
                'mac_addr': mac_addr,
                'customer_vsid': segmentation_id
            })