Thursday, September 22, 2016

Certificates

For self signed certificates, the public half of the certificate can be obtained by using a browser (such as Firefox) exporting the certificate. The exported certificate should be in the form of pem. Now you can use the following command to convert it to .crt file.

   openssl x509 -outform der -in your-cert.pem -out your-cert.crt
 
 
If only allows system wide acceptance of the certificates, do the following:

   1. copy pem to /etc/ssl/certs

   2. Run the following command to create a file name:
      
         openssl x509 -noout -hash -in _PEM_FILE

   3. The above command will produce a hash, then create a link in /etc/ssl/certs:

         ln -s _PEM_FILE_ <theHash>.0
 

Thursday, August 18, 2016

Enable OpenStack sending log to a remote rsyslog server


On OpenStack side:

Security Rules, open the following ports: These rules are required when all your nodes running in a OpenStack cloud.

   9200 (ElasticSearch)
   9300 (ElasticSearch transport between nodes)
   9400 (for syslog) to collect via logstash
   5601 (Kibana)
   22, 80 and icmp

Config rsyslog to remote logging:
create a file in /etc/rsyslog.d, named it like 60-openstack.conf
put the following content in the that file

local6.*               @10.0.50.9:9400

NOTE: that the ip address must be the remote rsyslog server IP. When working with ElasticSearch, that IP should be the IP address of logstash server. The port 9400 should match up with the UDP port sets in /etc/logstash/conf.d/logstach.conf file. Using port lower than 1024 will require special permission. After making these changes, restart the service like this:

service rsyslog restart

Config OpenStack component to use the new log facility:

Change component file such as nova.conf, neutron.conf to use syslog like the following:

[DEFAULT]
debug = False
use_syslog = True
syslog_log_facility = LOG_LOCAL6

You can use LOG_LOCAL0 to LOG_LOCAL7 as long as the facility points to the remote logging server.

After making these changes, restart the components



This procedure is using ElasticSearch logstash as a rsyslog server. When there is no particular filter setup, you still will be able to use kibana to chart log data.  Follow these steps to produce a pie chart:

1. Use the logstash-* index
2. Click on Visualize button at the top of the kibana screen
3. Click on Pie Chart
4. Select from new search
5. Select split slices
6. Select terms from the aggregation  drop down box
7. Select syslog_program.raw from the field drop down box, leave others alone
8. Click on the run button at the options bar, a chart should be displayed

Wednesday, August 17, 2016

How to install docker client working

apt-get update
apt-get -y install docker.io
ln -sf /usr/bin/docker.io /usr/local/bin/docker 

Tuesday, August 9, 2016

OpenStack wiered errors

This is the post I will use to record some of the strange errors I have encounted.
    1. When image file gets moved to a different location, glance will fail to provide the image for a VM, but the instance somewhere will get multiple fixed IP addresses. This is a very strange problem. After going to the database, corrected the image_location value field records, restart glance services will resolve this error.
   2. There is also a problem when instance_path is not writable by libvirt-qemu user, for some reason, each VM will get two private IPs. Make sure that the libvirt-qemu user can write to instance_path which is defined in nova.conf file.
     

Monday, August 8, 2016

Setup Ansible to use openstack cloud module


Follow these steps to install ansible and shade to use openstack cloud modules.
 
sudo apt-add-repository ppa:ansible/ansible -y
sudo apt-get update && sudo apt-get install ansible -y 
sudo apt-get install python-dev python-pip libssl-dev libffi-dev -y
sudo pip install six shade --upgrade

Friday, July 22, 2016

TUN TAP VETH Devices

The following content are copied from this original post, referenced here purely for my own convenience. All credits of creating the post go to the original author. Thanks.

http://www.naturalborncoder.com/virtualization/2014/10/17/understanding-tun-tap-interfaces/

TUN Interfaces

TUN devices work at the IP level or layer three level of the network stack and are usually point-to-point connections. A typical use for a TUN device is establishing VPN connections since it gives the VPN software a chance to encrypt the data before it gets put on the wire. Since a TUN device works at layer three it can only accept IP packets and in some cases only IPv4. If you need to run any other protocol over a TUN device you’re out of luck. Additionally because TUN devices work at layer three they can’t be used in bridges and don’t typically support broadcasting.

List all network devices in the system

Go to directory /sys/class/net. This directory should contain all the physical and virtual network devices.

TAP Interfaces

TAP devices, in contrast, work at the Ethernet level or layer two and therefore behave very much like a real network adaptor. Since they are running at layer two they can transport any layer three protocol and aren’t limited to point-to-point connections. TAP devices can be part of a bridge and are commonly used in virtualization systems to provide virtual network adaptors to multiple guest machines. Since TAP devices work at layer two they will forward broadcast traffic which normally makes them a poor choice for VPN connections as the VPN link is typically much narrower than a LAN network (and usually more expensive).

Managing Virtual Interfaces

It really couldn’t be simpler to create a virtual interface:
ip tuntap add name tap0 mode tap
ip link show
The above command creates a new TAP interface called tap0 and then shows some information about  the device. You will probably notice that after creation the tap0 device reports that it is in the down state. This is by design and it will come up only when something binds it (see here). The output of the show command will look something like this:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
 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 state UP mode DEFAULT group default qlen 1000
 link/ether 08:00:27:4a:5e:e1 brd ff:ff:ff:ff:ff:ff
3: tap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 500
 link/ether 36:2b:9d:5c:92:78 brd ff:ff:ff:ff:ff:ff
To remove a TUN/TAP interface just replace “add” in the creation command with “del”. Note that you have to specify the mode when deleting, presumably you can create both a tun and a tap interface with the same name.

Creating Veth Pairs

A pair of connected interfaces, commonly known as a veth pair, can be created to act as virtual wiring. Essentially what you are creating is a virtual equivalent of a patch cable. What goes in one end comes out the other. The command to create a veth pair is a little more complicated than some:
ip link add ep1 type veth peer name ep2
 This will create a pair of linked interfaces called ep1 and ep2 (ep for Ethernet pair, you probably want to choose more descriptive names). When working with OpenStack, especially on a single box install, it’s common to use veth pairs to link together the internal bridges. It is also possible to add IP addresses to the interfaces, for example:

ip addr add 10.0.0.10 dev ep1
ip addr add 10.0.0.11 dev ep2
Now you can use ip address show to check the assignment of IP addresses which will output something like this:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
 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 group default qlen 1000
 link/ether 08:00:27:4a:5e:e1 brd ff:ff:ff:ff:ff:ff
 inet 192.168.1.141/24 brd 192.168.1.255 scope global eth0
 valid_lft forever preferred_lft forever
 inet6 fe80::a00:27ff:fe4a:5ee1/64 scope link
 valid_lft forever preferred_lft forever
4: ep2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
 link/ether fa:d3:ce:c3:da:ad brd ff:ff:ff:ff:ff:ff
 inet 10.0.0.11/32 scope global ep2
 valid_lft forever preferred_lft forever
5: ep1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
 link/ether e6:80:a3:19:2c:10 brd ff:ff:ff:ff:ff:ff
 inet 10.0.0.10/32 scope global ep1
 valid_lft forever preferred_lft forever
Using a couple of parameters on the ping command shows us the veth pair working:
ping -I 10.0.0.10 -c1 10.0.0.11
PING 10.0.0.11 (10.0.0.11) from 10.0.0.10 : 56(84) bytes of data.
64 bytes from 10.0.0.11: icmp_seq=1 ttl=64 time=0.036 ms
--- 10.0.0.11 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.036/0.036/0.036/0.000 ms
The -I parameter specifies the interface that should be used for the ping. In this case the 10.0.0.10 interface what chosen which is a pair with 10.0.0.11 and as you can see the ping is there and back in a flash. Attempting to ping anything external fails since the veth pair is essentially just a patch cable (although ping’ing eth0 works for some reason).

Thursday, July 14, 2016

How to install vagrant and vagrant-managed-server plugin

1. Download latest vagrant deb package and install it:

   https://www.vagrantup.com/downloads.html
   dpkg -i vagrant_1.8.4_x86_64.deb 

2. Install dependencies:

   apt-get -qqy install ruby-dev make

3. Install the vagrant-managed-servers plugin

   vagrant plugin install vagrant-managed-servers