Wednesday, August 17, 2016

Study OpenStack Octavia in Mitaka by using DevStack (1)

octavia

Octavia

You must prepare ram greater equal than 32GB. That's in my minimum ram testing.
In my previous testing, I only have 4GB ram, it always failed and cannot launch Amphora.
So don't make the mistake.

Installation

You can see my previous Blog to show how to install DevStack Mitaka.

http://gogosatellite.blogspot.tw/2016/04/using-devstack-to-install-openstack.html

Here is the local.conf.

[[local|localrc]]

# Load the external LBaaS plugin.
enable_plugin neutron-lbaas https://git.openstack.org/openstack/neutron-lbaas stable/mitaka
enable_plugin octavia https://git.openstack.org/openstack/octavia stable/mitaka
enable_plugin neutron-lbaas-dashboard https://git.openstack.org/openstack/neutron-lbaas-dashboard stable/mitaka

DEST=/opt/stack

HOST_IP=192.168.2.131

ADMIN_PASSWORD=password
MYSQL_PASSWORD=password
RABBIT_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=tokentoken


ENABLED_SERVICES=key,rabbit,mysql,horizon
ENABLED_SERVICES+=,n-api,n-crt,n-cpu,n-net,n-cond,n-sch,n-novnc,n-cauth
ENABLED_SERVICES+=,g-api,g-reg

# Enabling Neutron (network) Service
disable_service n-net
enable_service q-svc
enable_service q-agt
enable_service q-dhcp
enable_service q-l3
enable_service q-meta
enable_service q-metering
enable_service neutron

Q_PLUGIN=ml2
#Q_USE_DEBUG_COMMAND=True
if [ "$Q_PLUGIN" = "ml2" ]; then
  #Q_ML2_TENANT_NETWORK_TYPE=gre
  Q_ML2_TENANT_NETWORK_TYPE=vxlan
  :
fi
## Neutron options
FIXED_RANGE=10.0.0.0/24
FIXED_NETWORK_SIZE=256
NETWORK_GATEWAY=10.0.0.1
PRIVATE_SUBNET_NAME=privateA

PUBLIC_SUBNET_NAME=public-subnet
FLOATING_RANGE=192.168.2.0/24
PUBLIC_NETWORK_GATEWAY=192.168.2.2
##Q_FLOATING_ALLOCATION_POOL=start=192.168.27.102,end=192.168.27.110
PUBLIC_INTERFACE=eth0
Q_USE_PROVIDERNET_FOR_PUBLIC=True
OVS_PHYSICAL_BRIDGE=br-ex
PUBLIC_BRIDGE=br-ex
OVS_BRIDGE_MAPPINGS=public:br-ex

LIBVIRT_TYPE=qemu

# Enable LBaaS v2
ENABLED_SERVICES+=,q-lbaasv2
ENABLED_SERVICES+=,octavia,o-cw,o-hk,o-hm,o-api


IMAGE_URLS="http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-uec.tar.gz"

SCREEN_LOGDIR=/opt/stack/screen-logs
SYSLOG=True
LOGFILE=~/devstack/stack.sh.log


Q_USE_DEBUG_COMMAND=True

# RECLONE=No
RECLONE=yes
OFFLINE=False

[[post-config|$NOVA_CONF]]
[DEFAULT]
cpu_allocation_ratio=32.0
ram_allocation_ratio=32.0
disk_allocation_ratio=32.0

Now you can start to install devstack.

./stack.sh

Create Backend Server

Be patient, We lauch Backend Server first.

You can see my previous Blog to download and hack a Ubuntu VM.

http://gogosatellite.blogspot.tw/2016/08/html-charsetutf-8-cloud-vm-to-use-user.html

After launch a Ubuntu VM and run a SimpleHTTPServer.

python -m SimpleHTTPServer 80

where we enable port 80.

Create Octavia Service

Horizon

You can easily use Horizon to launch Octavia service. It's quite simple. Mention that you must add the Backend VM as member VM and adding floating IP to Amphora.

After Create Octavia Service.

After that, wait for 5min+ util you see the log from o-cw.log.

tail -f o-cw.log -n 100
.

2016-08-17 04:00:02.604 20588 WARNING octavia.amphorae.drivers.haproxy.rest_api_driver [-] Could not connect to instance. Retrying.
2016-08-17 04:00:03.607 20588 WARNING octavia.amphorae.drivers.haproxy.rest_api_driver [-] Could not connect to instance. Retrying.
2016-08-17 04:00:04.609 20588 WARNING octavia.amphorae.drivers.haproxy.rest_api_driver [-] Could not connect to instance. Retrying.
2016-08-17 04:00:05.612 20588 WARNING octavia.amphorae.drivers.haproxy.rest_api_driver [-] Could not connect to instance. Retrying.
2016-08-17 04:00:06.614 20588 WARNING octavia.amphorae.drivers.haproxy.rest_api_driver [-] Could not connect to instance. Retrying.
2016-08-17 04:00:07.616 20588 WARNING octavia.amphorae.drivers.haproxy.rest_api_driver [-] Could not connect to instance. Retrying.
.
.
2016-08-17 04:01:12.083 20588 INFO octavia.controller.worker.tasks.database_tasks [-] Mark ACTIVE in DB for load balancer id: 93a920f0-a934-4ef9-bcb7-32c9ed022966
2016-08-17 04:01:16.512 20588 INFO octavia.controller.queue.endpoint [-] Creating listener '906bd763-d1eb-4d7f-967b-669cbdde9bab'...
2016-08-17 04:01:25.631 20588 INFO octavia.controller.queue.endpoint [-] Creating pool '51ae89ca-5f0a-4344-b217-a0527cb11992'...

After you see the poll created, you can see the provisioning_status=ACTIVE or it is PENDING_CREATED. Or you can wait for provisioning_status becoming ACTIVE.

stack@devoct:~/devstack$ neutron lbaas-loadbalancer-list
+--------------------------------------+-----------------+-------------+---------------------+----------+
| id                                   | name            | vip_address | provisioning_status | provider |
+--------------------------------------+-----------------+-------------+---------------------+----------+
| 0cc3a0dd-3849-4a95-9f9c-126bb8dc1437 | Load Balancer 1 | 10.0.0.10   | ACTIVE              | octavia  |
| 93a920f0-a934-4ef9-bcb7-32c9ed022966 | Load Balancer 2 | 10.0.0.17   | ACTIVE              | octavia  |
+--------------------------------------+-----------------+-------------+---------------------+----------+

Where Load Balancer 2 is our target.

Remodify Security Group of the Amphora and VM

It's quite important that if you can not connect to the backend server, it probly is due to security group. So we allow all traffic connected in the network to avoid problem. Mention that, when you create Octavia Service by user Demo, the Amphora VM is launched by admin (not Demo). You will not see the Amphora VM information in user Demo, but you can see the Octavia Service in User Demo. If you are using Horizon, switch to admin user and check the instance you will see the Amphora VM running on user admin not demo.

So if you want to allow all traffic in the network, you must remodify security group for both user demo and admin.

Security Group in User Demo

To allow all traffic, you can use Horizon to enable icmp, tcp, udp, dns, http, ssh for ingress and egress.

stack@devoct:~/devstack$ nova secgroup-list-rules default
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 80        | 80      | 0.0.0.0/0 |              |
| tcp         | 1         | 65535   | 0.0.0.0/0 |              |
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
| udp         | 1         | 65535   | 0.0.0.0/0 |              |
| tcp         | 53        | 53      | 0.0.0.0/0 |              |
| tcp         | 443       | 443     | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

Security Group in User Admin

stack@devoct:~/devstack$ nova secgroup-list
+--------------------------------------+-----------------------------------------+------------------------+
| Id                                   | Name                                    | Description            |
+--------------------------------------+-----------------------------------------+------------------------+
| 001944c9-721a-44fa-b400-0a07f598221c | default                                 | Default security group |
| 95697e4b-cd96-49e3-a865-093ee7835390 | lb-0cc3a0dd-3849-4a95-9f9c-126bb8dc1437 |                        |
| 67c13a32-a5f4-4cec-bc7a-10758b503671 | lb-93a920f0-a934-4ef9-bcb7-32c9ed022966 |                        |
| 2fb55456-98e4-411d-9442-a3b72a30bf4a | lb-mgmt-sec-grp                         |                        |
+--------------------------------------+-----------------------------------------+------------------------+

where lb-93a920f0-a934-4ef9-bcb7-32c9ed022966 is our lb service. To modify the security group as followed by using Horizon. Here we enable all tcp, icmp, http for both ingress and egress.

stack@devoct:~/devstack$ nova secgroup-list-rules lb-93a920f0-a934-4ef9-bcb7-32c9ed022966
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 1         | 65535   | 0.0.0.0/0 |              |
| tcp         | 80        | 80      | 0.0.0.0/0 |              |
| udp         | 1         | 65535   | 0.0.0.0/0 |              |
| tcp         | 1025      | 1025    | 0.0.0.0/0 |              |
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

Result

From Client and to Access Floating IP of the Amphora.
where we add 192.168.140.8 to Amphora as a floating IP.

junmeinde-MacBook-Pro:~ junmein$ curl 192.168.140.8
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>
<title>Directory listing for /</title>
<body>
<h2>Directory listing for /</h2>
<hr>
<ul>
<li><a href=".bash_history">.bash_history</a>
<li><a href=".bash_logout">.bash_logout</a>
<li><a href=".bashrc">.bashrc</a>
<li><a href=".cache/">.cache/</a>
<li><a href=".profile">.profile</a>
<li><a href=".ssh/">.ssh/</a>
<li><a href=".sudo_as_admin_successful">.sudo_as_admin_successful</a>
<li><a href=".viminfo">.viminfo</a>
</ul>
<hr>
</body>
</html>

In the Backend VM

ubuntu@testu:~$ sudo python -m SimpleHTTPServer 80

10.0.0.18 - - [17/Aug/2016 08:09:30] "GET / HTTP/1.1" 200 -
10.0.0.18 - - [17/Aug/2016 08:09:53] "GET / HTTP/1.1" 200 -

You will see the traffic flow from client to Amphora and to Backend Server.

What is 10.0.0.18 from the above result

stack@devoct:~/devstack$ nova list
+--------------------------------------+----------------------------------------------+--------+------------+-------------+----------------------------------------------------------------------------------+
| ID                                   | Name                                         | Status | Task State | Power State | Networks                                                                         |
+--------------------------------------+----------------------------------------------+--------+------------+-------------+----------------------------------------------------------------------------------+
| 66cac671-ad9e-4815-9f00-9d0889b8bdca | amphora-54fd4f13-6b56-49e5-af76-88aabc01df68 | ACTIVE | -          | Running     | lb-mgmt-net=192.168.0.6; private=fd4a:3193:7fb5:0:f816:3eff:fe22:9bde, 10.0.0.18 |
| 48a7ad73-57d9-4e75-80ca-5753a9f047ed | amphora-73a06a20-42d7-4e1c-8320-613984f35428 | ACTIVE | -          | Running     | lb-mgmt-net=192.168.0.5; private=fd4a:3193:7fb5:0:f816:3eff:fe11:b756, 10.0.0.11 |

You can use admin to see the detailed of Amphora instance and you will find the 10.0.0.18 is the IP of the Amphora.

And you can ping this IP, 10.0.0.18, from backend server for trouble shooting to make sure the security group with right setting.

ubuntu@testu:~$ ping 10.0.0.18
PING 10.0.0.18 (10.0.0.18) 56(84) bytes of data.
64 bytes from 10.0.0.18: icmp_req=1 ttl=64 time=2.25 ms
64 bytes from 10.0.0.18: icmp_req=2 ttl=64 time=1.13 ms
^C

Debug

  • No neutron-lbaasv2-agent Daemon in Mitaka version /usr/bin/python /usr/local/bin/neutron-lbaasv2-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/services/loadbalancer/haproxy/lbaas_agent.ini

  • Memory too Small

Please make sure you have large memory, since I waste a lot of time to debug it, since the Amphora cannot be launched. The following is the error message:

Cannot set up guest memory 'pc.ram': Cannot allocate memory

After enlarge memory to 32GB and Disk to 50GB, everything seems better.

Reference

How to use command line to launch a VM.

http://gogosatellite.blogspot.tw/search?q=minimum

Hacking Ubuntu Cloud Image to Have Your Own User and Password

Hacking Cloud VM to use User name password to Login

Hacking Cloud VM to use User password to Login

Most of cloud image use key-pair to login. It's really hard for a beginner.
There is a way to hack the cloud image to login with usual user and password without keypairs.
This is a greate tool for me.

Hacking the Cloud VM

Download backdoor-image

$bzr branch lp:~smoser/+junk/backdoor-image

You might need to install bzr through apt-get install bzr.

Into backdoor-image folder

$cd backdoor-image

Download a Ubuntu cloud image

$ wget http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img

cp image to a backup image

$cp precise-server-cloudimg-amd64-disk1.img ubuntu12.04-server-cloudimg-amg64-disk1.img

Set the user and password to the cloud image

$./backdoor-image --user ubuntu --password ubuntu --password-auth ubuntu12.04-server-cloudimg-amg64-disk1.img

Perfectly

Thursday, August 4, 2016

努力升级

最近好多周邊配備升級了,包含我的MAC電腦也升級SSD。
自己也該隨著升級,心態,能力,都該升級了。
更努力,更專注,更投入,才行。

Friday, July 15, 2016

OpenStack(kilo): Dynamically Adding Nic Card to VM

nicadding

OpenStack(kilo): Adding Nic Card to VM

Dynamically adding a Nic to VM without reboot.

Initially, In the VM, we have eth0 only.

$ip link list
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
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether fa:16:3e:2e:50:12 brd ff:ff:ff:ff:ff:ff

Attach Nic Card to VM

Command Line

If you are using DevStack, you can use the command source openrc admin demo. So that you can use OpenStack command line.

To add Nic Card to VM, we can use the following commands.

neutron port-create private
neutron port-list
nova interface-attach --port-id <portid> <instanceName>
nova interface-detach <instanceName> <portid>

You then can login to VM, and check nic card with ip link list command.

It's very simple, really. And now we can discuss it more detailed.

Detailed Command with debug mode

The most important thing is to study how to call rest-api. You can use DEBUG mode.

stack@kiloceilo:~/devstack$ neutron port-create private --debug
DEBUG: keystoneclient.session REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:5000/v2.0 -H "Accept: application/json" -H "User-Agent: python-keystoneclient"
DEBUG: urllib3.util.retry Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG: keystoneclient.session RESP: [200] content-length: 340 vary: X-Auth-Token server: Apache/2.4.7 (Ubuntu) date: Fri, 15 Jul 2016 08:13:28 GMT content-type: application/json x-openstack-request-id: req-86f058df-70a5-4b45-90f2-0d4ce227548f
RESP BODY: {"version": {"status": "stable", "updated": "2014-04-17T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}], "id": "v2.0", "links": [{"href": "http://172.16.235.128:5000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/", "type": "text/html", "rel": "describedby"}]}}

DEBUG: stevedore.extension found extension EntryPoint.parse('table = cliff.formatters.table:TableFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('shell = cliff.formatters.shell:ShellFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('value = cliff.formatters.value:ValueFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('yaml = clifftablib.formatters:YamlFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('json = clifftablib.formatters:JsonFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('html = clifftablib.formatters:HtmlFormatter')
DEBUG: neutronclient.neutron.v2_0.port.CreatePort get_data(Namespace(admin_state=True, columns=[], device_id=None, device_owner=None, extra_dhcp_opts=[], fixed_ip=None, formatter='table', mac_address=None, max_width=0, name=None, network_id=u'private', no_security_groups=False, prefix='', request_format='json', security_groups=[], tenant_id=None, variables=[], vnic_type=None))
DEBUG: keystoneclient.auth.identity.v2 Making authentication request to http://172.16.235.128:5000/v2.0/tokens
DEBUG: urllib3.util.retry Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG: keystoneclient.session REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:9696/v2.0/networks.json?fields=id&name=private -H "User-Agent: python-neutronclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}7c01e319a42caeda349739980976abf13be0c5f0"
DEBUG: urllib3.util.retry Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG: keystoneclient.session RESP: [200] date: Fri, 15 Jul 2016 08:13:28 GMT content-length: 62 content-type: application/json x-openstack-request-id: req-5a6e63a4-ae1b-45d4-8b89-395136efb81e
RESP BODY: {"networks": [{"id": "2b696172-5599-4663-85bd-42de265e56df"}]}

DEBUG: keystoneclient.session REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X POST http://172.16.235.128:9696/v2.0/ports.json -H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}7c01e319a42caeda349739980976abf13be0c5f0" -d '{"port": {"network_id": "2b696172-5599-4663-85bd-42de265e56df", "admin_state_up": true}}'
DEBUG: urllib3.util.retry Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG: keystoneclient.session RESP: [201] date: Fri, 15 Jul 2016 08:13:28 GMT content-length: 609 content-type: application/json x-openstack-request-id: req-2f23d4dc-a2d1-402a-9580-4b7cfa89c100
RESP BODY: {"port": {"status": "DOWN", "binding:host_id": "", "allowed_address_pairs": [], "device_owner": "", "binding:profile": {}, "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.149"}], "id": "1db9fa8e-d376-4034-87ea-7c6620daefcd", "security_groups": ["ef5a81ce-2404-4b8f-8fe2-39af5823f8c9"], "device_id": "", "name": "", "admin_state_up": true, "network_id": "2b696172-5599-4663-85bd-42de265e56df", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:b2:68:b1"}}

Created a new port:
+-----------------------+-----------------------------------------------------------------------------------+
| Field                 | Value                                                                             |
+-----------------------+-----------------------------------------------------------------------------------+
| admin_state_up        | True                                                                              |
| allowed_address_pairs |                                                                                   |
| binding:host_id       |                                                                                   |
| binding:profile       | {}                                                                                |
| binding:vif_details   | {}                                                                                |
| binding:vif_type      | unbound                                                                           |
| binding:vnic_type     | normal                                                                            |
| device_id             |                                                                                   |
| device_owner          |                                                                                   |
| fixed_ips             | {"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.149"} |
| id                    | 1db9fa8e-d376-4034-87ea-7c6620daefcd                                              |
| mac_address           | fa:16:3e:b2:68:b1                                                                 |
| name                  |                                                                                   |
| network_id            | 2b696172-5599-4663-85bd-42de265e56df                                              |
| security_groups       | ef5a81ce-2404-4b8f-8fe2-39af5823f8c9                                              |
| status                | DOWN                                                                              |
| tenant_id             | e07408c60a9e44b6b38161aaa3f776ae                                                  |
+-----------------------+-----------------------------------------------------------------------------------+

List all port to get information.

stack@kiloceilo:~/devstack$ neutron port-list --debug
DEBUG: keystoneclient.session REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:5000/v2.0 -H "Accept: application/json" -H "User-Agent: python-keystoneclient"
DEBUG: urllib3.util.retry Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG: keystoneclient.session RESP: [200] content-length: 340 vary: X-Auth-Token server: Apache/2.4.7 (Ubuntu) date: Fri, 15 Jul 2016 08:15:48 GMT content-type: application/json x-openstack-request-id: req-3087bcbd-a113-490c-87c8-f134d2c68ef0
RESP BODY: {"version": {"status": "stable", "updated": "2014-04-17T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}], "id": "v2.0", "links": [{"href": "http://172.16.235.128:5000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/", "type": "text/html", "rel": "describedby"}]}}

DEBUG: stevedore.extension found extension EntryPoint.parse('table = cliff.formatters.table:TableFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('csv = cliff.formatters.commaseparated:CSVLister')
DEBUG: stevedore.extension found extension EntryPoint.parse('yaml = clifftablib.formatters:YamlFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('json = clifftablib.formatters:JsonFormatter')
DEBUG: stevedore.extension found extension EntryPoint.parse('html = clifftablib.formatters:HtmlFormatter')
DEBUG: neutronclient.neutron.v2_0.port.ListPort get_data(Namespace(columns=[], fields=[], formatter='table', max_width=0, page_size=None, quote_mode='nonnumeric', request_format='json', show_details=False, sort_dir=[], sort_key=[]))
DEBUG: keystoneclient.auth.identity.v2 Making authentication request to http://172.16.235.128:5000/v2.0/tokens
DEBUG: urllib3.util.retry Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG: keystoneclient.session REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:9696/v2.0/ports.json -H "User-Agent: python-neutronclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}94a754e9f1e835cbe08f80379281c74f14bf7727"
DEBUG: urllib3.util.retry Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG: keystoneclient.session RESP: [200] date: Fri, 15 Jul 2016 08:15:48 GMT content-length: 10386 content-type: application/json x-openstack-request-id: req-fd17bd6b-3444-45e6-9aea-3a6a566ec675
RESP BODY: {"ports": [{"status": "ACTIVE", "binding:host_id": "kiloceilo", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:router_gateway", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.3"}], "id": "0155e3e5-1139-46c1-97a6-54baabf9615e", "security_groups": [], "device_id": "f8cfe243-5908-4003-a776-59ce891e5d80", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {"port_filter": true, "ovs_hybrid_plug": true}, "binding:vnic_type": "normal", "binding:vif_type": "ovs", "mac_address": "fa:16:3e:be:57:b1"}, {"status": "ACTIVE", "binding:host_id": "kiloceilo", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:dhcp", "binding:profile": {}, "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.2"}], "id": "01ca3998-19ae-4b9c-b9bc-1a7e53dff980", "security_groups": [], "device_id": "dhcp66142bd9-a6da-5b33-9b98-3219a929d3f5-2b696172-5599-4663-85bd-42de265e56df", "name": "", "admin_state_up": true, "network_id": "2b696172-5599-4663-85bd-42de265e56df", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "binding:vif_details": {"port_filter": true, "ovs_hybrid_plug": true}, "binding:vnic_type": "normal", "binding:vif_type": "ovs", "mac_address": "fa:16:3e:7b:c6:a5"}, {"status": "ACTIVE", "binding:host_id": "kiloceilo", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:router_interface", "binding:profile": {}, "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.1"}], "id": "19bae3c4-0b9e-43da-bf05-bd8c84066a10", "security_groups": [], "device_id": "f8cfe243-5908-4003-a776-59ce891e5d80", "name": "", "admin_state_up": true, "network_id": "2b696172-5599-4663-85bd-42de265e56df", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "binding:vif_details": {"port_filter": true, "ovs_hybrid_plug": true}, "binding:vnic_type": "normal", "binding:vif_type": "ovs", "mac_address": "fa:16:3e:fe:cc:77"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.8"}], "id": "1c640b7a-2622-43b3-b146-d874ab30946d", "security_groups": [], "device_id": "39bc1b07-3e2b-47e2-a5aa-31744f0f063c", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:43:e0:a2"}, {"status": "DOWN", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "", "binding:profile": {}, "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.149"}], "id": "1db9fa8e-d376-4034-87ea-7c6620daefcd", "security_groups": ["ef5a81ce-2404-4b8f-8fe2-39af5823f8c9"], "device_id": "", "name": "", "admin_state_up": true, "network_id": "2b696172-5599-4663-85bd-42de265e56df", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:b2:68:b1"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.13"}], "id": "1deab452-8d32-4082-8b8b-3a6a94f2bece", "security_groups": [], "device_id": "b1f40376-8f75-4102-8aab-1d3971da6193", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:67:70:d8"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.14"}], "id": "2041e300-28f9-49c6-9e2c-323f46c24412", "security_groups": [], "device_id": "d85329c0-7fcf-43e8-b744-f28f119a9adb", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:3f:61:87"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.9"}], "id": "3df4b7d0-7c48-4b74-9918-2edd43ec6479", "security_groups": [], "device_id": "fbd8f36f-47cb-4da9-a524-a2b24e37a6b5", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:8f:db:08"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.12"}], "id": "4fb9d343-ae17-490d-9d2c-2d96259958f9", "security_groups": [], "device_id": "20c3e9de-85df-4249-9866-51b4c4f288e1", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:05:eb:dd"}, {"status": "ACTIVE", "binding:host_id": "kiloceilo", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "compute:nova", "binding:profile": {}, "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.147"}], "id": "66f42774-c2cc-4b46-9589-30df1e19b496", "security_groups": ["ef5a81ce-2404-4b8f-8fe2-39af5823f8c9"], "device_id": "e4f6117e-27b3-487c-b487-2e34da1021f5", "name": "", "admin_state_up": true, "network_id": "2b696172-5599-4663-85bd-42de265e56df", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "binding:vif_details": {"port_filter": true, "ovs_hybrid_plug": true}, "binding:vnic_type": "normal", "binding:vif_type": "ovs", "mac_address": "fa:16:3e:2e:50:12"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.7"}], "id": "9f566f04-3f01-4d29-a63b-a75f69fcf89b", "security_groups": [], "device_id": "429d33cf-b712-4814-9833-03366e3696ae", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:48:56:cf"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.11"}], "id": "a22ef65a-cd25-47bb-a7d4-bb126367768f", "security_groups": [], "device_id": "47414206-5cb5-488b-8876-ac7ae3552fdb", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:b5:d1:bb"}, {"status": "ACTIVE", "binding:host_id": "kiloceilo", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "compute:probe", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.4"}], "id": "ad1f4818-b11d-4898-8258-c23ea4dc65dd", "security_groups": ["0bd4135f-9555-4a34-a1c5-f3e4556c90bd"], "device_id": "kiloceilo", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "89a01dccec8c4228b679f347b10b79ab", "binding:vif_details": {"port_filter": true, "ovs_hybrid_plug": true}, "binding:vnic_type": "normal", "binding:vif_type": "ovs", "mac_address": "fa:16:3e:31:bc:61"}, {"status": "ACTIVE", "binding:host_id": "kiloceilo", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "compute:probe", "binding:profile": {}, "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.3"}], "id": "b8ce74b5-cbbb-4630-a779-9da79fa78fe1", "security_groups": ["ef5a81ce-2404-4b8f-8fe2-39af5823f8c9"], "device_id": "kiloceilo", "name": "", "admin_state_up": true, "network_id": "2b696172-5599-4663-85bd-42de265e56df", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "binding:vif_details": {"port_filter": true, "ovs_hybrid_plug": true}, "binding:vnic_type": "normal", "binding:vif_type": "ovs", "mac_address": "fa:16:3e:b8:be:a1"}, {"status": "N/A", "binding:host_id": "", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "network:floatingip", "binding:profile": {}, "fixed_ips": [{"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.10"}], "id": "c2c90b0a-4781-46f6-9a94-d06eb74e6244", "security_groups": [], "device_id": "4acb3f1d-bed1-4864-b465-62071222b654", "name": "", "admin_state_up": true, "network_id": "3e2df9ef-8dcc-4763-9ee9-fa811db91d15", "tenant_id": "", "binding:vif_details": {}, "binding:vnic_type": "normal", "binding:vif_type": "unbound", "mac_address": "fa:16:3e:aa:be:81"}, {"status": "DOWN", "binding:host_id": "kiloceilo", "allowed_address_pairs": [], "extra_dhcp_opts": [], "device_owner": "", "binding:profile": {}, "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.148"}], "id": "d22191ab-895a-44e0-a641-5117e1c63505", "security_groups": ["ef5a81ce-2404-4b8f-8fe2-39af5823f8c9"], "device_id": "", "name": "", "admin_state_up": true, "network_id": "2b696172-5599-4663-85bd-42de265e56df", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "binding:vif_details": {"port_filter": true, "ovs_hybrid_plug": true}, "binding:vnic_type": "normal", "binding:vif_type": "ovs", "mac_address": "fa:16:3e:0a:24:0c"}]}

+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                            |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
| 0155e3e5-1139-46c1-97a6-54baabf9615e |      | fa:16:3e:be:57:b1 | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.3"}  |
| 01ca3998-19ae-4b9c-b9bc-1a7e53dff980 |      | fa:16:3e:7b:c6:a5 | {"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.2"}      |
| 19bae3c4-0b9e-43da-bf05-bd8c84066a10 |      | fa:16:3e:fe:cc:77 | {"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.1"}      |
| 1c640b7a-2622-43b3-b146-d874ab30946d |      | fa:16:3e:43:e0:a2 | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.8"}  |
| 1db9fa8e-d376-4034-87ea-7c6620daefcd |      | fa:16:3e:b2:68:b1 | {"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.149"}    |
| 1deab452-8d32-4082-8b8b-3a6a94f2bece |      | fa:16:3e:67:70:d8 | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.13"} |
| 2041e300-28f9-49c6-9e2c-323f46c24412 |      | fa:16:3e:3f:61:87 | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.14"} |
| 3df4b7d0-7c48-4b74-9918-2edd43ec6479 |      | fa:16:3e:8f:db:08 | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.9"}  |
| 4fb9d343-ae17-490d-9d2c-2d96259958f9 |      | fa:16:3e:05:eb:dd | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.12"} |
| 66f42774-c2cc-4b46-9589-30df1e19b496 |      | fa:16:3e:2e:50:12 | {"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.147"}    |
| 9f566f04-3f01-4d29-a63b-a75f69fcf89b |      | fa:16:3e:48:56:cf | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.7"}  |
| a22ef65a-cd25-47bb-a7d4-bb126367768f |      | fa:16:3e:b5:d1:bb | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.11"} |
| ad1f4818-b11d-4898-8258-c23ea4dc65dd |      | fa:16:3e:31:bc:61 | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.4"}  |
| b8ce74b5-cbbb-4630-a779-9da79fa78fe1 |      | fa:16:3e:b8:be:a1 | {"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.3"}      |
| c2c90b0a-4781-46f6-9a94-d06eb74e6244 |      | fa:16:3e:aa:be:81 | {"subnet_id": "4f10c5ce-7cf3-481f-af7c-e7ff80a700dc", "ip_address": "172.16.235.10"} |
| d22191ab-895a-44e0-a641-5117e1c63505 |      | fa:16:3e:0a:24:0c | {"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.148"}    |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+

Now Attach OVS port to VM.

stack@kiloceilo:~/devstack$ nova --debug interface-attach --port-id d22191ab-895a-44e0-a641-5117e1c63505 test1
DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:5000/v2.0 -H "Accept: application/json" -H "User-Agent: python-keystoneclient"
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
INFO (connectionpool:203) Starting new HTTP connection (1): 172.16.235.128
DEBUG (connectionpool:383) "GET /v2.0 HTTP/1.1" 200 340
DEBUG (session:226) RESP: [200] content-length: 340 vary: X-Auth-Token server: Apache/2.4.7 (Ubuntu) date: Fri, 15 Jul 2016 08:18:14 GMT content-type: application/json x-openstack-request-id: req-3f0026bc-97b9-4b54-9381-e04c81fe953e
RESP BODY: {"version": {"status": "stable", "updated": "2014-04-17T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}], "id": "v2.0", "links": [{"href": "http://172.16.235.128:5000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/", "type": "text/html", "rel": "describedby"}]}}

DEBUG (v2:76) Making authentication request to http://172.16.235.128:5000/v2.0/tokens
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG (connectionpool:383) "POST /v2.0/tokens HTTP/1.1" 200 2694
DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers?name=test1 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}09fcc1a6bf4799dc4a65c96a7fced53d2998c268"
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
INFO (connectionpool:203) Starting new HTTP connection (1): 172.16.235.128
DEBUG (connectionpool:383) "GET /v2/e07408c60a9e44b6b38161aaa3f776ae/servers?name=test1 HTTP/1.1" 200 362
DEBUG (session:226) RESP: [200] date: Fri, 15 Jul 2016 08:18:14 GMT content-length: 362 content-type: application/json x-compute-request-id: req-58da8547-07bd-4655-9557-4d5ea73b7c29
RESP BODY: {"servers": [{"id": "e4f6117e-27b3-487c-b487-2e34da1021f5", "links": [{"href": "http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "self"}, {"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "bookmark"}], "name": "test1"}]}

DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}09fcc1a6bf4799dc4a65c96a7fced53d2998c268"
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG (connectionpool:383) "GET /v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5 HTTP/1.1" 200 1806
DEBUG (session:226) RESP: [200] date: Fri, 15 Jul 2016 08:18:14 GMT content-length: 1806 content-type: application/json x-compute-request-id: req-7dd7fb8a-58ea-4e7c-ac21-ccaf814f2fbc
RESP BODY: {"server": {"status": "ACTIVE", "updated": "2016-07-15T07:58:59Z", "hostId": "66b3d5bcf0238e5c02f41ceae66e09a90624594b499b5ef2a52470de", "OS-EXT-SRV-ATTR:host": "kiloceilo", "addresses": {"private": [{"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:2e:50:12", "version": 4, "addr": "10.0.0.147", "OS-EXT-IPS:type": "fixed"}, {"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:2e:50:12", "version": 4, "addr": "172.16.235.14", "OS-EXT-IPS:type": "floating"}]}, "links": [{"href": "http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "self"}, {"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "bookmark"}], "key_name": null, "image": {"id": "def244bc-7291-45cb-b336-005e90b61d00", "links": [{"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/images/def244bc-7291-45cb-b336-005e90b61d00", "rel": "bookmark"}]}, "OS-EXT-STS:task_state": null, "OS-EXT-STS:vm_state": "active", "OS-EXT-SRV-ATTR:instance_name": "instance-00000036", "OS-SRV-USG:launched_at": "2016-07-15T07:58:59.000000", "OS-EXT-SRV-ATTR:hypervisor_hostname": "kiloceilo", "flavor": {"id": "1", "links": [{"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/flavors/1", "rel": "bookmark"}]}, "id": "e4f6117e-27b3-487c-b487-2e34da1021f5", "security_groups": [{"name": "default"}], "OS-SRV-USG:terminated_at": null, "OS-EXT-AZ:availability_zone": "nova", "user_id": "606dca546499433a915459e2db358e14", "name": "test1", "created": "2016-07-15T07:58:51Z", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "OS-DCF:diskConfig": "AUTO", "os-extended-volumes:volumes_attached": [], "accessIPv4": "", "accessIPv6": "", "progress": 0, "OS-EXT-STS:power_state": 1, "config_drive": "True", "metadata": {}}}

DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X POST http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5/os-interface -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}09fcc1a6bf4799dc4a65c96a7fced53d2998c268" -d '{"interfaceAttachment": {"port_id": "d22191ab-895a-44e0-a641-5117e1c63505"}}'
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG (connectionpool:383) "POST /v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5/os-interface HTTP/1.1" 200 279
DEBUG (session:226) RESP: [200] date: Fri, 15 Jul 2016 08:18:15 GMT content-length: 279 content-type: application/json x-compute-request-id: req-f26cafe1-f5da-4c3c-8907-58ce8471702b
RESP BODY: {"interfaceAttachment": {"port_state": "DOWN", "fixed_ips": [{"subnet_id": "ccdb4f67-568b-47a0-b652-c1d8b8d66135", "ip_address": "10.0.0.148"}], "port_id": "d22191ab-895a-44e0-a641-5117e1c63505", "net_id": "2b696172-5599-4663-85bd-42de265e56df", "mac_addr": "fa:16:3e:0a:24:0c"}}

Result

Now, In the VM, we have eth1.

$ ip link list
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
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether fa:16:3e:2e:50:12 brd ff:ff:ff:ff:ff:ff
4: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether fa:16:3e:0a:24:0c brd ff:ff:ff:ff:ff:ff

Detach Nic Card From VM

Detach Nic Card.

stack@kiloceilo:~/devstack$ nova --debug interface-detach test1 d22191ab-895a-44e0-a641-5117e1c63505
DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:5000/v2.0 -H "Accept: application/json" -H "User-Agent: python-keystoneclient"
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
INFO (connectionpool:203) Starting new HTTP connection (1): 172.16.235.128
DEBUG (connectionpool:383) "GET /v2.0 HTTP/1.1" 200 340
DEBUG (session:226) RESP: [200] content-length: 340 vary: X-Auth-Token server: Apache/2.4.7 (Ubuntu) date: Fri, 15 Jul 2016 08:25:12 GMT content-type: application/json x-openstack-request-id: req-60ba77ef-b798-424f-bdb2-76aead8155a6
RESP BODY: {"version": {"status": "stable", "updated": "2014-04-17T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}], "id": "v2.0", "links": [{"href": "http://172.16.235.128:5000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/", "type": "text/html", "rel": "describedby"}]}}

DEBUG (v2:76) Making authentication request to http://172.16.235.128:5000/v2.0/tokens
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG (connectionpool:383) "POST /v2.0/tokens HTTP/1.1" 200 2694
DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers?name=test1 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}5b5fc87bd3e95d2fc6ce0e09717b602f5071344f"
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
INFO (connectionpool:203) Starting new HTTP connection (1): 172.16.235.128
DEBUG (connectionpool:383) "GET /v2/e07408c60a9e44b6b38161aaa3f776ae/servers?name=test1 HTTP/1.1" 200 362
DEBUG (session:226) RESP: [200] date: Fri, 15 Jul 2016 08:25:12 GMT content-length: 362 content-type: application/json x-compute-request-id: req-ee3d5398-79bb-4c02-88a9-f29177ea7bda
RESP BODY: {"servers": [{"id": "e4f6117e-27b3-487c-b487-2e34da1021f5", "links": [{"href": "http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "self"}, {"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "bookmark"}], "name": "test1"}]}

DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X GET http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}5b5fc87bd3e95d2fc6ce0e09717b602f5071344f"
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG (connectionpool:383) "GET /v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5 HTTP/1.1" 200 1941
DEBUG (session:226) RESP: [200] date: Fri, 15 Jul 2016 08:25:12 GMT content-length: 1941 content-type: application/json x-compute-request-id: req-17707da0-e9bf-4ecc-acd6-8547dda31dbf
RESP BODY: {"server": {"status": "ACTIVE", "updated": "2016-07-15T07:58:59Z", "hostId": "66b3d5bcf0238e5c02f41ceae66e09a90624594b499b5ef2a52470de", "OS-EXT-SRV-ATTR:host": "kiloceilo", "addresses": {"private": [{"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:2e:50:12", "version": 4, "addr": "10.0.0.147", "OS-EXT-IPS:type": "fixed"}, {"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:0a:24:0c", "version": 4, "addr": "10.0.0.148", "OS-EXT-IPS:type": "fixed"}, {"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:2e:50:12", "version": 4, "addr": "172.16.235.14", "OS-EXT-IPS:type": "floating"}]}, "links": [{"href": "http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "self"}, {"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5", "rel": "bookmark"}], "key_name": null, "image": {"id": "def244bc-7291-45cb-b336-005e90b61d00", "links": [{"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/images/def244bc-7291-45cb-b336-005e90b61d00", "rel": "bookmark"}]}, "OS-EXT-STS:task_state": null, "OS-EXT-STS:vm_state": "active", "OS-EXT-SRV-ATTR:instance_name": "instance-00000036", "OS-SRV-USG:launched_at": "2016-07-15T07:58:59.000000", "OS-EXT-SRV-ATTR:hypervisor_hostname": "kiloceilo", "flavor": {"id": "1", "links": [{"href": "http://172.16.235.128:8774/e07408c60a9e44b6b38161aaa3f776ae/flavors/1", "rel": "bookmark"}]}, "id": "e4f6117e-27b3-487c-b487-2e34da1021f5", "security_groups": [{"name": "default"}, {"name": "default"}], "OS-SRV-USG:terminated_at": null, "OS-EXT-AZ:availability_zone": "nova", "user_id": "606dca546499433a915459e2db358e14", "name": "test1", "created": "2016-07-15T07:58:51Z", "tenant_id": "e07408c60a9e44b6b38161aaa3f776ae", "OS-DCF:diskConfig": "AUTO", "os-extended-volumes:volumes_attached": [], "accessIPv4": "", "accessIPv6": "", "progress": 0, "OS-EXT-STS:power_state": 1, "config_drive": "True", "metadata": {}}}

DEBUG (session:196) REQ: curl -g -i --cacert "/opt/stack/data/CA/int-ca/ca-chain.pem" -X DELETE http://172.16.235.128:8774/v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5/os-interface/d22191ab-895a-44e0-a641-5117e1c63505 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}5b5fc87bd3e95d2fc6ce0e09717b602f5071344f"
DEBUG (retry:155) Converted retries value: 0 -> Retry(total=0, connect=None, read=None, redirect=0)
DEBUG (connectionpool:383) "DELETE /v2/e07408c60a9e44b6b38161aaa3f776ae/servers/e4f6117e-27b3-487c-b487-2e34da1021f5/os-interface/d22191ab-895a-44e0-a641-5117e1c63505 HTTP/1.1" 202 0
DEBUG (session:226) RESP: [202] date: Fri, 15 Jul 2016 08:25:12 GMT content-length: 0 content-type: text/html; charset=UTF-8 x-compute-request-id: req-121a281d-70eb-4541-9b1a-2b737edbef1d

Result

In the VM, eth1 is disappeard.

$ ip link list
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
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether fa:16:3e:2e:50:12 brd ff:ff:ff:ff:ff:ff

Monday, July 4, 2016

SVM演算法於python的使用

svm

前言

在很久以前,我是做演算法的,我记得,我最后一个接触的演算法就是SVM。 但那时只到听过这个演算法而已。 几年后,竟然有机会接触到演算法,竟然还是SVM。这过程真有趣。 以前总是想实现算法,现在python实在太方便了,lib呼叫就什么事情都解决了。

这也是当初我学Golang,最后转回python的原因。python的lib太强大了。

也感谢,聪明又美丽的北一女学妹,给我以下的blog,加速我的学习。

http://yourgene.pixnet.net/blog/post/115169530

SVM用法

from sklearn import svm
X = [[0, 0], [1, 1],[2, 2]]
y = [0, 1, 2]
clf = svm.SVC()
clf.fit(X, y)
print clf.predict([[5., 5.]])

X為多維的training data,y為label。

One-Class SVM

One-Class

http://scikit-learn.org/stable/autoexamples/svm/plotoneclass.html

What's the meaning of nu

http://qiita.com/SE96UoC5AfUt7uY/items/88006646179adf68cb95

One-Class SVM,异常判定。 有的时候,我们有大量资料,我们只想知道,我们现在的资料是否为异常。 我们可以用以下的方式,实现。

from sklearn import svm
X = [[0, 0], [1, 1],[2, 2]]
y = [0, 1, 2]
clf = svm.OneClassSVM(nu=0.1, kernel="rbf", gamma=0.1)
clf.fit(X)

print clf.predict([[3, 3]])

return值-1為異常。