From Fedora Project Wiki

< GSOC 2017

Revision as of 14:27, 29 March 2017 by Mikeman7 (talk | contribs)

Contact Information

Michael Viveros, personal site, michaelviveros@gmail.com, 905-807-9537

Abstract

This project's main goal is to create a .NET Core library wrapping the systemd init system. The main features of the systemd API that will be wrapped by the library are viewing and starting/stopping units (services, sockets, devices, jobs). This project will take advantage of utilizing existing solutions like the Tmds.Dbus library which can be used to communicate with systemd from .NET code over the D-Bus message bus. I am a good fit for this project because I am a quick-learner, I have 12 months of ASP.NET experience at 2 different companies, I have a strong desire to contribute to open-source software and I made a .NET Core prototype which wraps the ListUnits method of systemd.

Project

This project will make it possible to access the systemd API from .NET code. This benefits the community since users can use a higher-level framework like .NET to manage their system as opposed to lower-level methods (UNIX commands, shell scripts). This makes it easier for new users who are unfamiliar with Linux development to be able to learn more about Linux by being able to use a popular framework they might be familiar with to interact with their init system. Additionally, it makes it possible to write more sophisticated applications related to managing your Linux system since you can take advantage of higher-level .NET concepts like classes, interfaces and unit/integration tests.

On the technical side, systemd exposes an API which can be accessed by other processes through the D-Bus message bus system. The systemd API has a Manager interface used to manage units. Units can be services, sockets, devices and jobs. The Manager interface has methods like ListUnit, StartUnit, StopUnit and Reboot. To access the systemd API over D-bus in .NET code, you can use the Tmds.Dbus Nuget package to write .NET interfaces which use D-bus to connect to APIs of services like NetworkManager or systemd. For example, the following .NET code will define an IManager interface used to access the systemd API’s Manager interface and it’s ListUnits method.

[DBusInterface("org.freedesktop.systemd1.Manager")]
public interface IManager: IDBusObject
{
    Task<Unit[]> ListUnitsAsync();
}

Then you can call the ListUnits method by connecting to the D-bus and creating a proxy object used to access the systemd API and it’s Manager interface.

using (var connection = new Connection(Address.Session))
{
    await connection.ConnectAsync();
    var systemd = connection.CreateProxy<ISystemd>("org.freedesktop.systemd1", "/org/freedesktop/systemd1");
    var manager = systemd as IManager;
    var unitList = await manager.ListUnitsAsync();
    numUnits = numUnitsSpecified ? numUnits : unitList.Length;
    for (int i = 0; i < numUnits; i ++)
    {
        Console.WriteLine($"Unit - {unitList[i].name}");
    }
}

Below is a table of potential project milestones with specific deliverables for each milestone.

Weeks Due Date Milestone Deliverables
1 - 2 Fri. June 9th Design List of at least 5 systemd functions that will be implemented with justification as to why these functions were chosen. List of additional libraries this project will use including examples of how they will be used
3 - 4 Fri. June 23rd Prototype Prototype implementing at least 2 of the systemd functions that uses additional libraries
5 Fri. June 30th Test Prototype Integration/unit tests for prototype (NUnit, XUnit)
6 Fri. July 7th Publish Prototype Publish working prototype as NuGet package and add documentation
7 Fri. July 14th Prototype Feedback Get feedback about prototype from community
8 - 9 Fri. July 28th Library Add other systemd functions to prototype based on list of functions from Design milestone and community feedback
10 Fri. August 4th Test Library Integration/unit tests for library (NUnit, XUnit)
11 - 12 Mon. August 21st Publish Prototype Publish working library as NuGet package and add documentation

Additionally, I will write weekly blog posts by end-of-day Friday containing information about my progress that week and how it fits into the current milestone, problems I am facing (including what I’m doing to fix them) and next steps for the following week.

Related Work

There is a systemd wrapper for Python called “systemd” which is implemented using C extensions for Python (Cython). It uses C libraries like sd-daemon and sd-journal to send systemd daemon notifications and to access logging from the systemd journal. It does not wrap any functions related to managing units.

As mentioned in the Project section, there is a Nuget package called Tmds.Dbus which can be used to write .NET interfaces which use D-bus to connect to APIs of services like NetworkManager or systemd.

I made a .NET Core prototype which uses the Tmds.Dbus NuGet package to access the systemd API in .NET code. It was developed on the Fedora 25 OS but will work on any Linux distribution that uses systemd. Program.cs will call the ListUnits method of the systemd API to get all the currently loaded units in the system and then print the results. See the GitHub repo for detailed information about how it was implemented.

SystemdSample.gif

About Me

  • Education - 5 years of schooling, finishing undergrad degree in Software Engineering and Management from McMaster University in Hamilton, Ontario, Canada
  • Work experience - 20 months of co-op experience at 4 different companies ranging from an investment bank to an educational software company that makes a Learning Management System (LMS).
    • 12 months of which were writing ASP.NET code for 2 different companies and included projects like adding a database-agnostic layer to a product and making a widget to reset a student’s progress in a course
  • Programming experience - created a Django app where users can answer census questions (CensusTest) and created a GIMP plugin which generates collages (CollageCreator)
  • Open source contributions - I haven’t contributed source code directly but I had a great discussion in the Django users group about database models, I created an issue with a UI library that wasn’t working and I wrote a blog about how to write apps with web technologies using the Cordova framework

Why Fedora?

I have a strong desire to contribute to open-source software. For the past year, I've had my mind set on doing Google Summer of Code before I graduate. I turned down a job offer and postponed my job search just so I can do Google Summer of Code this summer. Fedora seems like a great organization to contribute to for Google Summer of Code and I've been interested in Fedora and Red Hat for awhile now. Ever since I read a book called “Under The Radar” by Bob Young (one of the founders of Red Hat), I’ve really wanted to get involved in an open-source community. The book is about how open source software can be a successful business and uses Red Hat as a running example. I learned about the “The Cathedral and the Bazaar” essay, by Eric Raymond, one of the key voices behind the open source movement, which argued that the best way to develop software is to make it as widely open-source as possible. One of my favourite anecdotes was about when Netscape released their open-source browser on mozilla.org, it did not contain any cryptography since it was illegal to “export” cryptography in the US at the time. Within 2 hours, members of the community from Europe released a version of the browser which had full-strength encryption. This example of the power and collaboration of the open-source community is why I really want to get involved with open-source software and I think the Fedora community would be a great place to do that.

I definitely plan on contributing to Fedora after GSOC if I get accepted and would love to contribute more to the Fedora .NET community and the Fedora community in general.

Why This Project?

I've outlined the benefits of this project to the community, deliverables I plan on completing and related work I've researched in the sections above. One reason I would be a good fit for this project is that I am a quick-learner. I’ve had to learn 4 large code bases from different companies for my co-ops and I’ve developed applications in my spare time ranging from a Django website to a GIMP plugin written in Scheme. So I will be able to quickly learn about systemd, D-Bus, .NET Core and how they can all connect to make the wrapper library for this project.

Additionally, I have 12 months of work experience at 2 different companies developing ASP.NET applications so I am very familiar with .NET and C#. One project I completed was adding an additional data layer to one of the company’s products to make it database-agnostic. This involved migrating database-specific queries in SQL to server-side C# code using LINQ expressions. This project resulted in fewer support issues for the company since they had one C# code base to maintain instead of several database-specific SQL code bases to maintain. I also wrote many unit and integration tests for my work using NUnit so I will be able to easily add tests for this project using NUnit or another library like XUnit.

Lastly, my large amount of work experience has taught me professionalism and how to make a contribution. I’ve learned to ask questions after first trying to find the answer myself, to be diligent in every task I do and to be efficient with my time by being conscious of how long I spend on certain tasks and to consider alternatives after spending too long on a task. Additionally, I’ve learned the importance of taking the time to write good documentation as can be see by my detailed README for my systemd prototype repo. At my most recent co-op, I made a lasting contribution to the company by developing a continuous integration prototype, on my own, without being asked. I saw a problem with the existing manual process of developers having to copy over code to test servers and I was able to fix it by automating this process. I will have the same mindset when working on this project to be conscious of my surroundings and to take the time to think of ways I can contribute to improve the Fedora .NET community.


In terms of other commitments, I am travelling to Mexico, tentatively from June 7th - 11th. I can work extra hours during the day and/or on weekends to make up the time. I do not have any other commitments so I will be able to give Google Summer of Code my full time and attention.