Exemplo n.º 1
0
class TestNode(unittest.TestCase):
    def setUp(self):
        self.node = None
        self.conn = None
        self.driver = DummyDriver()

    def create_dummies(self, node_name="", node_exists=False):
        self.node = Node(name=node_name, tags=["tag1"], size=Size(ram=512))
        self.conn = DummyConn(node_name, node_exists)

    def test_up(self):
        self.create_dummies("nodetocreate", node_exists=False)

        self.node.up(self.driver, self.conn)
        self.assertTrue(self.conn.deploy_called)

    def test_down(self):
        self.create_dummies("nodetodestroy", node_exists=True)

        self.node.down(self.driver, self.conn)
        self.assertTrue(self.conn.dummy_lib_cloud_node.destroy_called)
Exemplo n.º 2
0
class TestNode(unittest.TestCase):

	def setUp(self):
		self.node = None
		self.conn = None
		self.driver = DummyDriver()

	def create_dummies(self, node_name="", node_exists=False):
		self.node = Node(	name=node_name, 
							tags=["tag1"],
							size=Size(ram=512))
		self.conn = DummyConn(node_name, node_exists)

	def test_up(self):
		self.create_dummies("nodetocreate", node_exists=False)
		
		self.node.up(self.driver, self.conn)
		self.assertTrue(self.conn.deploy_called)
		
	def test_down(self):
		self.create_dummies("nodetodestroy", node_exists=True)
		
		self.node.down(self.driver, self.conn)
		self.assertTrue(self.conn.dummy_lib_cloud_node.destroy_called)
Exemplo n.º 3
0
from blitzem.model import Node, LoadBalancer, Size, defaults, user_public_ssh_key
from libcloud.compute.deployment import MultiStepDeployment, ScriptDeployment, SSHKeyDeployment
from blitzem.deployment import LoggedScriptDeployment

defaults["deployment"] = MultiStepDeployment([
		# Note: This key will be added to the authorized keys for the root user
		# (/root/.ssh/authorized_keys)
		SSHKeyDeployment(open(user_public_ssh_key).read()),
		# Serve a simple text file on each node to demonstrate load balancing effect
		LoggedScriptDeployment("apt-get update; apt-get install dtach"),
		LoggedScriptDeployment("mkdir web; cd web; hostname > hostname.txt; dtach -n /tmp/simple_http.worker python -m SimpleHTTPServer 8080")
	])



"""
==== WEB TIER ====
"""

LoadBalancer(	name="web_lb1",
				applies_to_tag="web",
				port=8080,
				protocol="http")

# A simple pair of nodes in the 'web' tier
Node(	name="web1",
		tags=["web"])

Node(	name="web2",
		tags=["web"])
Exemplo n.º 4
0
	def create_dummies(self, node_name="", node_exists=False):
		self.node = Node(	name=node_name, 
							tags=["tag1"],
							size=Size(ram=512))
		self.conn = DummyConn(node_name, node_exists)
Exemplo n.º 5
0
import os

from blitzem.model import Node, Size, defaults
from libcloud.compute.deployment import MultiStepDeployment, ScriptDeployment, SSHKeyDeployment

# Can override specific default settings.
defaults["os"] = "Ubuntu 11.10"


"""
==== WEB TIER ====
"""
# A simple node in the 'web' tier
Node(	name="web1",
		tags=["web"])

# A node with more customized settings - also tagged 'peakload' for scaling control
Node(	name="web2",
		os="Ubuntu 11.04",
		tags=["web", "peakload"],
		size=Size(ram=512))

"""
==== APP TIER ====
"""
Node(	name="app1",
		os="Ubuntu 11.04",
		tags=["app"])

# also tagged 'peakload' for scaling control
Node(	name="app2",
Exemplo n.º 6
0
 def create_dummies(self, node_name="", node_exists=False):
     self.node = Node(name=node_name, tags=["tag1"], size=Size(ram=512))
     self.conn = DummyConn(node_name, node_exists)