Cisco Virl1.5でflatを追加する

flatってなんやねんというのは割愛
Virl1.3までは　flatter.shで作成できるみたいだけど、1.3以降は動かない。残念。
なので、手動にて追加が必要。

#interface.dにBridgeの設定ファイルを作成

```sh

virl@virl-2:~$ cd /etc/network/interfaces.d/
virl@virl-2:/etc/network/interfaces.d$ sudo vi br31.cfg

auto br31
 iface br31 inet static
 address 172.16.31.254/24
 netmask 255.255.255.0
 bridge_maxwait 0
 bridge_ports dummy5 eth4
 bridge_stp off
 post-up ip link set br31 promisc on

```


Bridgeは30以降じゃないとダメ。
アドレスは適宜環境によって変えます。

#neutronのコンフィグファイルを修正

```sh
virl@virl-2:~$ sudo cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.old
virl@virl-2:~$ sudo vi /etc/neutron/neutron.conf

network_vlan_ranges=flat,flat1,ext-net,flat2

bridge_mappings=flat:br1,flat1:br2,ext-net:br3,flat2:br31

```
#ML2コンフィグファイルを修正
```sh
virl@virl-2:/$ sudo cp /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.old
virl@virl-2:/$
virl@virl-2:/$ sudo vi /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2_type_flat]
~
flat_networks = flat,flat1,ext-net,flat2

```

#neutronサービスの再起動したあとに各種設定
```sh
virl@virl-2:/$ sudo systemctl restart neutron-server.service

virl@virl-2:/$ neutron net-create --shared --provider:physical_network=flat2 --provider:network_type=flat flat2
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2019-01-09T05:43:51                  |
| description               |                                      |
| id                        | xxxxxxxxxxxxxxxx　　　　　　　　　　　 |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| mtu                       | 1500                                 |
| name                      | flat2                                |
| provider:network_type     | flat                                 |
| provider:physical_network | flat2                                |
| provider:segmentation_id  |                                      |
| router:external           | False                                |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | 　     |
| updated_at                | 2019-01-09T05:43:51                  |
+---------------------------+--------------------------------------+

virl@virl-2:/$ neutron subnet-create flat2 172.16.31.0/24 --name flat2 --allocation-pool start=172.16.31.50,end=172.16.31.250 --gateway=172.16.31.2 --dns-nameservers list=true 8.8.8.8 8.8.8.4
Created a new subnet:
+-------------------+---------------------------------------------------+
| Field             | Value                                             |
+-------------------+---------------------------------------------------+
| allocation_pools  | {"start": "172.16.31.50", "end": "172.16.31.250"} |
| cidr              | 172.16.31.0/24                                    |
| created_at        | 2019-01-09T05:45:52                               |
| description       |                                                   |
| dns_nameservers   | 8.8.8.8                                           |
|                   | 8.8.8.4                                           |
| enable_dhcp       | True                                              |
| gateway_ip        | 172.16.31.2                                       |
| host_routes       |                                                   |
| id                | xxxxxxxxxxxxxxx                                   |
| ip_version        | 4                                                 |
| ipv6_address_mode |                                                   |
| ipv6_ra_mode      |                                                   |
| name              | flat2                                             |
| network_id        | xxxxxxxxxxxxxxx                                   |
| subnetpool_id     |                                                   |
| tenant_id         | xxxxxxxxxxxxxxx                                   |
| updated_at        | 2019-01-09T05:45:52                               |
+-------------------+---------------------------------------------------+
virl@virl-2:/$
```

#VIRL-Coreファイルの編集

```sh
virl@virl-2:/$ sudo cp /etc/virl/virl-core.ini /etc/virl/virl-core.ini.old
virl@virl-2:/$ sudo vi /etc/virl/virl-core.ini

[linuxbridge]
~
bridge_flat2 = br31

```

#完成したので確認
```sh
virl@virl-2:/$ neutron net-list
+--------------------------------------+------------+-----------------------------------------------------+
| id                                   | name       | subnets                                             |
+--------------------------------------+------------+-----------------------------------------------------+
| 259aa2b5-c3d9-423a-99c1-66e37ced9115 | ext-net    | b46526b0-204e-4d17-8043-0ada82dce4e5 172.16.3.0/24  |
| 301cc17f-bb81-4ff6-9d82-90d3d198dd53 | flat1      | 91b7d3f2-64b8-4613-ab02-c00bcc43491a 172.16.2.0/24  |
| 47e760e6-38db-4e7a-a237-d800570b91ee | guest_snat | 5ca972fd-0c70-4f56-a6c2-0c2ad3a27910 10.254.0.0/16  |
| 897b9ba5-a8f8-4e36-9352-9adc4b0d512d | guest      | 4420225b-da58-496b-9934-18a0984429a0 10.255.0.0/16  |
| c7162449-32e8-49ae-8d6b-e3f40bc02ee5 | flat       | b4bbb26a-ac22-4782-b8dc-20c6a4410b5f 172.16.1.0/24  |
| ecd32bb7-053d-434b-a986-01642012b47e | flat2      | 24fd0682-10d2-49bd-8f25-0297ade09798 172.16.31.0/24 |
+--------------------------------------+------------+-----------------------------------------------------+
virl@virl-2:/$ neutron subnet-list
+--------------------------------------+------------+----------------+---------------------------------------------------+
| id                                   | name       | cidr           | allocation_pools                                  |
+--------------------------------------+------------+----------------+---------------------------------------------------+
| b46526b0-204e-4d17-8043-0ada82dce4e5 | ext-net    | 172.16.3.0/24  | {"start": "172.16.3.50", "end": "172.16.3.240"}   |
| 4420225b-da58-496b-9934-18a0984429a0 | guest      | 10.255.0.0/16  | {"start": "10.255.0.2", "end": "10.255.255.254"}  |
| b4bbb26a-ac22-4782-b8dc-20c6a4410b5f | flat       | 172.16.1.0/24  | {"start": "172.16.1.50", "end": "172.16.1.240"}   |
| 5ca972fd-0c70-4f56-a6c2-0c2ad3a27910 | guest_snat | 10.254.0.0/16  | {"start": "10.254.0.2", "end": "10.254.255.254"}  |
| 91b7d3f2-64b8-4613-ab02-c00bcc43491a | flat1      | 172.16.2.0/24  | {"start": "172.16.2.50", "end": "172.16.2.240"}   |
| 24fd0682-10d2-49bd-8f25-0297ade09798 | flat2      | 172.16.31.0/24 | {"start": "172.16.31.50", "end": "172.16.31.250"} |
+--------------------------------------+------------+----------------+---------------------------------------------------+
virl@virl-2:/$ neutron subnet-show flat2
+-------------------+---------------------------------------------------+
| Field             | Value                                             |
+-------------------+---------------------------------------------------+
| allocation_pools  | {"start": "172.16.31.50", "end": "172.16.31.250"} |
| cidr              | 172.16.31.0/24                                    |
| created_at        | 2019-01-09T05:45:52                               |
| description       |                                                   |
| dns_nameservers   | 8.8.8.8                                           |
|                   | 8.8.8.4                                           |
| enable_dhcp       | True                                              |
| gateway_ip        | 172.16.31.2                                       |
| host_routes       |                                                   |
| id                | 24fd0682-10d2-49bd-8f25-0297ade09798              |
| ip_version        | 4                                                 |
| ipv6_address_mode |                                                   |
| ipv6_ra_mode      |                                                   |
| name              | flat2                                             |
| network_id        | ecd32bb7-053d-434b-a986-01642012b47e              |
| subnetpool_id     |                                                   |
| tenant_id         | 0a67f18fb8814efc8000fa3dd05fc7c7                  |
| updated_at        | 2019-01-09T05:45:52                               |
+-------------------+---------------------------------------------------+
virl@virl-2:/$ ls /sys/devices/virtual/net/
br1             dummy11  dummy7  ifb15  ifb24  ifb5            tap7235ca57-6b
br2             dummy12  dummy8  ifb16  ifb25  ifb6            tap937d3398-f0
br3             dummy13  dummy9  ifb17  ifb26  ifb7            tapd591e1eb-4d
br4             dummy14  ifb0    ifb18  ifb27  ifb8            tapdd0b5b81-c7
brq47e760e6-38  dummy15  ifb1    ifb19  ifb28  ifb9            tape262db57-55
brq897b9ba5-a8  dummy2   ifb10   ifb2   ifb29  lo              vethc2109f6
docker0         dummy3   ifb11   ifb20  ifb3   tap1e3f79b3-3f  vxlan-34
dummy0          dummy4   ifb12   ifb21  ifb30  tap436bf2e0-32  vxlan-46
dummy1          dummy5   ifb13   ifb22  ifb31  tap4964fe29-06
dummy10         dummy6   ifb14   ifb23  ifb4   tap6471da01-2c

```
この時点だと、/sys/devices/virtual/net/にbr31がないので再起動する。

#再起動してLOGINする
```shell
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-116-generic x86_64)

  System load:         0.74               IP address for br31:    172.16.31.254
  Usage of /:          12.9% of 59.38GB   IP address for br1:     172.16.1.250
  Memory usage:        8%                 IP address for br2:     172.16.2.250
  Swap usage:          0%                 IP address for br3:     172.16.3.250
  Processes:           385                IP address for br4:     172.16.10.250
  IP address for eth0: 192.168.8.202      IP address for docker0: 172.17.0.1
Last login: Wed Jan  9 05:07:47 2019 from 192.168.8.170
virl@virl-2:~$
virl@virl-2:~$ ls /sys/devices/virtual/net/
br1             dummy0   dummy2  ifb0   ifb16  ifb23  ifb30  lo
br2             dummy1   dummy3  ifb1   ifb17  ifb24  ifb31  tap4964fe29-06
br3             dummy10  dummy4  ifb10  ifb18  ifb25  ifb4   tap6471da01-2c
br31            dummy11  dummy5  ifb11  ifb19  ifb26  ifb5   tapd591e1eb-4d
br4             dummy12  dummy6  ifb12  ifb2   ifb27  ifb6   vethe51f579
brq47e760e6-38  dummy13  dummy7  ifb13  ifb20  ifb28  ifb7   vxlan-34
brq897b9ba5-a8  dummy14  dummy8  ifb14  ifb21  ifb29  ifb8   vxlan-46
docker0         dummy15  dummy9  ifb15  ifb22  ifb3   ifb9

```

今度こそ完成。