neutron N版qos紹介


著者:呂嘉偉
QOSの構成
システムにqosの構成をサポートさせる:
1.neutron-serverのneutronを修正する.conf構成
# vim /etc/neutron/neutron.conf
service_plugins = neutron.services.qos.qos_plugin.QoSPlugin

2.neutron-serverのml 2_を修正するconf.ini構成
# vim /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
extension_drivers=qos

3.ovs-agent構成の変更
# vim /etc/neutron/plugins/ml2/ml2_conf.ini
[agent]
extensions=qos

4.構成policy.jsonは使用するユーザーにqosポリシーを使用する権利を持たせる(以下の構成はすべてデフォルトであり、構成しないことができる)
# vim /etc/neutron/policy.json
"get_policy": "rule:regular_user",
"create_policy": "rule:regular_user",
"update_policy": "rule:regular_user",
"delete_policy": "rule:regular_user",
"get_policy_bandwidth_limit_rule": "rule:regular_user",
//         ,           、      
"create_policy_bandwidth_limit_rule": "rule:admin_only",
"delete_policy_bandwidth_limit_rule": "rule:admin_only",
"update_policy_bandwidth_limit_rule": "rule:admin_only",
"get_rule_type": "rule:regular_user",
//  dscp     ,          、  dscp  
"get_policy_dscp_marking_rule": "rule:regular_user",
"create_dscp_marking_rule": "rule:admin_only",
"delete_dscp_marking_rule": "rule:admin_only",
"update_dscp_marking_rule": "rule:admin_only",
"get_rule_type": "rule:regular_user",
 

5.neutron-serverとovs-agentの再起動
QOS使用
tcp向け
例1ポートのポリシーおよび帯域幅制限ルールの作成
# neutron qos-policy-create bw-limiter
Created a new policy:
+-----------------+--------------------------------------+
| Field           | Value                                |
+-----------------+--------------------------------------+
| created_at      | 2016-11-16T06:59:11Z                 |
| description     |                                      |
| id              |7f951336-6ed8-4b1b-b93f-6491fbe855b0 |
| name            | bw-limiter                           |
| revision_number | 1                                    |
| rules           |                                      |
| shared          | False                                |
| tenant_id       | f332909670c841abb78c2e30e8c50c68     |
| updated_at      | 2016-11-16T06:59:11Z                 |
+-----------------+--------------------------------------+
# neutron qos-bandwidth-limit-rule-createbw-limiter --max-kbps 3000 --max-burst-kbps 300
Created a new bandwidth_limit_rule:
+----------------+--------------------------------------+
| Field          | Value                                |
+----------------+--------------------------------------+
| id             |530f4a1c-6711-4ca5-a374-1b869ad14b4c |
| max_burst_kbps | 300                                  |
| max_kbps       | 3000                                 |
+----------------+--------------------------------------+
ポリシーをポートにバインドするには、次の手順に従います.
# neutron port-update88101e57-76fa-4d12-b0e0-4fc7634b874a --qos-policy bw-limiter
Updated port:88101e57-76fa-4d12-b0e0-4fc7634b874a
ポートのQOSポリシーをキャンセルするには:
# neutron port-update88101e57-76fa-4d12-b0e0-4fc7634b874a --no-qos-policy
Updated port:88101e57-76fa-4d12-b0e0-4fc7634b874a
ポート作成時にQOSを指定します.
# neutron port-create port-name--qos-policy-id bw-limiter
例2ネットワークのQOSポリシーの作成
ネットワーク上に構築されたすべてのダミーマシンは、ネットワークのqosによって制限され、dhcpおよび仮想ルータのポートは制限されません.
# neutron net-update013328fd-9001-4bef-9c97-f97c5efc22cc --qos-policy bw-limiter
Updated network:013328fd-9001-4bef-9c97-f97c5efc22cc
IPメッセージ
例3 DSCP
# neutron qos-policy-create dscp-marking
Created a new policy:
+-----------------+--------------------------------------+
| Field           | Value                                |
+-----------------+--------------------------------------+
| created_at      | 2016-11-17T07:25:51Z                 |
| description     |                                      |
| id              |d787d85d-9012-48fc-adcc-aaf9f57540ed |
| name            | dscp-marking                         |
| revision_number | 1                                    |
| rules           |                                      |
| shared          | False                                |
| tenant_id       | f332909670c841abb78c2e30e8c50c68     |
| updated_at      | 2016-11-17T07:25:51Z                 |
+-----------------+--------------------------------------+
# neutron qos-dscp-marking-rule-createdscp-marking --dscp-mark 26
Created a new dscp_marking_rule:
+-----------+--------------------------------------+
| Field    | Value                               |
+-----------+--------------------------------------+
| dscp_mark | 26                                   |
| id       | 334ce934-2f60-4ff4-93cb-d4aa3b707973 |
+-----------+--------------------------------------+
# neutron port-update750901a3-70b3-4907-a52a-0025fac9d6c1 --qos-policy dscp-marking
Updated port:750901a3-70b3-4907-a52a-0025fac9d6c1
注意:1つのポートにはqosポリシーが1つしかありません.1つのqosポリシーは、帯域幅規則とdscp規則を同時に含むことができる.qosポリシーはポートにバインドされた後、直接削除することはできません.
QOSの原理
このセクションでは、ovsをqosとして実装する下位ソフトウェア、ovs-agentを使用して実装されるneutron qos機能についてのみ説明します.
Neutron定義qosルールタイプ:
VALID_RULE_TYPES =[RULE_TYPE_BANDWIDTH_LIMIT,
                    RULE_TYPE_DSCP_MARKING,
                   RULE_TYPE_MINIMUM_BANDWIDTH,
                    ]
N版Ovs-agentは、帯域幅制限速度が虚機の出方向制限速度のみを実現する前の2つのルールをサポートしている.neutron qos-available-rule-typesを使用して、現在のシステムでサポートされているルールタイプを表示します.
# neutronqos-available-rule-types
+-----------------+
|type            |
+-----------------+
|dscp_marking    |
|bandwidth_limit |
+-----------------+
ポートDscpの実現原理
Ovs-agentは、ovsの対応するポートのフローテーブル規則を変更することによって、IPメッセージのdscp値を変更します.具体的なコードは以下の通りです.
neutron/plugins/ml2/drivers/openvswitch/agent/extension_drivers/qos_driver.py
def update_dscp_marking(self, port, rule):
    …………….
    …………….
    else:
      for flow in flows:
         actions = str(flow).partition("actions=")[2]
      acts = actions.split(',')
      # mod_nw_tos = modify type of service header
       # This is the second byte of the IPv4 packet header.
        # DSCP makes up the upper 6 bits of this header field.
       actions = "mod_nw_tos:" + mark + ","
       actions += ','.join([act for act in acts if "mod_nw_tos:" not in act])
      self.br_int.mod_flow(reg2=0, in_port=port, table=0,
                  actions=actions)

ポート帯域幅制限速度の実現原理
ovs上のポートのingress_を変更することでpolicing_rateとingress_policing_burst属性値は虚機出方向の制限速度を実現し、実現コードは以下の通りである.
neutron/plugins/ml2/drivers/openvswitch/agent/extension_drivers/qos_driver.py
def update_bandwidth_limit(self, port, rule):
    ………
    self.br_int.create_egress_bw_limit_for_port(vif_port.port_name,
                          max_kbps,
                                                max_burst_kbps)

neutron/agent/common/ovs_lib.py
class OVSBridge(BaseOVS):
    def create_egress_bw_limit_for_port(self, port_name, max_kbps,
                      max_burst_kbps):
        self._set_egress_bw_limit_for_port(port_name, max_kbps, max_burst_kbps)
    def _set_egress_bw_limit_for_port(self, port_name, max_kbps,
                     max_burst_kbps):
      with self.ovsdb.transaction(check_error=True) as txn:
          txn.add(self.ovsdb.db_set('Interface', port_name,
                    ('ingress_policing_rate', max_kbps)))
        txn.add(self.ovsdb.db_set('Interface', port_name,
                    ('ingress_policing_burst',max_burst_kbps)))

ネットワーク制限速度の実現原理
N版では、ユーザは、ネットワークにqosポリシーをバインドすることができ、ダミーがネットワーク上に作成されると、ダミーポートのnetwork_qos_policy_id属性値はqosポリシーのidに等しく、ovs-agentはovsを操作し、最下位でqosポリシーに従って対応する操作を行います.虚機は作成中にnovaによってovsのポートを作成し、この操作はovs-agentによって取得され、ovs-agentのrpc_loopプロセスではprocess_が使用されますnetwork_portsメソッドは、新しいポートを処理します.次に,ソースコード解析により,ネットワーク制限機能を用いた後,ovsポートがqosポリシーをどのように設定されたかを解析する.
Neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
Class OVSNeutronAgent:
def process_network_ports(self, port_info, ovs_restarted):
……
    if devices_added_updated:
            start = time.time()
            (skipped_devices, need_binding_devices,
            security_disabled_ports, failed_devices['added']) = (
                self.treat_devices_added_or_updated(
                    devices_added_updated, ovs_restarted))
def treat_devices_added_or_updated(self, devices, ovs_restarted):
    …… ……
    for details in devices:
    …… ……
    if 'port_id' in details:
      …… ……
        self.ext_manager.handle_port(self.context, details)

ここのext_managerはovs-agentの追加プラグインを管理し、第1節の構成のqosはextensionの1つです.
neutron/agent/l2/l2_agent_extensions_manager.py
class L2AgentExtensionsManager:
    def handle_port(self, context, data):
        """Notify all agent extensions to handle port."""
          for extension in self:
            if hasattr(extension.obj, 'handle_port'):
              extension.obj.handle_port(context, data)

neutron/agent/l2/extensions/qos.py
class QosAgentExtension:
    def handle_port(self, context, port):
      """Handle agent QoS extension for port.
 
   
      This method applies a new policy to a port using the QoS driver.
      Update events are handled in _handle_notification.
    """
    …… ……

これにより、qosポリシーに含まれるルール(帯域幅制限速度またはdscp)に基づいてovsを対応する動作を行い、ネットワークに対する制限速度を実現する.
まとめ
本稿では,N版のqos機能を構成,使用,原理の3つの面から紹介した.ovsをqosの実装ソフトウェアとして使用する場合、N版ovs-agentでは、方向の帯域幅制限とdscp制限しか実現できません.現在、速度制限機能はフローティングIP速度制限をサポートしていない.