Skip to content

Instantly share code, notes, and snippets.

@tadeboro
tadeboro / Compress.java
Created January 7, 2017 21:35
Creating tar.gz in java using Apache Commons Compress
package compress;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.FileVisitResult;
@tadeboro
tadeboro / playbook.yml
Created July 16, 2018 20:49
Testing Redfish playbook
- name: Redfish test
gather_facts: false
connection: local
hosts: localhost
tasks:
- name: Runy dummy redfish task
redfish_system:
id: /redfish/v1/Systems/1
base_url: "http://localhost:8000"
username: demo
Failures:
1) ManageIQ::Providers::Lenovo::PhysicalInfraManager::Refresher will perform a full refresh with ems1
Failure/Error: EmsRefresh.refresh(ems)
ActiveRecord::HasManyThroughSourceAssociationNotFoundError:
Could not find the source association(s) :management_devices in model Hardware. Try 'has_many :physical_chassis_management_devices, :through => :physical_chassis_hardwares, :source => <name>'. Is it one of vm_or_template, vm, miq_template, host, computer_system, physical_switch, networks, firmwares, disks, hard_disks, floppies, cdroms, partitions, volumes, guest_devices, storage_adapters, nics, ports, physical_ports, or connected_physical_switches?
# /home/tadej/xlab/wwt/manageiq/app/models/manageiq/providers/inventory/persister.rb:29:in `persist!'
# /home/tadej/xlab/wwt/manageiq/app/models/manageiq/providers/base_manager/refresher.rb:162:in `save_inventory'
# /home/tadej/xlab/wwt/manageiq/app/models/manageiq/providers/base_manager/refresher.rb:96:in `block in r
@tadeboro
tadeboro / redfish-debug.md
Last active August 1, 2019 07:56
Manually inspecting Redfish API responses

Redfish API debugging

Debugging the Redfish API is relatively easy since JSON is at least partially human-readable (programmer-readable maybe? ;).

Manually inspecting Redfish responses

Inspect the Redfish API responses using curl is relatively simple. We start by running this:

$ ansible-test units tests/unit/test_x.py
...
========================================== FAILURES ===========================================
________________________________________ test_my_stuff ________________________________________
[gw0] linux -- Python 3.7.6 /tmp/python-8s1dwmns-ansible/python
def test_my_stuff():
> assert dict(a=3) == dict(b=2)
E AssertionError
tests/unit/test_x.py:2: AssertionError
@tadeboro
tadeboro / playbook.yaml
Created March 25, 2020 09:46
Making sure all lines match certain regex
---
- name: Test
hosts: localhost
gather_facts: false
tasks:
- name: Dummy data
shell: echo -e "1 a\n1 b\n1 c\n"
register: result
@tadeboro
tadeboro / test.sh
Created March 27, 2020 11:50
LOcal git clone
#!/bin/bash
rm -rf x.git y
git init --bare x.git
git clone x.git y
cd y
echo bla > bla.txt
@tadeboro
tadeboro / setup.sh
Created April 28, 2020 11:01
Test setup for community.vmware collection
#!/bin/bash
mkdir vmware && cd vmware
mkdir -p collections/ansible_collections/community
git clone \
--depth=1 \
https://github.com/ansible-collections/vmware.git \
collections/ansible_collections/community/vmware
@tadeboro
tadeboro / test__set_cwd.py
Created May 8, 2020 22:00
Testing AnsibleModule._set_cwd method
# -*- coding: utf-8 -*-
# (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import pytest
@tadeboro
tadeboro / ansible-output.txt
Created August 2, 2020 20:27
ansible-test units output using pytest 6.0.1
$ ansible-test units --python 3.8 tests/unit/modules/test_asset.py
WARNING: PyYAML will be slow due to installation without libyaml support for interpreter: /home/tadej/xlab/sensu/venvt/bin/python
Unit test with Python 3.8
================================================= test session starts =================================================
platform linux -- Python 3.8.3, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /home/tadej/xlab/sensu/ansible_collections/sensu/sensu_go/tests/unit/modules, configfile: ../../../../../../venvt/lib64/python3.8/site-packages/ansible_test/_data/pytest.ini
plugins: xdist-1.34.0, forked-1.3.0, mock-3.2.0
gw0 [0] / gw1 [0] / gw2 [0] / gw3 [0] / gw4 [0] / gw5 [0] / gw6 [0] / gw7 [0]
======================================================= ERRORS ========================================================