Nested KVM環境でのNewton版OpenStack構築メモ

RDOを使用したNewton版OpenStack構築メモです。

## ■ OpenStack環境整備の目標感
KVM環境を整備して、OpenStack用の仮想マシンをデプロイします。
必要最小限なAll-In-One構成を目指します。

- 仮想マシン名：newton
- CPU数：4CPU
- メモリ：8,192MB
- ハードディスク：80GB
- CentOSバージョン：CentOS Linux release 7.3.1611 (Core) 

## ■ OpenStack構築メモ
### (1) CentOSインストール
まずは、OpenStack構築するためのLinux母艦として、CentOSをインストールします。

- "CentOS-7-x86_64-Minimal-1611.iso"のダウンロード（/home/tsubo/iso配下に置くものとする）
- CentOSのインストール

```
$ sudo virt-install \
> --name newton \
> --ram 8192 \
> --disk path=/var/lib/libvirt/images/newton.qcow2,size=80,bus=virtio,format=qcow2 \
> --vcpus 4 \
> --os-variant rhel7 \
> --network bridge=br-ext \
> --graphics none \
> --console pty,target_type=serial \
> --location /home/tsubo/iso/CentOS-7-x86_64-Minimal-1611.iso \
> --extra-args 'console=ttyS0,115200n8 serial'
```
- テキストモードでの各種インストールのパラメータ設定

```
Starting installer, one moment...
anaconda 21.48.22.93-1 for CentOS Linux 7 started.
 * installation log files are stored in /tmp during the installation
 * shell is available on TTY2
 * when reporting a bug add logs from /tmp as separate text/plain attachments
00:47:09 Not asking for VNC because we don't have a network
================================================================================
================================================================================
Installation

 1) [x] Language settings                 2) [!] Time settings
        (English (United States))                (Timezone is not set.)
 3) [!] Installation source               4) [!] Software selection
        (Processing...)                          (Processing...)
 5) [!] Installation Destination          6) [x] Kdump
        (No disks selected)                      (Kdump is enabled)
 7) [ ] Network configuration             8) [!] Root password
        (Not connected)                          (Password is not set.)
 9) [!] User creation
        (No user will be created)
  Please make your choice from above ['q' to quit | 'b' to begin installation |
  'r' to refresh]: 

[anaconda] 1:main* 2:shell  3:log  4:storage-lo> Switch tab: Alt+Tab | Help: F1 
```

〜 以下、省略　〜


- Intel VT-xの有効化のため、xmlファイル編集

```
$ sudo virsh define /etc/libvirt/qemu/newton.xml 
$ virsh dumpxml newton
  ...

  <cpu mode='custom' match='exact'>
    <model fallback='allow'>IvyBridge</model>
    <feature policy='require' name='vmx'/>
  </cpu>

  ...
```

- "newton"仮想マシンの起動

```
$ virsh start newton
```

- "newton"仮想マシン上で、vt-xが有効化の確認

```
[root@newton ~]# cat /proc/cpuinfo | grep vmx
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm arat tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm arat tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm arat tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm arat tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt
```
- ntpの設定

```
[root@newton ~]# yum install -y ntp
[root@newton ~]# echo "server ntp.nict.jp prefer iburst" >> /etc/ntp.conf
[root@newton ~]# systemctl start ntpd
[root@newton ~]# systemctl enable ntpd
```
- Firewallの無効化

```
[root@newton ~]# yum install -y iptables-services
[root@newton ~]# systemctl stop firewalld.service
[root@newton ~]# systemctl disable firewalld.service
[root@newton ~]# systemctl start iptables.service
[root@newton ~]# systemctl enable iptables.service
```
- SELinuxの無効化

```
[root@newton ~]# sed -i "s/SELINUX=.*/SELINUX=permissive/" /etc/selinux/config
[root@newton ~]# setenforce 0
```
- 英語ロケール設定

```
[root@newton ~]# echo "LANG=en_US.utf-8" > /etc/environment
[root@newton ~]# echo "LC_ALL=en_US.utf-8" >> /etc/environment
```
- カーネルパラメータの設定

```
# cat <<'EOF' > /etc/sysconfig/modules/openstack-neutron.modules
> #!/bin/sh
> modprobe -b bridge >/dev/null 2>&1
> exit 0
> EOF
```
```
# chmod u+x /etc/sysconfig/modules/openstack-neutron.modules
```

```
# cat <<'EOF' > /etc/sysctl.d/bridge-nf-call
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> net.bridge.bridge-nf-call-arptables = 1
> EOF
```

### (2) RDO環境セットアップ

- RDOのパッケージとPackStackの取得

```
[root@newton ~]# yum install -y centos-release-openstack-newton
[root@newton ~]# yum update -y
[root@newton ~]# yum install -y openstack-packstack
[root@newton ~]# reboot
```
- Answer Fileの作成

```
[root@newton ~]# cd /root
[root@newton ~]# packstack --gen-answer-file=/root/answer.txt \
> --default-password=secrete \
> --os-heat-install=y \
> --os-heat-cloudwatch-install=y \
> --os-heat-cfn-install=y \
> 
```
- PackStackの実行

```
[root@newton ~]# packstack --answer-file=/root/answer.txt
Welcome to the Packstack setup utility

The installation log file is available at: /var/tmp/packstack/20170202-113439-SALMrK/openstack-setup.log

Installing:
Clean Up                                             [ DONE ]
Discovering ip protocol version                      [ DONE ]
Setting up ssh keys                                  [ DONE ]

... (snip)

10.79.5.190_compute.pp:                              [ DONE ]     
Applying Puppet manifests                            [ DONE ]
Finalizing                                           [ DONE ]

 **** Installation completed successfully ******

Additional information:
 * Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components.
 * Warning: NetworkManager is active on 10.79.5.190. OpenStack networking currently does not work on systems that have the Network Manager service enabled.
 * File /root/keystonerc_admin has been created on OpenStack client host 10.79.5.190. To use the command line tools you need to source the file.
 * To access the OpenStack Dashboard browse to http://10.79.5.190/dashboard .
Please, find your login credentials stored in the keystonerc_admin in your home directory.
 * To use Nagios, browse to http://10.79.5.190/nagios username: nagiosadmin, password: secrete
 * Because of the kernel update the host 10.79.5.190 requires reboot.
 * The installation log file is available at: /var/tmp/packstack/20170202-134107-oxzCAT/openstack-setup.log
 * The generated manifests are available at: /var/tmp/packstack/20170202-134107-oxzCAT/manifests
```
- NetworkManagerの無効化

```
[root@newton ~]# systemctl stop NetworkManager
[root@newton ~]# systemctl disable NetworkManager
```
- OpenStack構築結果の確認

```
[root@newton ~]# yum install -y openstack-utils
[root@newton ~]# cd /root
[root@newton ~]# source keystonerc_admin
[root@newton ~(keystone_admin)]# openstack-status
== Nova services ==
openstack-nova-api:                     active
openstack-nova-compute:                 active
openstack-nova-network:                 inactive  (disabled on boot)
openstack-nova-scheduler:               active
openstack-nova-cert:                    active
openstack-nova-conductor:               active
openstack-nova-console:                 inactive  (disabled on boot)
openstack-nova-consoleauth:             active
openstack-nova-xvpvncproxy:             inactive  (disabled on boot)
== Glance services ==
openstack-glance-api:                   active
openstack-glance-registry:              active
== Keystone service ==
openstack-keystone:                     inactive  (disabled on boot)
== Horizon service ==
openstack-dashboard:                    active
== neutron services ==
neutron-server:                         active
neutron-dhcp-agent:                     active
neutron-l3-agent:                       active
neutron-metadata-agent:                 active
neutron-openvswitch-agent:              active
neutron-metering-agent:                 active
== Cinder services ==
openstack-cinder-api:                   active
openstack-cinder-scheduler:             active
openstack-cinder-volume:                active
openstack-cinder-backup:                active
== Ceilometer services ==
openstack-ceilometer-api:               inactive  (disabled on boot)
openstack-ceilometer-central:           active
openstack-ceilometer-compute:           active
openstack-ceilometer-collector:         active
openstack-ceilometer-notification:      active
== Heat services ==
openstack-heat-api:                     active
openstack-heat-api-cfn:                 active
openstack-heat-api-cloudwatch:          active
openstack-heat-engine:                  active
== Support services ==
mariadb:                                active
openvswitch:                            active
dbus:                                   active
target:                                 active
rabbitmq-server:                        active
memcached:                              active
== Keystone users ==
/usr/bin/openstack-status: line 267: keystone: command not found
== Glance images ==
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| f91e45cb-114e-4322-8883-109f7392c912 | cirros |
+--------------------------------------+--------+
== Nova managed services ==
+----+------------------+--------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary           | Host   | Zone     | Status  | State | Updated_at                 | Disabled Reason |
+----+------------------+--------+----------+---------+-------+----------------------------+-----------------+
| 1  | nova-cert        | newton | internal | enabled | up    | 2017-02-02T05:03:55.000000 | -               |
| 2  | nova-consoleauth | newton | internal | enabled | up    | 2017-02-02T05:03:55.000000 | -               |
| 7  | nova-scheduler   | newton | internal | enabled | up    | 2017-02-02T05:03:54.000000 | -               |
| 8  | nova-conductor   | newton | internal | enabled | up    | 2017-02-02T05:03:55.000000 | -               |
| 9  | nova-compute     | newton | nova     | enabled | up    | 2017-02-02T05:03:49.000000 | -               |
+----+------------------+--------+----------+---------+-------+----------------------------+-----------------+
== Nova networks ==
WARNING: Command network-list is deprecated and will be removed after Nova 15.0.0 is released. Use python-neutronclient or python-openstackclient instead.
+--------------------------------------+---------+------+
| ID                                   | Label   | Cidr |
+--------------------------------------+---------+------+
| a0a076fe-fd31-4f37-a8ba-1f3d77ebb1da | public  | -    |
| bfb970fd-e8a6-4286-8f4e-59be750f76ed | private | -    |
+--------------------------------------+---------+------+
== Nova instance flavors ==
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
== Nova instances ==
+----+------+-----------+--------+------------+-------------+----------+
| ID | Name | Tenant ID | Status | Task State | Power State | Networks |
+----+------+-----------+--------+------------+-------------+----------+
+----+------+-----------+--------+------------+-------------+----------+
```
- 現状のネットワーク情報の確認

```
[root@newton ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:da:d9:d6 brd ff:ff:ff:ff:ff:ff
    inet 10.79.5.190/24 brd 10.79.5.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:feda:d9d6/64 scope link 
       valid_lft forever preferred_lft forever
3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether ae:d6:ce:67:cc:ba brd ff:ff:ff:ff:ff:ff
5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 7a:4a:e3:ba:2e:44 brd ff:ff:ff:ff:ff:ff
7: br-tun: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether e6:16:11:c4:52:47 brd ff:ff:ff:ff:ff:ff
9: br-ex: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether c2:46:27:8a:20:4d brd ff:ff:ff:ff:ff:ff
```
- ネットワークブリッジの設定

```
[root@newton ~]# ovs-vsctl list-br
br-ex
br-int
br-tun
```
```
[root@newton ~]# vi /etc/sysconfig/network-scripts/ifcfg-br-ex
```
```text:/etc/sysconfig/network-scripts/ifcfg-br-ex
DEVICE=br-ex
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=10.79.5.190
NETMASK=255.255.255.0
GATEWAY=10.79.5.1
DEFROUTE=yes
ONBOOT=yes
```
```
[root@newton ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
```
```text:/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=OVSPort
DEVICETYPE=ovs
NM_CONTROLLED=no
ONBOOT=yes
OVS_BRIDGE=br-ex
```
- ネットワーク再起動

```
[root@newton ~]# service network restart
```
- 再度、現状のネットワーク情報の確認

```
[root@newton ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 52:54:00:da:d9:d6 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5054:ff:feda:d9d6/64 scope link 
       valid_lft forever preferred_lft forever
3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether ae:d6:ce:67:cc:ba brd ff:ff:ff:ff:ff:ff
5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 7a:4a:e3:ba:2e:44 brd ff:ff:ff:ff:ff:ff
7: br-tun: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether e6:16:11:c4:52:47 brd ff:ff:ff:ff:ff:ff
9: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether c2:46:27:8a:20:4d brd ff:ff:ff:ff:ff:ff
    inet 10.79.5.190/24 brd 10.79.5.255 scope global br-ex
       valid_lft forever preferred_lft forever
    inet6 fe80::c046:27ff:fe8a:204d/64 scope link 
       valid_lft forever preferred_lft forever
```

## ■ OpenStackインストール後の各種設定
### (1) neutron仮想ネットワーク再構築

- デフォルドの仮想ネットワークの削除

```
[root@newton ~]# cd /root
[root@newton ~]# source /root/keystonerc_admin
[root@newton ~(keystone_admin)]# neutron router-gateway-clear router1
[root@newton ~(keystone_admin)]# neutron router-interface-delete router1 private_subnet
[root@newton ~(keystone_admin)]# openstack router delete router1
[root@newton ~(keystone_admin)]# openstack network delete private
[root@newton ~(keystone_admin)]# openstack network delete public
```
- “Public_net”ネットワークの作成

```
[root@newton ~]# cd /root
[root@newton ~]# source /root/keystonerc_admin
[root@newton ~(keystone_admin)]# openstack network create public_net --external
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2017-02-02T09:02:02Z                 |
| description               |                                      |
| headers                   |                                      |
| id                        | c920de08-7acf-44c9-8b13-b97033312267 |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| mtu                       | 1450                                 |
| name                      | public_net                           |
| project_id                | f88a985676884b468bb75550d4e86999     |
| project_id                | f88a985676884b468bb75550d4e86999     |
| provider:network_type     | vxlan                                |
| provider:physical_network | None                                 |
| provider:segmentation_id  | 62                                   |
| revision_number           | 2                                    |
| router:external           | External                             |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      | []                                   |
| updated_at                | 2017-02-02T09:02:02Z                 |
+---------------------------+--------------------------------------+
```
- “Public_subnet”サブネットワークの作成

```
[root@newton ~(keystone_admin)]# openstack subnet create public_subnet \
> --subnet-range 10.79.5.0/24 \
> --allocation-pool start=10.79.5.191,end=10.79.5.195 \
> --gateway 10.79.5.1 \
> --no-dhcp \
> --network public_net
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 10.79.5.191-10.79.5.195              |
| cidr              | 10.79.5.0/24                         |
| created_at        | 2017-02-02T09:04:39Z                 |
| description       |                                      |
| dns_nameservers   |                                      |
| enable_dhcp       | False                                |
| gateway_ip        | 10.79.5.1                            |
| headers           |                                      |
| host_routes       |                                      |
| id                | 2bb1c25e-aafb-407d-bf4d-a54e97c4cf0b |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | public_subnet                        |
| network_id        | c920de08-7acf-44c9-8b13-b97033312267 |
| project_id        | f88a985676884b468bb75550d4e86999     |
| project_id        | f88a985676884b468bb75550d4e86999     |
| revision_number   | 2                                    |
| service_types     | []                                   |
| subnetpool_id     | None                                 |
| updated_at        | 2017-02-02T09:04:39Z                 |
+-------------------+--------------------------------------+
```
- “admin_net”ネットワークの作成

```
[root@newton ~]# cd /root
[root@newton ~]# source /root/keystonerc_demo
[root@newton ~(keystone_demo)]# openstack network create admin_net
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | UP                                   |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2017-02-02T09:06:10Z                 |
| description             |                                      |
| headers                 |                                      |
| id                      | 9ea97f2d-7ead-44b1-91e1-afc7ca22e21e |
| ipv4_address_scope      | None                                 |
| ipv6_address_scope      | None                                 |
| mtu                     | 1450                                 |
| name                    | admin_net                            |
| project_id              | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| project_id              | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| revision_number         | 2                                    |
| router:external         | Internal                             |
| shared                  | False                                |
| status                  | ACTIVE                               |
| subnets                 |                                      |
| tags                    | []                                   |
| updated_at              | 2017-02-02T09:06:10Z                 |
+-------------------------+--------------------------------------+
```
- “admin_subnet”サブネットワークの作成

```
[root@newton ~(keystone_demo)]# openstack subnet create admin_subnet \
> --subnet-range 10.0.0.0/24 \
> --allocation-pool start=10.0.0.2,end=10.0.0.100 \
> --gateway 10.0.0.1 \
> --network admin_net
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 10.0.0.2-10.0.0.100                  |
| cidr              | 10.0.0.0/24                          |
| created_at        | 2017-02-02T09:07:33Z                 |
| description       |                                      |
| dns_nameservers   |                                      |
| enable_dhcp       | True                                 |
| gateway_ip        | 10.0.0.1                             |
| headers           |                                      |
| host_routes       |                                      |
| id                | 31a40092-042b-4f27-a00c-54c9324db2ac |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | admin_subnet                         |
| network_id        | 9ea97f2d-7ead-44b1-91e1-afc7ca22e21e |
| project_id        | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| project_id        | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| revision_number   | 2                                    |
| service_types     | []                                   |
| subnetpool_id     | None                                 |
| updated_at        | 2017-02-02T09:07:33Z                 |
+-------------------+--------------------------------------+
```
- “user_net”ネットワークの作成

```
[root@newton ~(keystone_demo)]# openstack network create user_net
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | UP                                   |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2017-02-02T09:09:05Z                 |
| description             |                                      |
| headers                 |                                      |
| id                      | 80feacbb-6bd5-4a3a-adff-a715b78c5d3e |
| ipv4_address_scope      | None                                 |
| ipv6_address_scope      | None                                 |
| mtu                     | 1450                                 |
| name                    | user_net                             |
| project_id              | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| project_id              | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| revision_number         | 2                                    |
| router:external         | Internal                             |
| shared                  | False                                |
| status                  | ACTIVE                               |
| subnets                 |                                      |
| tags                    | []                                   |
| updated_at              | 2017-02-02T09:09:05Z                 |
+-------------------------+--------------------------------------+
```
- “user_subnet”サブネットワークの作成

```
[root@newton ~(keystone_demo)]# openstack subnet create user_subnet \
> --subnet-range 172.16.0.0/24 \
> --allocation-pool start=172.16.0.2,end=172.16.0.100 \
> --gateway 172.16.0.1 \
> --network user_net
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 172.16.0.2-172.16.0.100              |
| cidr              | 172.16.0.0/24                        |
| created_at        | 2017-02-02T09:09:56Z                 |
| description       |                                      |
| dns_nameservers   |                                      |
| enable_dhcp       | True                                 |
| gateway_ip        | 172.16.0.1                           |
| headers           |                                      |
| host_routes       |                                      |
| id                | 9f0e59df-d6c8-4c2d-9de5-8979798e5350 |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | user_subnet                          |
| network_id        | 80feacbb-6bd5-4a3a-adff-a715b78c5d3e |
| project_id        | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| project_id        | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| revision_number   | 2                                    |
| service_types     | []                                   |
| subnetpool_id     | None                                 |
| updated_at        | 2017-02-02T09:09:56Z                 |
+-------------------+--------------------------------------+
```
- ルーターの作成

```
[root@newton ~]# cd /root
[root@newton ~]# source /root/keystonerc_demo
[root@newton ~(keystone_demo)]# openstack router create router1
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | UP                                   |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2017-02-02T09:10:50Z                 |
| description             |                                      |
| external_gateway_info   | null                                 |
| flavor_id               | None                                 |
| headers                 |                                      |
| id                      | 5ac71d5c-7c98-43d5-a59d-e219902fa867 |
| name                    | router1                              |
| project_id              | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| project_id              | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| revision_number         | 2                                    |
| routes                  |                                      |
| status                  | ACTIVE                               |
| updated_at              | 2017-02-02T09:10:50Z                 |
+-------------------------+--------------------------------------+
```
```
[root@newton ~(keystone_demo)]# neutron router-gateway-set router1 public_net
[root@newton ~(keystone_demo)]# neutron router-interface-add router1 admin_subnet
```
### (2) nova仮想マシンをKVMハイパーバイザで動作させる
- INTEL VT-xの有効化

```
[root@newton ~]# sudo modprobe kvm_intel
[root@newton ~]# lsmod|grep kvm
kvm_intel             170181  0 
kvm                   554609  1 kvm_intel
irqbypass              13503  1 kvm
```
- nova設定の変更

```
[root@newton ~]# vi /etc/nova/nova.conf
```
```text:/etc/nova/nova.conf
# Allowed values: kvm, lxc, qemu, uml, xen, parallels
virt_type=kvm
#virt_type=qemu
```
- OS再起動

```
[root@newton ~]# reboot
```
### (3) Ubuntuイメージ登録
- Ubuntu 16.04イメージファイルのダウンロード

```
[root@newton ~]# sudo yum install -y wget
[root@newton ~]# wget http://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
```
- Glaneへのイメージ追加

```
[root@newton ~]# cd /root
[root@newton ~]# source keystonerc_admin
[root@newton ~(keystone_admin)]# glance image-create --name "Ubuntu1604" --file /var/kvm/images/ubuntu-16.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --visibility public
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 186969f89823de2586e36b87e0f69875     |
| container_format | bare                                 |
| created_at       | 2017-02-02T05:54:34Z                 |
| disk_format      | qcow2                                |
| id               | 343a2c82-2959-4221-b567-bfc113020488 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1604                           |
| owner            | f88a985676884b468bb75550d4e86999     |
| protected        | False                                |
| size             | 322502656                            |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2017-02-02T05:54:37Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+
```
- 登録済みGlanceイメージの確認

```
[root@newton ~(keystone_admin)]# glance image-list
+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| f91e45cb-114e-4322-8883-109f7392c912 | cirros     |
| 343a2c82-2959-4221-b567-bfc113020488 | Ubuntu1604 |
+--------------------------------------+------------+
```
### (4) nova諸設定の追加
- keypair追加

```
[root@newton ~]# cd /root
[root@newton ~]# source keystonerc_demo
[root@newton ~(keystone_demo)]# openstack keypair create mykey
-----BEGIN RSA PRIVATE KEY-----

... (snip)

-----END RSA PRIVATE KEY-----
```
```
[root@newton ~(keystone_demo)]# nova keypair-list 
+-------+------+-------------------------------------------------+
| Name  | Type | Fingerprint                                     |
+-------+------+-------------------------------------------------+
| mykey | ssh  | 04:8c:27:d1:44:b3:e1:19:1a:d6:d8:13:70:d3:f9:70 |
+-------+------+-------------------------------------------------+
```
- ローカルPC環境に、プライベートキー情報を保存
- セキュリティグループ設定追加（ICMP送信/受信, TCPの全ポート送信/受信を開放）

```
[root@newton ~(keystone_demo)]# neutron security-group-rule-create --protocol icmp default
Created a new security_group_rule:
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-02-02T10:24:03Z                 |
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | 7abf3219-5de4-4747-a8e8-e233c913ce13 |
| port_range_max    |                                      |
| port_range_min    |                                      |
| project_id        | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| protocol          | icmp                                 |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| revision_number   | 1                                    |
| security_group_id | bff315ad-0f08-45f8-8b14-5d19a9f95aa6 |
| tenant_id         | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| updated_at        | 2017-02-02T10:24:03Z                 |
+-------------------+--------------------------------------+
```
```
[root@newton ~(keystone_demo)]# neutron security-group-rule-create --protocol tcp --port-range-min 1 --port-range-max 65535 default
Created a new security_group_rule:
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-02-02T10:24:37Z                 |
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | d8a982f6-99cc-4f73-ac35-814842937760 |
| port_range_max    | 65535                                |
| port_range_min    | 1                                    |
| project_id        | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| protocol          | tcp                                  |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| revision_number   | 1                                    |
| security_group_id | bff315ad-0f08-45f8-8b14-5d19a9f95aa6 |
| tenant_id         | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| updated_at        | 2017-02-02T10:24:37Z                 |
+-------------------+--------------------------------------+
```
- 登録済みセキュリティポリシの確認

```
[root@newton ~(keystone_demo)]# neutron security-group-list
+--------------------------------------+---------+----------------------------------------------------------------------+
| id                                   | name    | security_group_rules                                                 |
+--------------------------------------+---------+----------------------------------------------------------------------+
| bff315ad-0f08-45f8-8b14-5d19a9f95aa6 | default | egress, IPv4                                                         |
|                                      |         | egress, IPv6                                                         |
|                                      |         | ingress, IPv4, 1-65535/tcp                                           |
|                                      |         | ingress, IPv4, icmp                                                  |
|                                      |         | ingress, IPv4, remote_group_id: bff315ad-0f08-45f8-8b14-5d19a9f95aa6 |
|                                      |         | ingress, IPv6, remote_group_id: bff315ad-0f08-45f8-8b14-5d19a9f95aa6 |
+--------------------------------------+---------+----------------------------------------------------------------------+
```
- 登録済みフレーバーの確認

```
[root@newton ~(keystone_demo)]# nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
```
## ■ 試しに、nova仮想マシンを作成してみる
### (1) テナントネットワーク/nova仮想マシンの整備
- adminネットワーク用ポート作成

```
[root@newton ~(keystone_demo)]# neutron port-create admin_net
Created a new port:
+-----------------------+---------------------------------------------------------------------------------+
| Field                 | Value                                                                           |
+-----------------------+---------------------------------------------------------------------------------+
| admin_state_up        | True                                                                            |
| allowed_address_pairs |                                                                                 |
| binding:vnic_type     | normal                                                                          |
| created_at            | 2017-02-02T10:28:07Z                                                            |
| description           |                                                                                 |
| device_id             |                                                                                 |
| device_owner          |                                                                                 |
| extra_dhcp_opts       |                                                                                 |
| fixed_ips             | {"subnet_id": "31a40092-042b-4f27-a00c-54c9324db2ac", "ip_address": "10.0.0.4"} |
| id                    | 3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c                                            |
| mac_address           | fa:16:3e:49:48:8e                                                               |
| name                  |                                                                                 |
| network_id            | 9ea97f2d-7ead-44b1-91e1-afc7ca22e21e                                            |
| project_id            | 67d85efd952f4b6a8c03c6f86fecb8ea                                                |
| revision_number       | 4                                                                               |
| security_groups       | bff315ad-0f08-45f8-8b14-5d19a9f95aa6                                            |
| status                | DOWN                                                                            |
| tenant_id             | 67d85efd952f4b6a8c03c6f86fecb8ea                                                |
| updated_at            | 2017-02-02T10:28:07Z                                                            |
+-----------------------+---------------------------------------------------------------------------------+
```
- nova仮想マシンの作成（管理ポート：UUID: 3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c）

```
[root@newton ~(keystone_demo)]# nova boot --flavor 2 --image Ubuntu1604 --key-name mykey --security-groups default --nic port-id=3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c server1
+--------------------------------------+---------------------------------------------------+
| Property                             | Value                                             |
+--------------------------------------+---------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                            |
| OS-EXT-AZ:availability_zone          |                                                   |
| OS-EXT-STS:power_state               | 0                                                 |
| OS-EXT-STS:task_state                | scheduling                                        |
| OS-EXT-STS:vm_state                  | building                                          |
| OS-SRV-USG:launched_at               | -                                                 |
| OS-SRV-USG:terminated_at             | -                                                 |
| accessIPv4                           |                                                   |
| accessIPv6                           |                                                   |
| adminPass                            | u4qBLa6NB7nr                                      |
| config_drive                         |                                                   |
| created                              | 2017-02-02T10:32:02Z                              |
| description                          | -                                                 |
| flavor                               | m1.small (2)                                      |
| hostId                               |                                                   |
| id                                   | ab70f784-385d-44a8-b010-1322e7be94a7              |
| image                                | Ubuntu1604 (343a2c82-2959-4221-b567-bfc113020488) |
| key_name                             | mykey                                             |
| locked                               | False                                             |
| metadata                             | {}                                                |
| name                                 | server1                                           |
| os-extended-volumes:volumes_attached | []                                                |
| progress                             | 0                                                 |
| security_groups                      | default                                           |
| status                               | BUILD                                             |
| tags                                 | []                                                |
| tenant_id                            | 67d85efd952f4b6a8c03c6f86fecb8ea                  |
| updated                              | 2017-02-02T10:32:03Z                              |
| user_id                              | 538dcaaea36c4757bfd10fb862d50709                  |
+--------------------------------------+---------------------------------------------------+
```
- nova仮想マシンの接続インタフェース確認

```
[root@newton ~(keystone_demo)]# nova interface-list server1
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
| Port State | Port ID                              | Net ID                               | IP addresses | MAC Addr          |
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
| ACTIVE     | 3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c | 9ea97f2d-7ead-44b1-91e1-afc7ca22e21e | 10.0.0.4     | fa:16:3e:49:48:8e |
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
```
### (2) 外部ネットワークとのアクセス環境の整備
- Floatingipの作成

```
[root@newton ~(keystone_demo)]# neutron floatingip-create public_net
Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-02-02T10:32:59Z                 |
| description         |                                      |
| fixed_ip_address    |                                      |
| floating_ip_address | 10.79.5.191                          |
| floating_network_id | c920de08-7acf-44c9-8b13-b97033312267 |
| id                  | affd1370-760d-4148-9d48-5afb9f97eaf5 |
| port_id             |                                      |
| project_id          | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| revision_number     | 1                                    |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| updated_at          | 2017-02-02T10:32:59Z                 |
+---------------------+--------------------------------------+
```
- 登録済みFloatingipの確認

```
[root@newton ~(keystone_demo)]# neutron floatingip-list
+--------------------------------------+------------------+---------------------+---------+
| id                                   | fixed_ip_address | floating_ip_address | port_id |
+--------------------------------------+------------------+---------------------+---------+
| affd1370-760d-4148-9d48-5afb9f97eaf5 |                  | 10.79.5.191         |         |
+--------------------------------------+------------------+---------------------+---------+
```
- FloatingipとPortとの対応付け

```
[root@newton ~(keystone_demo)]# neutron floatingip-associate affd1370-760d-4148-9d48-5afb9f97eaf5 3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c
```
```
[root@newton ~(keystone_demo)]# neutron floatingip-list
+--------------------------------------+------------------+---------------------+--------------------------------------+
| id                                   | fixed_ip_address | floating_ip_address | port_id                              |
+--------------------------------------+------------------+---------------------+--------------------------------------+
| affd1370-760d-4148-9d48-5afb9f97eaf5 | 10.0.0.4         | 10.79.5.191         | 3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c |
+--------------------------------------+------------------+---------------------+--------------------------------------+
```

### (3) 外部ネットワークからのアクセス確認
- nova仮想マシン宛へのPingアクセス

```
$ ping 10.79.5.191
PING 10.79.5.191 (10.79.5.191): 56 data bytes
64 bytes from 10.79.5.191: icmp_seq=0 ttl=60 time=6.981 ms
64 bytes from 10.79.5.191: icmp_seq=1 ttl=60 time=3.223 ms
64 bytes from 10.79.5.191: icmp_seq=2 ttl=60 time=3.115 ms
64 bytes from 10.79.5.191: icmp_seq=3 ttl=60 time=10.910 ms
64 bytes from 10.79.5.191: icmp_seq=4 ttl=60 time=6.581 ms
^C
--- 10.79.5.191 ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 3.115/6.162/10.910/2.874 ms
```
- nova仮想マシンへのsshログイン

```
$ ssh -i mykey.pem ubuntu@10.79.5.191
The authenticity of host '10.79.5.191 (10.79.5.191)' can't be established.
ECDSA key fingerprint is SHA256:PTCeFS89cTqGAPGxGkDHuadrWsfjeMo0sU5zmEhXrmY.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.79.5.191' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-59-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


Last login: Thu Feb  2 10:34:53 2017 from 10.79.5.117
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@server1:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc pfifo_fast state UP group default qlen 1000
    link/ether fa:16:3e:49:48:8e brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.4/24 brd 10.0.0.255 scope global ens3
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe49:488e/64 scope link 
       valid_lft forever preferred_lft forever
```

## ■ さらに、２台目のnova仮想マシンを作成する
### (1) テナントネットワーク/nova仮想マシンの整備
- adminネットワーク用ポート作成

```
[root@newton ~(keystone_demo)]# neutron port-create admin_net
Created a new port:
+-----------------------+----------------------------------------------------------------------------------+
| Field                 | Value                                                                            |
+-----------------------+----------------------------------------------------------------------------------+
| admin_state_up        | True                                                                             |
| allowed_address_pairs |                                                                                  |
| binding:vnic_type     | normal                                                                           |
| created_at            | 2017-02-02T10:40:11Z                                                             |
| description           |                                                                                  |
| device_id             |                                                                                  |
| device_owner          |                                                                                  |
| extra_dhcp_opts       |                                                                                  |
| fixed_ips             | {"subnet_id": "31a40092-042b-4f27-a00c-54c9324db2ac", "ip_address": "10.0.0.11"} |
| id                    | 75f7e4ac-600b-4a45-9948-d45b3ec7169b                                             |
| mac_address           | fa:16:3e:7c:92:60                                                                |
| name                  |                                                                                  |
| network_id            | 9ea97f2d-7ead-44b1-91e1-afc7ca22e21e                                             |
| project_id            | 67d85efd952f4b6a8c03c6f86fecb8ea                                                 |
| revision_number       | 4                                                                                |
| security_groups       | bff315ad-0f08-45f8-8b14-5d19a9f95aa6                                             |
| status                | DOWN                                                                             |
| tenant_id             | 67d85efd952f4b6a8c03c6f86fecb8ea                                                 |
| updated_at            | 2017-02-02T10:40:11Z                                                             |
+-----------------------+----------------------------------------------------------------------------------+
```
- nova仮想マシンの作成（管理ポート：UUID: 75f7e4ac-600b-4a45-9948-d45b3ec7169b）

```
[root@newton ~(keystone_demo)]# nova boot --flavor 1 --image cirros --key-name mykey --security-groups default --nic port-id=75f7e4ac-600b-4a45-9948-d45b3ec7169b server2
+--------------------------------------+-----------------------------------------------+
| Property                             | Value                                         |
+--------------------------------------+-----------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                        |
| OS-EXT-AZ:availability_zone          |                                               |
| OS-EXT-STS:power_state               | 0                                             |
| OS-EXT-STS:task_state                | scheduling                                    |
| OS-EXT-STS:vm_state                  | building                                      |
| OS-SRV-USG:launched_at               | -                                             |
| OS-SRV-USG:terminated_at             | -                                             |
| accessIPv4                           |                                               |
| accessIPv6                           |                                               |
| adminPass                            | Qcu3AEVN3m4P                                  |
| config_drive                         |                                               |
| created                              | 2017-02-02T10:41:35Z                          |
| description                          | -                                             |
| flavor                               | m1.tiny (1)                                   |
| hostId                               |                                               |
| id                                   | 06521269-bddb-4def-8369-3f92fd2f4622          |
| image                                | cirros (f91e45cb-114e-4322-8883-109f7392c912) |
| key_name                             | mykey                                         |
| locked                               | False                                         |
| metadata                             | {}                                            |
| name                                 | server2                                       |
| os-extended-volumes:volumes_attached | []                                            |
| progress                             | 0                                             |
| security_groups                      | default                                       |
| status                               | BUILD                                         |
| tags                                 | []                                            |
| tenant_id                            | 67d85efd952f4b6a8c03c6f86fecb8ea              |
| updated                              | 2017-02-02T10:41:35Z                          |
| user_id                              | 538dcaaea36c4757bfd10fb862d50709              |
+--------------------------------------+-----------------------------------------------+
```
- nova仮想マシンの接続インタフェース確認

```
[root@newton ~(keystone_demo)]# nova interface-list server2
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
| Port State | Port ID                              | Net ID                               | IP addresses | MAC Addr          |
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
| ACTIVE     | 75f7e4ac-600b-4a45-9948-d45b3ec7169b | 9ea97f2d-7ead-44b1-91e1-afc7ca22e21e | 10.0.0.11    | fa:16:3e:7c:92:60 |
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
```
### (2) 外部ネットワークとのアクセス環境の整備
- Floatingipの作成

```
[root@newton ~(keystone_demo)]# neutron floatingip-create public_net
Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-02-02T10:44:47Z                 |
| description         |                                      |
| fixed_ip_address    |                                      |
| floating_ip_address | 10.79.5.195                          |
| floating_network_id | c920de08-7acf-44c9-8b13-b97033312267 |
| id                  | cb83e8bc-47c2-438a-8c74-2f1654ddc09c |
| port_id             |                                      |
| project_id          | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| revision_number     | 1                                    |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 67d85efd952f4b6a8c03c6f86fecb8ea     |
| updated_at          | 2017-02-02T10:44:47Z                 |
+---------------------+--------------------------------------+
```
- FloatingipとPortとの対応付け

```
[root@newton ~(keystone_demo)]# neutron floatingip-associate cb83e8bc-47c2-438a-8c74-2f1654ddc09c 75f7e4ac-600b-4a45-9948-d45b3ec7169b
```
```
[root@newton ~(keystone_demo)]# neutron floatingip-list
+--------------------------------------+------------------+---------------------+--------------------------------------+
| id                                   | fixed_ip_address | floating_ip_address | port_id                              |
+--------------------------------------+------------------+---------------------+--------------------------------------+
| affd1370-760d-4148-9d48-5afb9f97eaf5 | 10.0.0.4         | 10.79.5.191         | 3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c |
| cb83e8bc-47c2-438a-8c74-2f1654ddc09c | 10.0.0.11        | 10.79.5.195         | 75f7e4ac-600b-4a45-9948-d45b3ec7169b |
+--------------------------------------+------------------+---------------------+--------------------------------------+
```

### (3) 外部ネットワークからのアクセス確認
- nova仮想マシン宛へのPingアクセス

```
$ ping 10.79.5.195
PING 10.79.5.195 (10.79.5.195): 56 data bytes
64 bytes from 10.79.5.195: icmp_seq=0 ttl=60 time=213.721 ms
64 bytes from 10.79.5.195: icmp_seq=1 ttl=60 time=8.048 ms
64 bytes from 10.79.5.195: icmp_seq=2 ttl=60 time=2.879 ms
64 bytes from 10.79.5.195: icmp_seq=3 ttl=60 time=5.780 ms
64 bytes from 10.79.5.195: icmp_seq=4 ttl=60 time=8.354 ms
^C
--- 10.79.5.195 ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 2.879/47.756/213.721/83.005 ms
```
- nova仮想マシンへのsshログイン

```
$ ssh -i mykey.pem cirros@10.79.5.195
The authenticity of host '10.79.5.195 (10.79.5.195)' can't be established.
RSA key fingerprint is SHA256:VHpD4TfqBg2vMYnU6I2NRj4NXlN4SKhpQjTm50rW9Tc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.79.5.195' (RSA) to the list of known hosts.
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc pfifo_fast qlen 1000
    link/ether fa:16:3e:7c:92:60 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.11/24 brd 10.0.0.255 scope global eth0
    inet6 fe80::f816:3eff:fe7c:9260/64 scope link 
       valid_lft forever preferred_lft forever
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc pfifo_fast qlen 1000
    link/ether fa:16:3e:7c:92:60 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.11/24 brd 10.0.0.255 scope global eth0
    inet6 fe80::f816:3eff:fe7c:9260/64 scope link 
       valid_lft forever preferred_lft forever
```

## ■ 最終的に作成したneutron仮想ネットワーク構成
- nova仮想マシン一覧の確認

```
[root@newton ~(keystone_demo)]# nova list
+--------------------------------------+---------+--------+------------+-------------+----------------------------------+
| ID                                   | Name    | Status | Task State | Power State | Networks                         |
+--------------------------------------+---------+--------+------------+-------------+----------------------------------+
| ab70f784-385d-44a8-b010-1322e7be94a7 | server1 | ACTIVE | -          | Running     | admin_net=10.0.0.4, 10.79.5.191  |
| 06521269-bddb-4def-8369-3f92fd2f4622 | server2 | ACTIVE | -          | Running     | admin_net=10.0.0.11, 10.79.5.195 |
+--------------------------------------+---------+--------+------------+-------------+----------------------------------+
```
- neutronフローティングIP一覧の確認

```
[root@newton ~(keystone_demo)]# neutron floatingip-list
+--------------------------------------+------------------+---------------------+--------------------------------------+
| id                                   | fixed_ip_address | floating_ip_address | port_id                              |
+--------------------------------------+------------------+---------------------+--------------------------------------+
| affd1370-760d-4148-9d48-5afb9f97eaf5 | 10.0.0.4         | 10.79.5.191         | 3155cbf3-ddcb-4acd-b5a1-dc37f4a49a4c |
| cb83e8bc-47c2-438a-8c74-2f1654ddc09c | 10.0.0.11        | 10.79.5.195         | 75f7e4ac-600b-4a45-9948-d45b3ec7169b |
+--------------------------------------+------------------+---------------------+--------------------------------------+
```
![topology.png](https://qiita-image-store.s3.amazonaws.com/0/103595/de455a5d-58ff-73e9-6e88-96e916901232.png)


Newton版OpenStackが構築できたので、思う存分に、OpenStack技術を習熟したいと思います。