Skip to content

Instantly share code, notes, and snippets.

View tsaridas's full-sized avatar

Andreas Tsarida tsaridas

View GitHub Profile
import aiohttp
import asyncio
import json
async def get_vcenter_token(session, vcenter_url, username, password):
url = f"{vcenter_url}/rest/com/vmware/cis/session"
async with session.post(url, auth=aiohttp.BasicAuth(username, password)) as response:
if response.status == 200:
data = await response.json()
return data['value']
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/capability.h>
#include <sys/capability.h>
@tsaridas
tsaridas / upload_tar_folder.py
Created November 28, 2019 22:47
upload with requests a folder and tar it in chunks without saving to disk
#!/usr/bin/python
import tarfile
#import requests
# This class won't be needed if we create TarInfo objects manually as described below.
class DummyFile(object):
def __init(self):
#!/usr/bin/env python
import json
import shutil
from collections import namedtuple
from ansible.parsing.dataloader import DataLoader
from ansible.vars.manager import VariableManager
from ansible.inventory.manager import InventoryManager
from ansible.playbook.play import Play
from ansible.executor.task_queue_manager import TaskQueueManager
# Based on local.py (c) 2012, Michael DeHaan <[email protected]>
# Based on chroot.py (c) 2013, Maykel Moya <[email protected]>
# Based on func.py
# (c) 2014, Michael Scherer <[email protected]>
# (c) 2017 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
frontend http
mode http
bind :::80 v4v6
http-request lua.auth-request auth_request /is-allowed
http-request deny if ! { var(txn.auth_response_successful) -m bool }
backend auth_request
mode http
server auth_request 127.0.0.1:8080
@tsaridas
tsaridas / simple-salt-client
Last active December 26, 2017 20:38
simple-salt-client
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import zmq
import msgpack
root_file = '/var/cache/salt/master/.root_key'
with open(root_file) as f:
root_key = f.read()
msg = {'load': {'tgt_type': 'list', 'jid': '', 'cmd': 'publish', 'tgt': ['salt-minion-01'], 'key': root_key, 'arg': [], 'fun': 'test.ping', 'kwargs': {'delimiter': ':', 'show_timeout': True, 'show_jid': False}, 'ret': '', 'user': 'root'}, 'enc': u'clear'}
#!/usr/bin/env python
#
# Building a tar file chunk-by-chunk.
#
# taken from https://gist.github.com/chipx86/9598b1e4a9a1a7831054
# This is a quick bit of sample code for streaming data to a tar file,
# building it piece-by-piece. The tarfile is built on-the-fly and streamed
# back out. This is useful for web applications that need to dynamically
# build a tar file without swamping the server.
import os
@tsaridas
tsaridas / client.py
Created May 21, 2017 18:53 — forked from akx/client.py
Simple uWSGI + XML-RPC
import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost:3040')
print s.pow(2,3)
print s.sum([2,3])
print s.system.listMethods()
@tsaridas
tsaridas / Template_SNMP_DELL_OpenManage.xml
Created April 22, 2016 12:39 — forked from alice-xu/Template_SNMP_DELL_OpenManage.xml
Zabbix SNMP monitoring template for DELL Openmanage Server Administrator
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>2.0</version>
<date>2014-06-18T02:56:36Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>