Skip to content

Instantly share code, notes, and snippets.

View dotanh's full-sized avatar

Dotan Horovits dotanh

View GitHub Profile
@dotanh
dotanh / mysql-service-recipe.groovy
Created August 15, 2012 09:36
Cloudify recipe for MySQL
service {
name "mysql"
type "DATABASE"
lifecycle{
install "mysql_install.groovy"
start "mysql_start.groovy"
@dotanh
dotanh / gen_mysql_dump_snippet.groovy
Created August 15, 2012 09:23
Generate MySQL DB dump (snippet)
def builder = new AntBuilder()
builder.sequential {
echo(message:"runMysqlDump: ${debugMsg}")
exec(executable:"${binFolder}/${execFile}", osfamily:"${osName}", output:"${dumpSqlFullPath}") {
arg(line:"${argsLine}")
}
zip(destFile:"${dumpZipFullPath}", basedir: "${dumpFolder}" ,includes:"${sqlFileName}", update:true )
delete(file:"${dumpSqlFullPath}")
}
@dotanh
dotanh / install_mysql_snippet.sh
Created August 15, 2012 08:48
Automating MySQL installation
# Set environment variables
export PATH=$PATH:/usr/sbin:/sbin:/usr/bin || error_exit $? "Failed on: export PATH=$PATH:/usr/sbin:/sbin"
# Removing previous mysql installation if exists...
yum -y -q remove mysql mysql-server
# Removing old stuff (since in some cases, there are leftovers after uninstall)
rm -rf /usr/lib/mysql* || error_exit $? "Failed on: sudo rm -rf /usr/lib/mysql*"
rm -rf /var/lib/mysql* || error_exit $? "Failed on: sudo rm -rf /var/lib/mysql*"
@dotanh
dotanh / RESTful-Jersey-GET.java
Created May 17, 2012 08:55
RESTful client example using Apache Jersey: GET call
String serverBootResponse =
service.path("machine/createMachine")
.queryParam("name", serverName)
.queryParam("imageId", imageId)
.accept(MediaType.APPLICATION_XML)
.cookie(cookie)
.get(String.class);
final DocumentBuilder documentBuilder = createDocumentBuilder();
final Document doc =
@dotanh
dotanh / OpenstackCloudDriver.java
Created May 17, 2012 08:43
RESTful client example using Apache Jersey: POST call
String serverBootResponse =
service.path(this.pathPrefix + "servers")
.header("Content-Type", "application/json")
.header("X-Auth-Token", token)
.accept(MediaType.APPLICATION_XML)
.post(String.class, json);
final DocumentBuilder documentBuilder = createDocumentBuilder();
final Document doc =
documentBuilder.parse(new InputSource(new StringReader(serverBootResponse)));