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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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')
Пример #5
0
def test_list_servers_undetailed():
    sl = cs.servers.list(detailed=False)
    cs.assert_called('GET', '/servers')
    [assert_isinstance(s, Server) for s in sl]
Пример #6
0
def test_list_flavors_undetailed():
    fl = cs.flavors.list(detailed=False)
    cs.assert_called('GET', '/flavors')
    [assert_isinstance(f, Flavor) for f in fl]
Пример #7
0
def test_list_flavors():
    fl = cs.flavors.list()
    cs.assert_called('GET', '/flavors/detail')
    [assert_isinstance(f, Flavor) for f in fl]
Пример #8
0
def test_list_flavors():
    fl = cs.flavors.list()
    cs.assert_called('GET', '/flavors/detail')
    [assert_isinstance(f, Flavor) for f in fl]
Пример #9
0
def test_create_image():
    i = cs.images.create(server=1234, name="Just in case")
    cs.assert_called('POST', '/images')
    assert_isinstance(i, Image)
Пример #10
0
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)
Пример #12
0
def test_list_zones():
    sl = os.zones.list()
    os.assert_called('GET', '/zones/detail')
    [assert_isinstance(s, Zone) for s in sl]
Пример #13
0
def test_list_servers():
    sl = cs.servers.list()
    cs.assert_called('GET', '/servers/detail')
    [assert_isinstance(s, Server) for s in sl]
Пример #14
0
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')
Пример #15
0
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")
Пример #20
0
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')
Пример #21
0
def test_list_servers():
    sl = cs.servers.list()
    cs.assert_called('GET', '/servers/detail')
    [assert_isinstance(s, Server) for s in sl]
Пример #22
0
def test_list_zones():
    sl = os.zones.list()
    os.assert_called('GET', '/zones/detail')
    [assert_isinstance(s, Zone) for s in sl]
Пример #23
0
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]
Пример #25
0
def test_list_zones_undetailed():
    sl = os.zones.list(detailed=False)
    os.assert_called('GET', '/zones')
    [assert_isinstance(s, Zone) for s in sl]
Пример #26
0
def test_list_images():
    il = cs.images.list()
    cs.assert_called("GET", "/images/detail")
    [assert_isinstance(i, Image) for i in il]
Пример #27
0
def test_create_zone():
    s = os.zones.create(api_url="http://foo.com", username='******',
                        password='******')
    os.assert_called('POST', '/zones')
    assert_isinstance(s, Zone)
Пример #28
0
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]
Пример #29
0
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)
Пример #30
0
def test_get_ipgroup():
    ipg = cs.ipgroups.get(1)
    cs.assert_called("GET", "/shared_ip_groups/1")
    assert_isinstance(ipg, IPGroup)
Пример #31
0
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)
Пример #33
0
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)
Пример #35
0
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_list_ipgroups():
    ipl = cs.ipgroups.list()
    cs.assert_called('GET', '/shared_ip_groups/detail')
    [assert_isinstance(ipg, IPGroup) for ipg in ipl]
Пример #37
0
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')
Пример #38
0
def test_list_images_undetailed():
    il = cs.images.list(detailed=False)
    cs.assert_called('GET', '/images')
    [assert_isinstance(i, Image) for i in il]