Skip to content

Instantly share code, notes, and snippets.

View skamithi's full-sized avatar

Stanley Karunditu skamithi

  • Raleigh, North Carolina
View GitHub Profile
@skamithi
skamithi / test_prefix_check.py
Last active August 29, 2015 14:15
ansible unit testing post - test ip route show functionality
@mock.patch('library.prefix_check.single_route_check_run')
@mock.patch('library.prefix_check.AnsibleModule')
def test_route_check_route_found(mock_module, mock_single_run):
"""
prefix_check - test action when prefix is found
"""
# on success, single_route_check_run() will return true
mock_single_run.return_value = True
result = prefix_check.check_if_route_exists(mock_module)
@skamithi
skamithi / test_prefix_check.py
Last active August 29, 2015 14:15
ansible module exit functionality tester
@mock.patch('library.prefix_check.check_if_route_exists')
@mock.patch('library.prefix_check.AnsibleModule')
def test_main_exit_functionality_success(mock_module,
mock_route_check):
"""
prefix_check - test_main_exit_functionality - success
"""
# This creates a instance of the AnsibleModule mock.
instance = mock_module.return_value
@skamithi
skamithi / test_prefix_check.py
Last active August 29, 2015 14:15
ansible module argument tester
import mock
import library.prefix_check as prefix_check
from nose.tools import assert_equals
@mock.patch('library.prefix_check.check_if_route_exists')
@mock.patch('library.prefix_check.AnsibleModule')
def test_module_args(mock_module,
mock_route_check):
"""
prefix_check - test module arguments
@skamithi
skamithi / ipv6-test.js
Created February 17, 2015 06:39
using phantomjs to get info from a website - closest thing to text base browser for a server
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
* @param onReady what to do when testFx condition is fulfilled,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
@skamithi
skamithi / prefix_check.py
Last active August 29, 2015 14:15
ansible module prefix_check
DOCUMENTATION = '''
---
module: prefix_check
author: Stanley Kamithi [email protected]
short_description: Check route prefix
description:
- Inspired by Cumulus Linux prefix_check Ansible Module. \
Given a route prefix, check to see if route exists. \
If the route exists, then do nothing. If route does not exist \
the module will exit with an error.
@skamithi
skamithi / notes.md
Last active August 29, 2015 14:15
testing when handlers kick in.
  • So to get handlers to work properly you must put the handlers in a different "host" definition.
- hosts: all
  roles:
     - requires_switchd_restart

- hosts: all
  roles:
 - system_basics
@skamithi
skamithi / specinfra_speed.patch
Created January 30, 2015 17:37
specinfra interface speed patch
commit 83cd84ddad6d4ebf683cfaa5850dc2dc0b823f2d
Author: Stanley Karunditu <[email protected]>
Date: Wed Jan 28 00:51:24 2015 -0500
get speed from /sys/class/net instead of ethtool. simpler way of doing it.
diff --git a/lib/specinfra/command/linux/base/interface.rb b/lib/specinfra/command/linux/base/interface.rb
index 2bb5bec..0ba7efc 100644
--- a/lib/specinfra/command/linux/base/interface.rb
+++ b/lib/specinfra/command/linux/base/interface.rb
@skamithi
skamithi / example.rb
Last active August 29, 2015 14:14
serverspec/specinfra for bonding
cumulus@leaf1$ netshow bond
Name Speed Mtu Mode Summary
-- ------ ------- ----- ------- -------------------------------
UP bond0 20G 1500 Bond/L3 BondMems: swp1s0(UP) swp1s1(UP)
IP: 10.1.2.1/30
cumulus@leaf1$
cumulus@leaf1$ bundle exec rspec
Interface "br0"
@skamithi
skamithi / serverspec.diff
Last active August 29, 2015 14:14
serverspec patches to make bridge class inherit from interface class
diff --git a/lib/serverspec/helper/type.rb b/lib/serverspec/helper/type.rb
index 5fcfaae..23d81a0 100644
--- a/lib/serverspec/helper/type.rb
+++ b/lib/serverspec/helper/type.rb
@@ -2,8 +2,8 @@ module Serverspec
module Helper
module Type
types = %w(
- base bridge cgroup command cron default_gateway file fstab group host
- iis_website iis_app_pool interface ipfilter ipnat iptables
@skamithi
skamithi / pep_501_check.md
Last active October 18, 2022 19:42
increasing size of max line to avoid pep8 e501 check

I use pymode to modify my python scripts. Keep on getting E501 when length of line is 82 or 83..which I think is just fine.

to fix this did the following

_$HOME/.config/pep8

[pep8]
max-line-length = 90