Skip to content

Instantly share code, notes, and snippets.

View rjloura's full-sized avatar

Rui Loura rjloura

View GitHub Profile
#!/usr/bin/node
var ip6addr = require('ip6addr');
addr = process.argv[2];
if (addr.indexOf('/') !== -1) {
var cidr = ip6addr.createCIDR(addr)
console.log(cidr.toString({format: 'v4'}));
@rjloura
rjloura / portolan_moray.md
Last active June 8, 2018 17:49
looking up portolan records and objects in portolan, moray, and manatee
[root@headnode (emy-7a) ~]# sdc-napi /networks?nic_tag=sdc_overlay | json -Ha provision_start_ip vnet_id
192.168.128.5 14544491
10.21.12.5 14855325
192.168.128.5 14855325

[root@1c52a1cf-bbfe-4dd4-b653-a0c2ecc8b8a2 (emy-7a:moray0) ~]# listbuckets | grep portolan
    "name": "portolan_vnet_mac_ip",
    "name": "portolan_underlay_mappings",
    "name": "portolan_cn_net_events",
@rjloura
rjloura / no_compute_resources_available.md
Last active January 11, 2019 16:52
Diagnosing "No Compute Resources Available" messages in Triton.

No Compute Resources Available

This error is somewhat ambiguious because there is seemingly no indication which resource is exhausted.

From Job UUID

Triton chooses compute nodes with a subcomponent called sdc-designation (also refered to as , DAPI). The full DAPI log for a provision job is embedded in the CNAPI log file and can be extracted with the workflow job uuid and the following script.

#!/bin/bash
@rjloura
rjloura / config_files.md
Last active September 18, 2025 05:37
smartos config files

All config data loader shell functions are implemented in smartos-live:overlay/generic/lib/sdc/config.sh

System Config:

  • Sources (one of the following):
    • /mnt/usbkey/config
    • /opt/smartdc/config/node.config
    • /var/tmp/node.config/node.config
    • /usbkey/config
  • Loader: load_sdc_config()
  • ([rui] this seems to do nothing on a CN boot as it never finds one of the files above)
@rjloura
rjloura / sdc-oneachcorezone.sh
Created February 7, 2018 15:42
Run a command on each triton core zone
#!/usr/bin/bash
function usage() {
echo "Usage: sdc-oneachcorevm.sh \"<command>\""
exit 1;
}
[[ $# -eq 1 ]] || usage
CMD=${@:1} # or is it ${*:1} ?
#!/bin/bash -x
# Default to continue
while true; do
read -p "Do you want to continue? [Y/n] " cont
if [[ $cont != "y" && $cont != "Y" && $cont != "" ]]; then
break;
fi
done;
@rjloura
rjloura / illumos_router_howto.md
Last active January 14, 2019 17:01
Illumos SmartOS Router

In the following diagram we want to route traffic from rui11 (10.222.222.100/24) to dhcp0 (10.99.99.3/24) via the ruirouter0 router.

Topology:

+-----------------------+             +--------------------------+           +-----------------------+
|       dhcp0           |             |        ruirouter0        |           |        rui11          |
+-----------------------+             +--------------------------+           +-----------------------+
|                       |             |                          |           |                       |
|     10.99.99.3/24     <-------------+       10.99.99.101/24    |     +-----+    10.222.222.100/24  |
@rjloura
rjloura / ip_address.js
Last active March 13, 2018 20:20
Convert IPv4 String to Unsigned int in big endian byte order
/*
* An example of how to convert an IPv4 address from a dotted decimal string to
* a Big Endian binary representation.
*/
var assert = require('assert');
ip = '10.99.99.3'
@rjloura
rjloura / mswitch.md
Created January 5, 2018 21:20
Managing multiple manta users

Create a ~/.mantarc like so:

export MANTA_URL=https://us-east.manta.joyent.com
export MANTA_USER=rui.loura
unset MANTA_SUBUSER # Unless you have subusers
export MANTA_KEY_ID=$(ssh-keygen -l -f $HOME/.ssh/id_ecdsa.pub | awk '{print $2}')

Then drop the following into your ~/.bashrc or ~/.bash_profile

@rjloura
rjloura / xfce_caps_to_escape.md
Last active January 15, 2021 10:22
How to set capslock to escape key in xfce4

My chromebook doesn't have a caps lock key, it has a "search" key. When running crouton xfce4 is unaware of this key in the keybaord mappings GUI. This is how I ended up mapping the search/capslock key to escape.

  1. Run xev(1)
  2. Strike the capslock (aka search, or super_L key) and ook for entries like the following:
KeyPress event, serial 28, synthetic NO, window 0x2600001,
    root 0xd3, subw 0x0, time 16308538, (449,411), root:(1043,703),
    state 0x0, keycode 133 (keysym 0xff1b, Escape), same_screen YES,
    XKeysymToKeycode returns keycode: 9
 XLookupString gives 1 bytes: (1b)