Skip to content

Instantly share code, notes, and snippets.

View jackhong's full-sized avatar

Jack C Hong jackhong

  • NICTA
  • Sydney, Australia
View GitHub Profile
labwiki:
repositories:
default:
type: git
top_dir: ~/tmp/labwiki
is_primary: true
plugins:
experiment:
plugin_dir: labwiki_experiment_plugin
job_service:

Support property operation information via FRCP

Existing implementation

To construct and send a configure message

topic.configure(membership: ['a', 'b', 'c'], name: 'bob', some_id: 100)

Serialise to XML

# EXISTING options
# By default it loads node proxy, and this is its id
uid: bob
# How to connect to pubsub server
uri: xmpp://localhost
# Which environment to use, the value is the one of pre-defined ones in omf_common
environment: development
class ResourceFactory
def self.create(res_type, res_options, creation_options, &callback)
# Find out Resource Module by resource type then:
#
# Initialise AbstractResource with provided resource parameters
AbstractResource.new(res_type, options, creation_options) do |resource|
# Then calling optional supplied callback
callback.call(resource)
end
end
@jackhong
jackhong / gist:4082758
Created November 16, 2012 00:25
Replace error_messages for
# @bob is the object binding to the form
-if @bob.errors.any?
#error_explanation
%h2= "#{pluralize(@bob.errors.count, "error")} prohibited this from being saved:"
%ul
- @bob.errors.full_messages.each do |msg|
%li= msg
@jackhong
jackhong / try_rete.rb
Created November 12, 2012 02:40
Try omf rete
require 'pp'
require 'omf_rete/store'
N = 100
s = OMF::Rete::Store.create 3
(1..N).each do |i|
s.addTuple(["node_#{i}", 'status', 'ok'])
end
@jackhong
jackhong / magic_rc_ple.rb
Created November 9, 2012 01:24
RC integration with Planetlab, some notes
# Original ruby script
#
require "xmlrpc/client"
require "pp"
XMLRPC::Config.module_eval do
remove_const :ENABLE_NIL_PARSER
const_set :ENABLE_NIL_PARSER, true
end
@jackhong
jackhong / dsl_sexp.rb
Created October 10, 2012 03:09
Sexp of DSL
# Given the asynchronous nature of all operations,
# a simple property assignment is actually a chain of callbacks behind the scene.
# Take this not too simple example
g.applications[:name => 'app_foo'].target_ip = g[:name => 'node1'].interfaces[:name => 'wlan0'].ip
# If we think about xmpp communication, the work flow would be sth like this. (simplified pseudo code)
g[:name => 'node1'].request_interfaces[:name => 'wlan0'] do |i|
@jackhong
jackhong / test01.rb
Created October 8, 2012 00:55
DSL in OMF 6
# Original test01.rb
defProperty('res1', "unconfigured-node-1", "ID of a node")
defProperty('res2', "unconfigured-node-2", "ID of a node")
defGroup('Actor', property.res1)
onEvent(:ALL_UP) do |event|
wait 3
info "TEST - allGroups"
@jackhong
jackhong / gist:3719731
Created September 14, 2012 04:09
Sample exp script
@node = @comm.get_topic(`hostname`.chomp)
@node.on_message lambda {|m| m.operation == :inform && m.read_content('inform_type') == 'FAILED' } do |message|
logger.error message
end
device_request = @comm.request_message([:devices])
device_request.on_inform_status do |message|
@devices = message.read_property('devices').items