Skip to content

Instantly share code, notes, and snippets.

View allthingsclowd's full-sized avatar
🎲
42

Graham Land allthingsclowd

🎲
42
View GitHub Profile
@allthingsclowd
allthingsclowd / Deploy_Heat_Stack.py
Created March 10, 2017 16:13
Python function to call Fujitsu's K5 IaaS Orchestration EndPoint
def deploy_heat_stack(k5token, stack_name, stack_to_deploy, stack_parameters):
"""Summary : K5 HEAT API call to send a heat stack, wrapped in a string, to a K5 Project
Returns:
TYPE: JSON Object containing the new Stack Id or Error Codes
"""
orchestrationURL = unicode(get_endpoint(k5token, "orchestration")) + unicode("/stacks")
print orchestrationURL
token = k5token.headers['X-Subject-Token']
@allthingsclowd
allthingsclowd / simple_3_node_template.yml
Last active March 10, 2017 20:19
Fujitsu K5 IaaS OpenStack Heat Template
heat_template_version: 2013-05-23
# Author: Graham Land
# Date: 08/03/2017
# Purpose: Fujitsu K5 OpenStack IaaS Heat Template that deploys 3 servers on a new network and attaches the network to a given router.
# Input parameters -
# routerId - unique id of the router that the network should be attached to
# imageName - the image OS that will be deployed
# flavorName - the vcpu and ram size of the servers
# dataVolume - the size of the data volume to be attached to the servers
# cidr - private network ip address details
@allthingsclowd
allthingsclowd / K5_Cookie_Cutter.md
Last active March 10, 2017 16:46
Infrastructure as Code deployments using Fujitsu K5 IaaS OpenStack Heat Templates and Python
@allthingsclowd
allthingsclowd / OpenStack_Fujitsu_K5_Server_Build_API_Demo.py
Created January 27, 2017 17:19
# OpenStack_Fujitsu_K5_Server_Build_API_Demo Another demo of how a virtual server can be instantiated though the OpenStack APIs on Fujitsu K5's IaaS Platform
#!/usr/bin/python
"""Summary:
The following tutorial demonstrates how the native OpenStack APIs can be used to deploy a server, network, subnet and router
on the Fujitsu K5 IaaS Platform
Author: Graham Land
Date: 27/01/17
Twitter: @allthingsclowd
Github: https://github.com/allthingscloud
Blog: https://allthingscloud.eu
@allthingsclowd
allthingsclowd / PHP_CMSimple.yaml
Created January 24, 2017 19:37
Fujitsu K5 Demo Stack that deploys PHP-CMSimple Application
heat_template_version: 2013-05-23
# Author: Graham Land
# Date: 24/01/2017
# Website: https//allthingscloud.eu
# Purpose: Template to demonstrate the basic format/usage of HOT template to deploy a PHP_CMSimple Server
description: PHP_CMSimple Demo Server
# Input parameters
parameters:
@allthingsclowd
allthingsclowd / MultiProjectAPIDemo.md
Created January 18, 2017 21:32
MultiProjectDemoLink
@allthingsclowd
allthingsclowd / K5-Subnet-Route-Update.py
Created January 18, 2017 20:20
Snippet of K5 API call to update subnet routes
def add_static_route_to_subnet(k5token, subnetid, routes, region):
# e.g. routes = = [{'destination': '192.168.101.0/24', 'nexthop': u'192.168.100.2'},{'destination': '192.168.100.0/24', 'nexthop': u'192.168.100.2'}]
subnetURL = 'https://networking.' + region + \
'.cloud.global.fujitsu.com/v2.0/subnets/' + subnetid
try:
response = requests.put(subnetURL,
headers={'X-Auth-Token': k5token,
'Content-Type': 'application/json'},
json={"subnet": {"host_routes": routes}})
return response
@allthingsclowd
allthingsclowd / K5-Update-Router-Routes.py
Created January 18, 2017 20:14
Snippet of K5 router routes update
def update_router_routes(k5token, routerid, routes, region):
# e.g. routes = [{'destination': '192.168.10.0/24', 'nexthop': u'192.168.100.2'}, {'destination': '192.168.11.0/24', 'nexthop': u'192.168.100.2'}]
try:
routerURL = 'https://networking-ex.' + region + \
'.cloud.global.fujitsu.com/v2.0/routers/' + routerid
response = requests.put(routerURL,
headers={'X-Auth-Token': k5token,
'Content-Type': 'application/json'},
json={"router": {"routes": routes}})
return response
@allthingsclowd
allthingsclowd / AddInterPojectRoute.py
Last active January 18, 2017 19:59
snippet of K5 function to add remote interface current project router
def inter_project_connection_create(k5token, router, port, region):
routerURL = 'https://networking-ex.' + region + \
'.cloud.global.fujitsu.com/v2.0/routers/' + \
router + '/add_cross_project_router_interface'
try:
response = requests.put(routerURL,
headers={'X-Auth-Token': k5token,
'Content-Type': 'application/json'},
json={"port_id": port})
@allthingsclowd
allthingsclowd / ReScope_K5_Token.py
Created January 18, 2017 17:52
Example snippet to rescope a k5 token
def get_rescoped_token(k5token, projectid, region):
"""Get a regional project token - rescoped
Returns:
STRING: Regionally Scoped Project Token
Args:
k5token (TYPE): valid regional token
projectid (TYPE): project id to scope to
region (TYPE): k5 region