<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>JackKozik.com &#187; Web Programming</title> <atom:link href="http://jackkozik.com/category/web/feed" rel="self" type="application/rss+xml" /><link>http://jackkozik.com</link> <description>Web Programming, Home Networking and Personal Travel</description> <lastBuildDate>Mon, 04 Sep 2023 14:26:56 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.9.2</generator> <item><title>Openstack Kilo on home network &#8211; part 2</title><link>http://jackkozik.com/openstack-kilo-home-network-part-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openstack-kilo-home-network-part-2</link> <comments>http://jackkozik.com/openstack-kilo-home-network-part-2/#comments</comments> <pubDate>Wed, 26 Aug 2015 02:42:20 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[2015]]></category> <category><![CDATA[Kilo]]></category> <category><![CDATA[Openstack]]></category><guid isPermaLink="false">http://jackkozik.com/?p=5298</guid> <description><![CDATA[<p>In my previous post, I outlined the steps followed to install OpenStack Kilo on CENTOS7.  In this post I show the steps to setup networking, routing, and spinning up a couple of test instances. Create Networks In this section, I list the steps to create two OpenStack networks: Homelan. This network connects the OpenStack VMs [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-kilo-home-network-part-2/">Openstack Kilo on home network &#8211; part 2</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>In my <a href="http://jackkozik.com/openstack-kilo-centos7-using-rdos-packstack/">previous post</a>, I outlined the steps followed to install OpenStack Kilo on CENTOS7.  In this post I show the steps to setup networking, routing, and spinning up a couple of test instances.</p><h2>Create Networks</h2><p>In this section, I list the steps to create two OpenStack networks:</p><ol><li>Homelan. This network connects the OpenStack VMs to an external network, which in my case is my home LAN.</li><li>Tenant.  This network connects the OpenStack VMs internally.</li></ol><p>From the root login,  run the following neutron commands:</p><h5>Create network homelan-net, subnet homelan-subnet</h5><p>My OpenStack Kilo server sits in my home network, 192.168.100.0/26.  The server is .154 and gateway .162.  The homelan-net network gateways to my home LAN and through my cable modem, to the internet.   The virtual machines that sit inside the OpenStack cloud on a different network and will map their IP addresses to one of the IP addresses in the allocation pool .70 thru .99.  This mapping is assigned one at a time as the VMs are created.</p><pre># source keystonerc_admin
# neutron net-create homelan-net --router:external
# neutron subnet-create homelan-net 192.168.100.0/24 \
   --name homelan-subnet \
   --allocation-pool start=192.168.100.70,end=192.168.100.99 \
   --disable-dhcp --gateway 192.168.100.162</pre><h5>Create network tenant-net, subnet tenant-subnet</h5><p>The neutron commands below create a tentant-net that has a DHCP-based address pool  in the 10.0.0.0/24 address block.  Virtual machines will be created  with an address from this DHCP address pool.</p><pre># neutron net-create tenant-net
# neutron subnet-create tenant-net 10.0.0.0/24 \
    --name tenant-subnet --gateway 10.0.0.1 --dns-nameservers list=true\          8.8.4.4 8.8.8.8</pre><p>Verify the setup by going to the OpenStack  dashboard. It displays the networks:</p><p>Admin-&gt;Networks<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/08/AdminNetworkNewNets080315.jpg"><img class="alignright size-full wp-image-5299" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/AdminNetworkNewNets080315.jpg" alt="AdminNetworkNewNets080315" width="670" height="299" /></a></p><p>&nbsp;</p><h2>Create Router</h2><p>After creating the networks, connect them together through a router, using the following neutron commands:</p><pre># neutron router-create router1
# neutron router-interface-add router1 tenant-subnet
# neutron router-gateway-set router1 homelan-net</pre><p>The router setup can be verified at the OpenStack dashboard:</p><p>Admin-&gt;Routers<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/08/AdminRouters080315.jpg"><img class="alignleft size-full wp-image-5300" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/AdminRouters080315.jpg" alt="AdminRouters080315" width="661" height="224" /></a></p><p>Admin-&gt;Routers-&gt;router1<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/08/AdminRoutersDetails080315.jpg"><img class="alignleft size-full wp-image-5301" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/AdminRoutersDetails080315.jpg" alt="AdminRoutersDetails080315" width="650" height="372" /></a></p><p>The OpenStack Dashboard displays the same thing, but graphically.</p><p><a href="http://jackkozik.com/wp-content/uploads/2015/08/ProjectNetworkNetworkTopology080315.jpg"><img class="alignleft size-full wp-image-5305" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/ProjectNetworkNetworkTopology080315.jpg" alt="ProjectNetworkNetworkTopology080315" width="256" height="502" /></a></p><p>&nbsp;</p><h2></h2><p>The tenant-net is where the instances will connect.  Let&#8217;s bring up two.</p><h2>Spin-up Cirros Instance</h2><p>WIth the networks and router setup, we have the base for spinning up the default image supplied with the packstack installation.</p><p>Cirros is a barebones linux distribution well-suited for verifying OpenStack installations.</p><p>You can see the cirros image in the OpenStack dashboard:</p><p><a href="http://jackkozik.com/wp-content/uploads/2015/08/SystemImages080315.jpg"><img class="alignleft size-full wp-image-5302" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/SystemImages080315.jpg" alt="SystemImages080315" width="678" height="227" /></a></p><p>&nbsp;</p><p>To spin-up cirros, first setup a key-pair and some access control rules:</p><pre># nova keypair-add 080315-key &gt; 080315-key.key
<span style="color: #333333;"># chmod 600 080315-key.key</span>
# nova keypair-list
+------------+-------------------------------------------------+
| Name       | Fingerprint                                     |
+------------+-------------------------------------------------+
| 080315-key | c9:02:a4:18:f5:32:f4:3c:64:5a:0e:e1:5e:be:f8:39 |
+------------+-------------------------------------------------+
# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
# nova secgroup-add-rule default tcp 80 80  0.0.0.0/0</pre><p>&nbsp;</p><p>Now use the nova command to boot-up a cirros instance.  The nova command needs to know the id of the tenant-net.  I can get this with the neutron net-list command.</p><pre># neutron net-list
+--------------------------------------+-------------+-------------------------------------------------------+
| id                                   | name        | subnets                                               |
+--------------------------------------+-------------+-------------------------------------------------------+
| f8f04abf-dcba-46b7-9094-910e58530f0f | tenant-net  | 4a626740-7a14-443a-873d-d490132bbe10 10.0.0.0/24      |
| dbc40c3e-0175-4774-8b63-20896990c806 | homelan-net | 81f1eb33-0265-4d23-b668-d69b7a29c4b1 192.168.100.0/24 |
+--------------------------------------+-------------+-------------------------------------------------------+

# nova boot --flavor m1.tiny --image cirros 
       --nic net-id=f8f04abf-dcba-46b7-9094-910e58530f0f   
       --security-group default --key-name 080315-key cirros081315
#</pre><p>The new image, named  cirros081315, interfaces to the tenant-net network; it is allocated a DHCP-based address from the 10.0.0.0/24 pool.  The virtual machine needs to have it&#8217;s IP address mapped through the router to a floating IP address on  the homelan interface of the router.</p><p>The following commands allocates a floating IP address,  then the IP address gets associated with the cirros instance.</p><pre># neutron floatingip-create homelan-net
Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    |                                      |
| floating_ip_address | 192.168.100.71                       |
| floating_network_id | dbc40c3e-0175-4774-8b63-20896990c806 |
| id                  | f104ccad-7227-4bc8-8bc5-e74a9656cfd5 |
| port_id             |                                      |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 0487893a0cdb4ac18c8837f9e7e177ab     |
+---------------------+--------------------------------------+
<span style="color: #333333;"># nova floating-ip-associate cirros081315 192.168.100.71</span></pre><p>The new instance can be found in the OpenStack dashboard:</p><p><a href="http://jackkozik.com/wp-content/uploads/2015/08/AdminInstancesCIrros080415.png"><img class="alignleft size-full wp-image-5303" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/AdminInstancesCIrros080415.png" alt="AdminInstancesCIrros080415" width="878" height="99" /></a></p><p>&nbsp;</p><p>Login to the instance using the following:</p><pre>ssh -i 080315-key.key cirros@192.168.100.71</pre><p>Verify that  pings to  the internet work, verify ssh to other servers on the homelan. If you get this far, things are in pretty good shape.</p><h2>Spin-up a Fedora instance</h2><p><img class="aligncenter" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQRXGzljyUJy7n3TiZwe5SLnrq-q8WJnZlO4ur17OH72WfUcX8jIw" alt="" width="204" height="204" />With cirros working, I want to verify that I can import my usual image and spin it up.    And, I haven&#8217;t used Fedora 22 yet and this will give me a chance to see what&#8217;s changed.</p><p>The following commands imports a Fedora image, spins it up into instance, then using a floating IP address, maps the instance to my home LAN.</p><pre># glance image-list
+--------------------------------------+------------------------+
| ID                                   | Name                   |
+--------------------------------------+------------------------+
| 571a3d1f-afce-4e8b-b180-acf11903ada2 | cirros                 |
| e6c70bd3-dd5c-4687-ba5f-2bf6c6196b22 | Fedora 22 Cloud x86_64 |
+--------------------------------------+------------------------+

# nova boot --flavor m1.small --image "Fedora 22 Cloud x86_64" \
  --nic net-id=f8f04abf-dcba-46b7-9094-910e58530f0f \  
  --security-group default \
  --key-name 080315-key fedora22080315
# neutron floatingip-create homelan-net
Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    |                                      |
| floating_ip_address | 192.168.100.72                       |
| floating_network_id | dbc40c3e-0175-4774-8b63-20896990c806 |
| id                  | d23783fe-18bc-44b8-9ba6-299c7917046c |
| port_id             |                                      |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 0487893a0cdb4ac18c8837f9e7e177ab     |
+---------------------+--------------------------------------+
# nova floating-ip-associate fedora22080315  192.168.100.72</pre><p>Note that this new Fedora instance uses the same key-name and net-id as the cirros instance.  Login to the instance and verify connectivity:</p><pre># ssh -i 080315-key.key fedora@192.168.100.72
The authenticity of host '192.168.100.72 (192.168.100.72)' can't be established.
ECDSA key fingerprint is 1a:60:ef:e1:9b:f1:78:72:61:47:01:54:ab:21:6e:5d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.72' (ECDSA) to the list of known hosts.
$ ping yahoo.com
PING yahoo.com (206.190.36.45) 56(84) bytes of data.
64 bytes from ir1.fp.vip.gq1.yahoo.com (206.190.36.45): icmp_seq=1 ttl=47 time=107 ms
64 bytes from ir1.fp.vip.gq1.yahoo.com (206.190.36.45): icmp_seq=2 ttl=47 time=135 ms
64 bytes from ir1.fp.vip.gq1.yahoo.com (206.190.36.45): icmp_seq=3 ttl=47 time=120 ms
^C</pre><p>The OpenStack dashboard screen caps below show the Fedora and Cirros instances:</p><p>Project-&gt;Instances<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/08/ProjectsInstancesCirFed081415.png"><img class="alignleft size-full wp-image-5307" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/ProjectsInstancesCirFed081415.png" alt="ProjectsInstancesCirFed081415" width="802" height="287" /></a><br /> Projects-&gt;Network-&gt;Network Topology<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/08/ProjectsNetworkNTopology081415.png"><img class="alignleft size-full wp-image-5308" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/ProjectsNetworkNTopology081415.png" alt="ProjectsNetworkNTopology081415" width="519" height="636" /></a></p><div style="clear: both;"></div><h6>Web Server on Fedora 22</h6><p>Just to confirm end-to-end networking, the following steps setup a web server on the Fedora 22 instance.  Continuing from the Fedora ssh session above, run the following:</p><pre>$ sudo su -
# yum groupinstall "Web Server"
# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
# systemctl start  httpd.service</pre><p>The IP address for the Fedora instance is .72.  Go to another PC on the homelan and verify that the newly installed web server works. The default apache test page looks like the following:</p><p><a href="http://jackkozik.com/wp-content/uploads/2015/08/Apache081415.png"><img class="alignleft size-full wp-image-5309" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/08/Apache081415.png" alt="Apache081415" width="480" height="663" /></a></p><div style="clear: both;"></div><h2>Comments</h2><p>In my write-up here, I setup the networks, router, image, and instances using OpenStack command lines.  In past installations, I used the OpenStack dashboard.  This time around I took the extra effort to learn the command lines.   I would say that the web interface was easier and probably what I will use going forward.</p><p>For my records, and the potential benefit of others, here&#8217;s the entire sequence of commands all in one big gist:</p><script src="https://gist.github.com/8fd7ab71fe2a3e83842f.js"></script><h2>References</h2><ul><li><a href="https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture1">Diving into OpenStack Network Architecture &#8211; Part 2 &#8211; Basic Use Cases</a></li><li><a href="http://docs.openstack.org/juno/install-guide/install/yum/content/neutron-initial-networks.html">Create initial networks</a></li><li><a href="http://docs.openstack.org/juno/install-guide/install/yum/content/launch-instance-neutron.html">Launch an instance with OpenStack Networking (neutron)</a></li><li><a href="http://www.ksingh.co.in/blog/2015/07/12/deploying-openstack-kilo-using-rdo/">Deploying OpenStack KILO Using RDO</a></li><li><a href="http://community.redhat.com/blog/2015/01/rdo-quickstart-doing-the-neutron-dance/">RDO Quickstart: Doing the Neutron Dance</a></li></ul><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-kilo-home-network-part-2/">Openstack Kilo on home network &#8211; part 2</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/openstack-kilo-home-network-part-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>OpenStack Kilo on CENTOS7 using packstack on home server</title><link>http://jackkozik.com/openstack-kilo-centos7-using-rdos-packstack/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openstack-kilo-centos7-using-rdos-packstack</link> <comments>http://jackkozik.com/openstack-kilo-centos7-using-rdos-packstack/#comments</comments> <pubDate>Sat, 01 Aug 2015 16:10:34 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[2015]]></category> <category><![CDATA[cloud]]></category> <category><![CDATA[Home Computing]]></category> <category><![CDATA[Kilo]]></category> <category><![CDATA[Openstack]]></category><guid isPermaLink="false">http://jackkozik.com/?p=5261</guid> <description><![CDATA[<p>I have a home network server (with one NIC) that I dedicate to OpenStack testing. It is time for me to migrate to OpenStack Kilo on CENTOS7. As with my previous OpenStack setup, I am using the RDO community&#8217;s packstack tool. This note logs my experience, for my notes, and the potential benefit of others. [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-kilo-centos7-using-rdos-packstack/">OpenStack Kilo on CENTOS7 using packstack on home server</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>I have a home network server (with one NIC) that I dedicate to OpenStack testing. It is time for me to migrate to OpenStack Kilo on CENTOS7. As with my previous OpenStack setup, I am using the RDO community&#8217;s packstack tool. This note logs my experience, for my notes, and the potential benefit of others.</p><p>I generally followed the RDO Quickstart instructions, so chapeau to the community for laying out the steps for me.</p><h2>CENTOS7 with Static IP.</h2><p><a href="http://jackkozik.com/wp-content/uploads/2015/07/Centos7logo072215.jpeg"><img class="alignright size-full wp-image-5271" src="http://jackkozik.com/wp-content/uploads/2015/07/Centos7logo072215.jpeg" alt="Centos7logo072215" width="183" height="183" /></a>I picked CENTOS7 and did a bare-metal install usinga DVD I burned from the iso image named <code>CentOS-7-x86_64-LiveKDE-1503</code>.  I installed new disk partitions, reformatting my drives.</p><p>As I learned from previous packstack installs, the networking needs to be configured with a static IP address. This can be done at CENTOS7 install time.  Look for the &#8220;Networking &amp; Hosts&#8221; button. Click it. On the next screen, there will be an icon at the bottom right; click it and edit the interface: change it from DHCP to manual.</p><p>The following screen cap from CENTOS7 install gives  an idea of what I did.</p><p><a href="http://jackkozik.com/wp-content/uploads/2015/07/IMG_0887.jpg"><img class="alignleft size-full wp-image-5273" src="http://jackkozik.com/wp-content/uploads/2015/07/IMG_0887.jpg" alt="IMG_0887" width="900" height="675" /></a></p><p>&nbsp;</p><p>My passed Fedora/Centos install experience is to let the default DHCP networking  get installed, then manually change things to static IP address. Not this time; here, I found setting the static IP at install time was easier for me.</p><h2>Setup network, ssh, hosts and selinux</h2><h3>/etc/hosts and hostname</h3><p>The packstack scripts need the hosts file and the hostname setup correctly.</p><pre># hostnamectl set-hostname kozik4.lan
# vi /etc/hostname
kozik4.lan
# vi /etc/hosts
127.0.0.1 kozik4.lan kozik4 localhost.localdomain localhost
129.168.100.154 kozik4.lan kozik4</pre><h3>SELinux</h3><p>I turn SELinux to permissive mode ; edit a line in SElinux config file:</p><pre># setenforce permissive
# vi /etc/selinux/config
...
SELINUX=permissive
...</pre><h3>sshd for root login</h3><p>OpenStack’s install script requires root access for ssh login. To setup ssh:</p><pre># vi /etc/ssh/sshd_config
...
PermitRootLogin yes
...
# systemctl  enable sshd.service
# systemctl  start sshd.service</pre><p>When done with the install, I will turned off root login access.</p><h3>Network Manager</h3><p>Following the RDO Quickstart guide, turn off NetworkManager and turn on network</p><pre># systemctl stop NetworkManager.service
# systemctl disable NetworkManager.service
# systemctl enable network.service
# systemctl start network.service</pre><p>Then reboot. Make sure basic networking is running. Verify ssh for root login works.  Use another PC on the same LAN and verify ssh into the server works.</p><h2>Install OpenStack Kilo on CENTOS7</h2><p>In the root login, run the following steps. Make sure each one runs successfully before starting the next.</p><pre># yum update -y
# yum install -y https://rdoproject.org/repos/rdo-release.rpm
# yum install -y openstack-packstack</pre><p>At this point, I insert a work around that is specific to my setup. This particular CENTOS7 distribution pulls in mariaDB as part of KDE. I found that this created a conflict with the packstack scripts. As I documented <a href="http://jackkozik.com/openstack-rdo-packstack-kilo-install-stuck-centos-7-mariadb-conflict/">in a previous post</a>, uninstall mariaDB as follows.</p><pre># yum remove mariadb-server</pre><h3>Run packstack</h3><p>Now run the main install script, packstack. Note, I am adding orchestration in addition to the default install.</p><pre># packstack --allinone --os-heat-install=y</pre><p>Note that this last step is the big installation step. It runs for a long time, and if it fails, it will give detailed error messages and pointers to log files. If you run into troubles, apply workarounds and to re-try, run packstack with an answer file, as follows:</p><pre># packstack  --answer-file=packstack-answers-20150704-200908.txt</pre><p>Assuming the packstack install works, verify the basic dashboard works by bringing-up the login screen. For my home server, <code>http://192.168.100.154/dashboard</code>:</p><p><a href="http://jackkozik.com/wp-content/uploads/2015/07/OpenstackLogin072215.png"><img class="alignleft size-full wp-image-5268" src="http://jackkozik.com/wp-content/uploads/2015/07/OpenstackLogin072215.png" alt="OpenstackLogin072215" width="312" height="384" /></a></p><h3>Setup Bridging</h3><p>In order for the OpenStack VM to network with my home lan, I needed to get bridging setup. First, I made the br-ex bridge points to the IP address/gateway that I originally setup for the NIC (in CENTOS7, the NIC is assigned a name <code>enp3s0</code>).</p><p>I edited <code>ifcfg-br-ex</code> as follows:</p><pre># vi /etc/sysconfig/network-scripts/ifcfg-br-ex
DEVICE=br-ex
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=192.168.100.154
NETMASK=255.255.255.0
ONBOOT=yes
GATEWAY=192.168.100.162
DNS1=8.8.8.8
DNS2=8.8.4.4</pre><p>By default, the NIC (enp3s0) has the external IP address and gateway. Since we moved that to the external bridge, we need to make the NIC card look like a member of the bridge. I edited the <code>ifcfg-enp3s0</code> as follows:</p><pre># vi /etc/sysconfig/network-scripts/ifcfg-enp3s0
DEVICE="enp3s0"
ONBOOT=yes
HWADDR=40:16:7E:B1:64:CD
TYPE=OVSPort
DEVICETYPE="ovs"
OVS_BRIDGE="br-ex"</pre><p>At this point, I rebooted. When done, check everything. Verify ping to the Internet, verify the same, inbound. Verify ssh, both inbound and outbound.</p><p>For reference, I record my network setup here:</p><pre>[root@kozik4 ~]# ifconfig
br-ex: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 192.168.100.154  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::4216:7eff:feb1:64cd  prefixlen 64  scopeid 0x20
        ether 40:16:7e:b1:64:cd  txqueuelen 0  (Ethernet)
        RX packets 142320  bytes 27075628 (25.8 MiB)
        RX errors 0  dropped 15257  overruns 0  frame 0
        TX packets 3632  bytes 1435026 (1.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet6 fe80::4216:7eff:feb1:64cd  prefixlen 64  scopeid 0x20
        ether 40:16:7e:b1:64:cd  txqueuelen 1000  (Ethernet)
        RX packets 149724  bytes 27519634 (26.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4016  bytes 1460686 (1.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  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 2627327  bytes 289453679 (276.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2627327  bytes 289453679 (276.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
		
# ip route show
default via 192.168.100.162 dev br-ex
169.254.0.0/16 dev enp3s0  scope link  metric 1002
169.254.0.0/16 dev br-ex  scope link  metric 1004
192.168.100.0/24 dev br-ex  proto kernel  scope link  src 192.168.100.154</pre><h2>OpenStack Dashboard</h2><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/openstack-cloud-software.png"><img class="alignright size-full wp-image-4764" src="http://jackkozik.com/wp-content/uploads/2014/08/openstack-cloud-software.png" alt="openstack-cloud-software" width="206" height="195" /></a>The dashboard is found at <code>http://192.168.100.154/dashboard</code>. The User Name is <code>admin</code>, the password for the dashboard is found in the <code>/root/keystone_admin</code> file. By default, I was able to access the dashboard from any PC on my home lan. For access from outside of my home LAN, I setup a NAT mapping in my home gateway, but I had to setup an alias in the OpenStack horizon apache configuration.</p><pre># vi /etc/httpd/conf.d/15-horizon_vhost.conf
...
ServerName kozik4.lan
ServerAlias os.mydomain.net # Add this line
...
 
# systemctl restart httpd.service</pre><p>The name <code>os.mydomain.net</code> is a sub-domain name that I own, where I map it to the Internet routable IP address my ISP gives me. Verifiy that <code>http://os.mydomain.net/dashboard</code> works.</p><p>Once  logged in,  the dashboard shows the network setup that packstack installs for us by default.  It sets up a private and public networks IP addresses that don&#8217;t match my needs.  So I need to clear this out.   The way OpenStack works, you cannot delete everything in one hammer-style step; you need to disassemble the networking one step at a time.</p><p>First, you need to delete the router, then delete the networks.</p><h2>Remove the packstack default router and networks</h2><h3>Delete the pre-installed router</h3><p>This step deletes the default router that packstack setup for us. The dashboard gives a nice GUI to do this.  Navigate to Admin-&gt;Routers.</p><p>Admin-&gt;Routers<img class="alignnone" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/07/AdminRouters072215.jpg" alt="AdminRouters072215" width="669" height="219" /></p><p>Before we can delete router1, we need to delete its interfaces.  Click on &#8220;router1&#8243;</p><p>Admin-&gt;Routers-&gt;router1<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/07/AdminRouterDetails072215.jpg"><img class="alignleft size-full wp-image-5264" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/07/AdminRouterDetails072215.jpg" alt="AdminRouterDetails072215" width="663" height="346" /></a>Using he GUI, we can delete these two interfaces, and then we can delete the router.</p><p>But for my own education and the potential automation of future installs, I figured out how to do this with  OpenStack command line scripts.  The easiest way to display this is to screen scrape my putty commands and insert it inline below:</p><script src="https://gist.github.com/f4600f7fcf65fd294d59.js"></script><p>Go back to the dashboard Admin-&gt;Routers page, verify that the router has been cleared. I know, the command line steps are alot more difficult than clicking the &#8220;Delete Router&#8221; button, but this is how I learn.</p><p>Admin-&gt;Routers<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/07/AdminRouterEmpty072215.jpg"><img class="alignleft size-full wp-image-5265" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/07/AdminRouterEmpty072215.jpg" alt="AdminRouterEmpty072215" width="678" height="209" /></a></p><h3></h3><h3>Delete Pre-Installed Networks</h3><p>From the dashboard Admin-&gt;Networks. We want to delete the two networks packstack setup for us. In packstack (OpenStack?) terminology, the private network is the range of IP addresses used by the virtual machines used by the admin project within this OpenStack installation. The public network maps to the interface that routes packets to outside networks&#8230; in this case, the public network will eventually be assigned addresses that fit within my home lan (not Internet addressable IP address).</p><p>The Networks dashboard shows two networks. I want to remove them. It turns out you need to click on each of the networks and delete the subnets attached to the network.  On the dash board it is pretty easy to do.</p><p>Admin-&gt;Networks<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/07/AdminNetworks072215.jpg"><img class="alignleft size-full wp-image-5266" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/07/AdminNetworks072215.jpg" alt="AdminNetworks072215" width="682" height="303" /></a></p><p>&nbsp;</p><p>Here&#8217;s the command lines that will delete these two networks.  Note, again, I typed the commands into my putty screen, and scraped them and inserted them inline below.</p><script src="https://gist.github.com/bce7053044734a073249.js"></script><p>Verify that the Networks are gone in the dashboard.</p><p>Admin-&gt;Networks<br /> <a href="http://jackkozik.com/wp-content/uploads/2015/07/AdminNetworkEmpty072215.jpg"><img class="alignleft size-full wp-image-5267" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2015/07/AdminNetworkEmpty072215.jpg" alt="AdminNetworkEmpty072215" width="693" height="226" /></a></p><p>&nbsp;</p><p>Ok, to this point we have a clean slate ready to bring in images, spin up instances, and network them together.</p><h3>References</h3><ul><li><a href="https://www.rdoproject.org/Quickstart">RDO Quickstart</a></li><li><a href="https://www.rdoproject.org/Neutron_with_existing_external_network">Neutron with existing external network</a></li><li><a href="https://virtuallylg.wordpress.com/2015/04/07/openstack-juno-rdo-packstack-deployment-to-an-external-network-config-via-neutron-2/">Openstack Juno- RDO Packstack deployment to an external network &amp; config via Neutron</a></li><li><a href="http://www.flashguides.co.uk/guide/Installing_OpenStack_Kilo_on_CentOS_with_Packstack">Installing OpenStack Kilo RDO on CentOS With Packstack</a></li></ul><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-kilo-centos7-using-rdos-packstack/">OpenStack Kilo on CENTOS7 using packstack on home server</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/openstack-kilo-centos7-using-rdos-packstack/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Openstack RDO packstack Kilo install stuck on CENTOS 7 &#8211; MariaDB conflict</title><link>http://jackkozik.com/openstack-rdo-packstack-kilo-install-stuck-centos-7-mariadb-conflict/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openstack-rdo-packstack-kilo-install-stuck-centos-7-mariadb-conflict</link> <comments>http://jackkozik.com/openstack-rdo-packstack-kilo-install-stuck-centos-7-mariadb-conflict/#comments</comments> <pubDate>Mon, 06 Jul 2015 18:11:02 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Web Programming]]></category> <category><![CDATA[2015]]></category> <category><![CDATA[CENTOS7]]></category> <category><![CDATA[mariaDB]]></category> <category><![CDATA[Openstack]]></category> <category><![CDATA[RDO packstack Kilo]]></category><guid isPermaLink="false">http://jackkozik.com/?p=5254</guid> <description><![CDATA[<p>Background: I got stuck on RDO packstack Kilo install onto CENTOS7. I got some strange log entries I didn&#8217;t understand &#8211; I post the problem and the solution here for my records and maybe to help someone else. For my RDO packstack Kilo install setup, I followed the normal Quick Start  steps on a bare metal installed [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-rdo-packstack-kilo-install-stuck-centos-7-mariadb-conflict/">Openstack RDO packstack Kilo install stuck on CENTOS 7 &#8211; MariaDB conflict</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p><a href="http://jackkozik.com/wp-content/uploads/2015/07/kilologo.png"><img class="alignright size-full wp-image-5258" src="http://jackkozik.com/wp-content/uploads/2015/07/kilologo.png" alt="kilologo" width="176" height="70" /></a>Background: I got stuck on RDO packstack Kilo install onto CENTOS7. I got some strange log entries I didn&#8217;t understand &#8211; I post the problem and the solution here for my records and maybe to help someone else.</p><p>For my RDO packstack Kilo install setup, I followed the normal <a href="https://www.rdoproject.org/Quickstart">Quick Start</a>  steps on a bare metal installed version of CENTOS 7 (CentOS-7-x86_64-LiveKDE-1503).</p><p>I ran the following step in the install guide:</p><pre># packstack --allinone</pre><p>The packstack installed failed with the following error on the console:</p><pre>Error: Execution of '/usr/bin/rpm -e mariadb-server-5.5.41-2.el7_0.x86_64' returned 1: error: Failed dependencies:
You will find full trace in log /var/tmp/packstack/20150704-200908-</pre><p>This is an error pointing to the following log file entry:</p><pre>Error: Execution of '/usr/bin/rpm -e mariadb-server-5.5.41-2.el7_0.x86_64' returned 1: error: Failed dependencies:
        mariadb-server is needed by (installed) akonadi-mysql-1.9.2-4.el7.x86_64</pre><p>This is only my second install using packstack, and it is my first attempt at installing RDO packstack Kilo; so, I wasn&#8217;t familiar with the troubleshoot this kind of problem. It didn&#8217;t make sense to me that packstack would be trying to uninstall (rpm -e) MariaDB. The error indicates that the uninstall wouldn&#8217;t work because another package akonadi-mysql was using it &#8212; right? is that how I read this?  FYI:  <a href="https://en.wikipedia.org/wiki/Akonadi">Akonadi </a>is a storage service that runs under KDE&#8230; I wasn&#8217;t familiar with it.</p><p>Browsing the <a href="https://www.rdoproject.org/Workaround_archive">RDO Workaround archives</a> , I found a short article on this topic: <a href="https://www.rdoproject.org/Workaround_archive#Packstack_fails_when_mariadb-server_is_installed">Packstack fails when mariadb-server is installed</a>. The body of the article shows a log file message that is different enough from mine that I didn&#8217;t find it right away.</p><p>I tried the recommended fix to uninstall MariaDB and re-run RDO packstack Kilo:</p><pre># yum remove mariadb-server
# packstack  --answer-file=packstack-answers-20150704-200908.txt</pre><p>This fixed my problem!</p><p>I was able to run packstack to completion and bring up the openstack horizon dashboard. Note: I didn&#8217;t re-run packstack &#8211;allinone; I followed the packstack workflow requirement to re-run an install using the answer file previously generated.</p><p>Since the workaround was written for Juno and Fedora 20, I thought the fix was just a coincidence, but in reading the details, the original problem was triggered by installing KDE ontop of Fedora 20. Since I picked a KDE distribution of CENTOS7, maybe my problem and the original workaround write-up are related?!</p><p>Respectfully submitted,<br /> Jack</p><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-rdo-packstack-kilo-install-stuck-centos-7-mariadb-conflict/">Openstack RDO packstack Kilo install stuck on CENTOS 7 &#8211; MariaDB conflict</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/openstack-rdo-packstack-kilo-install-stuck-centos-7-mariadb-conflict/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Setting up Virtual Servers in Openstack environment</title><link>http://jackkozik.com/setting-virtual-servers-openstack-environment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-virtual-servers-openstack-environment</link> <comments>http://jackkozik.com/setting-virtual-servers-openstack-environment/#comments</comments> <pubDate>Tue, 27 Jan 2015 04:16:03 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[Openstack]]></category> <category><![CDATA[ProxyPass]]></category> <category><![CDATA[VirtualHost]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4961</guid> <description><![CDATA[<p>Background on Setting up Virtual Servers in Openstack environment: Once I got my Openstack environment setup, and I was able to create a couple of instances, I had to figure out the easiest way of managing IP Addresses and sub-domain names for web access to each of my instances. I needed web access to my [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/setting-virtual-servers-openstack-environment/">Setting up Virtual Servers in Openstack environment</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Background on Setting up Virtual Servers in Openstack environment: Once I got my Openstack environment setup, and I was able to create a couple of instances, I had to figure out the easiest way of managing IP Addresses and sub-domain names for web access to each of my instances.</p><p>I needed web access to my openstack host. I needed web access to each of my instances, which are running virtually on the same host. Further, since I am running all of this on one server in my home network, I need to somehow map all of this to one external IP address.</p><p>This is nothing too new to me. I have lots of vintages of Linux servers in my basement, and I sort of know the ropes around setting up NAT-ing, Virtual Servers, and proxies. My question was: what&#8217;s the best practice? What would be the easiest?</p><p>I couldn&#8217;t find anything directly on this (let me know if you have a reference). So here&#8217;s what I decided to do.</p><h3>Enable Openstack Dashboard Network Access</h3><p>By default, the Openstack Horizon Django configuration strictly controls who can get access. It&#8217;s roughly localhost only. For testing purposes, I went into the settings file and removed all restrictions:</p><pre>$ cd /etc/openstack-dashboard
$ vi local_settings
...
#ALLOWED_HOSTS = ['horizon.example.com', ]
ALLOWED_HOSTS = ['*']
ZZ
$ systemctl restart httpd.service</pre><p>I tried making a restrictive list, but it kept getting in my way. When done setting up, I will lock this up.</p><p>I then verified from a different PC in the same subnet that http://192.168.100.154/dashboard works.</p><h3>Map Openstack Host to External IP Address</h3><p>Using my home router, I configured an address mapping between port 80 and my Openstack host. Here&#8217;s the screen shot:</p><div id="attachment_4960" style="width: 614px" class="wp-caption alignnone"><a href="http://jackkozik.com/wp-content/uploads/2015/01/NetgearRouterPortForwarding012215.png"><img class="wp-image-4960 size-large" src="http://jackkozik.com/wp-content/uploads/2015/01/NetgearRouterPortForwarding012215-1024x103.png" alt="NetgearRouterPortForwarding012215" width="604" height="60" /></a><p class="wp-caption-text">Port Forwarding Table from my home router</p></div><p>Now verify that http://my.external.IP.address/dashboard works.</p><h3>Setup an Openstack Subdomain Name</h3><p>One of my domain names, jackkozik.net points to my home router&#8217;s IP address. I setup an Openstack subdomain name, using my zoneedit account &#8212; I used os.jackkozik.net. Sorry no screen shot. I am (perhaps too liberally) showing my domain name, but I am reluctant to show my IP addresses. Zoneedit is pretty quick, but distributing a new subdomain address takes anywhere from 0 to 60 minutes.</p><p>I then edit Openstack&#8217;s virtual server configuration adding os.jackkozik.net as a ServerAlias, as follows:</p><pre>$ cd /etc/httpd/conf.d
$ vi 15-horizon_vhost.conf
...
&lt;VirtualHost *:80&gt;
ServerName kozik4.lan
ServerAlias os.jackkozik.net # Add this line
...
ZZ
$ systemctl restart httpd.service</pre><p>Then assuming the subdomain has had a chance to get distributed, verify http://os.jackkozik.net/dashboard.</p><p>Openstack&#8217;s install scripts automatically setup this VirtualHost.</p><h3>Create Subdomains for Each of My Instances</h3><p>Within Openstack, I create instances that are automatically assigned IP addresses from a pool in the range of 192.168.100.100-119. Of course these instances are accessible from my home network (eg http://192.168.100.100 displays a nice Apache default screen). But I only have one external IP address and I need a mechanism to for external web access.</p><p>Absent any better approach (I hope to find one!), I am using Apache&#8217;s ProxyPass capability. I have used this for physical servers, why not use it for virtual machines?!</p><p>For starters, I created another subdomain in zoneedit. I decided to name each external instance with a letter followed by the least significant digits from the IP address. My first subdomain is named f100: That is, it is a Fedora instance and it&#8217;s running an instance mapped to 192.168.100.100. In zoneedit, I enter the subdomain f100.jackkozik.net, and I put the same external IP address that I used for os.jackkozik.net.</p><p>Within the Apache configuration files, I created a virtual server named f100.jackkozik.net, and used ProxyPass to map it to (redirect it to?) the web server running on 192.168.100.100. See the following config file:</p><pre>$ cd /etc/httpd/conf.d
$ vi openstackInstances_vhost.conf
# This file configures all the proxy modules:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
&lt;VirtualHost *:80&gt;
ServerName f100.jackkozik.net
ProxyPreserveHost On
ProxyPass / http://192.168.100.100/
ProxyPassReverse / http://192.168.100.100/
&lt;/VirtualHost&gt;
ZZ
$ systemctl restart httpd.service</pre><p>I created this file and put it in the conf.d directory. It automatically gets read whenever the apache web server starts.</p><p>From here, allowing enough time for zoneedit to work, I verified that http://f100.jackkozik.net worked from both my home network and from an outside network (I sometime use my desktop PC at work test this; more commonly I use the Chrome browser on my Android phone).</p><p>I edit this file for each new instance I setup.</p><p>So each of my instances think they are sitting on the internet, but really the Openstack host Apache server and my home network router&#8217;s NAT function are fooling it.</p><h3>Fix ALLOWED_HOSTS</h3><p>Finally, once I got everything working, I fixed ALLOWED_HOSTS to permit any traffic from my home subnet and only allow requests from URL os.jackkozik.net from the Internet. See following:</p><pre>$ cd /etc/openstack-dashboard
$ vi local_settings
...
ALLOWED_HOSTS = ['localhost', 'os.jackkozik.net', 'kozik4.lan', ]
#ALLOWED_HOSTS = ['*']
ZZ
$ systemctl restart httpd.service</pre><p>The post <a rel="nofollow" href="http://jackkozik.com/setting-virtual-servers-openstack-environment/">Setting up Virtual Servers in Openstack environment</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/setting-virtual-servers-openstack-environment/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Openstack Icehouse on home network &#8211; part 2</title><link>http://jackkozik.com/openstack-icehouse-on-home-network/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openstack-icehouse-on-home-network</link> <comments>http://jackkozik.com/openstack-icehouse-on-home-network/#comments</comments> <pubDate>Thu, 21 Aug 2014 17:55:59 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[2014]]></category> <category><![CDATA[Dashboard]]></category> <category><![CDATA[fedora]]></category> <category><![CDATA[Horizon]]></category> <category><![CDATA[Openstack]]></category> <category><![CDATA[packstack]]></category> <category><![CDATA[RDO]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4783</guid> <description><![CDATA[<p>In  my previous post titled OpenStack Icehouse on Fedora 20 using packstack on home PC, I list the steps I followed to install Openstack Icehouse on home network.  This was mostly working from the command line of the Openstack PC. This posting is part 2.  With the installation from part 1, I can now use the Openstack Dashboard. [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-icehouse-on-home-network/">Openstack Icehouse on home network &#8211; part 2</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p><span style="line-height: 1.5;">In </span><span style="line-height: 1.5;"> my previous post titled </span><em style="line-height: 1.5;"><a href="http://jackkozik.com/openstack-icehouse-on-fedorda-20-using-the-rdo-communities-packstack-on-my-home-network-server/">OpenStack Icehouse on Fedora 20 using packstack on home PC</a>, </em><span style="line-height: 1.5;">I list the steps I followed to install Openstack Icehouse on home network.  This was mostly working from the command line of the Openstack PC.</span></p><p>This posting is part 2.  With the installation from part 1, I can now use the Openstack Dashboard.  It is a nice web interface that contains straight forward menus.  In the sections below, I will show screen captures from a web browser connected to the Dashboard; I will also show some command line text from a putty window.</p><p>This writeup will show steps for setting up a public subnet that links Openstack to my home network and setting up a private subnet for my guest instances to use.  Then I will show how to create an instance using the bare-bones cirros image.  And finally, I&#8217;ll install into the image repository a Fedora 20 cloud image and spin it up with a basic web server.</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/NetworkTopology.png"><img class=" wp-image-4837 alignright" style="border: 1px solid black;" alt="NetworkTopology" src="http://jackkozik.com/wp-content/uploads/2014/08/NetworkTopology.png" width="323" height="165" /></a></p><p>Since Openstack and the Openstack Dashboard are new to me,  I do all of this with the generous help of the references listed below, especially recognizing Seth Jenning&#8217;s excellent  <a href="https://www.youtube.com/watch?v=GYTctLuPbOs">Openstack Icehouse on Fedora 20 using RDO</a> video.</p><h3>Create a public network.</h3><p>Starting with the Openstack Dashboard, logged in as admin, create a public network.  My home network is 192.168.100.0/24.  The IP address 192.168.100.163 is the address of my home router, gateway to the internet. My Openstack Icehouse host is 192.168.100.154.  And Openstack needs a subnet, referred to as public, that sits in this address range.</p><p>The naming convention of calling the network 192.168.100.0/24 public started with the packstack install scripts.  In the context of Openstack, this network is the one with a gateway to the internet and thus it is referred to as public, even though we know the internet defines 192.168.x.x IP addresses as private.</p><p><strong>Openstack Dashboard Menu:</strong> Admin-&gt;Networks-&gt;Create Network</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksCreateNetwork081514.png"><img class="alignleft  wp-image-4784" style="border: 1px solid black;" alt="AdminNetworksCreateNetwork081514" src="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksCreateNetwork081514.png" width="691" height="414" /></a></p><p><strong>Openstack Dashboard Menu:</strong> Admin-&gt;Networks-&gt;public-&gt;Create Subnet</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksPublicCreateSubnet1.png"><img class="alignleft  wp-image-4785" style="border: 1px solid black;" alt="AdminNetworksPublicCreateSubnet1" src="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksPublicCreateSubnet1.png" width="692" height="512" /></a></p><p><strong>Openstack Dashboard Menu:</strong> Admin-&gt;Networks-&gt;public-&gt;Create Subnet 2</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksPublicCreateSubnet2.png"><img class="alignleft  wp-image-4786" style="border: 1px solid black;" alt="AdminNetworksPublicCreateSubnet2" src="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksPublicCreateSubnet2.png" width="694" height="499" /></a></p><h3>Create a private subnet</h3><p>Next, create  a subnet that is private to the Openstack host.  The addresses must be different from the public_subnet.  These addresses will never leave the Openstack host and it&#8217;s underlying Open vSwitch network address space.   The references use 10.0.0.0/24 as the network and 10.0.0.1 as the gateway address &#8212; and that&#8217;s what I use below.  Further, the guest instances each need to be given an IP address, and 10.0.0.2, 10.0.0.20 address are what I choose to be the range for a DHCP address pool.</p><p><span style="line-height: 1.5;"><strong>Openstack Dashboard Menu:</strong> Project-&gt;Network-&gt;Network Topology-&gt;Create Network &#8212; &#8220;private&#8221;</span></p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectPublicNetworktopologyCreateNetwork1.png"><img class="alignleft  wp-image-4787" style="border: 1px solid black;" alt="ProjectPublicNetworktopologyCreateNetwork1" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectPublicNetworktopologyCreateNetwork1.png" width="694" height="307" /></a></p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Network-&gt;Network Topology-&gt;Create Network-&gt;Subnet</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworktopologyCreateNetwork2.png"><img class="alignleft  wp-image-4788" style="border: 1px solid black;" alt="ProjectNetworktopologyCreateNetwork2" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworktopologyCreateNetwork2.png" width="693" height="565" /></a></p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Network-&gt;Network Topology-&gt;Create Network-&gt;Subnet Details</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworktopologyCreateNetwork3.png"><img class="alignleft  wp-image-4789" style="border: 1px solid black;" alt="ProjectNetworktopologyCreateNetwork3" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworktopologyCreateNetwork3.png" width="691" height="497" /></a></p><h3>Create a router</h3><p>Ok, there&#8217;s a public and a private subnet defined.  Openstack Dashboard has a really simple way to connect them together with a router function.  Create a router, define a default gateway and then add interfaces to private subnets.</p><p><strong>Openstack Dashboard Menu:</strong> Projects-&gt;Network Topology-&gt;Create Router</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworktopologyCreateRouter.png"><img class="alignleft  wp-image-4790" style="border: 1px solid black;" alt="ProjectNetworktopologyCreateRouter" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworktopologyCreateRouter.png" width="690" height="195" /></a></p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Routers-&gt;Set Gateway</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/PorjectsRoutersSetGateway.png"><img class="alignleft  wp-image-4791" style="border: 1px solid black;" alt="PorjectsRoutersSetGateway" src="http://jackkozik.com/wp-content/uploads/2014/08/PorjectsRoutersSetGateway.png" width="692" height="329" /></a></p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Routers-&gt;router-&gt;Add Interface</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectRoutersRouterAddInterface.png"><img class="alignleft  wp-image-4792" style="border: 1px solid black;" alt="ProjectRoutersRouterAddInterface" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectRoutersRouterAddInterface.png" width="695" height="404" /></a></p><h3>Verify Network Topology</h3><p>All the steps upto this point were building a network into which virtual machines connect to the home LAN.  Run the Dashboard command below to see two subnets connect to a router.  The public subnet is on the home LAN.  The private subnet is the address space where the guests instances will connect.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Network Topology</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectsNetworkTopology.png"><img class="alignleft size-full wp-image-4793" style="border: 1px solid black;" alt="ProjectsNetworkTopology" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectsNetworkTopology.png" width="241" height="547" /></a></p><div style="clear: both;"></div><h3>Setup Security Group Rules</h3><p>The references suggest that for trial/learning purposes, the Security Group Rules should be wide open.  The idea is while learning the technology, the security settings can obscure basic setup issues.  In the long run, this needs to be managed more carefully.</p><p>First, remove the default rules that packstack setup, then install rules that permit incoming and outgoing TCP/UDP/ICMP &#8212; all ports.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Compute-&gt;Access and Security-&gt;default</p><p>Delete all the default rules and rebuild the rules so that the Security Group Rules table looks as follows:</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectComputeAccessSecurityDefaultAddRules.png"><img class="alignleft size-full wp-image-4797" alt="ProjectComputeAccessSecurityDefaultAddRules" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectComputeAccessSecurityDefaultAddRules.png" width="898" height="456" /></a></p><h3>Setup an ssh key pair</h3><p>Using the normal ssh tools, make an ssh public and private key pair.  The Openstack Dashboard lets you cut / paste your own public key into the project.  The instances that get created will have the  public key pre-installed into it.  To access instances that Openstack creates, use the private key as an option in an ssh command line.</p><p>Go to the root login of the Openstack host, at the command prompt create a key and copy the public key into the clipboard.</p><pre>[root@kozik4 ~]# ssh-keygen -t rsa -f cloud.key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in cloud.key.
Your public key has been saved in cloud.key.pub.
The key fingerprint is:
36:37:4d:d3:5b:82:45:53:48:98:24:00:8b:0b:3b:06 root@kozik4.lan
The key's randomart image is:
+--[ RSA 2048]----+
|      .......==o.|
|     . .   .o+.. |
|E . . .     + o .|
| . o .     o . + |
|  + .   S o . .  |
| . .   . o .     |
|                 |
|                 |
|                 |
+-----------------+
[root@kozik4 ~]# ls
anaconda-ks.cfg  ifconfig5.out         packstack-answers-20140803-201418.txt
cloud.key        installpackstack.log  packstack.log
cloud.key.pub    keystonerc_admin      rdorelease.log
ifconfig1.out    keystonerc_demo       runpackstack.log
ifconfig2.out    ovs1.out              yumupdate.log
ifconfig3.out    ovs2.out
ifconfig4.out    ovs3.out
[root@kozik4 ~]# cat cloud.key.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDijKn/k5ejNii3SaNugO75Njz1LQHyDDwI5blZO4+CZTRL/O/8czffrUUfK8+j3QjAx7MByNJVkj8YCGtOAYv5wCFEhzkRhqNNJlH235L++QV6ai/XPD7b0VcqhCjQTkDIfyBMp7fZO+D0BGdvTjBiQXIJdZLqZWV2j9qH8EHHS55OlOXpAAcMHvRRgWFtMdn5YSLUcq8X5HRtvfesLL7quJmNDc8/rS6mhmL/NFU56r+SJpHvr7N59U7ywNejLgFp6hfz4zZw3nWDH9y+by1zdWbNfATIO362SRue+FvuF060ss4Ciesuqw5v3tJMeyq9JM41lu8fQaIeBqoJTB43 root@kozik4.lan
[root@kozik4 ~]#</pre><p>In putty screen like the above example, select the text output from the &#8216;cat cloud.key.pub&#8217; command and paste into the Openstack Dashboard as follows.</p><p><strong>Openstack Dashboard Menu: </strong>Project-&gt;Access &amp; Security-&gt;Key Pairs-&gt;Import Key Pair</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectAccessSecurityImportKeyPair2.png"><img class="alignleft  wp-image-4801" style="border: 1px solid black;" alt="ProjectAccessSecurityImportKeyPair2" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectAccessSecurityImportKeyPair2.png" width="695" height="581" /></a></p><h3>Launch Test Instance &#8216;cirros&#8217; and assign floating IP</h3><p>To help verify that the Openstack packstack installed correctly, spin-up the barebones cirros image.  This image is a really small linux distribution.  I&#8217;ve never heard of cirros, but I get the purpose of it.  My initial setup had troubles, and cirros helped me trouble shoot basic setup problems.  I was glad the initial install pulled it in.</p><p>The following steps startup an instance, link it to the private subnet, and map the private IP address of the instance to a floating IP address on the public subnet.  <a href="http://docs.openstack.org/user-guide/content/Launching_Instances_using_Dashboard.html#add_floating_ip">Floating IP addresses </a>were new to me, and it wasn&#8217;t obvious how they should be used, at first.  I think of it as a generalized NATing function, that lets me hide my home network topology from the Openstack instances.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Images-&gt;Launch-&gt;Details</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectImagesLaunchDetails.png"><img class="alignleft  wp-image-4802" style="border: 1px solid black;" alt="ProjectImagesLaunchDetails" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectImagesLaunchDetails.png" width="694" height="636" /></a></p><p>Connect the instance to the private subnet.  Note: the web page below requires you to drag the private line and drop it into the Selected Networks cyan-colored bar.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Images-&gt;Launch-&gt;Networking</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectImagesLaunchNetworking.png"><img class="alignleft  wp-image-4803" style="border: 1px solid black;" alt="ProjectImagesLaunchNetworking" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectImagesLaunchNetworking.png" width="686" height="349" /></a></p><p>Verify the test instance is running:</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Instances</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstances.png"><img class="alignleft  wp-image-4804" style="border: 1px solid black;" alt="ProjectInstances" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstances.png" width="901" height="328" /></a></p><p>Allocate a Floating IP address</p><p><strong>Openstack Dashboard Menu:</strong> Projects-&gt;Access &amp; Security-&gt;Floating IPs-&gt;Allocate IP to Project</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectAccessSecurityFloatingIPAllocate.png"><img class="alignleft  wp-image-4806" style="border: 1px solid black;" alt="ProjectAccessSecurityFloatingIPAllocate" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectAccessSecurityFloatingIPAllocate.png" width="689" height="255" /></a></p><p>Associate the instance&#8217;s private IP address to an IP address on the public subnet.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Access &amp; Security-&gt;Floating IP-&gt;Associate</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectAccessSecurityFloatingIPManageFloatingAssociations.png"><img class="alignleft  wp-image-4807" style="border: 1px solid black;" alt="ProjectAccessSecurityFloatingIPManageFloatingAssociations" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectAccessSecurityFloatingIPManageFloatingAssociations.png" width="689" height="318" /></a></p><p>Verify that the instance has two IP addresses and is running ok.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Instance</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstanceswIP.png"><img class="alignleft  wp-image-4808" style="border: 1px solid black;" alt="ProjectInstanceswIP" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstanceswIP.png" width="909" height="321" /></a></p><p>Go back to the 192.168.100.154 host putty prompt (root login, home directory).  Verify that we can setup an ssh connection to the new instance. The default login id is cirros. The Instances web page above tells us to use the 192.168.100.101.</p><pre># ssh -i cloud.key cirros@192.168.100.101
The authenticity of host '192.168.100.101 (192.168.100.101)' can't be established.
RSA key fingerprint is 34:51:4c:22:c3:67:d3:47:38:83:c2:ee:55:0f:4b:e5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.101' (RSA) to the list of known hosts.

$ ifconfig
eth0      Link encap:Ethernet  HWaddr FA:16:3E:62:7D:36
          inet addr:10.0.0.3  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:fe62:7d36/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1

$ ping yahoo.com
PING yahoo.com (98.139.183.24): 56 data bytes
64 bytes from 98.139.183.24: seq=0 ttl=47 time=49.484 ms
64 bytes from 98.139.183.24: seq=1 ttl=47 time=121.366 ms
64 bytes from 98.139.183.24: seq=2 ttl=47 time=81.164 ms</pre><p>Note: the ifconfig shows that the instance only knows about the private_subnet address 10.0.0.3. Also, an important test to verify: check that the instance can access the internet, I used ping yahoo.com.</p><h3>Create a Fedora 20 instance</h3><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/f20-change.png"><img class=" wp-image-4775 alignright" alt="f20-change" src="http://jackkozik.com/wp-content/uploads/2014/08/f20-change.png" width="179" height="179" /></a>The cirros instance installation steps above helped to verify that basic functionality worked.  But cirros is not a linux distribution I want to use; I want to use the latest version of Fedora.  In this section I repeat some of the steps from the previous section to get a Fedora 20 instance started.  There&#8217;s enough different here that I wanted to document it.</p><p>From the <a href="http://fedoraproject.org/en/get-fedora#clouds">Fedora In the Cloud web page</a>, right click the 64-bit qcow2 image and &#8220;Copy Link Address.&#8221;  The Images page has an option to import new images using a URL.</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/FedoraProjectCloud.png"><img class="alignleft  wp-image-4813" style="border: 1px solid black;" alt="FedoraProjectCloud" src="http://jackkozik.com/wp-content/uploads/2014/08/FedoraProjectCloud.png" width="705" height="277" /></a></p><p>Create an image from this URL:</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Create Image</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectImageCreateImage.png"><img class="alignleft  wp-image-4812" style="border: 1px solid black;" alt="ProjectImageCreateImage" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectImageCreateImage.png" width="691" height="795" /></a></p><p>Following the same steps as the cirros image, launch the Fedora 20 image.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Instance-&gt;Launch Instance</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstancesLaunchInstanceFedora.png"><img class="alignleft  wp-image-4814" style="border: 1px solid black;" alt="ProjectInstancesLaunchInstanceFedora" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstancesLaunchInstanceFedora.png" width="694" height="637" /></a></p><p>Be sure to click the Networking tab and select private subnet, then click on Launch.</p><p>Once the instance is running, allocate a Floating IP.  Go to the Projects-&gt;Access &amp; Security-&gt;Floating IP menu. First run Allocate IP to Project then Manage Floating IP Associations for the Fedora 20 instance&#8230; just like we did for the cirros instance.</p><p>The Instance Dashboard page now shows 2 instances.</p><p><strong>Openstack Dashboard Menu:</strong> Project-&gt;Instance</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstanceswFedora.png"><img class="alignleft  wp-image-4815" style="border: 1px solid black;" alt="ProjectInstanceswFedora" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectInstanceswFedora.png" width="907" height="445" /></a></p><p>And the Network Topology page gives a nice picture of how everything is wired together.</p><p>Openstack Das<strong>hboard Menu:</strong>  Project-&gt;Network-&gt;Network Topology</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworkNetworkTopologyFedora.png"><img class="alignleft  wp-image-4816" style="border: 1px solid black;" alt="ProjectNetworkNetworkTopologyFedora" src="http://jackkozik.com/wp-content/uploads/2014/08/ProjectNetworkNetworkTopologyFedora.png" width="625" height="638" /></a></p><p>So, just like with cirros, go to the Openstack host root login  prompt and ssh to the Fedora instance.  The Instance page above show 192.168.100.102 as the IP address.</p><pre># ssh -i cloud.key fedora@192.168.100.102
The authenticity of host '192.168.100.102 (192.168.100.102)' can't be established.
RSA key fingerprint is 2e:b3:7b:6b:06:43:cf:d5:95:95:49:38:5f:ab:20:39.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.102' (RSA) to the list of known hosts.
[fedora@fedora-20 ~]$ ifconfig
eth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 10.0.0.4  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::f816:3eff:fe9b:baf5  prefixlen 64  scopeid 0x20																					<link />
        ether fa:16:3e:9b:ba:f5  txqueuelen 1000  (Ethernet)

lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)

[fedora@fedora-20 ~]$ ping yahoo.com
PING yahoo.com (206.190.36.45) 56(84) bytes of data.
64 bytes from ir1.fp.vip.gq1.yahoo.com (206.190.36.45): icmp_seq=1 ttl=49 time=1         06 ms
64 bytes from ir1.fp.vip.gq1.yahoo.com (206.190.36.45): icmp_seq=2 ttl=49 time=1         56 ms
64 bytes from ir1.fp.vip.gq1.yahoo.com (206.190.36.45): icmp_seq=3 ttl=49 time=1         02 ms</pre><p>Note:  the Fedora guest instance only knows the private address 10.0.0.4.  The default login id, fedora, has sudo permissions and access to the root login is done with a &#8216;sudo su -&#8217; command. It is important also to verify that it can talk to the outside world, and thus verify that ping yahoo.com works.</p><p>To further test my Fedora 20 instance, I switched over to the Fedora 20 instance root login and installed apache:</p><pre>[fedora@fedora-20 ~]$ sudo su -
[root@fedora-20 ~]# yum groupinstall "Web Server"
[root@fedora-20 ~]# systemctl enable httpd.service
[root@fedora-20 ~]# systemctl start  httpd.service</pre><p>From here, I go to another PC in my home network and verify that the default web server works.</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/ApacheDefaultWebPage.png"><img class="alignleft  wp-image-4819" style="border: 1px solid black;" alt="ApacheDefaultWebPage" src="http://jackkozik.com/wp-content/uploads/2014/08/ApacheDefaultWebPage.png" width="714" height="534" /></a></p><h3>References</h3><ul><li><a href="https://www.youtube.com/watch?v=GYTctLuPbOs">Openstack Icehouse on Fedora 20 using RDO</a></li><li><a href="http://openstack.redhat.com/Quickstart">RDO Quickstart</a></li><li><a href="http://fedoraproject.org/get-fedora#clouds">Fedora in the Cloud</a></li><li><a href="http://openstack.redhat.com/Running_an_instance">Running an Instance</a></li><li><a href="http://openstack.redhat.com/Difference_between_Floating_IP_and_private_IP">Difference between Floating IP and private IP</a></li><li><a href="http://www.marcoberube.com/archives/76">My RDO Installation Procedure</a></li><li><a href="http://theruddyduck.typepad.com/theruddyduck/2014/02/install-and-ccnfigure-openstack-neutron.html">Install and Configure Openstack Neutron</a></li><li><a href="http://allthingsopen.com/2013/08/23/openstack-packstack-installation-with-external-connectivity/">Openstack Packstack with External Connectivity</a></li></ul><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-icehouse-on-home-network/">Openstack Icehouse on home network &#8211; part 2</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/openstack-icehouse-on-home-network/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>OpenStack Icehouse on Fedora 20 using packstack on home PC</title><link>http://jackkozik.com/openstack-icehouse-on-fedorda-20-using-the-rdo-communities-packstack-on-my-home-network-server/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openstack-icehouse-on-fedorda-20-using-the-rdo-communities-packstack-on-my-home-network-server</link> <comments>http://jackkozik.com/openstack-icehouse-on-fedorda-20-using-the-rdo-communities-packstack-on-my-home-network-server/#comments</comments> <pubDate>Thu, 14 Aug 2014 21:15:38 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[Fedora 20]]></category> <category><![CDATA[Icehouse]]></category> <category><![CDATA[Openstack]]></category> <category><![CDATA[RDO]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4758</guid> <description><![CDATA[<p>Inspired by the RDO quickstart howto page, I record here the steps I followed to setup OpenStack Icehouse on Fedora 20 on my home server. Install Fedora 20 I have been using Fedora/Redhat for years, but the most recent install I did was Fedora 16, so I am a little out of date with the new [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-icehouse-on-fedorda-20-using-the-rdo-communities-packstack-on-my-home-network-server/">OpenStack Icehouse on Fedora 20 using packstack on home PC</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p><span style="line-height: 1.5;">Inspired by the <a href="http://openstack.redhat.com/Quickstart">RDO quickstart howto page</a>, I record here the steps I followed to setup OpenStack Icehouse on Fedora 20 on my home server.</span></p><h3>Install Fedora 20</h3><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/f20-change.png"><img class=" wp-image-4775 alignright" alt="f20-change" src="http://jackkozik.com/wp-content/uploads/2014/08/f20-change.png" width="205" height="205" /></a>I have been using Fedora/Redhat for years, but the most recent install I did was Fedora 16, so I am a little out of date with the new processes and procedures. For me, my first step was to go to the Fedora distribution page and down load an ISO to make an install DVD (I selected the <a href="http://download.fedoraproject.org/pub/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso">Fedora 20 Desktop Edition Live Media</a>).</p><p><span style="line-height: 1.5;">My hardware was brand new, and I installed Fedora 20 onto a 2T RAID Intel PC box. I let the Fedora installer format my disks to the default settings. I configured a login and timezone and let the install run. Everything worked the first time.</span></p><p>The next couple of steps I follow by sitting infront of the console for my PC. I usually do everything through ssh and/or VNC, but for Openstack setup, I stayed at the console.</p><h3>Prep for Openstack Icehouse on Fedora 20: Static IP, /etc/hosts, sshd, NetworkManager</h3><h4>Static IP Address</h4><p>The Fedora install configures the host  to use DHCP to get the initial IP address. The host needs a static IP for Openstack setup to work.  The default  network-scripts for the main host interface are easily edited. For my install, the  interface is named p2p1 (in the old days this would be named eth0).</p><p>Configure the ifcfg-p2p1 script to look something like the following:</p><pre><code>
# vi /etc/sysconfig/network-scripts/ifcfg-p2p1
TYPE="Ethernet"
BOOTPROTO=static
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="p2p1"
UUID="42a635ee-281c-44fc-9e16-f4e23111d4fb"
ONBOOT="yes"
HWADDR=40:16:7E:B1:64:CD
IPADDR=192.168.100.154
PREFIX=24
GATEWAY=192.168.100.163
DNS1=8.8.8.8
DNS2=192.168.100.163
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
</code></pre><p>Note: the host&#8217;s IP address and its gateway IP address are inside my private IP address range (192.168.100.0/24). I will use these addresses throughout my write-up.</p><p>Before I reboot, I want to change a couple of other host configurations.</p><h4>/etc/hosts and hostname</h4><p>It turns hostname must be setup right or the packstack script will get stuck.</p><pre><code>
# hostname kozik4.lan
# vi /etc/hostname
kozik4.lan
# vi /etc/hosts
127.0.0.1 kozik4.lan kozik4 localhost.localdomain localhost
129.168.100.154 kozik4.lan kozik4
</code></pre><p>Note: .lan is my home network private domain name. I don&#8217;t share .lan publically.</p><h4>SELinux</h4><p>I turn off SELinux; edit a line in SElinux config file:</p><pre><code>
# setenforce permissive
# vi /etc/selinux/config
...
SELINUX=permissive
...
</code></pre><h4>sshd for root</h4><p>Openstack&#8217;s install script requires root access for ssh login. To setup ssh:</p><pre><code>
# vi /etc/ssh/sshd_config
...
PermitRootLogin yes
...
# systemctl  enable sshd.service
# systemctl  start sshd.service
</code></pre><h4>firewalld and NetworkManager</h4><p>Disable firewalld and NetworkManager as recommended in several of the references.</p><pre><code>
systemctl disable firewalld

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
systemctl enable network.service
systemctl start network.service
</code></pre><p>From here,  reboot. Everything should come back ok. Nothing really changed except switching from dynamic to static IP addressing.  Verify from another PC that ssh root@192.168.100.154 works. Verify that ping yahoo.com works.</p><p>For reference, ifconfig looks like this:</p><pre><code>
# ifconfig
lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)

p2p1: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 192.168.100.154  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::4216:7eff:feb1:64cd  prefixlen 64  scopeid 0x20																				<link />
        ether 40:16:7e:b1:64:cd  txqueuelen 1000  (Ethernet)
</code></pre><h3>Install/update Openstack software</h3><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/RDOlogo.jpe"><img class="alignleft size-full wp-image-4765" alt="RDOlogo" src="http://jackkozik.com/wp-content/uploads/2014/08/RDOlogo.jpe" width="160" height="160" /></a></p><div style="clear: both;"></div><p>From the host&#8217;s root login at /root, run each of the following yum installs, one at a time, verifying that they complete successfully.</p><pre><code>
yum update -y
yum install -y http://rdo.fedorapeople.org/rdo-release.rpm
yum install -y openstack-packstack 
packstack --allinone --provision-all-in-one-ovs-bridge=n
</code></pre><p>The last install is the big one.  The packstack script is what puts OpenStack Icehouse on Fedora 20; It will take awhile to run.</p><p>It took me a couple of tries to get the last step to work. The hostname must cleanly resolve for the packstack scripts to work. Further, the packstack scripts runs ssh root@192.168.100.154. If this is not setup right, packstack will fail. Note: the packstack script prompts you for your root password.</p><h3>Setup Open vSwitch Bridging</h3><p>Once done, the packstack scripts sets up an <a href="http://openvswitch.org/">Open vSwitch </a>network as summarized here.</p><pre><code>
# ifconfig
br-ex: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet6 fe80::3442:c4ff:fe5c:874b  prefixlen 64  scopeid 0x20																				<link />
        ether 36:42:c4:5c:87:4b  txqueuelen 0  (Ethernet)

br-int: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet6 fe80::a817:aff:fee8:934c  prefixlen 64  scopeid 0x20																				<link />
        ether aa:17:0a:e8:93:4c  txqueuelen 0  (Ethernet)

lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)

p2p1: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 192.168.100.154  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::4216:7eff:feb1:64cd  prefixlen 64  scopeid 0x20																				<link />
        ether 40:16:7e:b1:64:cd  txqueuelen 1000  (Ethernet)
</code></pre><p><span style="line-height: 1.5;">It turns out that this setup does not connect with the outside world &#8212; the default install scripts don&#8217;t have a place for me to tell it my home network setup (that I know of). The br-ex needs to connect to the outside world and p2p1 needs to connect to br-ex.</span></p><p>There&#8217;s some discussion in RDO community to make it easier for novices like me to connect the packstack install to a home network&#8217;s subnet. But for now, there&#8217;s a few simple steps to follow to get  the PC&#8217;s main interface to connect to the Open vSwitch infrastructure setup by packstack.</p><p>For starters, connect the external bridge (named br-ex) to the home network,  by editing the br-ex config file that packstack creates:</p><pre><code>
# vi /etc/sysconfig/network-scripts/ifcfg-br-ex
DEVICE=br-ex
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=192.168.100.154
NETMASK=255.255.255.0
GATEWAY=192.168.100.163
DNS1=8.8.8.8
ONBOOT=yes
</code></pre><p>Note: the br-ex bridge has the IP address and GATEWAY address that I would normally use to access the PC.</p><p>And, the host&#8217;s interface p2p1 needs to be updated to become Open vSwitch aware, editting the ifcfg-p2p1 file to look like the following:</p><pre><code>
# vi /etc/sysconfig/network-scripts/ifcfg-p2p1
DEVICE=p2p1
ONBOOT="yes"
HWADDR="40:16:7E:B1:64:CD"
TYPE="OVSPort"
DEVICETYPE="ovs"
OVS_BRIDGE="br-ex"
</code></pre><p>And one more thing, the openstack dashboard access is limited to localhost only.  Remove this access control, for now.</p><pre><code>
# vi /etc/openstack-dashboard/local_settings
#ALLOWED_HOSTS = ['192.168.100.154', 'kozik4.lan', 'localhost', ]
ALLOWED_HOSTS = ['*', ]
</code></pre><p>From here, reboot. When the computer comes back up,  verify that basic network looks good. Here&#8217;s what ifconfig looks like:</p><pre><code>
# ifconfig
br-ex: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 192.168.100.154  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::4216:7eff:feb1:64cd  prefixlen 64  scopeid 0x20																				<link />
        ether 40:16:7e:b1:64:cd  txqueuelen 0  (Ethernet)

lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)

p2p1: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet6 fe80::4216:7eff:feb1:64cd  prefixlen 64  scopeid 0x20																				<link />
        ether 40:16:7e:b1:64:cd  txqueuelen 1000  (Ethernet)
# ovs-vsctl list-ports br-ex
p2p1
</code></pre><p>Above, verify that  the host&#8217;s IP address is tied to br-ex and the interface p2p1 shows as a port on br-ex. These look good. Also verify that ssh root@192.168.100.154 works; then go to another PC and run the same command. Finally, to make sure that the host can route to the internet, ping yahoo.com. These basic plumbing tests are needed for the rest of openstack to work, and in my case, it didn&#8217;t work the first time, and these basic sanity tests helped me troubleshoot.</p><p>A stuck point for me:  when I reached this point one time before, I couldn&#8217;t ping yahoo.com.  Which was disappointing because everything else worked.  So I ran the following command:</p><pre><code># ip route show
default via 192.168.100.163 dev br-ex  # Verify this line is here!!
169.254.0.0/16 dev p2p1  scope link  metric 1002
169.254.0.0/16 dev br-ex  scope link  metric 1004
169.254.0.0/16 dev br-int  scope link  metric 1005
192.168.100.0/24 dev br-ex  proto kernel  scope link  src 192.168.100.154
</code></pre><p>Unlike what I list above, the default route didn&#8217;t get configured for my host&#8217;s network.  I found some helpful notes that suggested manually adding it in (ip route add default via&#8230;).  That worked, but what worked better for me was to disable NetworkManager (see steps I list earlier).</p><p>As an aside, the ip route show output above works for me, but doesn&#8217;t look right.  The lines that begin with 169.254.0.0 shouldn&#8217;t be there (I think).  Something is not quite right, but I don&#8217;t know if it is worth fixing.  Anyway&#8230;</p><p>What I get now, is every time I boot, I get a clean network setup, incoming and outgoing.</p><p>Ok, once the PC&#8217;s network setup is stable after boot,  run the openstack-status script; the script returns a long list of status lines and two key lines indicate a failed status.</p><pre><code>
# openstack-status
...
neutron-server:                         failed
rabbitmq-server:                        failed
...
</code></pre><p>For whatever reason (probably some fault in my setup steps), rabbitmq and neutron servers failed to start. I saw this issue addressed in the video referenced below; these services are easily restarted as shown below</p><pre><code>
systemctl start rabbitmq-server.service
systemctl start neutron-server.service
</code></pre><p>&#8230; everything comes back and the next steps work fine.</p><h3>Openstack Dashboard</h3><p>As a last step, go to a web browser and verify that you can login to the openstack dashboard. Once this step works, you should be able to do everything from a web browser or Putty terminal.</p><p>The dashboard is found at http://192.168.100.154/dashboard. The User Name is admin, the password for the dashboard is found in the keystone_admin file.  Once you can login, then installing OpenStack Icehouse on Fedora 20 is complete.</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/OSHorizonLogin080514.png"><img class="alignleft size-full wp-image-4762" alt="OSHorizonLogin080514" src="http://jackkozik.com/wp-content/uploads/2014/08/OSHorizonLogin080514.png" width="414" height="469" /></a></p><div style="clear: both;"></div><p>Once we are logged in, we need to navigate to the Admin-&gt;Routers page and delete the default router that packstack setup for us, select all the routers (only one) and then click on the &#8220;Delete Routers&#8221; button below:</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/AdminRoutersDelete080614.png"><img class="alignleft  wp-image-4772" style="border: 1px solid black;" alt="AdminRoutersDelete080614" src="http://jackkozik.com/wp-content/uploads/2014/08/AdminRoutersDelete080614.png" width="619" height="222" /></a></p><p>Then we need to go to the Admin-&gt;Networks page and delete the networks.  Select all the Networks, then click on the &#8220;Delete Networks&#8221; button below:</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksDelete080614.png"><img class="alignleft  wp-image-4773" style="border: 1px solid black;" alt="AdminNetworksDelete080614" src="http://jackkozik.com/wp-content/uploads/2014/08/AdminNetworksDelete080614.png" width="621" height="352" /></a></p><p><span style="line-height: 1.5;">With the demo network and router setup re-initialized,  we have a clean slate that we can build upon.</span></p><p>End of part 1.  I next need to writeup the steps to configure a OpenStack, including how to load images, create instances, network those instances together, and bridge them to the home network.  In addition, I will writeup how to map a &#8220;floating IP address&#8221; between an instance and my home network.   All for next time.</p><h3>References</h3><ul><li><a href="https://www.youtube.com/watch?v=GYTctLuPbOs">Openstack Icehouse on Fedora 20 using RDO</a></li><li><a href="http://openstack.redhat.com/Quickstart">RDO Quickstart</a></li><li><a href="https://ask.openstack.org/en/question/24719/how-to-install-packstack-allinone-on-fedora-20-with-an-existing-external-network/">How To: install packstack allinone on Fedora 20 with an existing external network </a></li><li><a href="http://openstack.redhat.com/Fedora_20_with_existing_network">Fedora 20 with existing network</a></li><li><a href="http://allthingsopen.com/2013/08/23/openstack-packstack-installation-with-external-connectivity/">OPENSTACK PACKSTACK INSTALLATION WITH EXTERNAL CONNECTIVITY</a></li><li><a href="https://www.youtube.com/watch?v=8zFQG5mKwPk">RDO Icehouse: Configuring the external bridge</a></li></ul><p>The post <a rel="nofollow" href="http://jackkozik.com/openstack-icehouse-on-fedorda-20-using-the-rdo-communities-packstack-on-my-home-network-server/">OpenStack Icehouse on Fedora 20 using packstack on home PC</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/openstack-icehouse-on-fedorda-20-using-the-rdo-communities-packstack-on-my-home-network-server/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Audi Connected Car &#8211; 2014 S7</title><link>http://jackkozik.com/audi-connected-car-2014-s7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=audi-connected-car-2014-s7</link> <comments>http://jackkozik.com/audi-connected-car-2014-s7/#comments</comments> <pubDate>Sun, 15 Jun 2014 16:53:13 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[2014]]></category> <category><![CDATA[Audi]]></category> <category><![CDATA[Audi Connect]]></category> <category><![CDATA[Audi S7]]></category> <category><![CDATA[Connected Car]]></category> <category><![CDATA[T-Mobile US]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4841</guid> <description><![CDATA[<p>My Audi Connected Car is a 2014 S7.  I got it the beginning of June, and I have been learning how to use the Audi Connect service. In my Audi S7, it has a T-Mobile SIM card, connecting it to the T-Mobile US 3G/UMTS network &#8211; the first 6 months of usage is free.  I have turned [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/audi-connected-car-2014-s7/">Audi Connected Car &#8211; 2014 S7</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>My Audi Connected Car is a 2014 S7.  I got it the beginning of June, and I have been learning how to use the Audi Connect service.</p><div id="attachment_4936" style="width: 160px" class="wp-caption alignright"><a href="http://jackkozik.com/wp-content/uploads/2014/09/TMOSIM2a.png"><img class="wp-image-4936" src="http://jackkozik.com/wp-content/uploads/2014/09/TMOSIM2a-300x185.png" alt="TMOSIM2a" width="150" height="93" /></a><p class="wp-caption-text">SIM Card</p></div><p>In my Audi S7, it has a T-Mobile SIM card, connecting it to the T-Mobile US 3G/UMTS network &#8211; the first 6 months of usage is free.  I have turned on the Audi Connect service, linked it with my Google account, linked it with the iPhone App.  I even turned on the Wifi hotspot in my car.  It all works pretty good.  My T-Mobile service is data-only &#8212; I see no way to use the TMO voice or text features.</p><p>Here are my notes.</p><h3>Audi Connect iPhone App</h3><p><a style="color: #ea9629; text-decoration: underline; outline: #000000;" href="http://jackkozik.com/wp-content/uploads/2014/08/AudiConnectiPhoneLogoCrop082614.png"><img class="wp-image-4842 alignright" src="http://jackkozik.com/wp-content/uploads/2014/08/AudiConnectiPhoneLogoCrop082614.png" alt="AudiConnectiPhoneLogoCrop082614" width="154" height="154" /></a></p><p>The Audi S7 has a simple iPhone App.  Two useful features:</p><ul><li><strong>Online Destinations.</strong> I can enter addresses onto an Online Destinations form; these addresses will show-up on my Audi S7&#8242;s navigation menu.</li><li><strong>Car Finder.</strong>  I setup the Audi S7 to report it&#8217;s GPS coordinates when ever the car shuts off.  The Car Finder feature lets me find where my car is parked.  This is a nice feature, but a little gimmicky for me. You could also <a title="find vin for free" href="https://www.justcarchecks.co.uk/find-vin-for-free/">find vin for free</a> here.</li></ul><div id="attachment_4843" style="width: 170px" class="wp-caption aligncenter"><a href="http://jackkozik.com/wp-content/uploads/2014/08/CarFinderShrink082614.png"><img class="wp-image-4843 size-full" src="http://jackkozik.com/wp-content/uploads/2014/08/CarFinderShrink082614.png" alt="CarFinderShrink082614" width="160" height="284" /></a><p class="wp-caption-text">Car Finder App</p></div><div style="clear: both;"></div><h3>Google Maps &#8211; &#8220;Save to Car&#8221;</h3><p>The Audi Connect service also ties into Google Maps.  When I registered my google login with Audi Connect (my.audi.com, Services -&gt; Dest From Google Maps), Google maps added an option to let me save a map address to my car.  Here&#8217;s a Google Maps screen shot:</p><div id="attachment_4844" style="width: 596px" class="wp-caption alignleft"><a href="http://jackkozik.com/wp-content/uploads/2014/08/GoogleMapsSaveToCar082614.png"><img class="wp-image-4844 size-full" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2014/08/GoogleMapsSaveToCar082614.png" alt="GoogleMapsSaveToCar082614" width="586" height="216" /></a><p class="wp-caption-text">http://maps.google.com</p></div><div style="clear: both;"></div><p>So if I am going to visit some place new to me, I can look up the address on Google Maps, save it with the &#8220;Send to Car&#8221; option and have the address show on a menu in the Audi S7 Navigation menu.  Really cool.  I like this feature.</p><p>I can erase saved destinations using the mobile app.</p><h3>myAudi Portal &#8211; my.audi.com</h3><p>To setup the Audi Connected Car service, I got a login on the myAudi portal, <a href="http://my.audi.com">my.audi.com</a>. The portal helped me setup the Destination From Google Maps and Destination Input Services.  The portal required me to enter my VIN number, and it gave me a key to use when setting up the car.</p><p>Here&#8217;s a snapshot from the portal:</p><div id="attachment_4847" style="width: 526px" class="wp-caption alignleft"><a href="http://jackkozik.com/wp-content/uploads/2014/08/MyAudiCom082714.png"><img class="wp-image-4847" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2014/08/MyAudiCom082714.png" alt="MyAudiCom082714" width="516" height="375" /></a><p class="wp-caption-text">http://my.audi.com</p></div><p>&nbsp;</p><p>&nbsp;</p><h3>Audi Connect</h3><p><a href="http://jackkozik.com/wp-content/uploads/2014/09/audiconnect091714.jpg"><img class="alignright wp-image-4951 size-full" style="border: 1px solid black;" src="http://jackkozik.com/wp-content/uploads/2014/09/audiconnect091714.jpg" alt="audiconnect091714" width="175" height="37" /></a> The <a href="https://www.myaudiconnect.com">MyAudiConnect </a>website links the Audi&#8217;s TMO service to the <a href="http://my.audi.com/">myAudi </a>service.  The key parameters are the 19-20 characters printed on the SIM card (technically known as an ICCID &#8212; see the <a href="http://en.wikipedia.org/wiki/Subscriber_identity_module">SIM wiki)</a> and the car&#8217;s 17 character VIN number.     The Audi Connect Car uses T-Mobile.  The My Audi Connect portal&#8217;s drop-down menu also lets you choose AT&amp;T.</p><p>As near as I can tell, I will never get a bill directly from T-Mobile.  It appears to come from Audi &#8212; but I am sure T-Mobile is getting paid.</p><div id="attachment_4945" style="width: 614px" class="wp-caption alignleft"><a href="http://jackkozik.com/wp-content/uploads/2014/09/tmoaudiconnect1.jpg"><img class="size-large wp-image-4945" src="http://jackkozik.com/wp-content/uploads/2014/09/tmoaudiconnect1-1024x523.jpg" alt="https://myaudiconnect.com" width="604" height="308" /></a><p class="wp-caption-text">https://myaudiconnect.com</p></div><p>The screenshot above indicates that my Account is active, but my Audi Connect and Wireless Networks are inactive &#8212; that&#8217;s correct, the car is parked, off, in my driveway. Also, it is hard to read, but the two airbrushed-out fields above are the car&#8217;s VIN number and the T-Mobile SIM card number.   Sorry if I got carried away with the red stuff.</p><h3>Dashboard View</h3><p>The view from the dashboard in the car is pretty intuitive.  When in the Navigation mode, the following screen displays when you selection &#8220;Destinations&#8221;</p><div id="attachment_4857" style="width: 614px" class="wp-caption alignleft"><a href="http://jackkozik.com/wp-content/uploads/2014/09/AudiConnectedCarDashboarda090514.jpg"><img class="wp-image-4857 size-large" src="http://jackkozik.com/wp-content/uploads/2014/09/AudiConnectedCarDashboarda090514-1024x606.jpg" alt="AudiConnectedCarDashboarda090514" width="604" height="357" /></a><p class="wp-caption-text">Navigation-&gt;Destination-&gt;Online destinations</p></div><p>The display shows an &#8220;Online destination&#8221; option and from there, the destinations that you set using the Google Maps &#8220;Send to Car&#8221; option are found.</p><p>A nice feature of the Audi Connected Car is the navigation  view superimposes satellite maps from Google Maps, as seen below:</p><div id="attachment_4938" style="width: 481px" class="wp-caption alignleft"><a href="http://jackkozik.com/wp-content/uploads/2014/09/SatelliteMap.jpg"><img class="wp-image-4938 size-full" src="http://jackkozik.com/wp-content/uploads/2014/09/SatelliteMap.jpg" alt="SatelliteMap" width="471" height="282" /></a><p class="wp-caption-text">Navigation Map w/Satellite View</p></div><div style="clear: both;"></div><p>Some additional Google Maps features of note:</p><ul><li>Google Search.  The traditional in-car Navigation systems have a very good database of point-of-interests and street address.  The Audi Connected Car lets you use a direct Google search to find nearby or destination-city destinations.</li><li>The Google Maps display settings let you put Places, Businesses, Panoramio pictures, or even pointers to WIKipedia</li></ul><p>Below are screen shots directly from Audi Connect information services.  First there&#8217;s a menu of simple services (not linked with Google), and below that is a screen capture of a radar weather map.  The content is formatted special for Audi and is not real websurfing.</p><div id="attachment_4954" style="width: 614px" class="wp-caption alignnone"><a href="http://jackkozik.com/wp-content/uploads/2014/09/AudiConnectInfoMenu.jpg"><img class="wp-image-4954 size-large" src="http://jackkozik.com/wp-content/uploads/2014/09/AudiConnectInfoMenu-1024x609.jpg" alt="AudiConnectInfoMenu" width="604" height="359" /></a><p class="wp-caption-text">Menu-&gt;Info-&gt;Audi Connect</p></div><p>&nbsp;</p><div id="attachment_4955" style="width: 614px" class="wp-caption alignnone"><a href="http://jackkozik.com/wp-content/uploads/2014/09/OnlineWeatherInformation.jpg"><img class="wp-image-4955 size-large" src="http://jackkozik.com/wp-content/uploads/2014/09/OnlineWeatherInformation-1024x674.jpg" alt="OnlineWeatherInformation" width="604" height="397" /></a><p class="wp-caption-text">Menu-&gt;Info-&gt;Audi Connect-&gt;Weather Info</p></div><h3>SIM Card Slot</h3><p>The car&#8217;s dashboard has a slot, hidden by a folding door, where the SIM card slot and two SD card slots are found.  Note:  only the SIM card is plugged in for the picture below.</p><div id="attachment_4937" style="width: 310px" class="wp-caption alignleft"><a href="http://jackkozik.com/wp-content/uploads/2014/09/SIMCardSlot.jpg"><img class="size-medium wp-image-4937" src="http://jackkozik.com/wp-content/uploads/2014/09/SIMCardSlot-300x124.jpg" alt="SIM Card Slot" width="300" height="124" /></a><p class="wp-caption-text">SIM Card Slot</p></div><h3>In Car WIFI</h3><p>The car lets you setup a WIFI hotspot that routes through the TMO UMTS/3G data service.  I tried it; it worked ok, but it&#8217;s not as fast as our 4G/LTE data service and I am not really sure why I&#8217;d ever want to use this &#8212; maybe for a guest?</p><p>Anyway, I ran a speedtest on the WIFI and for my neighborhood, the service is 1Meg down / 0.5 up.  Here&#8217;s a screenshot from my mobile:</p><h3><a href="http://jackkozik.com/wp-content/uploads/2014/09/SpeedTest.jpg"><img class="alignleft wp-image-4939 size-medium" src="http://jackkozik.com/wp-content/uploads/2014/09/SpeedTest-169x300.jpg" alt="SpeedTest" width="169" height="300" /><br /> </a></h3><div style="clear: both;"></div><p>&nbsp;</p><h3>References</h3><ul><li><a href="http://www.audi.com/etc/medialib/ngw/myaudi/pdf.Par.0061.File.pdf">Audi Connect Operating Manual</a></li><li><a href="http://www.audiusa.com/help/audi-connect#dtufilters/vehicleYear/null/vehicleName/null/">Audi Connect FAQ</a></li><li><a href="https://myaudiconnect.com/#/user/logout">My Audi Connect Portal (</a>needs login)</li></ul><p>The post <a rel="nofollow" href="http://jackkozik.com/audi-connected-car-2014-s7/">Audi Connected Car &#8211; 2014 S7</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/audi-connected-car-2014-s7/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>REST web service using Node,  was originally written in PHP</title><link>http://jackkozik.com/rest-web-service-using-node-was-originally-written-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rest-web-service-using-node-was-originally-written-in-php</link> <comments>http://jackkozik.com/rest-web-service-using-node-was-originally-written-in-php/#comments</comments> <pubDate>Tue, 04 Mar 2014 22:54:34 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[2014]]></category> <category><![CDATA[backend]]></category> <category><![CDATA[node-restify]]></category> <category><![CDATA[nodejs]]></category> <category><![CDATA[REST]]></category> <category><![CDATA[REST API]]></category> <category><![CDATA[restify]]></category> <category><![CDATA[Web Service]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4712</guid> <description><![CDATA[<p>Background on my REST web service using Node.js: One of my REST web service applications, originally written in PHP several years ago, needed to be cleaned up. I wanted to re-factored it to make it easier for me to maintain.   I had picked a PHP framework, and I was going to re-code. For my [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/rest-web-service-using-node-was-originally-written-in-php/">REST web service using Node,  was originally written in PHP</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Background on my REST web service using Node.js: One of my <a href="http://en.wikipedia.org/wiki/Representational_state_transfer">REST </a>web service applications, originally written in PHP several years ago, needed to be cleaned up. I wanted to re-factored it to make it easier for me to maintain.   I had picked a PHP framework, and I was going to re-code.</p><p>For my own education, I decided to use this project as a trigger to learn <a href="http://nodejs.org/">Node.js</a>.</p><p>I had been following the progress of the node community and some of the organizations at work had started using node, so I decided to give it a try. I had been using JavaScript for quite awhile doing front end programming in my browser applications and felt that it shouldn&#8217;t be too hard for me to learn.</p><p>The notes that follow capture some of my learnings and record some of the steps I followed to design and setup my new web service.</p><h2>Install Node.js on my Fedora Server</h2><p>I am a system admin of my own Fedora server, and I was looking to do a full install of nodejs. If you have a new Fedora sever (Fedora 18+), you just use &#8220;<code>yum install nodejs</code>&#8221; &#8212; but I have an older Fedora server so I had to dig around;  I found several useful Howto&#8217;s. What worked best for me was the following steps:</p><p>From root login:</p><pre><code>
$ cd /usr/local
$ wget http://nodejs.org/dist/v0.10.25/node-v0.10.25.tar.gz
$ tar zxvf node-v0.10.25.tar.gz
$ cd node-v0.10.25
$ ./configure
$ make
$ make install
</code></pre><p>Source: <a href="https://ask.fedoraproject.org/en/question/10229/how-to-install-nodejs-in-fedora/">Ask Fedora Project</a></p><p>I then put node into default login profile:</p><pre><code>$ cd /etc/profile.d
$ vi node.sh
#insert following lines
export PATH=/usr/local/bin:$PATH
export NODE_PATH=/usr/local/lib/node_modules
ZZ
</code></pre><p>From the root home directory and from my user log in id, I verified that node worked:</p><pre><code>$ node -v
v0.10.25
</code></pre><p>The in my user account, I wrote a hello world style test application:</p><pre><code>$ cd $HOME
$ mkdir helloworld
$ cd helloworld
$ vi app.js
// Insert the following files
// I forget which howto website I borrowed this from
var http = require('http');
var server = http.createServer(function(req, res) {
  console.log("web page accessed");
  res.writeHead(200);
  res.end('Hello Http');
});
server.listen(8000);
ZZ
$ node app.js
</code></pre><p>Note: the app.js is listening on port 8000. To make this work on my server, I needed to go into iptables and open port 8000. I am not going to show how to do that here, but it is easy to do and easy to overlook. It is worth the trouble to get this little app working because you&#8217;ll need port 8000 working for the next step.</p><p>Once port 8000 is open and the app.js script running, do the following command in a different terminal  window.</p><p>From user login:</p><pre><code>$ curl -i http://localhost:8000

</code></pre><p>Output:</p><pre><code>HTTP/1.1 200 OK
Date: Thu, 13 Feb 2014 16:27:00 GMT
Connection: keep-alive
Transfer-Encoding: chunked

</code><span style="font-family: monospace, serif;">Hello Http </span></pre><p>This turned out to be harder than I thought. The nodejs website offers Linux Binaries; I tried them and they didn&#8217;t work. I assume I did something wrong. Instead, I did the install from source setup.  On my machine, it took about 10 minutes to compile and build. (The make step was longer than I thought).</p><h2>Restify Module</h2><p>The node.js community has a large library of packaged <a href="https://www.npmjs.org/">modules</a>. I picked the <a href="http://mcavage.me/node-restify/">Restify</a> module to build my package upon.  Since I am new to node, I don&#8217;t really know what the best choice would be, I just wanted to leverage something that had some good howto articles.</p><p>To setup restify, I ran the following steps from my root login:</p><pre><code>$ npm install restify -g
</code></pre><p>Then from my development login, I wrote a barebones test application:</p><pre><code>$ cd $HOME
$ mkdir restify
$ cd restify
$ vi app.js
// insert the following lines
// borrowed from stack overflow article:
// http://stackoverflow.com/questions/17589178/why-should-i-use-restify
var restify = require('restify');
var server = restify.createServer();
function respond(req, res, next) {
    res.send('hello ' + req.params.name);
}
server.get('/hello/:name', respond);
server.listen(8000, function() {
    console.log('Listening on port 8000');
});
ZZ
$ node app.js
</code></pre><p>Like the previous hello world test, this one verifies that basic restify works. I ran &#8220;node app.js&#8221; in one terminal window and in the other, I ran the following:</p><pre><code>
$ curl -i http://localhost:8000/hello/jack

</code></pre><p>Output:</p><pre><code>HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 12
Date: Thu, 13 Feb 2014 17:03:19 GMT
Connection: keep-alive</code>

hello jack<code> </code></pre><p>I make this all look so easy, but along the way I had several gotcha type problems. I originally didn&#8217;t have the environment variables setup right. And, my initial installation of restify, I forgot to use the -g option. And for my initial setup, I did a couple of things in my root login that should have been done in my user login, etc. It is worth it to get the basic hello world done before you start.</p><p>Reference:  <a href="http://synthmedia.co.uk/blog/basic-nodejs-api-with-restify-and-save#.UxY9FvldXY0">Creating a basic node.js api with restify and save</a> by Dom Udall</p><h2>My REST Design</h2><p><a href="http://books.google.com/books?id=XUaErakHsoAC"><img class="alignright size-full wp-image-4730" alt="RESTbooks" src="http://jackkozik.com/wp-content/uploads/2014/03/RESTbooks.jpg" width="128" height="168" /></a>My web application edits and reports on some resources stored on my server. I want to grant access to these resource through a REST-ish API. The two key resources are charts and jefiles &#8212; it turns out that these are actually text files stored on my server. There is one chart file per year, so in my REST URI  I use the notation: chart/YY. The jefile files are monthly, with 12 months per year, so I picked the notation jefile/YY/MM.  In my REST URIs, MM=00-12 and YY is any two digits representing a year (eg YY==12 implies 2012, YY==98 implies 1998).</p><p>So, my design is for the following &#8220;GET&#8221; operations return data from the server to my web application:</p><pre># returns contents of chart file for the year YY, 
# where YY is 13 for 2013
http:&#47;&#47;localhost:8000/chart/YY 

# returns contents of jefile for the year YY, Month MM
# - where YY is 13 for 2013
# - where MM is 01-12, for a month
http:&#47;&#47;localhost:8000/jefile/YY/MM  

# returns concatenation of all jefiles for the year YY
# - where YY is 13 for 2013 (used for year to date reports)
http:&#47;&#47;localhost:8000/jefile/YY</pre><p>Also, for debugging purposes, I want both plain text and json formatted data returned. I picked the above syntax to represent plain text response. Here&#8217;s the syntax for json responses:</p><pre><code>http:&#47;&#47;localhost:8000/chart.json/YY
http:&#47;&#47;localhost:8000/jefile.json/YY/MM
http:&#47;&#47;localhost:8000/jefile.json/YY</code></pre><p>I have experimented with using MIME types or other header mechanisms to control plain text vs json. I like this method because it lets me debug in any a normal browser; no special REST browser plugins needed to be installed.  This approach is also valuable to me because it maintains continuity with my existing, several year old, PHP design approach.</p><p>So with this design, here&#8217;s the basic restify application.</p><p>From the file app.js:</p><pre><code>var restify = require('restify');

var server = restify.createServer();
server
  // Allow the use of POST
  .use(restify.fullResponse())
  // Maps req.body to req.params so there is no switching between them
  .use(restify.bodyParser());

server.get('/chart/:YY', getChart);
server.get('/chart.json/:YY', getChart);

server.get('/jefile/:YY', getJefileForYY);
server.get('/jefile.json/:YY', getJefileForYY);

server.get('/jefile/:YY/:MM', getJefile);
server.get('/jefile.json/:YY/:MM', getJefile);
server.put('/jefile/:YY/:MM', putJefile);

server.listen(8000, function() {
    console.log('Listening on port 8000');
});
</code></pre><p>The <code>server.get()</code> callback functions (eg <code>getJefile()</code> ) all follow a common pattern:</p><pre><code>function getJeFile(req, res, next) {
    console.log(params.req.YY);
    console.log(req.route.name);
    ...; 
    res.send(...);
    next();
}
</code></pre><p>The restify framework&#8217;s <code>server.get()</code> function takes the incoming REST request, parses the URI and matches it to the first parameter of the <code>server.get()</code> function,  and runs the callback  function with the request neatly parsed into the object <code>req</code>. Since in REST APIs, the GET method nominally has an empty message body, the only real input are the parameters parsed out of the URL. In my code above :YY and :MM ids are the names of the URI parameters.</p><p>These parameters are parsed by restify and stored  in the object <code>params.req</code>. For all of my server functions, I always have <code>params.req.YY</code> as in input. Restify API document covers this, but again, this design pattern is found throughout nodejs code as a way for a chain of functions to all share the same input and output objects.</p><p>The callback functions above (eg <code>getJeFile()</code>) generates the content that gets stored into the response object, the 2nd callback parameter <code>res</code>. When the callback function is complete, it calls <code>next()</code>, the 3rd parameter.</p><p>So here&#8217;s what my 3 <code>server.get()</code> callback functions look like.</p><p>From app.js:</p><pre><code>
getChart = function getChart(req, res, next) {
    console.log(req.route.name);
    var year = req.params.YY;
    // validate year
    // get contents of chart file
    // if I find any errors:  return next( Error object )
    res.send(chartFile);
    return next();
}

getJefile = function getJefile(req, res, next) {
    console.log(req.route.name);
    var year = req.params.YY;
    var month = req.params.MM;
    // validate year, month
    // read contents of jefile file
    // if I find any errors:  return next( Error object )
    res.send(jefileFile);
    return next();
}

getJefileForYY = function getJefileForYY(req, res, next) {
    console.log(req.route.name);
    var year = req.params.YY;
    // validate year
    // get contents of all of the jefile files, concatenate
    // If I find any errors:  return next( Error object )
    res.send(jefileFileForYY);
    return next();
}
</code></pre><p>Note:  the above code is simplified to better help explain what I am doing.</p><p>For the case where my web application wants to write content to the server, I use the REST PUT method. The PUT method writes or overwrites the full contents of a resource. Since I am working with whole files on the web server, PUT is appropriate. POST would be OK, if I was adding blocks of data to an existing file; but I am not.</p><p>So to make a PUT work in the restify framework, my <code>server.put()</code> callback function needs to parse and validate the message body, convert it from JSON to a native format then save the contents to a file on the server. Restify makes this pretty easy. Here&#8217;s the basics:</p><p>From app.js:</p><pre><code>
putJefile = function putJefile(req, res, next) {
    console.log(req.params);
    console.log(req.route.name);
    var year = req.params.YY;
    var month = req.params.MM;
    // validate year
    // validate requerst body, named jefilejson, is valid
    jefileFile = JSON.pars(req.params.jefilejson)
    // write contents of jefileFile to server, directory YY, file-MM
    res.send(200)
    return next();
}
</code></pre><p>Note: the message body holds a json object; in my case, the web application names the json object jefilejson. So to access the contents of the message body, you access req.params.jefilejson.</p><h2>Validating the MM and YY ids</h2><p>The server.get() routing function&#8217;s syntax makes it easy to match roughly correctly formatted URIs, but for me, it didn&#8217;t have enough checking power to verify that the YY and MM ids were correct. <code>Server.get()</code> just matches any character between the slashes; it doesn&#8217;t check that YY is 2 numeric digits or that MM is 01-12 only with the leading zero required. I had to add my own validation logic in each of my callback functions.</p><p>It turns out the code for verifying YY and MM ids was several lines of coded repeated multiple times. Node.js and restify design patterns give you the option of inserting additional callback functions into the <code>server.get()</code> function call. I added validation functions as follows:</p><p>From app.js:</p><pre><code>
server.get('/chart/:YY', validateYY, getChart);
server.get('/chart.json/:YY', validateYY, getChart);

server.get('/jefile/:YY', validateYY, getJefileForYY);
server.get('/jefile.json/:YY', validateYY, getJefileForYY);

server.get('/jefile/:YY/:MM', validateYY, validateMM, getJefile);
server.get('/jefile.json/:YY/:MM', validateYY, validateMM, getJefile);
server.put('/jefile/:YY/:MM', validateYY, validateMM, putJefile);
</code></pre><p>Now, I liked this because it let me re-factor a bunch of common code out of each of my callback functions. I have seen other node.js code snippets that take advantage of this coding pattern.</p><h2>Validation Functions and Error Handling.</h2><p>Within a nodejs or restify program, there&#8217;s a common way of handling errors. Since everything is asynchronous and chained together with next() functions, there needs to be a way to break the chain on error conditions. The key technique is to call the <code>next()</code> function with an <a href="http://docs.nodejitsu.com/articles/errors/what-is-the-error-object">Error object</a> as a parameter. Let me show how I coded the <code>validateYY()</code> function.</p><p>From app.js:</p><pre><code>
/*
** Validate YY id.
** -- syntax:  2 digits, 00-99
** -- directory nfroot+YY must exist
*/
function validateYY(req, res, next) {
    var ret = 500;
    var year = req.params.YY;
    console.log('validateYY:'+req.route.name);
    var isValidYY = year.match(/^\d\d$/);
    if (!isValidYY) {
        ret =  new Error("The field YY-'"+year+"' is not valid.  YY is a two digit year where YY is 00-99");
        ret.statusCode = 400;
        return next(ret);
    }
    /* Verify that YY exists */
    if (!fs.existsSync(nfroot+year)) {
        ret = new Error("The field YY-'"+year+"' is not valid. The diretory-'"+nfroot+year+"' doesn't exist on server.");
        ret.statusCode = 404;
        return next(ret);
    }
    /* Verify that YY is a directory */
    if (!fs.lstatSync(nfroot+year).isDirectory()) {
        ret = new Error("Server side problem:  The path -'"+nfroot+year+"' is a file, but must be a directory.");
        ret.statusCode = 500;
        return next(ret);
    }
    return next();
}
</code></pre><p>The key is the Error object. When I first saw code snippets using the Error object, I didn&#8217;t really know what&#8217;s going on. I Googled it and found there&#8217;s a rich design pattern built into node.js around how errors are handled. If you just jump into node.js like me, there&#8217;s lots of things you need to learn. Restify just leverages Error, assuming coders already know how to work node.js.</p><p>Notice in the code above, I tried really hard to follow best practices for mapping http error codes into my REST API definitions. For the case of  someone trying to access a resource like a particular jefile file within a year (eg ..jefile/YY/MM): If the syntax was wrong, I returned a Bad Format (400) error; if the format of the REST URI was right but the file requested file didn&#8217;t exist I returned a Not Found (404) error. Also, I even verified that YY in the path was really a directory on the server; if not, that&#8217;s shouldn&#8217;t ever happen &#8212; I returned a Server Error (500).</p><p>The way the function chaining works: if next() is passed an Error object, the chaining stops and a json formated response is generated with Error information. This powerful construct is built into node.js, but if you didn&#8217;t know it, you might start inventing it yourself, especially if you come from a PHP background, like me.</p><h2>Splitting Node applications into multiple files &#8211; Module Loading with Require</h2><p>When I first started my node project, I put everything into one big app.js file. This got too big and clumsy for me. I am used to working on projects where coding is split across multiple source files. The node documentation defines a method for split source code across multiple files&#8230;  similar to how multiple modules are handled in web browser applications.</p><p>I decided to dedicate a source file to each of my main REST resources. For this writeup, those would be chart.js and jefile.js. I still have a main app.js. The way to link them together is to use the require() functions at the top of each file:</p><p>Contents of app.js:</p><pre><code>
var restify = require('restify');
var chart = require('./chart');
var jefile = require('./jefile');
...
server.get('/chart/:YY', validateYY, chart.getChart);
server.get('/chart.json/:YY', validateYY, chart.getChart);
server.get('/jefile/:YY/:MM',validateYY,validateMM, jefile.getJefile);
server.get('/jefile.json/:YY/:MM',validateYY,validateMM,
             jefile.getJefile);
server.put('/jefile/:YY/:MM',validateYY,validateMM,jefile.putJefile);
</code></pre><p>Contents of jefile.js:</p><pre><code>
exports.putJefile = function putJefile(req, res, next) { ... }
exports.getJefile = function getJefile(req, res, next) { ... }
</code></pre><p>Contents of chart.js:</p><pre><code>
exports.getChart = function getChart(req, res, next) { ... }
</code></pre><p>Note a few things: the <code>require()</code> function for restify does not need a path. I installed the restify <a href="https://www.npmjs.org/doc/cli/npm.html">NPM globally (-g option)</a>.  The require() function is only needed in the main file, app.js. The restify routing functions (eg <code>server.get()</code>) references callback functions from the other source files, by prefixing with chart or jefile. And, the source code for those callbacks are written as exports (eg. <code>exports.getJefile =</code> &#8230;).</p><p>Note how I managed, syntactically, my REST GET API methods for returning plain or JSON responses.  ../chart/YY returns the contents of the chart file for year YY; ../chart.json/YY returns the same file, but in JSON format.  Visually, I would rather see the contents of the chart file in native format, but for web page development, I want all responses in JSON format.  The <code>server.get()</code> callback for both of these cases is <code>getChart()</code>.  The way the <code>getChart()</code> function knows to return json or native format is by looking at the req.route.name parameter; that tells me how the <code>getChart()</code> was called.</p><p>The way source files are modularized is a pattern is written about in the nodejs documentation, but it turns out there are many more advanced ways of managing modules. This one worked great for me. It also made it easier for me to debug and test each resource without wrecking, accidentally, the others.</p><p>Reference: <a href="http://nodejs.org/api/modules.html">Node API Docs: Modules </a></p><h2>Run Node and Apache both on Port 80</h2><p>As I get my REST web service using Node working, I need to integrate it into the web service infrastructure already installed on my server.  Port 80 today runs Apache serving  blogs, weather stations,  and a couple of web applications &#8212; all intertwined with Apache and I cannot just start over.</p><p>So I found a way to get Apache to work with node; I keep node on port 8000 and Apache on port 80 and configure an Apache &#8220;<code>ProxyPass</code>&#8221; for URLs to the node-based REST service.</p><p>In /etc/httpd/conf/httpd:</p><pre><code>&lt;VirtualHost 64.53.181.XXX 192.168.100.XXX &gt;
    ServerName mydomain.com
    ...
    ProxyPass /node http://localhost:8000/
    ...
&lt;/VirtualHost &gt;
</code></pre><p>Any URI with mydomain.com/node in it gets redirected to my node service. This is good, but part of the reason for moving to node is that it is supposed to give much improved performance &#8212; not that Apache is slow, but because it has years of historic features built into it that take longer to execute.</p><p>Well someday, I&#8217;ll run only node. But for now, for me, node must coexist and this method works for me.</p><h2>Conclusions</h2><p>Working with Javascript on the server side was nice.  For me, the debugging skills that I use for web page development carried over nicely to node development.  Nodejs&#8217;s asynchronous design pattern was new to me, but once I caught on, it wasn&#8217;t bad.  The way nodejs standardizes error handling is much better than the adhoc approaches that I have been using with PHP.</p><p>I found that I missed some of the PHP built in functions.  For example, to access files on the server, nodejs has a very robust <a href="http://nodejs.org/api/fs.html">File System module</a>.  It behaves differently from PHP, but I was able to figure it out &#8212; they are all based on the same underlying C libraries.  I resisted the temptation to use one of the frameworks that help bridge PHP developers into nodejs; they aren&#8217;t bad, but they worked against my objective to learn.</p><p>Some next steps:  I would like to do some performance comparisons.  Superficially, my REST API re-written in node is faster than the existing PHP implementation.  I&#8217;d like to quantify.  Also, I have written server side code, that I ought to be able to use inside the web client applications; that would be a nice thing to clean up.  Also, I&#8217;d like to get my node application to do logging at least equal to the logging I get from Apache &#8212; restify has some nice built in features for that.</p><p>There&#8217;s a big library of NPM modules out there. I&#8217;d like to learn more about them.  This time around, all I really needed was restify.  Maybe next time, I&#8217;ll try to use more of the features inside of it, or branch out and learn express.  Anyway, thanks to the greater nodejs community for helping me get started.</p><p><a href="http://jackkozik.com/wp-content/uploads/2014/03/nodejs-1024x768.png"><img class="size-medium wp-image-4728 alignleft" alt="nodejs-1024x768" src="http://jackkozik.com/wp-content/uploads/2014/03/nodejs-1024x768-300x225.png" width="300" height="225" /></a></p><p>The post <a rel="nofollow" href="http://jackkozik.com/rest-web-service-using-node-was-originally-written-in-php/">REST web service using Node,  was originally written in PHP</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/rest-web-service-using-node-was-originally-written-in-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>$.ajax logging using Ajax Global Events. Re-factoring Single Page Web Application</title><link>http://jackkozik.com/ajax-logging-using-ajax-global-events-re-factoring-single-page-web-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ajax-logging-using-ajax-global-events-re-factoring-single-page-web-application</link> <comments>http://jackkozik.com/ajax-logging-using-ajax-global-events-re-factoring-single-page-web-application/#comments</comments> <pubDate>Tue, 03 Dec 2013 04:14:42 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[$.ajax]]></category> <category><![CDATA[Jquery]]></category> <category><![CDATA[logging]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4670</guid> <description><![CDATA[<p>Background on $.ajax logging using Ajax Global Events:  So I&#8217;ve moved from jQuery 1.4 to 1.9. I have some time to refactor my code to take advantage of some of the new features of 1.9 and to get ready for 1.10; the next jQuery release removes some of the deprecated methods. For this round of coding, [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/ajax-logging-using-ajax-global-events-re-factoring-single-page-web-application/">$.ajax logging using Ajax Global Events. Re-factoring Single Page Web Application</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Background on $.ajax logging using Ajax Global Events:  So I&#8217;ve moved from jQuery 1.4 to 1.9. I have some time to refactor my code to take advantage of some of the new features of 1.9 and to get ready for 1.10; the next jQuery release removes some of the deprecated methods.</p><p>For this round of coding, I am focusing on the <code>$.ajax()</code> method. In my present design, my single page web application makes REST calls for many of the UI menu items. For example, a click on the FILE-&gt;LOAD menu item triggers a function call to code that retrieves a file from my server. The basic pattern is like this:</p><pre class="brush: jscript; title: ; notranslate">
// Start spinner
// start logging timer
$.ajax({&quot;url&quot;:RestURI,
 &quot;type&quot;:&quot;GET&quot;,
 &quot;dataType&quot;:&quot;json&quot;,
 success: function(data) {
 // Do success stuff (parse, format and display)
 // stop logging timer, do logging
 // stop spinnger
 }, /* end success: */

 error: function (req, stat, err) {
 // Do error stuff
 // stop logging timer, do logging
 // stop spinner
 } /* end error: */
});
</pre><p>I have more than 7 code blocks that follow this pattern. Since<a href="view-source:http://api.jquery.com/jQuery.ajax/#jqXHR"> the success/error/complete callback functions have been deprecated </a>and I need to touch the code anyways, I thought I&#8217;d use the newish<a href="http://api.jquery.com/category/ajax/global-ajax-event-handlers/"> <code>$.ajax()</code> global events handlers</a>  to clean up my code. The event handlers seem to be a useful place to put common pieces of code that really shouldn&#8217;t have been so liberally cut-and-pasted when I wrote the original code.</p><p><a href="http://jackkozik.com/wp-content/uploads/2013/12/jQueryIcon120213.jpg"><img class="alignright size-full wp-image-4678" alt="jQueryIcon120213" src="http://jackkozik.com/wp-content/uploads/2013/12/jQueryIcon120213.jpg" width="184" height="168" /></a>For each of my ajax code blocks, I put a generous amount of logging in. Maybe this logging should only be needed when writing/debugging the code, but for me, since I spend so little dedicated time on this application, I wanted to keep verbose logging on always to make it real easy for me to debug.</p><h4>$.ajax logging using Ajax Global Events</h4><p>The following new block of code is doing my <code>$.ajax</code> logging using Ajax Global Events.</p><pre class="brush: jscript; title: ; notranslate">
$(document).ajaxSend(function(evt, xhr, settings) {
 console.log(settings.type+&quot; &quot;+settings.url+&quot; Sent&quot;);
 start = new Date().getTime();
 // Other logging
});
$(document).ajaxSuccess(function(evt, xhr, settings) {
 console.log(settings.type+&quot; &quot;+settings.url+&quot; Success&quot;);
 // Other logging
});
$(document).ajaxError(function(evt, xhr, settings, exc) {
 console.log( settings.type+&quot; &quot;+settings.url+&quot; Failed. &quot;
 +xhr.status+&quot;-&quot;+xhr.statusText);
 // Other logging
});
$(document).ajaxComplete(function(evt, xhr, settings) {
 console.log(settings.type+&quot; &quot;+settings.url+&quot; Complete&quot;);
 end = new Date().getTime();
 diff = end - start;
 // Other logging
});
</pre><p>As you can see, the ajaxSend/ajaxSuccess/ajaxError/ajaxComplete events are fired in sequence at the <code>$.ajax()</code> function executes and after the  <code>.done()</code>, <code>.fail()</code> and <code>.compete()</code> callbacks are executed.</p><p>The &#8220;Other logging&#8221; comment represents 2 or 3 lines of code where I put logging information into a user visible menu item (REPORTS-&gt;LOG) where I can see even more details without having to open the console window. For me, this effort is a nice clean out some of the logging stuff, to make the application logic a little more visible;  this clears up a bunch of clutter for me.</p><h4>New-ish .done/.fail/.always Callbacks</h4><p>Therefore, my $.ajax() code blocks are straighten out to follow the new done/fail/always callbacks. Here&#8217;s an example new $.ajax() code block:</p><pre class="brush: jscript; title: ; notranslate">
// Start spinner
$.ajax({url:RestURI,
 type:&quot;GET&quot;,
 dataType:&quot;json&quot;})
 .done( function(data, textStatus, jqXHR) {
 // Do success stuff
 }) /* end done: */

 .fail( function (jqXHR, textStatus, err) {
 // Do error stuff
 }) /* end fail */

 .always( function() {
 // stop spinner
 }); /* End always */
</pre><p>Some things to note: I still put the start/stop spinner function calls inline. I may move this to the global even handlers, but not yet.</p><h4>Deferred Objects</h4><p>Also, the done/fail/always call backs follow the new<a href="http://api.jquery.com/category/deferred-object/"> Deferred Object</a> model. This will then let me setup some promise objects to let me address some of the async race conditions I have in my application.</p><p>For example, I have a case where I can run FILE-&gt;SAVE and then run REPORT-&gt;General and the report will produce results before the save was completed. I know how to fix this, but I was looking to use my new ajax code blocks architecture to get some practice with promise objects instead&#8230; for next time.</p><p>The post <a rel="nofollow" href="http://jackkozik.com/ajax-logging-using-ajax-global-events-re-factoring-single-page-web-application/">$.ajax logging using Ajax Global Events. Re-factoring Single Page Web Application</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/ajax-logging-using-ajax-global-events-re-factoring-single-page-web-application/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Code Snippets Causing Slow Website Load Time</title><link>http://jackkozik.com/code-snippets-causing-slow-webpage-load-time/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=code-snippets-causing-slow-webpage-load-time</link> <comments>http://jackkozik.com/code-snippets-causing-slow-webpage-load-time/#comments</comments> <pubDate>Thu, 07 Nov 2013 19:58:37 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4648</guid> <description><![CDATA[<p>Background on my Slow Website Load Time issue: I wrote a blog entry that described how I upgraded one of my web pages to use normalize.css (part of my migration to HTML5 Boilerplate 4.2). Normalize.css let me clean up my CSS nicely and helped teach me some discipline on CSS design. All good, but&#8230; The [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/code-snippets-causing-slow-webpage-load-time/">Code Snippets Causing Slow Website Load Time</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Background on my Slow Website Load Time issue: I wrote a blog entry that described how I upgraded one of my web pages to use <a href="http://necolas.github.io/normalize.css/">normalize.css</a> (part of my migration to <a href="http://html5boilerplate.com/">HTML5 Boilerplate </a>4.2). Normalize.css let me clean up my CSS nicely and helped teach me some discipline on CSS design. All good, but&#8230;</p><p>The blog posting took a crazy long time to load. I am used to WordPress blog pages being a little heavy and but this was too slow.</p><p>I had recently learned about the <a href="http://www.webpagetest.org/">WebPageTest.org</a> tool, and decided to use it to troubleshoot my issue. Other bloggers point to this website for workingSlow Website Load Time issuess. Here&#8217;s what the tool&#8217;s waterfall summary page  showed me:</p><div class="clear"><a href="http://jackkozik.com/wp-content/uploads/2013/11/Webpagetest17secBefore110713.png"><img class="alignleft size-full wp-image-4649" alt="Webpagetest17secBefore110713" src="http://jackkozik.com/wp-content/uploads/2013/11/Webpagetest17secBefore110713.png" width="258" height="157" /></a></div><div style="”clear: left”;"></div><p>&nbsp;</p><p>The chart had lots of red lines: these are lines that reflect 404 error timeouts. I was surprised; the posting didn&#8217;t have any links to external content (that I knew of!). I clicked on the waterfall thumbnail and saw the following:<br /> <a style="line-height: 1.5;" href="http://jackkozik.com/wp-content/uploads/2013/11/Webpagetest404err110713.png"><img class="alignleft size-full wp-image-4652" alt="Webpagetest404err110713" src="http://jackkozik.com/wp-content/uploads/2013/11/Webpagetest404err110713.png" width="827" height="69" /></a></p><p>&nbsp;</p><p>The 404s are from style.css, normalize.css, main.css, and jquery-ui &#8212; huh? These are links in my code snippet!</p><p>My blog postings showed the before/after of my &lt;head&gt; section of my normalized web page. Here&#8217;s the after snippet:</p><p><a href="http://jackkozik.com/wp-content/uploads/2013/11/HeadSection110713.png"><img class="alignleft size-full wp-image-4653" alt="HeadSection110713" src="http://jackkozik.com/wp-content/uploads/2013/11/HeadSection110713.png" width="608" height="128" /></a></p><p>&nbsp;</p><p>&nbsp;</p><p>So do web browsers resolve and fetch URLs embedded in &lt;pre&gt; sections? Really? (sorry to be ignorant about this, but I really didn&#8217;t think so). Yes a quick search of stackoverflow and I find that this questions has been asked and answered. When you have a &lt;pre&gt; block, you need to escape the &lt; and &gt; characters (&amp;lt; and &amp;gt;). <a href="http://stackoverflow.com/questions/42182/how-to-escape-and-inside-pre-tags">Stackoverflow reference</a></p><p>So, I manually edited my code snippets to escape the angle brackets, and everything loaded much more quickly. The browser no longer tried to resolve the URLs.</p><p>Here&#8217;s the new WebPageTest.org thumbnail (no red lines!)<br /> <a href="http://jackkozik.com/wp-content/uploads/2013/11/Webpagetest10secAfter110713.png"><img class="alignleft size-full wp-image-4654" alt="Webpagetest10secAfter110713" src="http://jackkozik.com/wp-content/uploads/2013/11/Webpagetest10secAfter110713.png" width="261" height="123" /></a></p><div style="clear: left;"></div><p>Oh, and while I was learning the WebPageTest.org tool, I found a bunch of other problems, which were much more obvious and easy to fix.</p><p>The post <a rel="nofollow" href="http://jackkozik.com/code-snippets-causing-slow-webpage-load-time/">Code Snippets Causing Slow Website Load Time</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/code-snippets-causing-slow-webpage-load-time/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>