Skip to main content

the avatar of Chun-Hung sakana Huang

Ansible install with openSUSE 13.2 and Mac

I start to study Ansible cause recently needs.

Ansible is python based, using SSH deploy packages to remote servers, it's like Puppet / Chef / Salt.


Online resource

I study from Oreilly - Ansible up & running
  • code example

    

How to install Ansible

Install Ansible

openSUSE 13.2 ( Most of linux could install ansible now )
Use zypper to query ansible package
# zypper   search   ansible
Loading repository data...
Reading installed packages...

S | Name    | Summary                                                                  | Type      
--+---------+--------------------------------------------------------------------------+-----------
 | ansible | SSH-based configuration management, deployment, and orchestration engine | package   
 | ansible | SSH-based configuration management, deployment, and orchestration engine | srcpackage

Install Ansible
# zypper install  -y  ansible

That's all you need to do :-)

Ansible is clientless, that mean you don't need to install any packages in your remote hosts, it's the most diff with puppet and other tools.
The role is
  • The control machine
    • The one that you use to control remote machines
    • needs to have python 2.6 or later installed.  
  • To manage a server with Ansible
    • Needs to have SSH and Python 2.5 or later installed.
Most linux has python later 2.5 ( Might be python 2.7 ), that's the reason - Nothing to install

What do you need to know? ( From Oreilly book ^^ )
I think the most important point is - you could use ssh and ssh key to execute some commands in remote servers.

What do I need to know?
    • Connect to a remote machine using SSH.
    • Interact with the bash command-line shell (pipes and redirection).
    • Install packages.
    • Use the sudo command.
    • Check and set file permissions.
    • Start and stop services.
    • Set environment variables.
    • Write scripts ( Any language )
  • You don't need to know python to use Ansible unless you want to write your own module.
  • You will need to learn some YAML and Jinja2 to use Ansible.     


That's all today, I will write some Ansible module command next time.

~ enjoy it

the avatar of Just Another Tech Blog

UNDERGRADUATE IMPLEMENTATION OF GARBAGE COLLECTION

Authors: David Mulder, Curtis Welborn

ABSTRACT

This paper describes the implementation of a garbage collector as an undergraduate research project. The garbage collector is a continuation of a project where an Assembler, Virtual Machine and Compiler were implemented as a capstone project. The project required modifying the compiler to allocate memory compatible with a mark and sweep algorithm, and adding the mark and sweep algorithm to the virtual machine. Computer Science faculty should take note that this was all completed by an undergraduate student within a year’s time, and that such challenges can reasonably be accomplished by undergraduate seniors.

INTRODUCTION

Challenges of the nature described in this paper are generally reserved for graduate students, and are considered outside the grasp of undergraduates. Computer Science faculty and students alike will be interested to note that the preceding project was completed entirely by an undergraduate senior. It is also interesting to note that the project was completed by an average student of little academic achievement, and that a Compiler, Assembler and Multi-Processed Virtual Machine with Garbage Collection were written within a year’s time.

As part of an undergraduate capstone, an Assembler, Virtual Machine and Compiler were implemented. The two-pass Compiler performs Lexical and Syntax analysis in the first pass, and Semantic analysis and Intermediate code generation in the second pass. Using Intermediate code as input, the Compiler then generates target code (assembly) that can be fed to the Assembler to generate byte-code. The byte-code can then be loaded into the Virtual Machine for execution [1]. Through independent study, a garbage collector was added to the virtual machine, which included extensive changes to the compiler.

The compiler had to be modified to place by-reference parameters onto the run-time stack first. An additional parameter is also added that counts the number of by-reference parameters. The counter is needed by the Mark and Sweep algorithm to determine the location of the by-reference parameters within an Activation Record.

To support the mark and sweep garbage collection algorithm, the virtual machine had to be modified to allocate memory from a list of available blocks. The mark and sweep algorithm is triggered when a call to allocate memory detects no free blocks. In the mark phase of the algorithm, the run-time stack is traversed searching for points that reference blocks allocated on the heap. Any block of memory reachable from the run-time stack must be marked as in use. During the sweep phase of the algorithm, the heap is searched looking for any blocks not marked as in use during the mark phase.
Screenshot from 2015-10-09 13:18:55

COMPILER MODIFICATIONS

The compiler was originally written to pass parameters to a function call via an activation record in the order they were written in the source language (a language called KXI, which is similar to java). It was necessary for the compiler to segregate between by-reference and by-value parameters. The mark phase of the algorithm must know the location of every by-reference parameter within a function calls’ activation record. See the ordering of variables in the current Activation Record of Figure 1. Because the variables are segregated, references are easily located based on offsets. For example, the first reference is located by an offset of 4*sizeof(int) from the base of the activation record (the return address, previous activation record pointer and reference counters are all integers), and the second reference is offset 5*sizeof(int) from the base.

The mark phase of the algorithm needed a special field inserted in each activation record that counts the number of by-reference parameters. This field was added in the activation record in such a way that the mark phase could iterate over each by-reference parameter and set the mark bit in the corresponding block for each object allocated on the heap. The field is referred to as the Reference Counter in Figure 1. The reference counter in this activation record tells us that there are 2 references. If we decremented the reference counter to 1, for example, the second reference on the stack would be interpreted as an integer.

VIRTUAL MACHINE MODIFICATIONS

In order to make space allocation more efficient, the heap was separated into large and small blocks. Bit vectors were used to keep track of which blocks are allocated on the heap.

An instruction was added to the virtual machine for allocating memory. Prior to the instruction, memory allocation consisted of just moving a pointer within the heap. The new allocation instruction calls the mark and sweep algorithm. If there is space available on the heap, the instruction returns a pointer to that block and marks the block as unavailable within one of the vectors that tracks all blocks in the heap.

If no available space is found, garbage collection is started. The algorithm must calculate the location of the activation record for the current function call then calculates the offset to the by-reference counter field in the activation record. Now having the number of pass by-references parameters in the current activation record, the algorithm can calculate the offset to each allocated block on the heap and set its mark bit to in use.

The algorithm must recursively follow references allocated inside of each block. This was achieved by organizing objects within a block in a similar manner to how function calls are organized in an activation record. In this way, lists, trees and even recursive data structures allocated on the heap can all be traversed and marked. In Figure 1, the mark phase will follow all references inside of Small Block A, so Small Block B is also marked.

Once all objects (blocks) and descendant objects have been marked, the algorithm calculates the location of the previous activation record. The same process of following references and marking objects proceeds for each activation record until all function calls on the run-time stack have been searched.

The sweep phase of the algorithm now iterates over the entire heap, checking the mark bit. If the mark bit is set (the block is in use), it clears the bit and moves on. This means that the block has a live reference to it which originated in an activation record that is currently on the run-time stack. Blocks A, B and D in Figure 1 have references pointing to them. These blocks will be un-marked and will remain allocated.

If the mark bit is not set, the algorithm clears the relevant marker in the vector of available blocks, freeing the block for reuse (See Small Block C in Figure 1) [2]. This allocated block will be freed during the sweep phase because it has no references pointing to it on the run-time stack.

CONCLUSION

This method of garbage collection is effective, but did prove to be inefficient. Because the algorithm isn’t activated until there is no remaining free space, the algorithm isn’t suitable for real time applications. The algorithm could be modified to operate incrementally, but it would still cause an occasional lag. These are known problems of garbage collection.

The greatest achievement of this project was the recognition of what can be accomplished by undergraduate seniors. Computer Science faculty should recognize that computing projects of this caliber can reasonably be expected in an undergraduate senior project course.

FUTURE WORK

The primary author has started work on an hp-ux pa-risc virtual machine. The first obstacle will be setting up the correct environment, based on descriptions in the pa-risc specifications. The second will be translating the pseudo code in the specification into C. A compiler/translator will be written to automatically convert the specification pseudo code into C.

A significant part of the project will be writing the loader, since it will need to include things such as run time linking. Ideally, the virtual machine will run at boot time and will include a boot loader. This would allow pa-risc software to run on virtually any hardware.

REFERENCES

[1] Mulder, D., Welborn, C., Lessons in converting from python to c++, Journal of Computing Sciences in Colleges, 29(2), 49-57, December 2013, http://dl.acm.org/citation.cfm?id=253542
[2] Jones, R., Lins, R. D., Garbage collection: Algorithms for automatic dynamic memory management, West Sussex, England

© CCSC, (2014). This is the author’s version of the work. It is posted here by permission of CCSC for your personal use. Not for redistribution. The definitive version was published in The Journal of Computing Sciences in Colleges, {volume 30, number 2, December 2014}, http://dl.acm.org/.

the avatar of Just Another Tech Blog

Deploying Configuration Profiles in OSX using QAS Group Policy

Here’s an alternative to applying Configuration Profiles in OSX without using an MDM client. Profiles are deployed using Group Policy over SMB, so you don’t have to open APN ports to Apple.
QAS is an AD bridge tool for unix/linux systems (including mac) that also provides Group Policy support. You can view more details here.

QAS Group Policy lets you specify Group Policy settings inside the Group Policy Management Editor, the same way you’d apply settings for a Windows host.
Screenshot from 2015-10-08 14:48:40It works similar to Apple’s Profile Manager.

Screenshot from 2015-10-08 14:54:54

You can also create custom profiles by writing preference manifests. The preference manifests are converted to Configuration Profiles before they’re applied on the OSX host.

On the OSX host, settings are retrieved from Group Policy, and installed as Configuration Profiles.

Screenshot from 2015-10-08 15:22:01

the avatar of Frédéric Crozat
the avatar of Kohei Yoshida

mdds 1.0.0

A new version of mdds is out, and this time, we’ve decided to bump up the version to 1.0.0. As always, you can download it from the project’s main page.

Here is the highlight of this release.

First off, C++11 is now a hard requirement starting with this release. It’s been four years since the C++11 standard was finalized. It’s about time we made this a new baseline.

Secondly, we now have an official API documentation. It’s programatically generated from the source code documentation via Doxygen, Sphinx and Breathe. Huge thanks to the contributors of the aforementioned projects. You guys make publishing API documentation such a breathe (no pun intended).

This release has finally dropped mixed_type_matrix which has been deprecated for quite some time now in favor of multi_type_matrix.

The multi_type_vector data structure has received some performance optimization thanks to patches from William Bonnet.

Aside from that, there is one important bug fix in sorted_string_map, to fix false positives due to incorrect key matching.

API versioning

One thing I need to note with this release is the introduction of API versioning. Starting with this release, we’ll use API versions to flag any API-incompatible releases. Going forward, anytime we introduce an API-incompatible change, we’ll use the version of that release as the new API version. The API version will only contain major and minor components i.e. API versions can be 1.0, 1.2, 2.1 etc. but never 1.0.6, for instance. That also implies that we will never introduce API-incompatible changes in the micro releases.

The API version will be a part of the package name. For example, this release will have a package name of mdds-1.0 so that, when using tools like pkg-config to query for compiler/linker flags, you’ll need to query for mdds-1.0 instead of simply mdds. The package name will stay that way until we have another release with an API-incompatible change.

a silhouette of a person's head and shoulders, used as a default avatar
a silhouette of a person's head and shoulders, used as a default avatar
darix posted at

A dive into requires with ranges

Disclaimer: I am aware that python does not allow easy installation of 2 libraries in parallel. It is just an example.

Let’s say you have an upstream requirement "needs pyfoo >= 1.6.0 but smaller than 2". Sounds easy right? Our naive solution will be:

Requires: python-pyfoo >= 1.6.0
Requires: python-pyfoo < 2

so far … so good. If your repository has only one version of pyfoo available we will probably get the package you want. now lets say we have more than one version available.

the avatar of Bernhard M. Wiedemann

targitter project – about OBS, tars and git

In OBS we use source tarballs everywhere to build rpms (and debs) from.

This has at least two major downsides:

  1. Storing all old tar files takes up a lot of disk space
  2. OBS workflows with .tar files and patches are rather different and somewhat disconnected from the git workflows we usually use everywhere else these days. E.g. for the SUSE OpenStack Cloud team we have a “trackupstream” jenkins job, that pulls the latest git version into a tarball once every day.

Fedora already keeps their metadata in git, but only a hash of the tarball.

So as one first step, I used two rather different projects to see how different the space usage would be. On the slow side I used 20 gtk2 tarballs from the last 5 years and on the fast side, I used 31 openstack-nova tarballs from Cloud:OpenStack:Master project from the last 5 months.
I used scripts that uncompressed each tarball, added it to a git repo and used git gc to trigger git’s compression.

Here are the resulting cumulative size graphs:

gtk2 size graph
nova size graph

The raw numbers after 20 tarballs: for nova the ratio is 89772:7344 = 12.2 and for gtk2 the ratio is 296836:53076 = 5.6

What do you think: would it be worth the effort to use more git in our OBS workflows?

Do we care about being able to reproduce the original tarballs? While this is possible, it has some challenges in differing file-ordering, timestamps, file-ownerships and compression levels.
Or would it be enough if OBS converted a tarball into a signed commit (so it cannot be forged without people being able to notice)?

Do you know of a tool that can uncompress tarballs in a way that allows to track the content as single files, and allows to later re-create the original verbatim tarball, such that upstream signatures would still match?

a silhouette of a person's head and shoulders, used as a default avatar

Aarhus: Presentations & the Table Styles in Writer

It is already a week since I am back from the great LibreOffice Conference in Aarhus. I enjoyed it a lot - talked to lots of people [eg. met Heiko for the first time in person - after having spent quite some time with him over hangouts :-)], listened to many nice presentations, gave my talks, and - even managed to find some time for the late night's hacking. Oh, and the train there and back was a good choice too - I have travelled with Stanislav who's translating & managing the Czech translations; and on the way back we have also met Jos.

Before I tell you about the Table Styles in Writer, the feature I was working on, let me share the slides from my presentations. First of all, I presented work of my GSoC students, Nathan Yee and Krisztian Pinter, during the GSoC panel:

Click the slide to see the presentation.
Then I talked about the recent achievements & plans of the LibreOffice Design team:
Click the slide to see the presentation.
Then on Thursday, I talked about what we have done in VCL, our graphics toolkit, to be able to make our rendering double-buffered:
Click the slide to see the presentation.

 

Table Styles in Writer

And now - the Table Styles in Writer. It is a feature that we have missed for a long time. In LibreOffice, we have the Table -> AutoFormat..., but applies the formatting only once; after you modify the table (like insert rows / columns) later, you basically destroy the look of the table.

During summer 2013, Alex Ivan was working on implementing the table styles as GSoC project. I rebased his work to the current master, and made it to work again. Unfortunately, the approach there turned out to be very aggressive - the changes first destroyed the Table AutoFormat feature, and then started building the Table Styles. This means that we could merge that only after we have the import and export for Table Styles - but the GSoC work did not get that far.

I reconsidered the approach, and tried to find a way that implements the core of the Table Styles functionality without destroying the Table AutoFormat - and it worked :-)

I have pushed the results to master. Now, when you apply the Table AutoFormat in Writer, it behaves as a Table Style: When you insert more rows/columns, they still keep the correct formatting, similarly deleting, or splitting tables keeps the table formatted. Direct formatting is applied over the style too, and you can clear it via "Clear Direct Formatting".

 

Further work

Loading/saving is not implemented though, so once you save the table with Table Style, it turns into a "normal" AutoFormat - the next time you open it, you see the formatting, but it is "static", ie. works as before the Table Styles work.

I hope to get the load/save done before 5.1; and there's also lots to be improved in the UI of Table Styles - but I believe the current state is already an improvement, and a step in the right direction.

the avatar of Chun-Hung sakana Huang

Setting up Spark single node with local disk

Setting up Spark single node with local disk

OS: Ubuntu 14.04 in GENI

Please use ssh key to login Ubuntu 14.04 in GENI

If you are /bin/bash user, you might want change your shell, you could use
$sudo   chsh   -s    /bin/bash  YourUserName

Use curl command to get auto install shell script, save filename as Install.sh

$ curl   https://dl.dropboxusercontent.com/u/12787647/iCAIR/Ubuntu1404SparkInstall.sh    >   Install.sh

Use sh to run the shell script.  It will auto install spark and other packages.
$ sh  Install.sh

After install Spark in your system, you could run spark interactive shell with follow command   
$ ~/spark/bin/spark-shell


You can check the SparkUI in http://localhost:4040 like

螢幕快照 2015-08-07 下午2.59.46.png



Basic  command practice
scala> val sakanaFile = sc.textFile("README.md")
sakanaFile: org.apache.spark.rdd.RDD[String] = MapPartitionsRDD[1] at textFile at :21
scala> sakanaFile.count()
res0: Long = 98
scala> val linesWithSpark = sakanaFile.filter(line => line.contains("Spark"))
linesWithSpark: org.apache.spark.rdd.RDD[String] = MapPartitionsRDD[2] at filter at :23
scala> linesWithSpark.count()
res1: Long = 19
scala> linesWithSpark.collect()

scala> linesWithSpark.collect.foreach(println)

the avatar of Efstathios Iosifidis

Install ownCloud on openSUSE Tumbleweed for Banana Pi M1


There's a tutorial how to create an openSUSE Tumbleweed SD card with MATE. You can follow this tutorial without installing MATE but keep it headless. You can download the image from openSUSE-Tumbleweed-BananaPi-headless-20150927.tar.xz (username: root, password: linux) and continue this tutorial.

Here we'll see how to install ownCloud on openSUSE for Banana Pi M1.

At the end of this tutorial will be a link to the image with ownCloud. Please use an SD card minimum 2GB and re-partition the SD card or use a USB stick to save ownCloud data directory.

Let's start with the procedure.

1. Install ownCloud from the repository. Choose the repository because you can have automatic updates.

zypper addrepo http://download.opensuse.org/repositories/isv:ownCloud:community/openSUSE_Factory_ARM/isv:ownCloud:community.repo

zypper refresh

zypper install owncloud

Don't be scared because this is factory repository. This is the official from ownCloud and it's the only one that is for ARM boards.

This will install all nessesary files. It will install apache2 and mariadb. At the end, it'll ask you if you want to see info about seting up mariadb.

You just installed MySQL server for the first time.

You can start it using:
rcmysql start

During first start empty database will be created for your automatically.

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

Regarding the servers apache and mariadb. If you're the only one user for ownCloud and don't have problem with speed, then you can use sqlite. If you have more users for the instance, then it's better to use mariadb. It's the same with apache. For lighter installations, you can use lighttpd or ngnix. Here I used apache2 but about database, it's up to you. You can either use sqlite or setup a mariadb darabase.

To setup a mariadb database, follow the commands.

mysql -u root -p

CREATE DATABASE owncloudb;

GRANT ALL ON owncloudb.* TO ocuser@localhost IDENTIFIED BY 'dbpass';

2. Change the file php.ini.

nano /etc/php5/apache2/php.ini

and change the strings (you can search by pressing control+w).

post_max_size = 50G
upload_max_filesize = 25G
max_file_uploads = 200
max_input_time = 3600
max_execution_time = 3600
session.gc_maxlifetime = 3600
memory_limit = 512M

3. Start the webserver.

systemctl start apache2.service
systemctl enable apache2.service

4. Create the data directory

It is recommended to use a data directory located on another partition of your SD card or a USB stick. The image requires minimum 2GB SD card, so you won't have enough storage to save your data.

Let's say you have a USB and you mounted under /mnt/USB folder. Create a directory and also give the right permissions.

mkdir /mnt/USB/owncloud_data
chmod -R 0770 /mnt/USB/owncloud_data
chown wwwrun /mnt/USB/owncloud_data

5. Final ownCloud installation.

Open your browser to the IP of your Banana Pi

http://IP_of_Banana_Pi/owncloud

Set a username/password for administrator. Choose a username other than admin, root, administrator, superuser because of your safety.
Then you have to set the date folder (remember our example is /mnt/USB/owncloud_data)
Choose if you want mariadb or sqlite.

If it's mariadb, then you should create the database

mysql -u root -p

CREATE DATABASE owncloudb;

GRANT ALL ON owncloudb.* TO ocuser@localhost IDENTIFIED BY 'dbpass';

DATABASE: owncloudb
USER: ocuser
PASSWORD: dbpass
HOST: localhost


and you're all set.

You can download the file openSUSE-Tumbleweed-20150930-BananaPi-ownCloud-8.1.3.tar.xz and just setup ownCloud as described on fifth step.