Пример #1
0
    def POST(self, Compute):
        creds = json.loads(web.data())
        name = creds.get('Compute').get('name')
        tenant_id = creds.get('Compute').get('tenant_id') 
        username = creds.get('Compute').get('username')
        password = creds.get('Compute').get('password')
        count = creds.get('Compute').get('count')
        os = creds.get('Compute').get('image')
        flavor = creds.get('Compute').get('flavor')
        send_auth = creds.get('Compute').get('auth_key')
        token = creds.get('Compute').get('token') 
        if token is None: 
            conn = driver.libcloud_driver_token(None, None, tenant_id, token)
        else: 
            conn = driver.libcloud_driver_password(username, password, tenant_id)
        compute_nodes = compute.ComputeNodes(conn)
        image_nodes = image.ComputeImages(conn)
        nodes = compute_nodes.get_nodes()  
        imageList = image_nodes.get_images() 
        sizeList = image_nodes.get_sizes() 
        send_size = image_nodes.get_size(flavor) 
        send_image = image_nodes.get_image(os) 

        i = 0 
        w = worker.WorkerQueue() 
        w.start()

        while i < int(count): 
            w.send(compute_nodes.create_node(name, send_image, send_size, send_auth))
            i += 1
        w.close() 
Пример #2
0
 def PUT(self, Compute):
     creds = json.loads(web.data())
     
     node_search = creds.get('Compute').get('node')
     tenant_id = creds.get('Compute').get('tenant_id') 
     username = creds.get('Compute').get('username')
     password = creds.get('Compute').get('password')
     token = creds.get('Compute').get('token') 
     if token is None: 
         conn = driver.libcloud_driver_token(None, None, tenant_id, token)
     else: 
         conn = driver.libcloud_driver_password(username, password, tenant_id)
     compute_nodes = compute.ComputeNodes(conn)
     nodes = compute_nodes.get_nodes()  
     node = compute_nodes.get_node(node_search)  
     
     w = worker.WorkerQueue() 
     w.start()
     i = 0
     
     while i < len(nodes): 
         if node_search == nodes[i].name:
             w.send(compute_nodes.reboot_node(nodes[i]))
         elif node_search == nodes[i].uuid:
             w.send(compute_nodes.reboot_node(nodes[i]))
         elif node_search in nodes[i].private_ips:
             w.send(compute_nodes.reboot_node(nodes[i]))
         elif node_search in nodes[i].public_ips:
             w.send(compute_nodes.reboot_node(nodes[i]))
         i += 1
         
     w.close() 
Пример #3
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     conn = driver.libcloud_driver_password("admin", "secrete", "admin")
     self.novatest = ComputeNodes(conn)
Пример #4
0
import unittest
import identity
import image
import driver
from compute import ComputeNodes
import random

_endpoint = "http://10.100.18.144:5000/v2.0" 
username = "******"
password = "******"
tenant_id = "b3c18bc8a54f4f1c93afe949f790d5c6"
image_id = "5b920dc1-52d1-4cce-aea4-effaf994c3de"
rand_seed = random.randint(10000000,99999999)
random_image_id = "%d-1234-1234-1234-abcdabcdabcd" % rand_seed

conn = driver.libcloud_driver_password("admin", "secrete", "admin")
token = ComputeNodes(conn).get_token()

class KeystoneAPITests(unittest.TestCase):
    
    def setUp(self):
        pass
        
    def test_get_token(self):
        #token = identity.get_token(keystone, username, password, "NATIVE")
        
        #if token == -1:
            #return web.webUnauthorized()
        
        auth_token = {}
        #auth_token['token'] = token.id