Skip to content

Instantly share code, notes, and snippets.

View ferdinandosimonetti's full-sized avatar

Ferdinando Simonetti ferdinandosimonetti

View GitHub Profile
@ferdinandosimonetti
ferdinandosimonetti / printNSXRulesForSection.py
Last active September 13, 2018 12:27
Python code to list every rule in a specific NSX section and prettyprint the resulting XML
import requests
import xml.dom.minidom
restHost = 'https://nsxhost.domain.priv'
baseEndpoint = '/api/4.0/firewall/globalroot-0/config/layer3sections'
userName = 'nsxuser@domain.priv'
userPass = 'nsxpass'
sectionName = 'My Section'
@ferdinandosimonetti
ferdinandosimonetti / ambari-agent.ini
Created October 5, 2018 08:10
INI file for Ambari Agent /etc/ambari-agent/conf/ambari-agent.ini - force_https_protocol parameter needed for Python >= 2.7.5
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@ferdinandosimonetti
ferdinandosimonetti / cert-verification.cfg
Created October 5, 2018 08:13
Python certificate verification config file /etc/python/cert-verification.cfg
# Possible values are:
# 'enable' to ensure HTTPS certificate verification is enabled by default
# 'disable' to ensure HTTPS certificate verification is disabled by default
# 'platform_default' to delegate the decision to the redistributor providing this particular Python version
# For more info refer to https://www.python.org/dev/peps/pep-0493/
[https]
verify=disable
@ferdinandosimonetti
ferdinandosimonetti / HDP-2.6.5.0-292.xml
Created October 5, 2018 08:44
VDF (version definition file) for a local package repository - Hortonworks HDP 2.6.5 - CentOS7/RHEL7 x64
<?xml version="1.0"?>
<repository-version xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="version_definition.xsd">
<release>
<type>STANDARD</type>
<stack-id>HDP-2.6</stack-id>
<version>2.6.5.0</version>
<build>292</build>
<compatible-with>2\.[3-6]\.\d+\.\d+</compatible-with>
<release-notes>http://example.com</release-notes>
<display>HDP-2.6.5.0</display>
@ferdinandosimonetti
ferdinandosimonetti / version-definitions.json
Last active October 5, 2018 08:58
JSON for loading a specific VDF (version definition file) into Ambari server via REST
{ "VersionDefinition": { "version_url": "http://repo.server.fqdn/HDP-2.6.5.0-292.xml" } }
@ferdinandosimonetti
ferdinandosimonetti / ambari-load-vdf.sh
Created October 5, 2018 09:01
REST operation to register a local repository on Ambari Server
curl -v -k -u admin:admin -H "X-Requested-By: ambari" -X POST http://ambari.server.fqdn:8080/api/v1/version_definitions -d @version-definitions.json
@ferdinandosimonetti
ferdinandosimonetti / version-registration.json
Created October 5, 2018 09:05
Output of ambari-load-vdf.sh - the VersionDefinition attribute "id"'s value should be referenced in Ambari blueprints
{
"resources" : [
{
"href" : "http://ambari.server.fqdn/api/v1/version_definitions/1",
"VersionDefinition" : {
"id" : 1,
"stack_name" : "HDP",
"stack_version" : "2.6"
}
}
@ferdinandosimonetti
ferdinandosimonetti / vmmodify.ps1
Last active July 7, 2022 22:27
several useful functions for hyper-v vms
function setVmMemory {
Param(
[parameter(Mandatory=$true)]
[String]
$Pattern,
[parameter(Mandatory=$true)]
[Byte]
$MemoryGB
)
@ferdinandosimonetti
ferdinandosimonetti / adduserstogroup.ps1
Created October 15, 2018 08:06
function to add AD users to AD groups from a CSV input file
function addUsersToGroup {
Param(
[parameter(Mandatory=$true)]
[String]
$InputFile
)
$a = import-csv -header utente,gruppo -path $InputFile
foreach ($row in $a) {
Add-ADGroupMember -members $row.utente -identity $row.gruppo
@ferdinandosimonetti
ferdinandosimonetti / extractPorts.py
Last active October 16, 2018 10:03
Extract listening ports (for Hadoop services) - example of reading from stdin and arrays
#!/usr/bin/python
#
# Usage example:
# jps|./extractPorts.py|bash
#
import sys
f = sys.stdin
# If you need to open a file instead:
#f = open('your.file')