Wednesday, January 30, 2013

How to anonymize the programs from your terminal with torify

http://linuxaria.com/howto/how-to-anonymize-the-programs-from-your-terminal-with-torify?lang=en


In the past I’ve posted an article about Anonymous browsing with Tor that can be useful when you use your favorite browser and you wish to stay anonymous thanks to the Tor software.
Tor (short for The Onion Router) is a system intended to enable online anonymity. Tor client software directs internet traffic through a worldwide volunteer network of servers to conceal a user’s location or usage from anyone conducting network surveillance or traffic analysis. Using Tor makes it more difficult to trace Internet activity, including “visits to Web sites, online posts, instant messages and other communication forms”, back to the user and is intended to protect users’ personal freedom, privacy, and ability to conduct confidential business by keeping their internet activities from being monitored.
Today I want to show some simple uses of the command torify that can be used from the Linux terminal.



torify is a simple wrapper that attempts to find the best underlying Tor wrapper available on a system. It calls torsocks or tsocks with a tor specific configuration file.
As first thing install the software, tor is usually found on all the repository so for Debian, Ubuntu and Mint you just have to type:
sudo apt-get install tor
In this example we’ll keep all the standard configuration but 2 things, in the file /etc/tor/torrc you should uncomment the directive:
ControlPort 9051
And set
CookieAuthentication 0
With these 2 options we set the port on which Tor will listen for local connections from Tor controller applications, and we tell to Tor that we don’t need an authentication, so any program can control Tor (don’t do this on a shared computer or server), later in this post I’ll show how to set a password, once changed save the file and restart tor with the command:
sudo /etc/init.d/tor restart
And now a simple example that shows how to use the command torify and start a new session on tor from the Linux terminal, as first thing I get my public IP address with:
$  curl ifconfig.me
79.35.56.153
So 79.35.56.153 is my public IP, now I use torify before the command curl in the command line :
$ torify curl ifconfig.me 2>/dev/null
74.120.15.150
As you can see now I browse on the net with a different Ip: 74.120.15.150, but from the command line I can also force Tor to start a “new session” with the command:
echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
250 OK
250 OK
250 closing connection
This small script connects to port 9051 and issue the command “signal newnym” that will make Tor switch to clean circuits, so new application requests don’t share any circuits with old ones, now if I check my IP I expect to see a new one:
$ torify curl ifconfig.me 2>/dev/null
46.59.74.15
In this small example I’ve used curl to get my ip address, but with torify you could use almost any terminal program, such as ssh, wget, w3m or BitchX.


How to set a password for Tor

If you are in a shared environment it’s better to set up a password for Tor, here it’s how you can do it in a few steps:
1) Generating your encrypted password:

In a terminal type:
tor --hash-password "passwordhere"
This will generate a password hash, you will need to save this for inserting into the TOR configuration file in the next step.
(This is the hash for “passwordhere”, 16:113BD60B17CD1E98609013B4426860D576F7096C189184808AFF551F65)
2) Editing the Tor configuration file :

Open the file /etc/tor/torrc and comment the line we set before:
#CookieAuthentication 0

Next find the line:
#HashedControlPassword 16:2283409283049820409238409284028340238409238

remove the # at the beginning and replace the password hash that is currently there with the hash you have just generated.
So with the hash generated in this example the configuration would be:
HashedControlPassword 16:113BD60B17CD1E98609013B4426860D576F7096C189184808AFF551F65

Save your changes.
3) Restart TOR:
Restart Tor so it get the new directives with:
sudo /etc/init.d/tor restart
Now you can use the former command to connect to teh Tor daemon, but using your password, so for me this would be:
echo -e 'AUTHENTICATE "passwordhere"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
References:
http://fixitts.com/2012/09/28/data-scraping-series-2-1-rotating-your-tor-ip-address-php-or-linux/
Using Tor to Anonymize Your Traffic (and setting up Tor in Arch Linux)
Using Tor in Ubuntu | Torify our life

Correct Lens Distortion in GIMP with GimpLensfun

http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Correct-Lens-Distortion-in-GIMP-with-GimpLensfun


While GIMP offers a wide range of tools for working with photos, it lacks one feature that is essential for serious photographers: the ability to automatically fix lens distortion. Fortunately, the GimpLensfun plugin fills the void quite nicely. As the name suggests, the plugin uses the excellent LensFun library as its back end. One way to install the plugin is to compile it from source. Start with installing the required packages. On Ubuntu, this can be done using the following command:
sudo apt-get install build-essential libgimp2.0-dev libexiv2-dev liblensfun-dev git
Grab then the latest source code from the project's GitHub repository:
git clone git://github.com/seebk/GIMP-Lensfun.git
Switch to the GIMP-Lensfun directory and run the make command to compile the plugin:
cd GIMP-Lensfun
make
Move then the compiled gimp-lensfun plugin to the ~/.gimp-2.x/plug-ins/ directory, and you are done. If you don't feel like getting your hands dirty compiling the plugin, you can grab the latest tarball from the project's website. The archive contains compiled versions of the plugin stored in the /bin/linux directory.


Once the plugin has been installed it can be accessed via the Filters | Enhance | GimpLensfun menu. The plugin automatically reads the lens and camera model along with the corresponding parameters from the photo's EXIF data, so all you need to do is to hit OK to apply lens correction.

Vert.x's journey teaches invaluable governance lessons

http://www.infoworld.com/d/open-source-software/fork-vmware-open-source-triumphs-again-211029


As the Vert.x community selects its future home, it offers a fascinating illustration of the role of governance


The community discussion of the Vert.x open source project was just starting when I wrote about it last week. Conducted entirely on the mailing list as a result of all the press the Vert.x dustup received, this group conversation has launched an educational parade of governance solutions.
I've had a deep interest in open source community governance for years; indeed, several years ago I sketched out a benchmark for comparing governance approaches. Community governance matters because when disputes arise it's important that every good-faith community participant has a right to join in the resolution. Many developers feel licensing and governance are a bureaucratic make-work nuisance imposed by an aging generation trying to retain control over software. But projects that neglect or ignore licensing and governance can discover too late how important it is.
[ Also on InfoWorld: Who controls Vert.x: Red Hat, VMware, or neither?. | Track the latest trends in open source with InfoWorld's Technology: Open Source newsletter. ]
Without shared ownership of concrete assets like copyrights and trademarks, as well as social assets (access right approvals, feature selection, and release management), times of crisis become opportunities for overprivileged community members to make self-serving fiat decisions at the expense of community members. The results can be forks or the departure of community members, and ironically those with control frequently find they lose more than they gain as the community evaporates.
The time to pick licenses and governance styles is early, before the arrival of existential crises, so the actions of Vert.x project leader Tim Fox in calling out the risk of covert corporate carve-ups are paying off. While some researchers are experimenting with automatic analysis of governance, the best way to compare and contrast today is to ask community members about their communities. It's worth tracing the path Vert.x has taken. Reading the thread will introduce you to the three main ideas the Vert.x community considered and illustrate some of the many governance choices available.
A community journey
Faced with the perception that VMware wanted to retain control at all costs, the first option the community considered was to create a fork and continue the existing approach independently. But it quickly became obvious that a fork was neither necessary nor helpful because VMware did not want to retain control of the project at all costs.
The next option considered was to run the project as it is now -- using GitHub as the host -- but trust concrete assets to a nonprofit foundation. Possible hosts for those assets included Software in the Public Interest (SPI), one of the oldest open source nonprofits, formed to host assets for the Debian project.
It gradually became apparent, however, that Vert.x needed a steward for more than just the concrete assets of the community. With two strong companies already involved -- Red Hat and VMware -- and the evident interest of more, the need for a guarantor of social assets became clear. Indeed, it was concern over who would have ultimate control over participation and contribution that lay behind Tim Fox's original posting. The conversation turned to understanding "full service" foundations, involving a governance methodology, a community philosophy, and concrete asset stewardship.


Both the Apache Software Foundation and the Eclipse Foundation were proposed early in the discussion, and much of the later discussion involved understanding the nature of these two foundations. Both are large communities with proven approaches, and they have much in common. Both have strong policies on ensuring cleanliness of the copyright provenance on all contributions, for example.
They differ in important ways, though. The deepest difference is their nonprofit type. Apache is a public-benefit nonprofit, registered with the IRS as such and able to accept tax-deductible donations. Eclipse is a member-benefit nonprofit; as such, its IRS registration does not allow tax deduction by donors.
Decision time
This difference goes beyond taxes to community ethos. Eclipse formally includes businesses in its governance and recognizes the affiliations of contributors, while Apache allows only contributors to engage in its governance and encourages hiding of affiliation.
In the end, it was probably this difference that settled the decision, and on Wednesday Tim Fox recommended that the community move to the Eclipse Foundation, saying, "I am not a huge fan of the ASF voting process, especially the veto, and the weaker notion of project leadership. I also think Eclipse is perhaps a little more 'business friendly' and that's going to be an important thing for Vert.x as we progress if we want to get a foothold in large enterprises."
Issues remain. Vert.x uses the permissive Apache License, and the Eclipse community will need to agree to an exception to its normal policy of using the copyleft Eclipse Public License. VMware will need to follow through on its commitment to donate the trademarks to Eclipse and satisfy its copyright provenance rules. Various members are concerned by the need to move the Git repository from GitHub to Eclipse, so contribution ownership tracking can be maintained. (GitHub does not offer this, although there's now a third-party solution.)
Hopefully these details will be sorted out. The whole experience has been educational, and I know many participants and readers have gleaned useful insights into the governance needs of a new open source community.

9 of the Best Free PHP Books

http://www.linuxlinks.com/article/20130119004851789/9oftheBestFreePHPBooks-Part1.html



Learning the PHP: Hypertext Preprocessor (PHP) programming language from scratch can be an arduous affair. Fortunately, budding developers that want to code in this language have a good range of introductory texts available to read, both in-print and to download. There are also many quality books that help programmers that have reached an intermediate level deepen their understanding of the language.
PHP has been at the helm of the web for many years. It is an extremely popular, interpreted scripting language that is ideally suited for web development. This language powers millions of web sites on the net and is extremely well supported by its user community. It is released under a non-copyleft free software license / open source license. PHP can be deployed on most Web servers and also as a standalone shell on almost all operating systems and platforms.
The word "Preprocessor" means that PHP makes changes before the HTML page is created. The code is executed on the server, generating HTML which is then sent to the client. PHP therefore enables a static webpage to become dynamic. The language is dynamically typed and easy to use. PHP comes with many extensions offering all kinds of functionality from system operations to numerical processing. One of the reasons why PHP is so popular is that it is simple to learn for a newcomer to the language, but provides advanced features for professional developers. Other reasons for its popularity include its embedded relationship with HTML, it provides a good mix of performance and flexibility to developers, has a relatively shallow learning curve, easy to debug and good performance.
The focus of this article is to select some of the finest PHP books which are available to download for free. Many of the books featured here can also be freely distributed to others.
To cater for all tastes, we have chosen a good range of books, encompassing general introductions to PHP, as well as books that will help you to effectively use the many advanced features of PHP. All of the texts here come with our strongest recommendation. So get reading (and downloading).
1. PHP Cookbook
PHP Cookbook
Website commons.oreilly.com/wiki/index.php/PHP_Cookbook
Author David Sklar, Adam Trachtenberg
Format HTML
Pages 632
The PHP Cookbook is a collection of problems, solutions, and practical examples for PHP programmers. The book contains a unique and extensive collection of best practices for everyday PHP programming dilemmas. It contains over 250 recipes, ranging from simple tasks to entire programs that demonstrate complex tasks, such as printing HTML tables and generating bar charts -- a treasure trove of useful code for PHP programmers, from novices to advanced practitioners.
Chapters cover:
  • Strings - PHP strings differ from C strings in that they are binary-safe (i.e., they can contain null bytes) and can grow and shrink on demand
  • Numbers - integers and floating-point numbers
  • Dates and Times - looks at the mktime, date functions
  • Arrays - lists: lists of people, lists of sizes, lists of books. To store a group of related items in a variable, use an array
  • Variables - they are the core of what makes computer programs powerful and flexible
  • Functions - help you create organized and reusable code
  • Classes and Objects - a class is a package containing two things: data and methods to access and modify that data; Objects play another role in PHP outside their traditional OO position
  • Web Basics - focuses on some web-specific concepts and organizational topics that will make your web programming stronger
  • Forms - seamless integration of form variables into your programs. It makes web programming smooth and simple, from web form to PHP code to HTML output
  • Database Access - PHP can interact with 17 different databases, some relational and some not. The relational databases it can talk to are DB++, FrontBase, Informix, Interbase, Ingres II, Microsoft SQL Server, mSQL, MySQL, Oracle, Ovrimos SQL Server, PostgreSQL, SESAM, and Sybase. The nonrelational databases it can talk to are dBase, filePro, HyperWave, and the DBM family of flat-file databases. It also has ODBC support
  • Web Automation - there are four ways to retrieve a remote URL in PHP
  • XML - with the help of a few extensions, PHP lets you read and write XML for every occasion
  • Regular Expressions - a powerful tool for matching and manipulating text
  • Encryption and Security - including obscuring data with encoding, verifying data with hashes, encrypting and decrypting data, and more
  • Graphics - with the assistance of the GD library, you can use PHP to create applications that use dynamic images to display stock quotes, reveal poll results, monitor system performance, and even create games
  • Internationalization and Localization - PHP can create applications that speak just about any language
  • Internet Services - covers sending mail including MIME mail, reading mail with IMAP or POP3, posting and reading messages to Usenet newsgroups, getting and putting files with FTP, looking up addresses with LDAP, using LDAP for user authentication, performing DNS lookups, checking if a host is alive, and getting information about a domain name
  • Files - PHP's interface for file I/O is similar to C's, although less complicated
  • Directories - PHP provides two ways to look in a directory to see what files it holds. The first way is to use opendir( ) to get a directory handle, readdir( ) to iterate through the files, and closedir( ) to close the directory handle. The second method is to use the directory class. Instantiate the class with dir( ), read each filename with the read( ) method, and close the directory with close( )
  • Client-Side PHP
  • PEAR - the PHP Extension and Application Repository, a collection of open source classes that work together. Developers can use PEAR classes to generate HTML, make SOAP requests, send MIME mail, and a variety of other common tasks
2. PHP 5 Power Programming
PHP 5 Power Programming
Website ptgmedia.peasoncmg.com
Author Andi Gutmans, Stig Saether Bakken and Derick Rethans
Format PDF
Pages 720
In PHP 5 Power Programming, PHP 5's co-creator and two leading PHP developers show you how to make the most of PHP 5's industrial-strength enhancements in any project, no matter how large or complex.
Their unique insights and realistic examples illuminate PHP 5's new object model, powerful design patterns, improved XML Web services support, and much more. Whether you are creating web applications, extensions, packages, or shell scripts, or migrating PHP 4 code, here are high-powered solutions you will not find anywhere else.
Review PHP's syntax and master its object-oriented capabilities, from properties and methods to polymorphism, interfaces, and reflection.
The book enables users to:
  • Master the four most important design patterns for PHP development
  • Write powerful web applications: handle input, cookies, session extension, and more
  • Integrate with MySQL, SQLite, and other database engines
  • Provide efficient error handling that is transparent to your users
  • Leverage PHP 5's improved XML support including parsing, XSLT conversions, and more
  • Build XML-based web services with XML-RPC and SOAP
  • Make the most of PEAR: work with the repository, use key packages, and create your own
  • Upgrade PHP 4 code to PHP 5, compatibility issues, techniques, and practical workarounds
  • Improve script performance: tips and tools for PHP optimization
  • Use PHP extensions to handle files/streams, regular expressions, dates/times, and graphics
  • Create original extensions and shell scripts
3. PHP Reference: Beginner to Intermediate PHP5
PHP Reference Book
Website www.phpreferencebook.com
Author Mario Lurig
Format PDF, ePub, HTML
Pages 163
PHP Reference Book: Beginner to Intermediate PHP5 is a collection of over 250 PHP functions with clear explanations in language anyone can understand, followed with as many examples as it takes to understand what the function does and how it works. One of the best PHP books to keep around as a PHP reference.
This PHP reference includes numerous additional tips, the basics of PHP, MySQL query examples, regular expressions syntax, and two indexes to help you find information faster: a common language index and a function index.
Topics include:
  • Operators
  • Control Structures
  • Global Variables
  • Variable Functions
  • String Functions
  • Array Functions
  • Date/Time Functions
  • Mathematical Functions
  • MySQL Functions
  • Directory & File System Functions
  • Output Control (Output Buffer)
  • Sessions
  • Regular Expressions
This book is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.0 License.

4. The Underground PHP and Oracle Manual
The Underground PHP and Oracle Manual
Website www.oracle.com
Author Christopher Jones, Alison Holloway, and many contributors
Format PDF
Pages 362
The Underground PHP and Oracle Manual is written for PHP programmers developing applications for the Oracle Database. It shows programmers how to use PHP with Oracle, and provides the fundamental building blocks needed to create high-performance PHP Oracle Web applications.
Topics covered:
  • Getting Started With PHP - provides a very brief overview of the PHP language
  • PHP Oracle Extensions - covers OCI8 (PHP's main Oracle extension) and PDO_OCI driver for the PHP Data Object extension
  • Installing Oracle Database 11g Express Edition - contains an overview of, and installation instructions for, Oracle Database 11g Express Edition for Linux and Windows
  • SQL with Oracle Database - contains an overview of some SQL*Plus, Oracle Application Express and Oracle SQL Developer features you can use to perform database development
  • Netbeans IDE for PHP - gives a high level overview of the NetBeans IDE - this provides tools to make PHP development productive and effective
  • Installing Apache HTTP Server - gives you the steps needed to install and configure the Apache HTTP Server for use with PHP
  • Installing and Configuring PHP - discusses the main ways of installing PHP on Linux and Windows
  • Installing PHP and Apache on Oracle Solaris 11.1
  • Connecting to Oracle Using OCI8 - covers connecting to an Oracle database from your PHP application, showing the forms of Oracle connection and how to tune them
  • Executing SQL Statements With OCI8 - discusses using SQL statements with the PHP OCI8 extension. It covers statement execution, the OCI8 functions available, handling transactions, tuning queries, and some useful tips and tricks
  • Using PL/SQL with OCI8 - PL/SQL is Oracle’s procedural language extension to SQL
  • Using Large Objects in OCI8 - Oracle Character Large Object (CLOB) and Binary Large Object (BLOB) types can be used for very large amounts of data. They can be used for table columns and as PL/SQL variables
  • Using XML with Oracle and PHP - covers the basics of using XML data with Oracle and PHP. It also shows how to access data over HTTP directly from the database
  • PHP Connection Pooling and High Availability - discusses connection pooling and how it applies to connection management
  • PHP and TimesTen In-Memory Database - TimesTen is an in-memory database that can be used standalone or as a cache to Oracle database
  • PHP and Oracle Tuxedo - shows using Oracle Tuxedo 11.1 with PHP applications running under Apache. HTTP requests are forwarded from Apache to mod_tuxedo which then invokes the PHP script engine. Oracle Tuxedo is a transaction oriented application server which can be used for developing and deploying applications written in PHP, Python and Ruby, as well as in the traditional languages C, C++, and COBOL
  • Globalization - discusses global application development in a PHP and Oracle Database environment. It addresses the basic tasks associated with developing and deploying global Internet applications, including developing locale awareness, constructing HTML content in the user-preferred language, and presenting data following the cultural conventions of the locale of the user
  • Testing PHP and the OCI8 Extension - discusses running the PHP test suite on Linux. The PHP source code includes command-line tests for all the core functionality and extensions
The book has been updated for Oracle Database Express Edition 11g Release 2. It is not a complete PHP syntax or Oracle SQL guide.
5. Symfony - The Book
Symfony - The Book
Website symfony.com/doc/current/book/index.html
Author SensioLabs
Format PDF
Pages 242
Symfony is a web application framework written in PHP that follows the model–view–controller (MVC) paradigm.
Topics covered include:
  • Symfony2 and HTTP Fundamentals
  • Symfony2 versus Flat PHP
  • Installing and Configuring Symfony
  • Creating Pages in Symfony2 - create a route, create a controller
  • Controller - a PHP function you create that takes information from the HTTP request and constructs and returns an HTTP response
  • Routing - the Symfony2 router lets you define creative URLs that you map to different areas of your application
  • Creating and using Templates - learn how to write powerful templates that can be used to return content to the user, populate email bodies, and more
  • Databases and Doctrine - learn the basic philosophy behind Doctrine and see how easy working with a database can be. Doctrine is a library whose sole goal is to give you powerful tools to make this easy
  • Databases and Propel - Propel is a free, open-source (MIT) object-relational mapping toolkit written in PHP
  • Testing - integrates with an independent library - called PHPUnit - to give a rich testing framework
  • Validation - Symfony2 ships with a Validator component that makes this task easy and transparent. This component is based on the JSR303 Bean Validation specification
  • Forms - build a complex form from the ground-up, learning the most important features of the form library along the way
  • Security - Symfony's security component is available as a standalone PHP library for use inside any PHP project
  • HTTP Cache - The Symfony2 cache system relies on the simplicity and power of the HTTP cache as defined in the HTTP specification
  • Translations - learn how to prepare an application to support multiple locales and then how to create translations for multiple locales
  • Service Container - this chapter is about a special PHP object in Symfony2 that helps you instantiate, organize and retrieve the many objects of your application
  • Performance - explore many of the most common and powerful ways to make your Symfony application even faster
  • Internals - an in-depth explanation of the Symfony2 internals
  • The Symfony2 Stable API - a subset of all Symfony2 published public methods (components and core bundles)
This book is licensed under the Attribution-Share Alike 3.0 Unported license.
6. PHP Essentials
PHP Essentials
Website www.techotopia.com/index.pho/PHP_Essentials
Author Neil Smyth
Format HTML
Pages -
This online e-book covers all aspects of PHP programming. It begins with a brief history of PHP, then gives an overview of PHP, and why it is so useful to web programmers. Subsequent chapters cover all areas of PHP in detail: the basics of the language, file and filesystem handling, object oriented programming, MySQL and SQLite database access, handling of HTML forms, using cookies and PHP sessions. All chapters are accompanied by real world examples.
Topics include:
  • The History of PHP
  • An Overview of PHP - a high level look at PHP and provide a basic understanding of what it is, what is does and how it does it
  • Creating a Simple PHP Script - construct the most basic of PHP examples, and in so doing the author takes two approaches to creating PHP powered web content: embedding PHP into an HTML page, and embed the HTML into the PHP
  • Commenting PHP Code - involves writing notes alongside the code to describe what the code does and how it works
  • An Introduction to PHP Variables - covers naming and creating a variable in PHP, assigning a value to a PHP variable, accessing PHP variable values, changing the type of a PHP variable, and checking whether a variable is set
  • Understanding PHP Variable Types - looks at the PHP integer, string, float and boolean variable types
  • PHP Constants - the opposite of a variable in that once it has been defined it cannot be changed
  • PHP Operators - enable us to perform tasks on variables and values such as assign, multiply, add, subtract and concatenate them
  • PHP Flow Control and Looping - explores conditional statements, looping statements, and switch statements and creates some examples that show how to implement these mechanisms
  • PHP Functions
  • PHP Arrays - provides a way to group together many variables such that they can be referenced and manipulated using a single variable
  • Working with Strings and Text in PHP - explores a number of the functions and techniques provided by PHP to enable you, as a web developer, to perform tasks such as changing the case of a string, replacing one part of a piece of text with another piece of text, searching text and much more
  • PHP, Filesystems and File I/O - covers all aspects of interacting with files and the filesystem
  • Working with Directories in PHP - work with file system directories
  • An Overview of HTML Forms - provides a basic grounding of HTML forms before moving on to the more PHP specific areas of building a form
  • PHP and HTML Forms - create a simple HTML form to gather information from the user and then create a PHP script to process that data once it has been submitted to the server
  • PHP and Cookies - Creating, Reading and Writing - looks at the use of cookies to maintain state, and the use of PHP sessions as an alternative to the use of cookies. It also provides an overview of the difference between cookies and PHP sessions
  • Understanding PHP Sessions - explores the concept of PHP sessions in more detail and provide some examples of how to create and use sessions
  • PHP Object Oriented Programming - introduces the basic concepts involved in object oriented programming and explains the concept as it relates to PHP development
  • Using PHP with MySQL - how to access information stored in a MySQL database from a PHP script and present that data to a user's web browser
  • PHP and SQLite - SQLite is an embedded database that is bundled with PHP starting with PHP 5 and implements a large subset of the SQL 92 standard
7. Practical PHP Programming
PracticalPHPProgramming
Website www.tuxradar.com/practicalphp
Author Paul Hudson
Format HTML
Pages -
Practical PHP Programming is a concise, starting resource for individuals that want to learn PHP programming. It assumes no PHP programming at all.
The book contains lots of information for newcomers as well as information on advanced functionality in PHP for veterans. It includes information on advanced features such as IMAP, XML and Sockets, as well as tips and tricks on how to program effectively in PHP.
Topics covered include:
  • Simple variables and operators
    • Types of data that is availabe
    • References, typecasting, and variable variables
    • Script variables, pre-set-variables, script contstants, and pre-set constants
    • Operators such as plus, minus, multiply, and divide
  • Functions:
    • Working with date and time
    • Mathematical functions
    • String manipulation
    • Creating data hashes
    • Regular expressions
    • Extension handling
    • Writing your own functions
    • Recursive, variable, and callback functions
  • Arrays:
    • Reading arrays
    • Manipulating arrays
    • Multidimensional arrays (arrays of arrays)
    • Saving arrays
  • Objects:
    • Objects and classes defined
    • Class inheritance
    • Access control
    • Runtime type information
    • Abstract and final properties and functions
    • Constructors and destructors
    • Magic functions
  • HTML Forms
    • Form design using HTML
    • Sending and receiving form data with PHP
    • Splitting forms across pages
    • Validating input
  • Files:
    • Reading and writing files
    • Temporary files
    • How to make a counter
    • Handling file uploads
    • File permissions
  • Databases:
    • What makes a database
    • What databases are available
    • SQL commands using MySQL
    • Connecting to MySQL through PHP
    • Using PEAR::DB for database abstraction
    • SQLite for systems without a database system
    • Normalisation and table joins
    • Table design considerations
    • Persistent connections and transactions
  • Cookies and Sessions:
    • How cookies and sessions compare
    • Which to use and when
    • How to use sessions
    • Using a database to store your sessions
    • Storing complex objects
  • Multimedia:
    • The multimedia formats that are available and their advantages
    • Creating basic image formats
    • Working with the rich-text format (RTF)
    • Creating portable document format (PDF) files
    • Working with the Shockwave Flash (SWF) format
  • XML & XSLT:
    • Standard XML manipulation
    • "SimpleXML" - the fast and easy way to use XML
    • XSL and transforming XML
  • Output Buffering:
    • When to use output buffering
    • Manipulating multiple buffers
    • Incremental data flushing
    • Output compression
  • Java and COM:
    • How to use COM
    • Finding out what components you have installed
    • Advanced COM - controlling Internet Explorer, and even writing VBScript
    • Distributed COM: COM over a network
    • Running Java in your scripts
    • Creating interfaces with Swing
  • Networks:
    • What sockets are, and basic socket use
    • How to use sockets outside of HTTP
    • How to create a basic server using PHP
    • Creating a web server
    • Helpful network-related functions
    • HTTP-specific and FTP-specific functions
    • The Curl library
  • Miscellaneous topics
  • Security concerns: 
    • Why register_globals matters
    • How to program secure PHP
    • Considerations for people who host others' web sites
    • Safe mode PHP
    • Encryption, simple and advanced
  • Performance:
    • Increasing performance by optimising your scripts
    • Increasing performance by optimising your SQL
    • Increasing performance by optimising your server
    • Caching PHP scripts
    • PHP the CGI vs. PHP the Apache module
  • Writing PHP:
    • How to analyse your system requirements
    • Using a development tool to help you code
    • File layout schemes and group development
    • Documentation and testing
    • Distribution your code and licensing your work
    • How to debug your scripts
    • Troubleshooting hints and tips
    • Where to get help if you still have a problem
  • Writing extensions: 
    • When to write a custom extension
    • How to design, create, and test your extension
  • Alternative PHP uses: 
    • How to use PHP to write shell scripts
    • How the CLI SAPI differs from "normal" PHP
    • Interacting with the dialog program to create command-line user interfaces
    • Using GTK+ to create graphical user interfaces
    • Using Glade to automatically generate GTK+ GUIs
    • Making text-based games with PHP
    • Making graphical games with PHP and SDL
    • Creating your own miniature language with PHP
  • Practical PHP
  • Bringing it to a close
  • Answers to Exercises
  • The future of PHP
8. Zend Framework: Surviving the Deep End
Zend Framework: Surviving the Deep End
Website survivethedeepend.com
Author Pádraic Brady
Format HTML
Pages -
Zend Framework: Surviving The Deep End is written in the form of a detailed tutorial following a step by step approach to building a real life application.
The book walks you through the process of building a complete Web application with the Zend Framework, starting with the basics and then adding in more complex elements, such as data pagination and sorting, user authentication, exception handling, localization, and Web services. Debugging and performance optimization are also covered in this fast-paced tutorial.
The book was written to guide readers through the metaphorical "Deep End". It is the place you find yourself in when you complete a few tutorials and scan through the Reference Guide, where you are buried in knowledge up to your neck but without a clue about how to bind it all together effectively into an application. This take on the Zend Framework offers a survival guide, boosting your understanding of the framework and how it all fits together by following the development of a single application from start to finish.
Topics include:
  • The Architecture of Zend Framework Applications
  • The Model
  • Installing the Zend Framework
  • A Not So Simple Hello World Tutorial
  • Standardise the Bootstrap Class with Zend_Application
  • Handling Application Errors
  • Developing a Blogging Application
  • Inplementing the Domain Model: Entries and Authors
  • Setting the Design with Zend_View, Zend_Layout, HTML 5 and Yahoo! User Interface Library
The text of this book is licensed under a Creative Commons Attribution-Non-Commercial-No Derivative Works 3.0.
9. Practical PHP Testing
Practical PHP Testing
Website www.giorgiosironi.com
Author Giorgio Sironi
Format PDF
Pages 61
Practical PHP Testing is targeted at PHP developers. It features articles published on the author's blog site, together with new content. The book includes code samples and TDD exercises.
Topics covered include:
  • PHPUnit usage - a unit testing software framework for the programming language PHP
  • Write clever tests
  • Assertions - declarations that must hold true for a test to be declared successful
  • Fixtures - write the code to set the world up in a known state and then return it to its original state when the test is complete
  • Annotations - a standard way to add metadata to code entities, such as classes or methods
  • Refactoring and Patterns - changing of complex and complicated programming codes into simple and confusion-less ones
  • Stubs - a piece of code used to stand in for some other programming functionality
  • Mocks -used in behavior verification
  • Command line options
  • The TDD theory - describes the fundamentals of Test-Driven Development and its benefits
  • Testing sqrt() - the PHP sqrt() function calculates the square root mathematical function on its argument
The ebook is licensed under a Creative Commons Attribution Noncommercial-Share Alike 3.0 License.       






Android Programming for Beginners: User Menus

http://www.linux.com/learn/docs/690708-android-programming-multiple-choice-lists


In our previous Android coding tutorials (part 1, part 2), you set up your dev environment, built a basic app, and then improved it by adding a menu and a second Activity. In this tutorial we're going to look at a very handy part of the Android API: ListView, ListActivity, and the associated methods which give you an easy way to show the user a list and then act when they click a list item.

Creating a ListView

A very common pattern in an Android activity is showing a list of items for the user to select from. The Android API provides the ListView and ListActivity classes to help out with this. Carrying on with the Countdown app from previous tutorials, we'll list a few sample countdown times for the user to select from to set the timer.
If all you want is a List, ListActivity will set your View up for you automatically; no need to write any XML at all. So onCreate()can be very simple:
public class CountdownActivity extends ListActivity {
  public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 
    Integer[] values = new Integer[] { 5, 10, 15, 20, 25, 30, 45, 60 }; 
    ArrayAdapter adapter = 
        new ArrayAdapter(this, android.R.layout.simple_list_item_1, 
                                  values);
    setListAdapter(adapter);
  }
}
CountdownActivity now extends ListActivity. ListActivity does a lot of the preparation work for you, so to show a list, you just need to create an array of values to show, hook it up to an ArrayAdapter, and set the ArrayAdapter as the ListActivity's ListAdapter. The ArrayAdapter has three parameters:
  1. The current context (this);
  2. The layout resource defining how each array element should be displayed;
  3. The array itself (values).
For the layout resource, we're use a standard Android resource, android.R.layout.simple_list_item_1. But you could create your own, or use another of the standard layout items (of which more later). You can also take a look at the XML of the standard resources.
The problem with this layout is that it only shows a list. We want to be able to see the countdown and the start button as well. This means setting up our own XML layout, rather than relying on ListActivity to generate its own layout. Add this to your XML, below the TextView and the Button:

It's important that the ListView should have the ID @android:id/list. This is what enables the ListActivity to do its magic without you explicitly setting up the List.
android 3 listchoice
Now go back to CountdownActivity.onCreate(), and put your previous display and button setup code back in, after the ListView setup:
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  
  Integer[] values .... etc ...
  [ ... ]
  setListAdapter(adapter);
  setContentView(R.layout.activity_main);
  countdownDisplay = (TextView) findViewById(R.id.time_display_box);
  Button startButton = (Button) findViewById(R.id.startbutton);
  [ .... etc .... ]
}
Again, it's important that you set up the ListView first, before setContentView(), or it won't work properly. Recompile and run, and you'll see the list appear below the text and button. What you won't see, though, is anything happening when you click the list elements. The next section will tackle that problem.
One final note: you can also set up an empty element in the layout, which will display if and only if the ListView is empty. Add this to your XML:
 
(You'll need to set up the string value in res/values/strings.xml, too). Now replace the array declaration line in CountdownActivity.onCreate()with this one:
Integer[] values = new Integer[] { };
Compile and run, and you'll see the empty text displayed, and no list. Put the array declaration back how it was, compile and run again, and the list shows, but no text. In our app this isn't particularly useful, but if you were populating the array from elsewhere in your code, it's a neat trick to have available.

Clicking on List elements

Now we have the List set up, we need to make it do something when you click on a list element. Specifically, it should set the countdown seconds to the new value, and change the display. Happily, Android has a straightforward API for this, too:
ListView list = getListView();
list.setOnItemClickListener(new OnItemClickListener() {
  public void onItemClick(AdapterView parent, View view, int position, 
                          long id ) {
    countdownSeconds = (Integer) getListAdapter().getItem(position);
    countdownDisplay.setText(Long.toString(countdownSeconds));
  }
});
This is all pretty self-explanatory! We grab the ListView, set its OnItemClickListener, and create an onItemClick() method for the Listener. As you can see here, onItemClick()has access to the position in the List of the item you clicked on. So we can grab the ListAdapter, get the item from that position, and then cast the value to an Integer. Save and run, and you have a list of values to set your timer.

Changing the List's appearance

Earlier, we mentioned the other standard layouts available. If you switch simple_list_item_1 to simple_list_item_single_choice, and rerun your code, you'll see that you get a selection indicator next to your list items. However, when you click it, the countdown value changes, but the selection indicator doesn't do anything. To make this work, you need to change your ListView, too. Add this attribute in your XML:

Run it again, and the selection indicator does its job. If you were using a ListActivity without an XML file, you could do this with a line of code in your app:
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); 

Conclusion

There are lots of situations in apps where you might want to show the user a list. ListView and ListActivity make that very easy, and as shown just above, there are plenty of ways to improve the UI experience. You could also look at providing a context menu (in these tutorials we've only used the options menu so far) when the user long-clicks on a list item. Or you could look at some form of back-end data storage, and allow the user to add and edit their own list items, so they have a list of countdown times that they regularly use. As ever, keep playing with the code and see where it takes you!
For more Android programming training resources, please visit the Linux training website.

Android Programming for Beginners: Part 1

http://www.linux.com/learn/docs/683628-android-programming-for-beginners-part-1


With Android phones and tablets making their way into more and more pockets and bags, dipping a toe into Android coding is becoming more popular too. And it's a great platform to code for -- the API is largely well-documented and easy to use, and it's just fun to write something that you can run on your own phone. You don't even need a phone at first, because you can write and test code in an emulator on your Linux PC.  In the first of this two-part intro to Android coding, get a basic timer app up and running and start learning about the Android API. This tutorial assumes some basic familiarity with Java, XML, and programming concepts, but even if you're shaky on those, feel free to follow along!

Dev environment and getting started

A note on versions: the most recent version of Android is 4.2 (Jelly Bean), but as you can see from this Wikipedia chart, there aren't many people using it yet. You're better off coding for one or both of 4.0 (Ice Cream Sandwich) or 2.3 (Gingerbread), especially as Android is entirely forwards-compatible (so your 2.3 code will run on 4.2) but not always backwards-compatible. The code here should work on either 4.0 or 2.3.
android countdown timer
The quickest way to get your dev environment set up is to download the Android Bundle. You'll also need JDK 6 (not just JRE); note that Android is not compatible with gcj. If you already have Eclipse, or wish to use another IDE, you can set it up for Android as described here.
Now, create a project called Countdown either using Eclipse, or from the command line. I set the BuildSDK to 4.0.3, and minimum SDK to 2.2, and (in Eclipse) used the BlankActivity template.

 

My First Android Project: Layout

For our very first program, we're going to do is to show a timer that counts down from 10 seconds when you click a button. Before writing the code, let's create the interface -- what the user will see when they start the app. Open up res/layout/activity_countdown.xmlto create an XML layout, using either the Eclipse graphical editor, or a text/XML editor, to enter this:

      
      
Note the references to @string/start and @string/__00_30. These values are stored in res/values/strings.xml:
Start
00:30
This illustrates the standard way of referring to Android resources. It's best practice to use string references rather than hard-coding strings.

My First Android Project: Code

Next, open up the CountdownActivity.java file in your editor, ready to write some code. You should already have an onCreate() method stub generated. onCreate() is always called when the Activity is first created, so you'll often do setup and app logic startup here. (Eclipse may also have created an onCreateOptionsMenu()method stub, which we'll ignore for now.) Enter this code:
public class CountdownActivity extends Activity {
 
  private static final int MILLIS_PER_SECOND = 1000;
  private static final int SECONDS_TO_COUNTDOWN = 30;
  private TextView     countdownDisplay;
  private CountDownTimer timer;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_countdown);
        
    countdownDisplay = (TextView) findViewById(R.id.time_display_box);
    Button startButton = (Button) findViewById(R.id.startbutton);
    startButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
        try {
          showTimer(SECONDS_TO_COUNTDOWN * MILLIS_PER_SECOND);
        } catch (NumberFormatException e) {
          // method ignores invalid (non-integer) input and waits
          // for something it can use
        }
      }
    });
  }
}
You'll notice the thing that makes this a surprisingly easy first project: the Android API includes a CountDownTimer that you can use. We set up this, and the countdown display, as private member variables. In onCreate() we use the built-in setContentView method to grab our XML layout The R.foo.barsyntax is a standard way to refer to Android XML resources in your code, so you'll see it a lot.
findViewById is another method you'll use a lot; here, it grabs the display and the Start button from the XML layout. For the Button to work when clicked, it needs an OnClickListener. This is an interface, so must be subclassed. We could create a whole new MyButton class to do this, but this is overkill for a single button. Instead, we do it inline, creating a new OnClickListener and its onClick() method. Ours simply calls showTimer() on the number of milliseconds we want to use (currently hard-coded).
So what does showTimer()do?
private void showTimer(int countdownMillis) {
  if(timer != null) { timer.cancel(); }
  timer = new CountDownTimer(countdownMillis, MILLIS_PER_SECOND) {
  @Override
  public void onTick(long millisUntilFinished) {
    countdownDisplay.setText("counting down: " +
    millisUntilFinished / MILLIS_PER_SECOND);
  }
  @Override
    public void onFinish() {
      countdownDisplay.setText("KABOOM!");
    }
  }.start();
}
The CountDownTimer class does most of the work for us, which is nice. Just in case there's already a running timer, we start off by cancelling it if it exists. Then we create a new timer, setting the number of milliseconds to count down (from the showTimer() parameter) and the milliseconds per count interval. This interval is how often the onTick()callback is fired.
CountDownTimer is another abstract class, and the __onTick()__ and __onFinish()__ methods must be implemented when it is subclassed. We override onTick() to decrease the countdown display by a second on every tick; and override onFinish() to set a display message once the countdown finishes. Finally, start() sets the timer going.
If you select 'Run' in Eclipse, you can choose to run this as an Android app, and an emulator will automatically be generated and run for you. Check out the Android docs if you need more information on setting up an emulator, or on running an app from the command line.
Congratulations, you've written your first Android app! In the second part of this series, we'll have a closer look at the structure of an Android app, and make some improvements to the timer to input a countdown time, a Stop button, and menu options. We'll also look at running it on a physical phone rather than the software emulator.
For more information in the mean time, you can check out the Android Development Training section of The Linux Foundation's Linux training website.

RHEV upgrade saga: Creating VMs on Open vSwitch

http://www.itworld.com/virtualization/336623/rhev-upgrade-saga-rhel-kvm-creating-vms-open-vswitch


In last week's post, we discussed how we created our network by integrating Open vSwitch into RHEL KVM. Now we need to create some virtual machines to run the workloads. (VMs are required to run within a virtual environment, so we need an easy way to create them.) Once more we will approach this from running on a RHEL 6 and RHEL 5 box, as the steps are somewhat different.
The libvirt that comes with stock RHEL 6 (and RHEV actually) is version 0.90.10-21, which, lucky for us, contains support for Open vSwitch, however the libvirt for RHEL 5 is version 0.8.2, which does not contain support for Open vSwitch. This means that for RHEL 5 we have to take some extra steps to manage our networks and implies that we can't use virt-manager to create our VMs. It also means on RHEL 5 that we can't import our Open vSwitch networks into virsh to make using virt-manager and other tools easier.
Even so, I feel that libvirt v1.0.1 is a better way to go, so I downloaded the source RPM from libvirt.org and rebuilt it on my RHEL 6 machine. This did require me to rebuild libssh2 (needed >= v1.4) and sanlock (needed >= v2.4) to get the proper versions of those tools to support libvirt 1.0.1.

# Get libssh2 >= v1.4 which is available from the Fedora Core 18 repository
# rpmbuild –rebuild libssh2-1.4.3-1.fc18.src.rpm
# rpm –Uvh /root/rpmbuild/RPMS/x86_64/{libssh2,libssh2-devel}-1.4.3-1.el6.x86_64.rpm
# Get sanlock >= 2.4 which is available from the Fedora Core 18 repository as well
# rpmbuild –rebuild sanlock-2.6.4.fc18.src.rpm
# rpm –Uvh /root/rpmbuild/RPMS/x86_64/{sanlock,sanlock-devel,sanlock-lib,sanlock-python,fence-sanlock}-2.6-4.el6.x86_64.rpm
# wget http://libvirt.org/sources/libvirt-1.0.1-1.fc17.src.rpm
# rpmbuild –rebuild libvirt-1.0.1-1.fc17.src.rpm
# rm /root/rpmbuild/RPMS/x86_64/libvirt*debuginfo*rpm
# rpm –Uvh /root/rpmbuild/RPMS/x86_64/libvirt*rpm
# service libvirtd restart

While this upgrade works for RHEL 6, it will NOT work on RHEL 5 as it would require installing so many new packages that it is far easier to just upgrade to RHEL 6. So if you are using RHEL 5, you should continue down the path to use libvirt 0.8.2.
Without a tool to manage multiple KVM nodes, it is very hard to do a rolling upgrade of libvirt. I am still looking for a good tool for this. RHEV may be the only usable interface, but I could also use OpenStack -- a discussion for another time.

For RHEL 6

Once libvirtd has been restarted, we can import our networks into libvirt for use, to do that we need to write a proper libvirt network XML file. Here is the one I used named ovsbr1.xml


ovsbr1







The key lines are the name of the bridge, the virtualport type, and portgroup. While I do not use VLANs, we want to make a default portgroup that includes all VMs, etc. This has no VLANs defined. So we need to define it in libvirt, verify it is defined, start it, and then verify it is active.


# virsh net-define ovsbr1.xml
# virsh net-list –all
Name                 State      Autostart     Persistent
--------------------------------------------------
default               active     yes           yes
ovsbr1               inactive   no            no
# virsh net-start ovsbr1
# virsh net-info  ovsbr1
Name                 ovsbr1
UUID            ffffff-ffffffff-ffffffffff-ffffffffff….
Active:          yes
Persistent:     no
Autostart:      no
Bridge:           ovsbr1


Building VMs

Before we make some VMs we need to place the VMs on our storage. There are multiple types of storage pools we can use: physical disk device (disk), pre-formatted block device (fs), logical volume manager volume group (logical), iscsi target (iscsi), multipath device (mpath), network directory (netfs), SCSI host adapater (scsi), or directories (dir). For our example we will be using a directory. However, for best performance a logical storage pool is recommended.


 # virsh pool-create-as VMs dir - - - - “/mnt/KVM”
#pool-list
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
VMs                  active     yes    


For a LVM based pool where the Volume Group already exists


# virsh pool-define-as vg_kvm logical --target /dev/vg_kvm 
# virsh pool-start vg_kvm
Pool vg_kvm started
# virsh pool-autostart vg_kvm
Pool vg_kvm marked as autostarted
# virsh pool-list
Name                 State      Autostart 
-----------------------------------------
default               active     yes       
vg_kvm              active     yes    


In general, we do not want to use the default location because it ends up being in an inconvenient location within the root filesystem. You may wish to delete it, so that VMs don't accidentally end up there. Use of a block storage device as a disk type such as iSCSI would be a better performer than a file system approach if the iSCSI server is running over a high speed network such as 10G. If all you have is 1G your mileage may vary.
I did this using a simple script that will assign the proper values for my VMs. Specifically the base memory, number of vCPUs, disk to a pool, the networks to use (in this case two Open vSwitch bridges), where to find the installation media, and finally the use of VNC to do the install.

# cat mkvm
set -x
virt-install --name $1 --ram 2048 --vcpus=2 --disk pool=VMs,size=$2 --network bridge=ovsbr0 --network bridge=ovsbr1 --cdrom /home/kvm/CentOS-5.8-x86_64-bin-DVD-1of2.iso --noautoconsole --vnc --hvm --os-variant rhel5

This makes it an easily repeatable process and the script takes two arguments, the vmname and the size in Gigabytes of the disk. Once I have a VM installed, I could then clone it as necessary. Run as such for a 12G VM named vmname.

# ./mkvm vmname 12

During the install you will have to configure your networks, to determine which Mac Addresses go with which you should use the following command:


# virsh dumpxml vmname
…
    
      
      
    
    
      
      
    


What you are looking for is which interface goes with which bridge via its Mac address as the Linux installer lists network adapters via Mac addresses not bridges. It does not even know there is a bridge there. Using the above script works on RHEL 6 and RHEL 5 and does not require you to go into and edit any XML files.
If you do have to edit the XML file containing the VM definition you can do so using:

# vi /etc/libvirt/qemu/vmname.xml
And once you finish editing
# virsh define vmname.xml

If you do not do the define command mentioned above, the changes may not be picked up.
Next we will clone some VMs from a gold master.

RHEV upgrade saga: RHEL KVM and the Open vSwitch

http://www.itworld.com/virtualization/335244/rhev-upgrade-saga-rhel-kvm-and-open-vswitch


A customer of mine recently switched from VMware Server to KVM, but they wanted better networking, which required installing and operating the Open vSwitch. Since they are using RHEL 5 (and I am using RHEL 6) we had to do some magic to install open vswitch. For RHEL 6 it is pretty simple. So here are the steps I took. All these were accomplished with a reference from Scott Lowe's posts (and with Scott's help via Twitter).
[Red Hat to acquire ManageIQ cloud software provider and Red Hat RHEV gets storage savvy]
The key requirement of this customer was that the KVM node and VMs had to share the same networking, which bridge routing would not do without some major configuration changes. They have a management network that is shared by all hosts whether virtual or physical to help in managing all aspects of their environment.

RHEL5 (installation)


# wget http://openvswitch.org/releases/openvswitch-1.7.1.tar.gz
# tar –xzf openvswitch-1.7.1.tar.gz

follow the instructions in INSTALL.RHEL to build your openvswitch RPMs such as:

# rpmbuild –bb rhel/openvswitch.spec
# cp rhel/kmodtool-openvswitch-el5.sh /usr/src/redhat/SOURCES
# rpmbuild –bb rhel/openvswitch-kmod-rhel5.spec

If there is a problem refer to the INSTALL.RHEL for using the –D option to rebuild the module with the kernel version. In my install I did NOT include –target= options as I was building for the host I was upon.

# rpm –ivh /usr/src/redhat/RPMS/x86_64/{kmod-openvswitch,openvswitch}-1.7.1*rpm

RHEL6 (installation)


# yum install kmod-openvswitch openvswitch

Now that we have installed openvswitch we should make sure that libvirtd is running first. If it is not then we cannot use KVM and therefore not OVS.

# service libvirtd status


If libvirtd is not running use the following to start immediately and to ensure it starts at boot.

# service libvirtd start
# chkconfig libvirtd on

Under normal circumstances, KVM starts with its own bridge named default, which is actually virbr0, if we are going to use the openvswitch, it is best to remove that bridge. First we need to see what bridges/networks exist. By default, it is fine to have this bridge also available as it becomes an internal only network using non-openvswitch constructs.


 # virsh –c qemu:///system net-list –all
Name                 State      Autostart     Persistent
--------------------------------------------------
default              active     yes           yes
# ifconfig –a |grep br0
virbr0    Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
virbr0-nic Link encap:Ethernet  HWaddr YY:YY:YY:YY:YY:YY


Now let's talk configuration, since this is the main reason for using openvswitch. We want the configuration to include an uplink from the physical devices to the openvswitch, then a link from the openvswitch to the Dom0 OS, and finally a link to each VM hosted. To complicate matters we need to have this done on two distinctly different networks. So how did we proceed?
First we need to configure Openvswitch, which goes along with Scott's article. First we configure the BRCOMPAT setting, which is commented out by default:/p>

# echo “BRCOMPAT=yes” >> /etc/sysconfig/openvswitch

Then start the openvswitch service(s) and configure them to start on reboot as well:

# /sbin/service openvswitch start
# /sbin/chkconfig openvswitch on

Check to see if KVM is running and openvswitch is installed properly, first by ensuring libvirtd is running properly and if the openvswitch components are loaded as modules and that the servers are running properly.

# virsh –c qemu:///system version
Compiled against library: libvirt 1.0.1
Using library: libvirt 1.0.1
Using API: QEMU 1.0.1
Running hypervisor: QEMU 0.12.1
# lsmod |grep brcom
brcompat 5905 0
openvswitch 92800 1 brcompat
# service openvswitch status
ovsdb-server is running with pid 2271
ovs-vswitchd is running with pid 2280

Now we need to create some openvswitches with some bonding thrown in for redundancy and bandwidth requirements. We also create a ‘named’ port on the openvswitch for our internal network.


# ovs-vsctl add-br ovsbr0
# ovs-vsctl add-bond ovsbr0 bond0 eth0 eth2 lacp=active # only needed for bonding
# ovs-vsctl add-port ovsbr0 mgmt0
# set interface mgmt0 type=internal

Before we go any further, we need to bring down the old interfaces, otherwise our changes to the configuration files will force a reboot. Since we are working with the existing Linux bond0 device and mapping that into the openvswitch, we should disable that bond0 device as follows.


Bonded:
 # ifdown bond0

Unbonded:
 # ifdown eth0


However, this is far from complete, we need to modify the ifcfg configurations within /etc/sysconfig/network-scripts to make all the networks come back on reboot. So the config scripts look like the following depending if we are using bonding or not:

Then we have to specify the bridge itself as a OVSBridge type.


ifcfg-ovsbr0
            DEVICE=ovsbr0
            ONBOOT=yes
            DEVICETYPE=ovs
            TYPE=OVSBridge
            HOTPLUG=no
            USERCTL=no


Finally we have to specify a new device to bring up to put the KVM node itself onto the openvswitch. In this case, we define it as type OVSPort and specify that it is part of the OVS_BRIDGE named ovsbr0. We give it the ip address assigned to the machine and the proper netmask.


ifcfg-mgmt0
            DEVICE=mgmt0
            ONBOOT=yes
            DEVICETYPE=ovs
            TYPE=OVSIntPort
            OVS_BRIDGE=ovsbr0
            USERCTL=no
            BOOTPROTO=none
            HOTPLUG=no

            IPADDR=A.B.C.D
            NETMASK=255.255.255.192


Finally, we set a default route for A.0.0.0/8 traffic that may be different than traffic going to the outside world.


route-mgmt0
            route add A.0.0.0/8 via W.X.Y.Z


Now the process is repeated for the next bonded network, which means we created two openvswitches. You can either reboot the server to make sure everything comes up properly and you have an alternative way into the machine (perhaps an ILO, DRAC, or IPMI mechanism) or you can shutdown the network and restart the network and the openvswitch constructs. I tested this by restarting the openvswitch and bringing up the mgmt0 network using normal means. I ran the following command with the following output and my openvswitches were created and all was working as expected.


# ovs-vsctl show
Bridge "ovsbr0"
        Port "ovsbr0"
            Interface "ovsbr0"
                type: internal
       Port "mgmt0"
            Interface "mgmt0"
                type: internal
       Port "bond0"
            Interface "eth2"
            Interface "eth0"
        Port "vnet7"
            Interface "vnet7"
    Bridge "ovsbr1"
        Port "bond1"
            Interface "eth3"
            Interface "eth1"
        Port "mgmt1"
            Interface "mgmt1"
                type: internal
        Port "ovsbr1"
            Interface "ovsbr1"
                type: internal
    ovs_version: "1.7.1"


Now enable the bridges and run some pings. If you are at a console you can run the following command:


# service network restart


Otherwise perhaps you want to test one interface at a time. In this case we did:


# ifup bond0 
or use # ifup eth0
# ifup ovsbr0
# ifup mgmt0


The ultimate test however is pinging the outside world and that worked flawlessly.
I would like to thank Scott Lowe for all his help from his blog post (originally for Ubuntu) and for his help on Twitter and Skype to solve the problem of getting not only openvswitch running but bonding my Dom0 to the vSwitch as well as all the DomU’s in use.
Next it is time to create some virtual machines and find a graphical management system that works for RHEV with the Open vSwitch.


AMD Roadrunner Platform Opens Server Design

http://www.serverwatch.com/server-news/amd-roadrunner-opens-server-design.html


The promise of the Open Compute Project is to provide new standards that promote server and data center flexibility. It's a promise that AMD wants to deliver on with its new Open 3.0 platform.
Open 3.0 was originally codenamed "Roadrunner" and is a new server motherboard approach that conforms to standards being developed by the Open Compute Project.
Suresh Gopalakrishnan explained during a keynote session at the Open Compute Summit this week that Open 3.0 is a single modular platform that can be tuned for multiple-use cases, whether its cloud, storage or high-performance computing. Gopalakrishnan defined Open 3.0 as the physical implementation of Open Compute.
According to Gopalakrishnan, the platform provides open management and no vendor lock-in.
The initial Open 3.0 motherboard is powered by a pair of AMD Opteron 6300 Series processors. The board supports up to 24 DIMM memory slots and 6 SATA connections. In terms of dimensions, the Open 3.0 motherboard measures 16" x 16.7" and will fit into 1U, 1.5U, 2U or 3U server chassis. AMD 3.0
"What's really exciting for me here is the way the Open Compute Project inspired AMD and specific consumers to collaboratively bring our 'vanity-free' design philosophy to a motherboard that suited their exact needs," Frank Frankovsky, chairman of the Open Compute Foundation and VP of Hardware Design and Supply Chain at Facebook, said in a statement.
AMD is working with a number of partners, including Quanta Computer, Tyan and Penguin Computing, and expects availability of Open 3.0 servers by the end of the first quarter of 2013.
AMD's Open 3.0 news followed some other big news from the Open Compute Summit, namely the new Common Slot specification. With the common slot architecture, the idea is to enable multiple types of CPUs to co-exist within a server.
"We are an active participant in that (Common Slot) and you will see different types of open hardware that we will help to drive to the market," Gopalakrishnan said. "We're very interested in how dense computing is coming together, and common slot is one approach to do that."