def test_create_load_balancer(): lb = cs.load_balancers.create( name="my-lb", protocol="HTTP", nodes=[{"address": "10.0.0.1", "protocol": "HTTP", "condition": NodeCondition.ENABLED}], virtual_ips=[{"type": VirtualIPType.PUBLIC}], ) cs.assert_called("POST", "/loadbalancers") assert_isinstance(lb, LoadBalancer)
def test_create_server(): s = cs.servers.create( name="My server", image=1, flavor=1, meta={'foo': 'bar'}, ipgroup=1, files={ '/etc/passwd': 'some data', # a file '/tmp/foo.txt': StringIO.StringIO('data') # a stream }) cs.assert_called('POST', '/servers') assert_isinstance(s, Server)
def test_create_server(): s = cs.servers.create( name = "My server", image = 1, flavor = 1, meta = {'foo': 'bar'}, ipgroup = 1, files = { '/etc/passwd': 'some data', # a file '/tmp/foo.txt': StringIO.StringIO('data') # a stream } ) cs.assert_called('POST', '/servers') assert_isinstance(s, Server)
def test_get_backup_schedule(): s = cs.servers.get(1234) # access via manager b = cs.backup_schedules.get(server=s) assert_isinstance(b, BackupSchedule) cs.assert_called('GET', '/servers/1234/backup_schedule') b = cs.backup_schedules.get(server=1234) assert_isinstance(b, BackupSchedule) cs.assert_called('GET', '/servers/1234/backup_schedule') # access via instance assert_isinstance(s.backup_schedule, BackupSchedule) cs.assert_called('GET', '/servers/1234/backup_schedule') # Just for coverage's sake b = s.backup_schedule.get() cs.assert_called('GET', '/servers/1234/backup_schedule')
def test_list_servers_undetailed(): sl = cs.servers.list(detailed=False) cs.assert_called('GET', '/servers') [assert_isinstance(s, Server) for s in sl]
def test_list_flavors_undetailed(): fl = cs.flavors.list(detailed=False) cs.assert_called('GET', '/flavors') [assert_isinstance(f, Flavor) for f in fl]
def test_list_flavors(): fl = cs.flavors.list() cs.assert_called('GET', '/flavors/detail') [assert_isinstance(f, Flavor) for f in fl]
def test_create_image(): i = cs.images.create(server=1234, name="Just in case") cs.assert_called('POST', '/images') assert_isinstance(i, Image)
def test_get_server_details(): s = cs.servers.get(1234) cs.assert_called('GET', '/servers/1234') assert_isinstance(s, Server) assert_equal(s.id, 1234) assert_equal(s.status, 'BUILD')
def test_load_balancer_add_virtual_ip(): lb = cs.load_balancers.get(71) virtual_ip = lb.virtual_ips.add(type="PUBLIC", ip_version="IPV6") cs.assert_called("POST", "/loadbalancers/71/virtualips") assert_isinstance(virtual_ip, VirtualIP)
def test_list_zones(): sl = os.zones.list() os.assert_called('GET', '/zones/detail') [assert_isinstance(s, Zone) for s in sl]
def test_list_servers(): sl = cs.servers.list() cs.assert_called('GET', '/servers/detail') [assert_isinstance(s, Server) for s in sl]
def test_get_zone_details(): s = os.zones.get(1) os.assert_called('GET', '/zones/1') assert_isinstance(s, Zone) assert_equal(s.id, 1) assert_equal(s.api_url, 'http://foo.com')
def test_create_zone(): s = os.zones.create(api_url="http://foo.com", username='******', password='******') os.assert_called('POST', '/zones') assert_isinstance(s, Zone)
def test_list_load_balancers(): lbs = cs.load_balancers.list() cs.assert_called("GET", "/loadbalancers") [assert_isinstance(lb, LoadBalancer) for lb in lbs]
def test_load_balancer_node_details(): lb = cs.load_balancers.get(71) node = lb.nodes.get(410) cs.assert_called("GET", "/loadbalancers/71/nodes/410") assert_isinstance(node, Node) assert_equal(node.id, 410)
def test_load_balancer_list_nodes(): lb = cs.load_balancers.get(71) nodes = lb.nodes.list() cs.assert_called("GET", "/loadbalancers/71/nodes") [assert_isinstance(node, Node) for node in nodes]
def test_get_load_balancer_details(): lb = cs.load_balancers.get(71) cs.assert_called("GET", "/loadbalancers/71") assert_isinstance(lb, LoadBalancer) assert_equal(lb.id, 71) assert_equal(lb.status, "ACTIVE")
def test_get_image_details(): i = cs.images.get(1) cs.assert_called("GET", "/images/1") assert_isinstance(i, Image) assert_equal(i.id, 1) assert_equal(i.name, "CentOS 5.2")
def test_load_balancer_list_virtual_ips(): lb = cs.load_balancers.get(71) virtual_ips = lb.virtual_ips.list() cs.assert_called("GET", "/loadbalancers/71/virtualips") [assert_isinstance(virtual_ip, VirtualIP) for virtual_ip in virtual_ips]
def test_list_zones_undetailed(): sl = os.zones.list(detailed=False) os.assert_called('GET', '/zones') [assert_isinstance(s, Zone) for s in sl]
def test_list_images(): il = cs.images.list() cs.assert_called("GET", "/images/detail") [assert_isinstance(i, Image) for i in il]
def test_list_ipgroups_undetailed(): ipl = cs.ipgroups.list(detailed=False) cs.assert_called("GET", "/shared_ip_groups") [assert_isinstance(ipg, IPGroup) for ipg in ipl]
def test_get_flavor_details(): f = cs.flavors.get(1) cs.assert_called('GET', '/flavors/1') assert_isinstance(f, Flavor) assert_equal(f.ram, 256) assert_equal(f.disk, 10)
def test_get_ipgroup(): ipg = cs.ipgroups.get(1) cs.assert_called("GET", "/shared_ip_groups/1") assert_isinstance(ipg, IPGroup)
def test_get_image_details(): i = cs.images.get(1) cs.assert_called('GET', '/images/1') assert_isinstance(i, Image) assert_equal(i.id, 1) assert_equal(i.name, 'CentOS 5.2')
def test_get_ipgroup(): ipg = cs.ipgroups.get(1) cs.assert_called('GET', '/shared_ip_groups/1') assert_isinstance(ipg, IPGroup)
def test_list_images(): il = cs.images.list() cs.assert_called('GET', '/images/detail') [assert_isinstance(i, Image) for i in il]
def test_create_ipgroup(): ipg = cs.ipgroups.create("My group", 1234) cs.assert_called('POST', '/shared_ip_groups') assert_isinstance(ipg, IPGroup)
def test_list_ipgroups(): ipl = cs.ipgroups.list() cs.assert_called('GET', '/shared_ip_groups/detail') [assert_isinstance(ipg, IPGroup) for ipg in ipl]
def test_list_images_undetailed(): il = cs.images.list(detailed=False) cs.assert_called('GET', '/images') [assert_isinstance(i, Image) for i in il]