Friday, August 29, 2014

Setup QCOW2 standard CentOS 7 cloud image to work with 2 VLANs on IceHouse ML2&OVS&GRE System

Notice, that same schema would work for any F20 or Ubuntu QCOW2 cloud images via qemu-nbd mount and increasing number of NICs interface files up to 2,3,...
Approach suggested down here  is universal. Any cinder volume been built up on
updated glance image ( 2 NICs ready ) would be 2 NICs ready as well

*********************************************
Update qcow2 image for 2 NIC interfaces
*********************************************
[root@icehouse1 Downloads]# modprobe nbd max_part=63
[root@icehouse1 Downloads]# qemu-nbd -c /dev/nbd0 CentOS-7-x86_64-GenericCloud-20140826_02.qcow2
[root@icehouse1 Downloads]# mount /dev/nbd0p1 /mnt/image
[root@icehouse1 Downloads]# chroot /mnt/image
[root@icehouse1 /]# cd /etc/sysconfig/network-*
[root@icehouse1 network-scripts]# ls
ifcfg-eth0   ifdown-ipv6    ifdown-Team      ifup-eth    ifup-post      ifup-tunnel
ifcfg-lo     ifdown-isdn    ifdown-TeamPort  ifup-ippp   ifup-ppp       ifup-wireless
ifdown       ifdown-post    ifdown-tunnel    ifup-ipv6   ifup-routes    init.ipv6-global
ifdown-bnep  ifdown-ppp     ifup             ifup-isdn   ifup-sit       network-functions
ifdown-eth   ifdown-routes  ifup-aliases     ifup-plip   ifup-Team      network-functions-ipv6
ifdown-ippp  ifdown-sit     ifup-bnep        ifup-plusb  ifup-TeamPort
[root@icehouse1 network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@icehouse1 network-scripts]# vi ifcfg-eth1
[root@icehouse1 network-scripts]# cat ifcfg-eth1
DEVICE="eth1"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="yes"
PEERDNS="yes"
IPV6INIT="no"
PERSISTENT_DHCLIENT="1"
[root@icehouse1 network-scripts]# exit
exit
****************************
Libguestfs  tools
****************************

sudo yum install libguestfs-tools      # Fedora/RHEL/CentOS
sudo apt-get install libguestfs-tools  # Debian/Ubuntu


[boris@icehouse1 Downloads]$  guestfish --rw -a trusty-server-cloudimg-amd64-disk1.img

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

> run
> list-filesystems
/dev/sda1: ext4
> mount /dev/sda1 /
> ls /etc/network/interfaces.d
eth0.cfg
> cp  /etc/network/interfaces.d/eth0.cfg /etc/network/interfaces.d/eth1.cfg
> edit /etc/network/interfaces.d/eth1.cfg
> ls  /etc/network/interfaces.d/
eth0.cfg
eth1.cfg
> cat /etc/network/interfaces.d/eth1.cfg
# The primary network interface
auto eth1
iface eth1 inet dhcp

> cat /etc/network/interfaces.d/eth0.cfg
# The primary network interface
auto eth0
iface eth0 inet dhcp


[boris@icehouse1 Downloads]$  guestfish --rw -a  Fedora-x86_64-20-20140407-sda.qcow2

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

> run
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
> list-filesystems
/dev/sda1: ext4
> mount /dev/sda1 /
> cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
> edit  /etc/sysconfig/network-scripts/ifcfg-eth1
> cat  /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"

> cat  /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"

> exit


*********************************************************
Upload image to glance and launch VM to this image
*********************************************************

   

  
  
  
  

[root@icehouse1 Downloads]# ssh centos@192.168.1.204
The authenticity of host '192.168.1.204 (192.168.1.204)' can't be established.
ECDSA key fingerprint is 46:54:d3:46:e3:d1:e0:a8:57:af:a8:22:f6:3a:ed:ea.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.204' (ECDSA) to the list of known hosts.
centos@192.168.1.204's password:
Last login: Sat Aug 30 06:00:10 2014
[centos@centos07twonic ~]$ sudo su
[root@centos07twonic centos]# ifconfig
eth0: flags=4163  mtu 1454
        inet 10.0.0.19  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::f816:3eff:fe9a:59f8  prefixlen 64  scopeid 0x20
        ether fa:16:3e:9a:59:f8  txqueuelen 1000  (Ethernet)
        RX packets 255  bytes 32133 (31.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 314  bytes 33467 (32.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163  mtu 1454
        inet 40.0.0.67  netmask 255.255.255.0  broadcast 40.0.0.255
        inet6 fe80::f816:3eff:fe6c:3c8d  prefixlen 64  scopeid 0x20
        ether fa:16:3e:6c:3c:8d  txqueuelen 1000  (Ethernet)
        RX packets 27  bytes 2762 (2.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 31  bytes 4869 (4.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)
        RX packets 12  bytes 976 (976.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 976 (976.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


[root@icehouse1 ~(keystone_admin)]# neutron net-list
+--------------------------------------+---------+-----------------------------------------------------+
| id                                   | name    | subnets                                             |
+--------------------------------------+---------+-----------------------------------------------------+
| 8b22b262-c9c1-4138-8092-0581195f0889 | private | 06530f5a-31af-4a14-a40f-808ee2e9e3ad 40.0.0.0/24    |
| 140d25a4-0d98-4424-a35a-2a985b2f0a17 | demonet | f2e318f8-05c6-4dda-8e8e-07f7a8f2c91a 10.0.0.0/24    |
| 295a5bba-c219-407f-830d-911cd2214349 | public  | c8421c61-7d85-4cf8-a5c8-03c05982bff9 192.168.1.0/24 |
+--------------------------------------+---------+-----------------------------------------------------+
 

[root@icehouse1 ~(keystone_admin)]# ip netns
qrouter-ecf9ee4e-b92c-4a5b-a884-d753a184764b
qrouter-4135e351-9ae4-4e89-9b23-7b131b2c4e6c
qdhcp-140d25a4-0d98-4424-a35a-2a985b2f0a17
qdhcp-8b22b262-c9c1-4138-8092-0581195f0889
 

[root@icehouse1 ~(keystone_admin)]# ip netns exec qdhcp-8b22b262-c9c1-4138-8092-0581195f0889 ssh centos@40.0.0.67
 

The authenticity of host '40.0.0.67 (40.0.0.67)' can't be established.
ECDSA key fingerprint is 46:54:d3:46:e3:d1:e0:a8:57:af:a8:22:f6:3a:ed:ea.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '40.0.0.67' (ECDSA) to the list of known hosts.
centos@40.0.0.67's password:
Last login: Sat Aug 30 15:20:36 2014 from 10.0.0.11
 

[centos@centos07twonic ~]$ curl http://169.254.169.254/latest/meta-data/local-ipv4
10.0.0.19


[root@icehouse1 ~(keystone_admin)]# ip netns exec qdhcp-140d25a4-0d98-4424-a35a-2a985b2f0a17 ssh   centos@10.0.0.19
centos@10.0.0.19's password:
Last login: Sat Aug 30 15:19:04 2014 from 10.0.0.11
[centos@centos07twonic ~]$ curl http://169.254.169.254/latest/meta-data/local-ipv4
10.0.0.19






   Same procedure done against Fedora 20 cloud image :-
  


[root@icehouse1 Downloads(keystone_admin)]# modprobe nbd max_part=63[root@icehouse1 Downloads(keystone_admin)]# qemu-nbd -c /dev/nbd0 Fedora-x86_64-20-20140407-sda.qcow2
[root@icehouse1 Downloads(keystone_admin)]# mount /dev/nbd0p1 /mnt/image
[root@icehouse1 Downloads(keystone_admin)]# chroot /mnt/image

[root@icehouse1 /(keystone_admin)]# ls -l
total 76
lrwxrwxrwx.  1 root root     7 Apr  8 02:28 bin -> usr/bin
dr-xr-xr-x.  4 root root  4096 Apr  8 02:29 boot
drwxr-xr-x.  4 root root  4096 Apr  8 02:29 dev
drwxr-xr-x. 63 root root  4096 Apr  8 02:30 etc
drwxr-xr-x.  2 root root  4096 Aug  7  2013 home
lrwxrwxrwx.  1 root root     7 Apr  8 02:28 lib -> usr/lib
lrwxrwxrwx.  1 root root     9 Apr  8 02:28 lib64 -> usr/lib64
drwx------.  2 root root 16384 Apr  8 02:27 lost+found
drwxr-xr-x.  2 root root  4096 Aug  7  2013 media
drwxr-xr-x.  2 root root  4096 Aug  7  2013 mnt
drwxr-xr-x.  2 root root  4096 Aug  7  2013 opt
drwxrwxr-x.  2 root root  4096 Apr  8 02:27 proc
dr-xr-x---.  2 root root  4096 Apr  8 02:29 root
drwxr-xr-x.  8 root root  4096 Apr  8 02:29 run
lrwxrwxrwx.  1 root root     8 Apr  8 02:28 sbin -> usr/sbin
drwxr-xr-x.  2 root root  4096 Aug  7  2013 srv
drwxrwxr-x.  2 root root  4096 Apr  8 02:27 sys
drwxrwxrwt.  2 root root  4096 Aug 30 07:39 tmp
drwxr-xr-x. 12 root root  4096 Apr  8 02:28 usr
drwxr-xr-x. 18 root root  4096 Apr  8 02:28 var

[root@icehouse1 /(keystone_admin)]# cd /etc/sysconfig/network-*
[root@icehouse1 network-scripts(keystone_admin)]# ls
ifcfg-eth0   ifdown-ipv6    ifdown-tunnel  ifup-ipv6   ifup-ppp          network-functions
ifcfg-lo     ifdown-isdn    ifup           ifup-ipx    ifup-routes       network-functions-ipv6
ifdown       ifdown-post    ifup-aliases   ifup-isdn   ifup-sit
ifdown-bnep  ifdown-ppp     ifup-bnep      ifup-plip   ifup-tunnel
ifdown-eth   ifdown-routes  ifup-eth       ifup-plusb  ifup-wireless
ifdown-ippp  ifdown-sit     ifup-ippp      ifup-post   init.ipv6-global
[root@icehouse1 network-scripts(keystone_admin)]# cp ifcfg-eth0 ifcfg-eth1
[root@icehouse1 network-scripts(keystone_admin)]# vi  ifcfg-eth1
[root@icehouse1 network-scripts(keystone_admin)]# vi  ifcfg-eth0
[root@icehouse1 network-scripts(keystone_admin)]# vi  ifcfg-eth1
[root@icehouse1 network-scripts(keystone_admin)]# exit

[root@icehouse1 ~(keystone_admin)]# neutron net-list
+--------------------------------------+---------+-----------------------------------------------------+
| id                                   | name    | subnets                                             |
+--------------------------------------+---------+-----------------------------------------------------+
| 8b22b262-c9c1-4138-8092-0581195f0889 | private | 06530f5a-31af-4a14-a40f-808ee2e9e3ad 40.0.0.0/24    |
| 140d25a4-0d98-4424-a35a-2a985b2f0a17 | demonet | f2e318f8-05c6-4dda-8e8e-07f7a8f2c91a 10.0.0.0/24    |
| 295a5bba-c219-407f-830d-911cd2214349 | public  | c8421c61-7d85-4cf8-a5c8-03c05982bff9 192.168.1.0/24 |
+--------------------------------------+---------+-----------------------------------------------------+

[root@icehouse1 ~(keystone_admin)]# ip netns
qrouter-ecf9ee4e-b92c-4a5b-a884-d753a184764b
qrouter-4135e351-9ae4-4e89-9b23-7b131b2c4e6c
qdhcp-140d25a4-0d98-4424-a35a-2a985b2f0a17
qdhcp-8b22b262-c9c1-4138-8092-0581195f0889

[root@icehouse1 ~(keystone_admin)]# ip netns exec qdhcp-8b22b262-c9c1-4138-8092-0581195f0889 ssh -i oskey45.pem fedora@40.0.0.71
Last login: Sat Aug 30 12:34:35 2014 from 40.0.0.11
[fedora@vf20twonicrxc ~]$ curl http://169.254.169.254/latest/meta-data/local-ipv4
40.0.0.71
[fedora@vf20twonicrxc ~]$ curl http://169.254.169.254/latest/meta-data/public-ipv4
192.168.1.205
[fedora@vf20twonicrxc ~]$ exit
logout
Connection to 40.0.0.71 closed.

[root@icehouse1 ~(keystone_admin)]# ip netns exec qdhcp-140d25a4-0d98-4424-a35a-2a985b2f0a17 ssh -i oskey45.pem fedora@10.0.0.23
Last login: Sat Aug 30 12:35:11 2014 from 40.0.0.11

[fedora@vf20twonicrxc ~]$ curl http://169.254.169.254/latest/meta-data/local-ipv4
40.0.0.71
[fedora@vf20twonicurl http://169.254.169.254/latest/meta-data/public-ipv4
192.168.1.205
[fedora@vf20twonicrxc ~]$ exit
logout
Connection to 10.0.0.23 closed.

*************************************
Ubuntu 14.04 guest snapshots
*************************************

 
  
   [root@icehouse1 Downloads]# ssh -i oskey45.pem ubuntu@192.168.1.203
   Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-35-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Sat Aug 30 14:34:00 UTC 2014

  System load:  0.01              Processes:           74
  Usage of /:   17.0% of 6.86GB   Users logged in:     1
  Memory usage: 4%                IP address for eth0: 10.0.0.24
  Swap usage:   0%                IP address for eth1: 40.0.0.72

  Graph this data and manage this system at:
    https://landscape.canonical.com/

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


  Last login: Sat Aug 30 14:34:00 2014

[root@icehouse1 ~(keystone_admin)]# ip netns exec qdhcp-140d25a4-0d98-4424-a35a-2a985b2f0a17 ssh  -i oskey45.pem ubuntu@10.0.0.24
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-35-generic x86_64)


 * Documentation:  https://help.ubuntu.com/

  System information as of Sat Aug 30 15:24:45 UTC 2014

  System load:  0.21              Processes:           76
  Usage of /:   19.3% of 6.86GB   Users logged in:     0
  Memory usage: 2%                IP address for eth0: 10.0.0.24
  Swap usage:   0%                IP address for eth1: 40.0.0.72

  Graph this data and manage this system at:
    https://landscape.canonical.com/

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


Last login: Sat Aug 30 15:24:44 2014


ubuntu@ubuntutwonicrsq:~$ curl http://169.254.169.254/latest/meta-data/local-ipv4
40.0.0.72
logout
Connection to 10.0.0.24 closed.


[root@icehouse1 ~(keystone_admin)]# ip netns exec qdhcp-8b22b262-c9c1-4138-8092-0581195f0889  ssh  -i oskey45.pem ubuntu@40.0.0.72

Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-35-generic x86_64)
 * Documentation:  https://help.ubuntu.com/

  System information as of Sat Aug 30 16:24:45 UTC 2014

  System load:  0.0               Processes:           88
  Usage of /:   19.7% of 6.86GB   Users logged in:     1
  Memory usage: 6%                IP address for eth0: 10.0.0.24
  Swap usage:   0%                IP address for eth1: 40.0.0.72

  Graph this data and manage this system at:
    https://landscape.canonical.com/

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


Last login: Sat Aug 30 16:24:46 2014 from 10.0.0.11
ubuntu@ubuntutwonicrsq:~$ curl http://169.254.169.254/latest/meta-data/local-ipv4
40.0.0.72


  

 
  Assigning floating IP for instance with two NICs :-


  
One of two available ports will allow to assign properly working floating IP.