remove 2 unused files
authorPaul Tonelli <paul.tonelli@logilab.fr>
Fri, 08 Mar 2013 11:30:24 +0100
changeset 48 c03c587f39d3
parent 47 4f52499c0eae
child 49 f5de218cf9d2
remove 2 unused files
_modules/openstack_client.py
bootstrap-script.sh
--- a/_modules/openstack_client.py	Fri Mar 08 11:29:47 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-#!/usr/bin/env python
-'''
-this module replaces temporarely the glance script from salt 
-(unavailable due to glanceclient not being available in debian)
-
-it also relies on the nova script (which works)
-'''
-
-from os import environ
-from glance import client as glance_client
-
-# Import third party libs
-HAS_NOVA = False
-try:
-    from novaclient.v1_1 import client
-    HAS_NOVA = True
-except ImportError:
-    pass
-
-_FLAVOR='m1.lvm'
-
-def _auth_nova():
-    '''
-    Set up nova credentials
-    identical to _auth in /usr/share/pyshared/salt/modules/nova.py
-    '''
-    user = __salt__['config.option']('keystone.user')
-    password = __salt__['config.option']('keystone.password')
-    tenant = __salt__['config.option']('keystone.tenant')
-    auth_url = __salt__['config.option']('keystone.auth_url')
-    return client.Client(
-        user, password, tenant, auth_url, service_type="compute"
-    )
-
-def _auth_glance(id_elements=None, force_update=False):
-    '''
-    really ugly, but works
-    to use glance with cmd.run
-    '''
-    if id_elements == None:
-        id_elements={
-                'OS_AUTH_URL': __salt__['config.option']('keystone.auth_url'),
-                'OS_TENANT_ID': __salt__['config.option']('keystone.tenant_id'),
-                'OS_TENANT_NAME': __salt__['config.option']('keystone.tenant'),
-                'OS_USERNAME': __salt__['config.option']('keystone.user'),
-                'OS_PASSWORD': __salt__['config.option']('keystone.password')
-                }
-        for key in id_elements:
-            if force_update or key not in environ:
-                environ[key] = id_elements[key]
-    return glance_client.get_client(host='0.0.0.0')
-
-def delete_image(id_image):
-    '''
-    delete image from glance
-
-    CLI Example::
-
-        salt '*'  openstack_client.delete_image\
-                00000000-0000-0000-0000-000000000000
-    '''
-    print __salt__['cmd.run']("glance delete " + id_image)
-
-def get_running_instances():
-    _auth_glance()
-    data = __salt__['nova.list']()
-    for i in data:
-        print str(i) + " len : " + str(len(i))
-    print gc.get_images()
-    return True
-
-#def test_pillars():
-#    pillars_val = __salt__['pillar.raw']()['master']
-#    print pillars_val
-#    for i in pillars_val:
-#        if i.find("keystone") != -1:
-#            print i + " : " + pillars_val[i]
-#    return True
-
-def upload_to_glance(path, filename, disk_format, other_params,
-        image_name=None):
-    g_client = _auth_glance()
-    if image_name == None:
-        image_name = filename.replace(".img","")
-    #glance upload initrd, kernel and get ids
-    print "sending "+ disk_format + " to glance"
-    output_add = __salt__['cmd.run']("glance add is_public=false disk_format="
-            + disk_format + " container_format=" + disk_format + " name=\""
-            + image_name + "\" " + other_params + " < " + path + "/" + filename)
-    id_image = output_add.split("ID: ")[1].split('\n')[0]
-    print "Uploaded " + disk_format + " with id : " + id_image
-    return id_image
-
-#def unpause(image_id):
-#    '''
-#    unpause first instance found with image matching id (not instance id)
-#    '''
-#    nt_ks = _auth_nova()
-#    for item in nt_ks.servers.list():
-#        if item.image['id'] == image_id:
-#            if item.status == 'PAUSED':
-#                print item.unpause()
-#                return True
-#    return False
-#
-#def resume(image_id):
-#    '''
-#    resume first instance found with image matching id (not instance id)
-#    '''
-#    nt_ks = _auth_nova()
-#    for item in nt_ks.servers.list():
-#        if item.image['id'] == image_id:
-#            if item.status == 'SUSPENDED':
-#                print item.resume()
-#                return True
-#    return False
-
-def item_list():
-    '''
-    Template for writing list functions
-    Return a list of available items (nova items-list)
-
-    CLI Example::
-
-        salt '*' nova.item_list
-    '''
-    nt_ks = _auth_nova()
-    ret = []
-    for item in nt_ks.servers.list():
-        ret.append(item.__dict__)
-        #ret[item.name] = {
-        #        'name': item.name,
-        #    }
-    return ret
-
-def check_running_container(human_id, image_id=None, flavor=None): #should be used in state
-    '''
-    if a container is active, use it, else create it
-
-    CLI Example::
-
-        salt '*' nova.check_running_container "ami-creator"
-    '''
-
-    nt_ks = _auth_nova()
-    matching_instances = [machine for machine in nt_ks.servers.list()
-            if item.nk.servers.list()[0].human_id == human_id]
-    if len(matching_instances) == 1:
-        machine = matching_instances[0]
-        if image_id != None:
-            assert machine.image['id'] == image_d
-        if flavor != None:
-            assert nt_ks.flavors.get(machine.flavor['id']) == image_d
-        if machine.status == 'PAUSED':
-            machine.unpause()
-        if machine.status == 'SUSPENDED':
-            machine.resume()
-        while machine.status != 'ACTIVE':
-            sleep(0.1) # wait for the machine to activate
-    elif len(matching_instances) == 0: #create image
-        nt_ks
-    else:
-        assert False
-    pass
-
--- a/bootstrap-script.sh	Fri Mar 08 11:29:47 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-### download image ###
-image_name=raring-server-cloudimg-amd64.tar.gz 
-image_address=http://cloud-images.ubuntu.com/raring/current/$image_name
-wget $image_address 
-mv $image_name /mnt
-
-#### install and configure salt-minion ####
-wget http://ftp.fr.debian.org/debian/pool/main/s/salt/salt-minion_0.12.1-1_all.deb
-wget http://ftp.fr.debian.org/debian/pool/main/s/salt/salt-common_0.12.1-1_all.deb
-dpkg -i salt-minion_0.12.1-1_all.deb salt-common_0.12.1-1_all.deb
-apt-get update
-apt-get -f --force-yes --yes install
-aptitude install salt-minion
-patch /etc/salt/minion minion.patch
-mkdir /etc/salt/srv
-cp -r _modules _states ami-creator.sls top.sls /etc/salt/srv 
-salt-call state.highstate
-salt-call vm_create.create_flavor $image_name gna