Canonical Voices

Posts tagged with 'mobile'

Victor Palau

Since my first steps into QML when the Ubuntu SDK was launched, I have become a bit addicted to it. I decided to try to write a QML declarative game, and I settle on a shooting fighter jet game. Finally had enough content to put out an alpha. Here is the video:


The code for it in on my LP Junk branches, not really ready for review yet ;) but happy to have help!

You might notice that I am using the keyboard to drive the game in my computer, I have also build a touch joystick that so far works ok in the Nexus 7, but needs some calibration.

PS: if you have some problems with playing the video, try jumping a head 10 secs, it also helps if you play it in HD :)


Read more
Daniel Holbach

Going mobile

Many asked me in the last time what became of the Ubuntu on Nexus7 project. I’m happy to say that it’s going really well. Some weeks ago it was already very easy to install Ubuntu on a Nexus7, since then things got better and better. Many bugs were ironed out, but the piece most folks have been concentrating on recently was the desktop-r-reduced-power-ram blueprint.

The spec says:

In the past few cycles, we saw that our desktop took more and more RAM to run the full session. Also, more daemons mean more interruptions on the CPU, and less battery file. We will get services to not run when not needed and work on improving the code of those components to consume less resources

Why is this so relevant in a mobile setting? Simple. Most mobile devices are less well-equipped than the common Desktop or Laptop, and every interruption, every bit of CPU usage, every disk access costs precious battery life. Fixing this kind of bugs will have a great and positive impact for all devices running Ubuntu.

Here’s a quick summary of the work which has been done:

  • Robert Ancell: look at why lightdm is using 30MB (it’s due to the memory locking – without locking it drops to 3.7M)
  • Michael Terry: Make lightdm selectively lock memory instead of using mlockall
  • Sébastien Bacher: look if gnome-keyring needs to be running all the time (needs to, restarting would mean having to unlock it again, e.g ask user for password every time)
  • Sébastien Bacher: look at what is making goa run for some users (it’s e-d-s)
  • Sébastien Bacher: set up follow-up meetings about the topics we didn’t cover during the session
  • Ken vanDine: check with online team if signond needs to be running all the time
  • Ken vanDine: investigate long running telepathy-indicator/mission-control
  • Iain Lane: drop g-c-c recommends on goa so it’s not installed by default
  • Oliver Grawert: seed zram-conf
  • Brian Murray: look at what update-notifier is used for nowadays, identify if those functionalities could be replaced/moved to upstart jobs [http://wiki.ubuntu.com/UpdateNotifier]
  • Colin Watson: fix upower memory leaks
  • Colin Watson: reduce update-notifier memory use

Update: Sébastien also mailed the ubuntu-devel@ list with a nice summary of the work.

We need your help

If you have a look at the desktop-r-reduced-power-ram blueprint you can see that there is still quite a bit of work which need to be done. There are assignees for some of the work items, but all of them will be happy to hear you offer help. The effort is coordinated on #ubuntu-desktop, so you best head there and start chatting with the team.

More information – live hangout

Tomorrow, 7 Feb 2013, at 9 UTC I am going to talk with my friend Sébastien Bacher on http://ubuntuonair.com about this initiative, so if you want to find out more, be sure to tune in or watch the recording in the ubuntuonair youtube channel afterwards.

Read more
Victor Palau

Last week I wrote about my first impressions on working with QML vs Android as I tried to translate a SimpleTodo application.

This week, I managed to find a few more spare hours to finish it. Not only that, but I have been able to go beyond what I had for Android. Specially on the UI part, QML makes it really simple to build in transitions and animations. I also found that defining States for the application had simplified the complexity of the program.

I don’t think that today there are official menus published for Ubuntu qml components, so I have implemented my own menu “a la” Ubuntu for phones. Here is a small video of the app:

or you can access the link here: http://www.youtube.com/watch?v=T-gDv-vDMhg

Overall, I highly recommend everyone to play with QML. Here are two very useful links if you are new to it:

And of course, lets not forget the awesome developer.ubuntu.com pages!


Read more
Victor Palau

A few months back, I decided to write a Simple ToDo app for Android, then I hooked it up to a cloud backend, using Juju. That was my first Android application, so I got to experience first hand the latest developer documentation and development environment.

Last month, Canonical launched Ubuntu for Phones, that gave me the idea to re-write the same application on QML using the Ubuntu Components.

Clearly comparing a new SDK-Alpha with a stable platform like Android will seem hardly fair, however, keep reading as you might be surprised of the results.

QML vs Dalvik Java

Lets start with QT/QML vs Dalvik/Java – I found QML really easy to get to grips with and be productive. I had the UI (see picture below) running in no time and I would say much faster than with Android.  QML is a very flexible declarative environment that allows you to embedded quick logic into the layout. This is a blessing and  a curse.

While with Android, it was very easy to keep a nice MVC  separation, I struggled to stop the leaks in QML. So while it is very easy to quickly write a functional application, it does not impose what you would consider as good development practices.

In summary, they are both very powerful development environments.

todoapp

IDE: Eclipse vs QtCreator

Part of the development experience is the IDE. I must say that I simply love the QTCreator. Possibly not as polish as Eclipse but you don’t need to read a manual to use it. Also, with a quick integration with the HUD, it is just very simple to use.

So what is QTCreator missing? A good emulator. The Android Development Kit (ADK) provides a really good user experience to develop mobile solutions. QMLScene gives you similar functionality but does not simulate a phone environment. However, all the technology is there, and  I am sure that will be included in the v1.0 version of the SDK.

Documentation

I can’t fault Android developer documentation, but taking into account its popularity, you  wouldn’t expect anything else.

I was very surprise of the quality of information on http://developer.ubuntu.com/ and specially with the component showcase.

componentshowcase

The only thing to watch out for is that in Android you can get all the info you need from a single website. With QML you quickly end up pinging between Digia, Nokia and Ubuntu pages.

The Code

The code is on my launchpad repos. The actual source functionality is not finished as I am still trying to figure out how to add menu options to access Done items. Anyway, the whole thing is pretty compact compare to the Dalvik code. The actual logic is almost identical in both. A ListView that is populate from an List model. All the data is persisted in SQLite db.

Conclusion

Both environments have been equally painless to work with, the difference is that the Ubuntu environment has *just* been released as an Alpha. I think this is the start of a very vibrant App development ecosystem.


Read more
niemeyer

Our son Otávio was born recently. Right in the first few days, we decided to keep tight control on the feeding times for a while, as it is an intense routine pretty unlike anything else, and obviously critical for the health of the baby. I imagined that it wouldn’t be hard to find an Android app that would do that in a reasonable way, and indeed there are quite a few. We went with Baby Care, as it has a polished interface and more features than we’ll ever use. The app also includes some basic statistics, but not enough for our needs. Luckily, though, it is able to export the data as a CSV file, and post-processing that file with the R language is easy, and allows extracting some fun facts about what the routine of a healthy baby can look like in the first month, as shown below.

Otávio

The first thing to do is to import the raw data from the CSV file. It is a one-liner in R:

> info = read.csv("baby-care.csv", header=TRUE)

Then, this file actually comes with other events that won’t be processed now, so we’ll slice it and grab only the rows and columns of interest:

> feeding <- info[info$Event.type == "Breast",
        c("Event.subType", "Start.Time", "End.Time", "Duration")]

This is how it looks like:

> feeding[100:103,]
    Event.subType       Start.Time         End.Time Duration
129          Left 2013/01/04 13:45 2013/01/04 14:01    00:16
132          Left 2013/01/04 16:21 2013/01/04 16:30    00:09
134         Right 2013/01/04 17:46 2013/01/04 17:54    00:08

Now things get more interesting. Let’s extract that duration column into a more useful vector, and do some basic analysis:

> duration <- as.difftime(as.vector(feeding$Duration), "%H:%M")

> length(duration)
[1] 365

> total = sum(duration)
> units(total) = "hours"
> total
Time difference of 63.71667 hours

> mean(duration)
Time difference of 10.47397 mins
> sd(duration)
[1] 5.937172

A total of 63 hours surprised me, but the mean time of around 10 minutes per feeding is within the recommendation, and the standard deviation looks reasonable. It may be more conveniently pictured as a histogram:

> hist(as.numeric(duration), breaks="FD",
    col="blue", main="", xlab="Minutes")

Duration histogram

Another point we were interested on is if both sides are properly balanced:

> sides <- c("  Right", "  Left")
> tapply(duration, feeding$Event.subType, mean)[sides]
   Right     Left 
10.72283 10.22099

Looks good.

All of the analysis so far goes over the whole period, but how has the daily intake changed over time? We’ll need an additional vector to compute this and visualize in a chart:

> day <- format(strptime(feeding$Start.Time, "%Y/%m/%d %H:%M"),
                "%Y/%m/%d")
> perday <- tapply(duration, day, sum)
> mean(perday)
[1] 136.5357
> sd(perday)
[1] 53.72735
> sd(perday[8:length(perday)])
[1] 17.49735

> plot(perday, type="h", col="blue", xlab="Day", ylab="Minutes")

Daily duration

The mean looks good, with about two hours every day. The standard deviation looks high on a first look, but it’s actually not that bad if we take off the first few days. Looking at the graph shows why: the slope on the left-hand side, which is expected as there’s less milk and the baby has more trouble right after birth.

The chart shows a red flag, though: one day seems well below the mean. This is something to be careful about, as babies can get into a loop where they sleep too much and miss being hungry, the lack of feeding causes hypoglycemia, which causes more sleep, and it doesn’t end up well. A rule of thumb is to wake the baby up every two hours in the first few days, and at most every four hours once he stabilizes for the following weeks.

So, this was another point of interest: what are the intervals between feedings?

> start = strptime(feeding$Start.Time, "%Y/%m/%d %H:%M")
> end = strptime(feeding$End.Time, "%Y/%m/%d %H:%M")
> interval <- start[-1]-end[-length(end)]

> hist(as.numeric(interval), breaks="FD", col="blue",
       main="", xlab="Minutes")

Interval histogram

Seems great, with most feedings well under two hours. There's a worrying outlier, though, of more than 6 hours. Unsurprisingly, it happened over night:

> feeding$End.Time[interval > 300]
[1] 2013/01/07 00:52

It wasn't a significant issue, but we don't want that happening often while his body isn't yet ready to hold enough energy for a full night of sleep. That's the kind of reason we've been monitoring him, and is important because our bodies are eager to get full nights of sleep, which opens the door for unintended slack. As a reward for that kind of control, we've got the chance to enjoy not only his health, but also an admirable mood.

Love, Dad.

Read more
Victor Palau

A very brief note to let you all know that I have moved the chromium test extension for browsing simulation under the Ubuntu-nexus7. Please submit improvements at your leasure:

https://code.launchpad.net/~ubuntu-nexus7/ubuntu-nexus7/chromium_extension


Read more
Victor Palau

To make it easier to keep up with the work and progress on the Nexus 7 , I have set up a topic in status.ubuntu.com and a wiki page with the performance goals for the release:

If there is  a missing Blueprint that should be track under this topic, please let me know.

 


Read more
David Pitkin

Another selection of mobile games from the Humble Bundle has been released with the fourth installment of the Humble Bundle for Android. As always we have awesome Ubuntu Desktop debuts: Splice, Walking Mars, Machinarium, and Crayon Physics Deluxe all now available in Ubuntu Software Center which is the easiest way to download and receive game updates on Ubuntu. Not only can you pay what you want for every DRM-free game on Ubuntu, support charity and redeem with Software Center, you can play the games on your mobile phone. This Bundle is a great way to pick up an Android versions of an Ubuntu favorite Superbrothers: Sword & Sworcery. The “Beat the Average” game, Machinarium, is a must play game that challenges and entertains simultaneously.

One Note The Eufloria developers want to focus on Humble Bundle support and polishing before they start selling in the Ubuntu Software Center. That is why Eufloria is set at a unobtainum price, get a copy while you can as part of the bundle. The bundle should tide your gaming needs as the Steam beta from Valve that started this week for Ubuntu rolls out to a wider audience, thanks for playing.

Read more
Victor Palau

Yesterday I mentioned how I got 7 hours of battery life whilst browsing, this was done at a brightness level of 76. After that I decided to run the test again but set the brightness level to 40. This gave me an extra hour , which is about 14% extra battery life. Was I expecting more? perhaps..

 


Read more
Victor Palau

I stumbled upon a Chrome OS test case that includes a chromium-browser extension that simulates user browsing. The extension does a 1 hour test split by:

  • [First 60% of the test] Browsing: a new website is loaded every minute.  The web page loaded is scrolled down one page every second, then scrolled back up one page every second.
  • [Next 20%] Email: Gmail is loaded in the foreground tab and audio is streamed from a background tab.
  • [Next 10%] Documents: Various Google Docs are loaded.
  • [Final 10%] Video: A full screen 480p YouTube Video is played.

Besides the fact that the audio requires flash, everything else worked in the Nexus 7. After a few tweaks to the extension, I had it running on a loop for 24 hours. Also, I changed it so the auto-browsing would start as soon as you launch chromium.

The next thing to do was to write a simple bash script that would launch the browser and log battery life and screen brightness to a file every 15 min. The assumption was that as the system run out of battery it would shutdown, and that last entry in the file would give me the battery life whilst browsing.

  • Battery levels can be read from here (thanks ogra!): /sys/class/power_supply/battery/capacity
  • Brightness levels can be read from here: /sys/class/backlight/pwm-backlight/brightness

I set it to run overnight at a screen brightness of 99. The good news is that the system suspended rather than just run out of juice at about 4:51 AM (according to the browser history).  3 hours later, I resumed it to find it in a good state.

All and all - the Nexus 7 with Ubuntu was browsing for just over 7 hours (7 hours and 12 minutes), so I am pretty happy with that. Although, for any reliable benchmarking, I would need at least 10 samples of the test run. If you want to check out the test, you can find all the code here: http://bazaar.launchpad.net/~vtuson/+junk/load_test_nexus7/

Here is a graphical representation of the results:

The brightness “auto-dim” was a bit disappointing, not to say erratic, and I have filed a couple of bugs against it.


Read more
Victor Palau

I decided to run some browser performance benchmarks from http://peacekeeper.futuremark.com/ in the Nexus 7 running Ubuntu, mainly to see how it compares with other platforms. Here are my basic conclusions as a result of the test:

  • In general Ubuntu + Nexus 7 performs pretty well
  • The Nexus 7 with Ubuntu and Chromium (629) performs better that the Android Nexus 7 (489)
  • Firefox performance (257) is pretty bad compare with Chromium (629). I have tested it in my laptop and the same different exist, however the more powerful hardware makes it not as relevant.

Unfortunately, I wasn’t able to access the detailed results (it displays blank), any suggestions why? My results are the bottom firefox (257) results, and the top Chrome (629):


Read more
Victor Palau

I just proposed the following blueprint  for UDS-R, and I though I will share it here to give it more visibility:

https://blueprints.launchpad.net/ubuntu/+spec/topic-raring-desktop-targets-for-embedded

What does it take to run Ubuntu Desktop on mobile devices?

It’s time to look at the core of Ubuntu and review it through a mobile lens. During 13.04, we will like to measure and improve how the guts of our platform performs against mobile metrics.

Things like battery life, memory footprint, support for sensors… are areas where needs and expectation widely vary between a PC and a mobile devices. 13.04 will be a cycle of exploration and learning. Because there is no better way to learn that getting your hands dirty, our practical exercise will be to get Ubuntu Desktop working on the Nexus 7.

The Nexus 7 exercise will be less like a 100 meters sprint (if you don’t cross the finish line you don’t get a score) and more like Javelin competition. The further that we can throw it, the higher the score!

On those basis, here are 8 types of Javelins to throw and some distance markers to hit for Ubuntu Desktop on Nexus 7:

*Memory Usage* ->Desktop runs well with 1GB RAM ->Desktop, Web Browser and email app all run well within 1GB -> Desktop runs well with 512MB -> Desktop, Web Browser and email app all run well within 512MB

*Power Mangement* -> Instant on ->Suspend/Resume 100 cycles with only 1 error -> boot up time <1 min -> Sensible Auto Suspend policy

*Battery Life* -> CPU on idle <1% -> Standby battery life is > 150 hours -> Battery life while browsing is > 8 hours -> Battery life playing HD video is > 5 hours -> Standby battery life is > 275 hours

*Testing* -> Functional shell test that can be loaded manually into the ROM ->Performance tests can be run -> Automated battery life test -> Automated battery life test

*Desktop Apps* -> Web browser boots < 3 sec -> Email client (local or web apps) -> Music Player -> Video Player -> Games

*Desktop Unity Performance* -> Fast App-Stack switching -> Launcher Reveal time < 2 secs -> Dash Reveal time < 3 secs ->Dash search < 5 sec ->Unity performs >60 FPS

*Functionality* -> Unity Desktop works ->touch input performs well -> Play a youtube video of a cat -> Play an HD movie -> Ubuntu one

*Sensors* -> Mic & Wifi -> Touch -> Camera -> position awareness sensors -> NFC

Click in the blueprint to see a summary of other releated UDS-R sessions.


Read more
Victor Palau

Oh my, seems that the Canonical team has been busy ;)

link to youtube video -  Here


Read more
Prakash

  • Quad-core 1.5GHz Snapdragon S4 CPU
  • 2GB of RAM
  • 4.7″ Display
  • Sealed battery which can’t be changed or replaced.
  • 8GB  or 16 GB of internal storage (which won’t be expandable as no microSD slot)
  • Price of US$ 399 (no contract or locked)

Read more
Victor Palau

If you thought I had concluded my blog series on demonstrating how Ubuntu is the best environment to write up “connected” or “cloud backend” Android Apps, think again!

So far this is what we covered:

  • Proof that you can access a Juju local environment from the Android Emulator  done!
  • Using a few charms from the charm store plus a custom one, set up a MySQL database that can be exposed through a web service with simple commands/steps - done!
  • Develop a TODO list android app and connect it to the web service, so they talk to each other. – done!

The next step is “How to test that it all works on a production environment”.  If you have tested to death both your Android application and your web service locally, it is time to check if they will still work in real life. How do we do this? With few simple commands, we are going to deploy the same web service into the Amazon Cloud, and  the application in a mobile phone. All managed from the comfort of my Ubuntu Desktop.

Deploying to Amazon Web Services (AWS)

The only pre-requisite here is that you do have an AWS account. Once you are logged into the AWS website, you can find the credentials that you will need to set up your juju environment.  You can find a tutorial on how to set up your Elastic Compute Cloud (ec2) environment –> here.

The required information for Juju is stored in the environment.yaml file in the ~/.juju folder. In the following sample file you can see that two environments have been defined:

  • “local” is the environment that I have been using in my PC to test my web service using LXC containers.
  • “aws” gives Juju the information required to deploy services using my Amazon account.
  • “local” is set as default. This means that if I just run “juju bootstrap” this command applies to the local environment. To bootstrap the AWS environment, I would do “juju bootstrap -e aws”.
default: local
environments:
 aws:
  type: ec2
  access-key: YOUR-ACCESS-KEY-GOES-HERE
  secret-key: YOUR-SECRET-KEY-GOES-HERE
  control-bucket: juju-faefb490d69a41f0a3616a4808e0766b
  admin-secret: 81a1e7429e6847c4941fda7591246594
  default-series: precise
  juju-origin: ppa
  ssl-hostname-verification: true
 local:
  type: local
  control-bucket: juju-a14dfae3830142d9ac23c499395c2785999
  admin-secret: 6608267bbd6b447b8c90934167b2a294999
  default-series: precise
  juju-origin: distro
  data-dir: /home/victorp/myjuju_data

With my environments now configured, it’s time to deploy my services. This first step is to bootstrap my environment:

juju bootstrap -e aws

With the command completed successfully, I can check the status and I will see that the juju control instance is now up and running in Amazon:

juju status -e aws
2012-09-19 11:43:34,248 INFO Connected to environment.
machines:
  0:
    agent-state: running
    dns-name: ec2-75-101-189-208.compute-1.amazonaws.com
    instance-id: i-0e4f7174
    instance-state: running
services: {}
2012-09-19 11:43:35,322 INFO 'status' command finished successfully

Lets continue deploying the services. As I am only doing testing, I want to pay the minimum for it, it will ask juju to set a constrain to only use micro instances. Then I will deploy a mysql and a lamp service:

juju set-constraints instance-type=t1.micro -e aws
juju deploy mysql -e aws
juju deploy --repository ~/mycharm local:lamp -e aws
juju set lamp website-database="android_todo" -e aws
juju set lamp website-bzr="lp:~vtuson/+junk/mytodo_web" -e aws
juju expose lamp -e aws
juju add-relation lamp mysql -e aws

With all my services now running I can go to the Amazon EC2 instance console and see how they have been deployed as micro instances. I can now also enter the public address for my lamp service and see the ToDo list table as expected.

Testing the Android App on a real phone

Running Juju status, I can retrieve the public url for the lamp service and I replace the uri vairable in the TodoSourceData class with “ec2-107-22-151-171.compute-1.amazonaws.com/database.php”.  The next step is to plug a HTC Desire set up on debug mode into my laptop’s usb port. The rest is taken care by the Android Eclipse plug-ins. When I click  the run project button, I am presented with a choice of targets:

I just need to press “OK” and my ToDo app is launched in the handset. Opening the menu options and pressing “Sync” fetches the ToDo data from the Amazon services, as expected:

That is all for today! Let me know if you have any suggestions on what else I should cover on this blog series.


Read more
Victor Palau

Droidcon – London

Just a brief post to say that I will be talking at DroidCon on 26th October in London. This is what I will be covering:

Most Android apps nowadays are a front or local client for online services, from backing up data to the cloud to providing a cross platform service. This requires developers to have access to not just an Android environment, but also to a staging server that they can mess with. This requires the app developer to either gain knowledge of how to set up this complex web, or wait for someone to do it for them.

Juju is a service orchestration tool that allows you to deploy cloud applications like WordPress or Mysql to live clouds such as Amazon Web Services (AWS). Juju Charms package the wisdom of experience Dev Ops so anyone can deploy a complex apps with few simple commands. This can first be done to a local environment running in your laptop, and once you are confident on the service, deploy it to a live cloud. Ubuntu ,the leading linux desktop distribution, brings together the best support for Android app development (used by the Google Android team) with an easy to use cloud deployment toolset.

This talk will explore the simplicity of developing an android app that needs to talk to a cloud service. The talk will be framed around an example of a “TODO list” android app that locally stores information into a SQLite database, and then backs-up user data to the cloud. The talk will show how a android developer can deploy, in his or her laptop, a complex web service with just a handful of commands, and then get the application talking to the service form within the android emulator. Join us to grasp how Ubuntu can provide android developers a full test environment in a box.

My Droidcon talk profile


Read more
Victor Palau

Time for the next chapter of my blog series about demonstrating how Ubuntu is the best environment to write up “connected” or “cloud backend” Android Apps.  As you might know, the Android SDK allows you to set up a sandboxed environment to develop Mobile apps in your desktop, using Juju  you can do the same for Cloud apps.

To walk you through how to put these great development tools together, I set out to accomplish:

  • Proof that you can access a Juju local environment from the Android Emulator  done!
  • Using a few charms from the charm store plus a custom one, set up a MySQL database that can be exposed through a web service with simple commands/steps  - done!
  • Develop a TODO list android app
  • Connect the android app and the webservice, so they talk to each other.

Today I am going to cover the bottom two bullet points in one go!  For this post, I am going to assume that you know a bit of Android development. If you want a great source of introductory material check Lars Vogel’s website.

I have created a simple ToDo Android application that can store tasks into a local SQLite db and allows you to “Star” important items. The code for my Simple Todo app is hosted in Launchpad. I have written my application for Android 2.3, but you can use a later version.

Reading remote data from the MySQL server is confined to a small class that retrieves a JSON object and translates it into a TodoItem object.  Equally , the server code that prints that content table into a JSON object is extremely simple. Beyond this, you can go crazy and implement a RESTfull API to sync the databases.

At the moment, I am just inserting Server side data into the Local database and making sure I don’t add duplicates.Here is a video that shows how easy is to work and test both environments:

Or Click Here for the video.

The same environment should then work if you are running the Android application on an external phone. But that is another blog post ;)


Read more
Victor Palau

It is time to continue with my blog series on demonstrating how Ubuntu is the best environment to write up “connected” or “cloud backend” Android Apps.  As you might know, the Android SDK allows you to set up a sandboxed environment to develop Mobile apps in your desktop, using Juju  you can do the same for Cloud apps.

To walk you through how to put these great development tools together, I set out to accomplish:

  • Proof that you can access a Juju local environment from the Android Emulator  done!
  • Using a few charms from the charm store plus a custom one, set up a MySQL database that can be exposed through a web service with simple commands/steps
  • Develop a TODO list android app
  • Connect the android app and the webservice, so they talk to each other.

Today is time to set-up our own Cloud environment in a PC.  A good starting point for a web application is a LAMP stack. If you hope for you service to get popular, you might want to split out the database service and the web service into their own instances so they can be scaled easily.

When I set out to do this, I wanted to write an extremely simple PHP page that would expose a data table from a Mysql server.  I looked up the available charms on the store. I found that you had a lot of charms for existing apps, but none that had  the bare bones of a LAMP stack and just allowed you to install your own web pages. However, I did find a charm to deploy Mysql and a very handy tool to manage it (phpmyadmin). Taking this as a starting point I developed a generic LAMP charm.

The first thing the LAMP charm does is to install and configure a new instance with Apache and PHP5 in an LXC container. The new charm will then copy any files under /website  inside the charm folder structure, into /var/www. It also allows you to specify a Bazaar branch. It will clone the branch into the webserver and copy the contents to /var/www. I keep my TODO application for this exercise here.

Using juju, you can set up a relationship with a Mysql service. A Mysql database is created by default at this time. You can change the name of the database as a configuration options. If you provide a file called mysql_config either on the /website folder or in the root of you Bazaar branch, this will be used to configure further the Mysql database.

The charm will store the details of the relationship in /var/webconfig. In there you can also find opendb.php, a basic script that will open the connection to the MySQL database for you.

So lets get started! Clone the Lamp branch to a folder of your choice. I have it under “~/Mycharm/precise/lamp”. (If you need to get started with juju check my previous post here)

juju bootstrap

#step1 - deploy Mysql as a service.
juju deploy mysql

#step2 - deploy phpmyadmin tool
juju deploy phpmyadmin
juju set phpmyadmin password="password"

#this makes phpmyadmin public - exposes port 80/tcp
juju expose phpmyadmin

#step3 - link phpmyadmin and mysql so the can talk to each other
juju add-relation phpmyadmin mysql

#step4 deploy lamp from your local folder
juju deploy --repository ~/mycharm local:lamp

#step5 set up your bazaar branch and publish your website
juju set lamp website-bzr="lp:~vtuson/+junk/mytodo_web"
juju expose lamp

#step6 configure your database and link lamp and mysql services
juju set lamp website-database="android_todo"
juju add-relation lamp mysql

Once Juju has completed all the commands, run “juju status”. Now go to the ip address for the LAMP services and visit the databaseweb.php page (e.g. http://192.168.122.174/databaseweb.php) , you get this rather ugly table:

Id Todo Is it starred
1 hello this is a sample 1
2 yes it works! 0

This table is displaying the contents of a Mysql database. You will get the same data if you visit your Myphpadmin service:

So there you are a full and scalable LAMP stack in your PC!

If you want to update the web service by pulling the latest version of the Bazaar branch, just run the following commands:

juju set lamp bzr-update="yes"
juju set lamp bzr-update=

With my web developer “hat” on, I can now hand this charm over to my Android app developer. They will be able to set up exactly the same environment locally to test their app without using expensive server time.

So “Using a few charms from the charm store plus a custom one, set up a MySQL database that can be exposed through a web service with simple commands/steps” – DONE!


Read more
John Bernard

We’ve been extremely busy at Computex, with over 1,000 people visiting the Ubuntu booth, and over 25 media interviews about Ubuntu for Android, Ubuntu Cloud and Ubuntu TV.

One of the highlights so far was ARM’s Ian Ferguson, director of server systems and our very own Mark Shuttleworth presenting a keynote session at the Computex industry forum about cloud computing. As part of this, they unveiled MiTAC’s new ARM server, based on Ubuntu. This is only the third ARM server made in the world and it’s a significant step forward in a new era of hyperscale computing. Based on ARM processors, these servers have higher densities and lower power to enable more efficient cloud deployments and lower cost.

The MiTAC server can be seen on the Ubuntu stand at M0106, Nangang Exhibition Hall, alongside the latest developments in Desktop and Cloud until the end of the show on June 9th.

Read more
John Bernard

Canonical will be exhibiting at Computex in Taipei, June 5th – 9th, Asia’s largest ICT trade show. We will be at the show alongside some our partners and biggest names in the industry. At the booth (at M0106 in the Nangang exhibition hall) we will be showcasing new products and services, including Ubuntu for Android, Ubuntu TV and Ubuntu Cloud.

Today, Ubuntu for Android will be demoed at a pre-show ARM media gathering and in addition, Mark Shuttleworth will be part of a keynote presentation on Tuesday at the TICC.

We look forward to seeing you at the booth. If you can’t be at Computex, we’ll be updating the blog with pictures and more as it unfolds.

Read more