forked from spark404/cs-functional-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloudstack_test_basic_instance.py
62 lines (52 loc) · 1.75 KB
/
cloudstack_test_basic_instance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
from marvin.asyncJobMgr import asyncJobMgr
from marvin.codes import (FAILED, PASS, ADMIN, DOMAIN_ADMIN,
USER, SUCCESS, XEN_SERVER)
from marvin.dbConnection import DbConnection
from marvin.cloudstackAPI import *
from marvin.cloudstackAPI.cloudstackAPIClient import CloudStackAPIClient
from marvin.cloudstackException import CloudstackAPIException
from marvin.cloudstackException import GetDetailExceptionInfo
from marvin.cloudstackConnection import CSConnection
from marvin.configGenerator import ConfigManager
from marvin.lib.utils import (random_gen, validateList)
from CSUtils import *
import json
import time
import sys
utils = CSUtils()
conn = utils.getConnection()
apiclient = CloudStackAPIClient(conn)
# Query Zone
lz = listZones.listZonesCmd()
lz.available = True
resp = apiclient.listZones(lz)
zone = resp[0]
# Create Network
lno = listNetworkOfferings.listNetworkOfferingsCmd()
lno.name="DefaultIsolatedNetworkOfferingWithSourceNatService"
resp = apiclient.listNetworkOfferings(lno)
offering = resp[0]
cn = createNetwork.createNetworkCmd()
cn.name = "test_isolated"
cn.displaytext = "Test Isolated"
cn.networkofferingid = offering.id
cn.zoneid = zone.id
network = apiclient.createNetwork(cn)
# Create Instance
lt = listTemplates.listTemplatesCmd()
lt.name = "tiny Linux"
lt.templatefilter="all"
resp = apiclient.listTemplates(lt)
template = resp[0]
lso = listServiceOfferings.listServiceOfferingsCmd()
lso.name = "tinyOffering"
resp = apiclient.listServiceOfferings(lso)
serviceOffering = resp[0]
dv = deployVirtualMachine.deployVirtualMachineCmd()
dv.zoneid = zone.id
dv.templateid=template.id
dv.serviceofferingid=serviceOffering.id
dv.networkids.append(network.id)
machine = apiclient.deployVirtualMachine(dv)
print repr(machine)