remove old experimental code

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2012-04-17 12:09:30 +10:00
parent 0c93a40b60
commit 8c7e46f4e6
3 changed files with 0 additions and 133 deletions

View File

@ -1,66 +0,0 @@
#!/usr/bin/python
import gettext
import sys
import os.path
import json
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
sys.path.insert(0, possible_topdir)
gettext.install('heat', unicode=1)
from heat.engine import parser
parameter_count = 1
def setparam(t, key, value):
global parameter_count
key_name = 'Parameters.member.%d.ParameterKey' % parameter_count
value_name = 'Parameters.member.%d.ParameterValue' % parameter_count
t[key_name] = key
t[value_name] = value
parameter_count += 1
filename = sys.argv[1]
with open(filename) as f:
json_blob = json.load(f)
(stack_name, tmp) = os.path.splitext(os.path.basename(filename))
params_dict = {}
setparam(params_dict, 'AWS::StackName', stack_name)
# Don't immediately see a way to have key name as a parameter and also
# file injection and monitoring
# need to insert key on creation and know what private key is
setparam(params_dict, 'KeyName', 'sdake_key')
# ^ that gets inserted into image
setparam(params_dict, 'AWS::StackName', stack_name)
setparam(params_dict, 'InstanceType', 'm1.xlarge')
setparam(params_dict, 'DBUsername', 'eddie.jones')
setparam(params_dict, 'DBPassword', 'adm1n')
setparam(params_dict, 'DBRootPassword', 'admone')
setparam(params_dict, 'LinuxDistribution', 'F16')
# set the keystone auth environs up
username = os.environ['OS_USERNAME']
password = os.environ['OS_PASSWORD']
tenant = os.environ['OS_TENANT_NAME']
auth_url = os.environ['OS_AUTH_URL']
params_dict['KeyStoneCreds'] = dict(username=username,
password=password,
tenant=tenant,
auth_url=auth_url,
strategy='keystone')
stack = parser.Stack(stack_name, json_blob, params_dict)
stack.start()

View File

@ -8,10 +8,6 @@ http://fedoraproject.org/wiki/Getting_started_with_OpenStack_on_Fedora_17#Previe
Tools
-----
+ experimental_create.py
- Example of creating an keypair and instantiating an instance after
one has been registered with JEOS create
+ experimental_ssh_eventlet.py
- Example of using ssh inside python with eventlets.

View File

@ -1,63 +0,0 @@
#!/usr/bin/python
import eventlet
from eventlet.green import socket
import libssh2
import time
import os
import random
import base64
import uuid
import M2Crypto
from novaclient.v1_1 import client
def instance_start(instance_name, image_name, flavor_name):
"""
Method to start an instance
"""
def _null_callback(p, n, out):
"""
Method to silence the default M2Crypto.RSA.gen_key output.
"""
pass
private_key = M2Crypto.RSA.gen_key(2048, 65537, _null_callback)
# this is the binary public key, in ssh "BN" (BigNumber) MPI format.
# The ssh BN MPI format consists of 4 bytes that describe the length
# of the following data, followed by the data itself in big-endian
# format. The start of the string is 0x0007, which represent the 7
# bytes following that make up 'ssh-rsa'. The key exponent and
# modulus as fetched out of M2Crypto are already in MPI format, so
# we can just use them as-is. We then have to base64 encode the
# result, add a little header information, and then we have a
# full public key.
username = os.environ['OS_USERNAME']
password = os.environ['OS_PASSWORD']
tenant = os.environ['OS_TENANT_NAME']
auth_url = os.environ['OS_AUTH_URL']
nova_client = client.Client(username, password, tenant, auth_url, service_type='compute', service_name='nova')
public_key_bn = '\x00\x00\x00\x07' + 'ssh-rsa' + private_key.e + private_key.n
public_key = 'ssh-rsa %s support@heat-api.org\n' % (base64.b64encode(public_key_bn))
private_key.save_key('/tmp/private_key', cipher=None)
random_uuid = uuid.uuid4()
key_uuid = uuid.uuid3(random_uuid, '%s %s %s' % (instance_name, image_name, flavor_name))
nova_client.keypairs.create(str(key_uuid), public_key)
image_list = nova_client.images.list()
for o in image_list:
if getattr(o, 'name', '') == image_name:
image_id = o.id #getattr(o, 'id', '')
flavor_list = nova_client.flavors.list()
for o in flavor_list:
if getattr(o, 'name', '') == flavor_name:
flavor_id = getattr(o, 'id', '')
nova_client.servers.create(name=instance_name, image=image_id,
flavor=flavor_id, key_name=str(key_uuid))
return private_key
instance_start('instance-F16-test', 'F16-x86_64', "m1.tiny")