[python-oca] create new repo
This commit is contained in:
commit
b202172a30
78 changed files with 4703 additions and 0 deletions
0
oca/tests/__init__.py
Normal file
0
oca/tests/__init__.py
Normal file
20
oca/tests/fixtures/cluster.xml
vendored
Normal file
20
oca/tests/fixtures/cluster.xml
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<CLUSTER>
|
||||
<ID>101</ID>
|
||||
<NAME>oneCluster</NAME>
|
||||
<HOSTS>
|
||||
<ID>2</ID>
|
||||
<ID>3</ID>
|
||||
</HOSTS>
|
||||
<DATASTORES>
|
||||
<ID>4</ID>
|
||||
<ID>5</ID>
|
||||
</DATASTORES>
|
||||
<VNETS>
|
||||
<ID>6</ID>
|
||||
<ID>7</ID>
|
||||
</VNETS>
|
||||
<TEMPLATE>
|
||||
<RESERVED_CPU><![CDATA[]]></RESERVED_CPU>
|
||||
<RESERVED_MEM><![CDATA[]]></RESERVED_MEM>
|
||||
</TEMPLATE>
|
||||
</CLUSTER>
|
||||
24
oca/tests/fixtures/clusterpool.xml
vendored
Normal file
24
oca/tests/fixtures/clusterpool.xml
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<CLUSTER_POOL>
|
||||
<CLUSTER>
|
||||
<ID>101</ID>
|
||||
<NAME>oneCluster</NAME>
|
||||
<HOSTS/>
|
||||
<DATASTORES/>
|
||||
<VNETS/>
|
||||
<TEMPLATE>
|
||||
<RESERVED_CPU><![CDATA[]]></RESERVED_CPU>
|
||||
<RESERVED_MEM><![CDATA[]]></RESERVED_MEM>
|
||||
</TEMPLATE>
|
||||
</CLUSTER>
|
||||
<CLUSTER>
|
||||
<ID>102</ID>
|
||||
<NAME>anotherCluster</NAME>
|
||||
<HOSTS/>
|
||||
<DATASTORES/>
|
||||
<VNETS/>
|
||||
<TEMPLATE>
|
||||
<RESERVED_CPU><![CDATA[]]></RESERVED_CPU>
|
||||
<RESERVED_MEM><![CDATA[]]></RESERVED_MEM>
|
||||
</TEMPLATE>
|
||||
</CLUSTER>
|
||||
</CLUSTER_POOL>
|
||||
42
oca/tests/fixtures/datastore.xml
vendored
Normal file
42
oca/tests/fixtures/datastore.xml
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<DATASTORE>
|
||||
<ID>100</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>Custom-DS</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>1</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<DS_MAD><![CDATA[fs]]></DS_MAD>
|
||||
<TM_MAD><![CDATA[ssh]]></TM_MAD>
|
||||
<BASE_PATH><![CDATA[/var/lib/one//datastores/100]]></BASE_PATH>
|
||||
<TYPE>0</TYPE>
|
||||
<DISK_TYPE>0</DISK_TYPE>
|
||||
<STATE>0</STATE>
|
||||
<CLUSTER_ID>-1</CLUSTER_ID>
|
||||
<CLUSTER/>
|
||||
<TOTAL_MB>9952</TOTAL_MB>
|
||||
<FREE_MB>8999</FREE_MB>
|
||||
<USED_MB>425</USED_MB>
|
||||
<IMAGES>
|
||||
<ID>2</ID>
|
||||
<ID>3</ID>
|
||||
</IMAGES>
|
||||
<TEMPLATE>
|
||||
<BASE_PATH><![CDATA[/var/lib/one//datastores/]]></BASE_PATH>
|
||||
<CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
|
||||
<DISK_TYPE><![CDATA[FILE]]></DISK_TYPE>
|
||||
<DS_MAD><![CDATA[fs]]></DS_MAD>
|
||||
<LN_TARGET><![CDATA[SYSTEM]]></LN_TARGET>
|
||||
<TM_MAD><![CDATA[ssh]]></TM_MAD>
|
||||
</TEMPLATE>
|
||||
</DATASTORE>
|
||||
79
oca/tests/fixtures/datastorepool.xml
vendored
Normal file
79
oca/tests/fixtures/datastorepool.xml
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<DATASTORE_POOL>
|
||||
<DATASTORE>
|
||||
<ID>0</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>system</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>1</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<DS_MAD><![CDATA[-]]></DS_MAD>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<BASE_PATH><![CDATA[/var/lib/one//datastores/0]]></BASE_PATH>
|
||||
<TYPE>1</TYPE>
|
||||
<DISK_TYPE>0</DISK_TYPE>
|
||||
<STATE>0</STATE>
|
||||
<CLUSTER_ID>-1</CLUSTER_ID>
|
||||
<CLUSTER>test</CLUSTER>
|
||||
<TOTAL_MB>0</TOTAL_MB>
|
||||
<FREE_MB>0</FREE_MB>
|
||||
<USED_MB>0</USED_MB>
|
||||
<IMAGES/>
|
||||
<TEMPLATE>
|
||||
<BASE_PATH><![CDATA[/var/lib/one//datastores/]]></BASE_PATH>
|
||||
<SHARED><![CDATA[YES]]></SHARED>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<TYPE><![CDATA[SYSTEM_DS]]></TYPE>
|
||||
</TEMPLATE>
|
||||
</DATASTORE>
|
||||
<DATASTORE>
|
||||
<ID>1</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>default</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>1</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<DS_MAD><![CDATA[fs]]></DS_MAD>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<BASE_PATH><![CDATA[/var/lib/one//datastores/1]]></BASE_PATH>
|
||||
<TYPE>0</TYPE>
|
||||
<DISK_TYPE>0</DISK_TYPE>
|
||||
<STATE>0</STATE>
|
||||
<CLUSTER_ID>-1</CLUSTER_ID>
|
||||
<CLUSTER/>
|
||||
<TOTAL_MB>9952</TOTAL_MB>
|
||||
<FREE_MB>8999</FREE_MB>
|
||||
<USED_MB>425</USED_MB>
|
||||
<IMAGES/>
|
||||
<TEMPLATE>
|
||||
<BASE_PATH><![CDATA[/var/lib/one//datastores/]]></BASE_PATH>
|
||||
<CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
|
||||
<DISK_TYPE><![CDATA[FILE]]></DISK_TYPE>
|
||||
<DS_MAD><![CDATA[fs]]></DS_MAD>
|
||||
<LN_TARGET><![CDATA[NONE]]></LN_TARGET>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<TYPE><![CDATA[IMAGE_DS]]></TYPE>
|
||||
</TEMPLATE>
|
||||
</DATASTORE>
|
||||
</DATASTORE_POOL>
|
||||
11
oca/tests/fixtures/group.xml
vendored
Normal file
11
oca/tests/fixtures/group.xml
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<GROUP>
|
||||
<ID>1</ID>
|
||||
<NAME>users</NAME>
|
||||
<TEMPLATE>
|
||||
<HELLO>world</HELLO>
|
||||
</TEMPLATE>
|
||||
<USERS>
|
||||
<ID>1</ID>
|
||||
<ID>2</ID>
|
||||
</USERS>
|
||||
</GROUP>
|
||||
21
oca/tests/fixtures/grouppool.xml
vendored
Normal file
21
oca/tests/fixtures/grouppool.xml
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<GROUP_POOL>
|
||||
<GROUP>
|
||||
<ID>1</ID>
|
||||
<NAME>users</NAME>
|
||||
<TEMPLATE/>
|
||||
<USERS>
|
||||
<ID>1</ID>
|
||||
<ID>2</ID>
|
||||
</USERS>
|
||||
</GROUP>
|
||||
<GROUP>
|
||||
<ID>2</ID>
|
||||
git <NAME>admins</NAME>
|
||||
<TEMPLATE/>
|
||||
<USERS>
|
||||
<ID>3</ID>
|
||||
<ID>4</ID>
|
||||
</USERS>
|
||||
</GROUP>
|
||||
</GROUP_POOL>
|
||||
|
||||
48
oca/tests/fixtures/host.xml
vendored
Normal file
48
oca/tests/fixtures/host.xml
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<HOST>
|
||||
<ID>7</ID>
|
||||
<NAME>dummyhost</NAME>
|
||||
<STATE>2</STATE>
|
||||
<IM_MAD>im_dummy</IM_MAD>
|
||||
<VM_MAD>vmm_dummy</VM_MAD>
|
||||
<VN_MAD>vn_dummy</VN_MAD>
|
||||
<TM_MAD>tm_dummy</TM_MAD>
|
||||
<LAST_MON_TIME>1277733596</LAST_MON_TIME>
|
||||
<CLUSTER/>
|
||||
<CLUSTER_ID>-1</CLUSTER_ID>
|
||||
<HOST_SHARE>
|
||||
<HID>0</HID>
|
||||
<DISK_USAGE>0</DISK_USAGE>
|
||||
<MEM_USAGE>1572864</MEM_USAGE>
|
||||
<CPU_USAGE>300</CPU_USAGE>
|
||||
<MAX_DISK>0</MAX_DISK>
|
||||
<MAX_MEM>16777216</MAX_MEM>
|
||||
<MAX_CPU>800</MAX_CPU>
|
||||
<FREE_DISK>0</FREE_DISK>
|
||||
<FREE_MEM>16777216</FREE_MEM>
|
||||
<FREE_CPU>800</FREE_CPU>
|
||||
<USED_DISK>0</USED_DISK>
|
||||
<USED_MEM>0</USED_MEM>
|
||||
<USED_CPU>0</USED_CPU>
|
||||
<RUNNING_VMS>3</RUNNING_VMS>
|
||||
</HOST_SHARE>
|
||||
<VMS>
|
||||
<ID>82</ID>
|
||||
<ID>84</ID>
|
||||
<ID>85</ID>
|
||||
<ID>95</ID>
|
||||
<ID>96</ID>
|
||||
</VMS>
|
||||
<TEMPLATE>
|
||||
<CPUSPEED>2.2GHz</CPUSPEED>
|
||||
<FREECPU>800</FREECPU>
|
||||
<FREEMEMORY>16777216</FREEMEMORY>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HYPERVISOR>dummy</HYPERVISOR>
|
||||
<MAC>50:20:20:20:20:21</MAC>
|
||||
<NAME>dummyhost</NAME>
|
||||
<TOTALCPU>800</TOTALCPU>
|
||||
<TOTALMEMORY>16777216</TOTALMEMORY>
|
||||
<USEDCPU>0</USEDCPU>
|
||||
<USEDMEMORY>0</USEDMEMORY>
|
||||
</TEMPLATE>
|
||||
</HOST>
|
||||
62
oca/tests/fixtures/hostpool.xml
vendored
Normal file
62
oca/tests/fixtures/hostpool.xml
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<HOST_POOL>
|
||||
<HOST>
|
||||
<ID>0</ID>
|
||||
<NAME>dummyhost</NAME>
|
||||
<STATE>2</STATE>
|
||||
<IM_MAD>im_dummy</IM_MAD>
|
||||
<VM_MAD>vmm_dummy</VM_MAD>
|
||||
<VN_MAD>vn_dummy</VN_MAD>
|
||||
<TM_MAD>tm_dummy</TM_MAD>
|
||||
<LAST_MON_TIME>1277912461</LAST_MON_TIME>
|
||||
<CLUSTER>default</CLUSTER>
|
||||
<CLUSTER_ID>1</CLUSTER_ID>
|
||||
<HOST_SHARE>
|
||||
<HID>0</HID>
|
||||
<DISK_USAGE>0</DISK_USAGE>
|
||||
<MEM_USAGE>1572864</MEM_USAGE>
|
||||
<CPU_USAGE>300</CPU_USAGE>
|
||||
<MAX_DISK>0</MAX_DISK>
|
||||
<MAX_MEM>16777216</MAX_MEM>
|
||||
<MAX_CPU>800</MAX_CPU>
|
||||
<FREE_DISK>0</FREE_DISK>
|
||||
<FREE_MEM>16777216</FREE_MEM>
|
||||
<FREE_CPU>800</FREE_CPU>
|
||||
<USED_DISK>0</USED_DISK>
|
||||
<USED_MEM>0</USED_MEM>
|
||||
<USED_CPU>0</USED_CPU>
|
||||
<RUNNING_VMS>3</RUNNING_VMS>
|
||||
</HOST_SHARE>
|
||||
<VMS/>
|
||||
<TEMPLATE></TEMPLATE>
|
||||
</HOST>
|
||||
<HOST>
|
||||
<ID>1</ID>
|
||||
<NAME>thost</NAME>
|
||||
<STATE>2</STATE>
|
||||
<IM_MAD>im_dummy</IM_MAD>
|
||||
<VM_MAD>vmm_dummy</VM_MAD>
|
||||
<VN_MAD>vn_dummy</VN_MAD>
|
||||
<TM_MAD>tm_dummy</TM_MAD>
|
||||
<LAST_MON_TIME>1277912461</LAST_MON_TIME>
|
||||
<CLUSTER>default</CLUSTER>
|
||||
<CLUSTER_ID>1</CLUSTER_ID>
|
||||
<HOST_SHARE>
|
||||
<HID>1</HID>
|
||||
<DISK_USAGE>0</DISK_USAGE>
|
||||
<MEM_USAGE>0</MEM_USAGE>
|
||||
<CPU_USAGE>0</CPU_USAGE>
|
||||
<MAX_DISK>0</MAX_DISK>
|
||||
<MAX_MEM>16777216</MAX_MEM>
|
||||
<MAX_CPU>800</MAX_CPU>
|
||||
<FREE_DISK>0</FREE_DISK>
|
||||
<FREE_MEM>16777216</FREE_MEM>
|
||||
<FREE_CPU>800</FREE_CPU>
|
||||
<USED_DISK>0</USED_DISK>
|
||||
<USED_MEM>0</USED_MEM>
|
||||
<USED_CPU>0</USED_CPU>
|
||||
<RUNNING_VMS>0</RUNNING_VMS>
|
||||
</HOST_SHARE>
|
||||
<VMS/>
|
||||
<TEMPLATE></TEMPLATE>
|
||||
</HOST>
|
||||
</HOST_POOL>
|
||||
38
oca/tests/fixtures/image.xml
vendored
Normal file
38
oca/tests/fixtures/image.xml
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<IMAGE>
|
||||
<ID>1</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>MATLAB install CD</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<TYPE>2</TYPE>
|
||||
<DISK_TYPE>0</DISK_TYPE>
|
||||
<PERSISTENT>0</PERSISTENT>
|
||||
<REGTIME>1435086617</REGTIME>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/4f3591cfe3a4e0a00789087a3f92c433]]></SOURCE>
|
||||
<PATH><![CDATA[]]></PATH>
|
||||
<FSTYPE><![CDATA[ext2]]></FSTYPE>
|
||||
<SIZE>400</SIZE>
|
||||
<STATE>1</STATE>
|
||||
<RUNNING_VMS>0</RUNNING_VMS>
|
||||
<CLONING_OPS>0</CLONING_OPS>
|
||||
<CLONING_ID>-1</CLONING_ID>
|
||||
<DATASTORE_ID>1</DATASTORE_ID>
|
||||
<DATASTORE>default</DATASTORE>
|
||||
<VMS/>
|
||||
<CLONES/>
|
||||
<TEMPLATE>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
</TEMPLATE>
|
||||
</IMAGE>
|
||||
116
oca/tests/fixtures/imagepool.xml
vendored
Normal file
116
oca/tests/fixtures/imagepool.xml
vendored
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<IMAGE_POOL>
|
||||
<IMAGE>
|
||||
<ID>0</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>data</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<TYPE>2</TYPE>
|
||||
<DISK_TYPE>0</DISK_TYPE>
|
||||
<PERSISTENT>0</PERSISTENT>
|
||||
<REGTIME>1435086617</REGTIME>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/4f3591cfe3a4e0a00789087a3f92c433]]></SOURCE>
|
||||
<PATH><![CDATA[]]></PATH>
|
||||
<FSTYPE><![CDATA[ext2]]></FSTYPE>
|
||||
<SIZE>400</SIZE>
|
||||
<STATE>1</STATE>
|
||||
<RUNNING_VMS>0</RUNNING_VMS>
|
||||
<CLONING_OPS>0</CLONING_OPS>
|
||||
<CLONING_ID>-1</CLONING_ID>
|
||||
<DATASTORE_ID>1</DATASTORE_ID>
|
||||
<DATASTORE>default</DATASTORE>
|
||||
<VMS/>
|
||||
<CLONES/>
|
||||
<TEMPLATE>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
</TEMPLATE>
|
||||
</IMAGE>
|
||||
<IMAGE>
|
||||
<ID>1</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>data2</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<TYPE>2</TYPE>
|
||||
<DISK_TYPE>0</DISK_TYPE>
|
||||
<PERSISTENT>0</PERSISTENT>
|
||||
<REGTIME>1435086683</REGTIME>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/bc928294936ce873228150af2052ebc3]]></SOURCE>
|
||||
<PATH><![CDATA[]]></PATH>
|
||||
<FSTYPE><![CDATA[ext2]]></FSTYPE>
|
||||
<SIZE>200</SIZE>
|
||||
<STATE>1</STATE>
|
||||
<RUNNING_VMS>0</RUNNING_VMS>
|
||||
<CLONING_OPS>0</CLONING_OPS>
|
||||
<CLONING_ID>-1</CLONING_ID>
|
||||
<DATASTORE_ID>1</DATASTORE_ID>
|
||||
<DATASTORE>default</DATASTORE>
|
||||
<VMS/>
|
||||
<CLONES/>
|
||||
<TEMPLATE>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
</TEMPLATE>
|
||||
</IMAGE>
|
||||
<IMAGE>
|
||||
<ID>2</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>data3</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<TYPE>2</TYPE>
|
||||
<DISK_TYPE>0</DISK_TYPE>
|
||||
<PERSISTENT>0</PERSISTENT>
|
||||
<REGTIME>1435086941</REGTIME>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/325e9c37fd02ae842a342ed5e464d0da]]></SOURCE>
|
||||
<PATH><![CDATA[]]></PATH>
|
||||
<FSTYPE><![CDATA[ext2]]></FSTYPE>
|
||||
<SIZE>200</SIZE>
|
||||
<STATE>1</STATE>
|
||||
<RUNNING_VMS>0</RUNNING_VMS>
|
||||
<CLONING_OPS>0</CLONING_OPS>
|
||||
<CLONING_ID>-1</CLONING_ID>
|
||||
<DATASTORE_ID>1</DATASTORE_ID>
|
||||
<DATASTORE>default</DATASTORE>
|
||||
<VMS/>
|
||||
<CLONES/>
|
||||
<TEMPLATE>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
</TEMPLATE>
|
||||
</IMAGE>
|
||||
</IMAGE_POOL>
|
||||
1
oca/tests/fixtures/one_auth
vendored
Normal file
1
oca/tests/fixtures/one_auth
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
test:test
|
||||
26
oca/tests/fixtures/template.xml
vendored
Normal file
26
oca/tests/fixtures/template.xml
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<VMTEMPLATE>
|
||||
<ID>1</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>test1</NAME>
|
||||
<PUBLIC>0</PUBLIC>
|
||||
<REGTIME>1320877281</REGTIME>
|
||||
<TEMPLATE>
|
||||
<CPU><![CDATA[1]]></CPU>
|
||||
<DISK>
|
||||
<IMAGE_ID><![CDATA[80]]></IMAGE_ID>
|
||||
</DISK>
|
||||
<MEMORY><![CDATA[2048]]></MEMORY>
|
||||
<NAME><![CDATA[test1]]></NAME>
|
||||
<NIC>
|
||||
<NETWORK_ID><![CDATA[21]]></NETWORK_ID>
|
||||
</NIC>
|
||||
<NIC>
|
||||
<NETWORK_ID><![CDATA[22]]></NETWORK_ID>
|
||||
</NIC>
|
||||
<VCPU><![CDATA[4]]></VCPU>
|
||||
</TEMPLATE>
|
||||
</VMTEMPLATE>
|
||||
|
||||
52
oca/tests/fixtures/templatepool.xml
vendored
Normal file
52
oca/tests/fixtures/templatepool.xml
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<VMTEMPLATE_POOL>
|
||||
<VMTEMPLATE>
|
||||
<ID>0</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>test</NAME>
|
||||
<PUBLIC>0</PUBLIC>
|
||||
<REGTIME>1320877281</REGTIME>
|
||||
<TEMPLATE>
|
||||
<CPU><![CDATA[1]]></CPU>
|
||||
<DISK>
|
||||
<IMAGE_ID><![CDATA[80]]></IMAGE_ID>
|
||||
</DISK>
|
||||
<MEMORY><![CDATA[2048]]></MEMORY>
|
||||
<NAME><![CDATA[test]]></NAME>
|
||||
<NIC>
|
||||
<NETWORK_ID><![CDATA[21]]></NETWORK_ID>
|
||||
</NIC>
|
||||
<NIC>
|
||||
<NETWORK_ID><![CDATA[22]]></NETWORK_ID>
|
||||
</NIC>
|
||||
<VCPU><![CDATA[4]]></VCPU>
|
||||
</TEMPLATE>
|
||||
</VMTEMPLATE>
|
||||
<VMTEMPLATE>
|
||||
<ID>1</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>test1</NAME>
|
||||
<PUBLIC>0</PUBLIC>
|
||||
<REGTIME>1320877281</REGTIME>
|
||||
<TEMPLATE>
|
||||
<CPU><![CDATA[1]]></CPU>
|
||||
<DISK>
|
||||
<IMAGE_ID><![CDATA[80]]></IMAGE_ID>
|
||||
</DISK>
|
||||
<MEMORY><![CDATA[2048]]></MEMORY>
|
||||
<NAME><![CDATA[test1]]></NAME>
|
||||
<NIC>
|
||||
<NETWORK_ID><![CDATA[21]]></NETWORK_ID>
|
||||
</NIC>
|
||||
<NIC>
|
||||
<NETWORK_ID><![CDATA[22]]></NETWORK_ID>
|
||||
</NIC>
|
||||
<VCPU><![CDATA[4]]></VCPU>
|
||||
</TEMPLATE>
|
||||
</VMTEMPLATE>
|
||||
</VMTEMPLATE_POOL>
|
||||
16
oca/tests/fixtures/user.xml
vendored
Normal file
16
oca/tests/fixtures/user.xml
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<USER>
|
||||
<ID>3</ID>
|
||||
<GID>0</GID>
|
||||
<GROUPS>
|
||||
<ID>0</ID>
|
||||
</GROUPS>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>dan</NAME>
|
||||
<PASSWORD>fe05bcdcdc4928012781a5f1a2a77cbb5398e106</PASSWORD>
|
||||
<AUTH_DRIVER>core</AUTH_DRIVER>
|
||||
<ENABLED>1</ENABLED>
|
||||
<LOGIN_TOKEN/>
|
||||
<TEMPLATE>
|
||||
<TOKEN_PASSWORD><![CDATA[97fc29a2162405277a5d2a0ef33acfcbd4f78e4e]]></TOKEN_PASSWORD>
|
||||
</TEMPLATE>
|
||||
</USER>
|
||||
54
oca/tests/fixtures/userpool.xml
vendored
Normal file
54
oca/tests/fixtures/userpool.xml
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<USER_POOL>
|
||||
<USER>
|
||||
<ID>0</ID>
|
||||
<GID>0</GID>
|
||||
<GROUPS>
|
||||
<ID>0</ID>
|
||||
</GROUPS>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>oneadmin</NAME>
|
||||
<PASSWORD>fe05bcdcdc4928012781a5f1a2a77cbb5398e106</PASSWORD>
|
||||
<AUTH_DRIVER>core</AUTH_DRIVER>
|
||||
<ENABLED>1</ENABLED>
|
||||
<LOGIN_TOKEN/>
|
||||
<TEMPLATE>
|
||||
<TOKEN_PASSWORD><![CDATA[97fc29a2162405277a5d2a0ef33acfcbd4f78e4e]]></TOKEN_PASSWORD>
|
||||
</TEMPLATE>
|
||||
</USER>
|
||||
<QUOTAS>
|
||||
<ID>0</ID>
|
||||
<DATASTORE_QUOTA/>
|
||||
<NETWORK_QUOTA/>
|
||||
<VM_QUOTA/>
|
||||
<IMAGE_QUOTA/>
|
||||
</QUOTAS>
|
||||
<USER>
|
||||
<ID>1</ID>
|
||||
<GID>0</GID>
|
||||
<GROUPS>
|
||||
<ID>0</ID>
|
||||
</GROUPS>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>serveradmin</NAME>
|
||||
<PASSWORD>f9f3c8912fc6cc53012d743ded329c4f5fb035a5</PASSWORD>
|
||||
<AUTH_DRIVER>server_cipher</AUTH_DRIVER>
|
||||
<ENABLED>1</ENABLED>
|
||||
<LOGIN_TOKEN/>
|
||||
<TEMPLATE>
|
||||
<TOKEN_PASSWORD><![CDATA[d53363ad24f9f5b44a95d028c78f1a9d3320fdee]]></TOKEN_PASSWORD>
|
||||
</TEMPLATE>
|
||||
</USER>
|
||||
<QUOTAS>
|
||||
<ID>1</ID>
|
||||
<DATASTORE_QUOTA/>
|
||||
<NETWORK_QUOTA/>
|
||||
<VM_QUOTA/>
|
||||
<IMAGE_QUOTA/>
|
||||
</QUOTAS>
|
||||
<DEFAULT_USER_QUOTAS>
|
||||
<DATASTORE_QUOTA/>
|
||||
<NETWORK_QUOTA/>
|
||||
<VM_QUOTA/>
|
||||
<IMAGE_QUOTA/>
|
||||
</DEFAULT_USER_QUOTAS>
|
||||
</USER_POOL>
|
||||
73
oca/tests/fixtures/vm.xml
vendored
Normal file
73
oca/tests/fixtures/vm.xml
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<VM>
|
||||
<ID>6</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>vm-example</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<LAST_POLL>1277729095</LAST_POLL>
|
||||
<STATE>3</STATE>
|
||||
<LCM_STATE>3</LCM_STATE>
|
||||
<RESCHED>0</RESCHED>
|
||||
<STIME>1277375180</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>dummy</DEPLOY_ID>
|
||||
<MEMORY>512</MEMORY>
|
||||
<CPU>1</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<TEMPLATE>
|
||||
<AUTOMATIC_REQUIREMENTS><![CDATA[!(PUBLIC_CLOUD = YES)]]></AUTOMATIC_REQUIREMENTS>
|
||||
<CPU><![CDATA[1]]></CPU>
|
||||
<DISK>
|
||||
<CLONE><![CDATA[YES]]></CLONE>
|
||||
<CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
|
||||
<DATASTORE><![CDATA[default]]></DATASTORE>
|
||||
<DATASTORE_ID><![CDATA[1]]></DATASTORE_ID>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
<DISK_ID><![CDATA[0]]></DISK_ID>
|
||||
<IMAGE><![CDATA[data]]></IMAGE>
|
||||
<IMAGE_ID><![CDATA[0]]></IMAGE_ID>
|
||||
<LN_TARGET><![CDATA[NONE]]></LN_TARGET>
|
||||
<READONLY><![CDATA[NO]]></READONLY>
|
||||
<SAVE><![CDATA[NO]]></SAVE>
|
||||
<SIZE><![CDATA[400]]></SIZE>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/3c1e70af31901a043238e787aba8e5d4]]></SOURCE>
|
||||
<TARGET><![CDATA[hda]]></TARGET>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<TYPE><![CDATA[FILE]]></TYPE>
|
||||
</DISK>
|
||||
<MEMORY><![CDATA[128]]></MEMORY>
|
||||
<VMID><![CDATA[0]]></VMID>
|
||||
</TEMPLATE>
|
||||
<USER_TEMPLATE>
|
||||
<GREETING><![CDATA[Hello World]]></GREETING>
|
||||
</USER_TEMPLATE>
|
||||
<HISTORY_RECORDS>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277375186</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277375186</PSTIME>
|
||||
<PETIME>1277375186</PETIME>
|
||||
<RSTIME>1277375186</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</HISTORY_RECORDS>
|
||||
</VM>
|
||||
215
oca/tests/fixtures/vmpool.xml
vendored
Normal file
215
oca/tests/fixtures/vmpool.xml
vendored
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
<VM_POOL>
|
||||
<VM>
|
||||
<ID>6</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>vm-example</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<LAST_POLL>1277729095</LAST_POLL>
|
||||
<STATE>3</STATE>
|
||||
<LCM_STATE>3</LCM_STATE>
|
||||
<RESCHED>0</RESCHED>
|
||||
<STIME>1277375180</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>dummy</DEPLOY_ID>
|
||||
<MEMORY>512</MEMORY>
|
||||
<CPU>1</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<TEMPLATE>
|
||||
<AUTOMATIC_REQUIREMENTS><![CDATA[!(PUBLIC_CLOUD = YES)]]></AUTOMATIC_REQUIREMENTS>
|
||||
<CPU><![CDATA[1]]></CPU>
|
||||
<DISK>
|
||||
<CLONE><![CDATA[YES]]></CLONE>
|
||||
<CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
|
||||
<DATASTORE><![CDATA[default]]></DATASTORE>
|
||||
<DATASTORE_ID><![CDATA[1]]></DATASTORE_ID>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
<DISK_ID><![CDATA[0]]></DISK_ID>
|
||||
<IMAGE><![CDATA[data]]></IMAGE>
|
||||
<IMAGE_ID><![CDATA[0]]></IMAGE_ID>
|
||||
<LN_TARGET><![CDATA[NONE]]></LN_TARGET>
|
||||
<READONLY><![CDATA[NO]]></READONLY>
|
||||
<SAVE><![CDATA[NO]]></SAVE>
|
||||
<SIZE><![CDATA[400]]></SIZE>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/3c1e70af31901a043238e787aba8e5d4]]></SOURCE>
|
||||
<TARGET><![CDATA[hda]]></TARGET>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<TYPE><![CDATA[FILE]]></TYPE>
|
||||
</DISK>
|
||||
<MEMORY><![CDATA[128]]></MEMORY>
|
||||
<VMID><![CDATA[0]]></VMID>
|
||||
</TEMPLATE>
|
||||
<USER_TEMPLATE/>
|
||||
<HISTORY_RECORDS>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277375186</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277375186</PSTIME>
|
||||
<PETIME>1277375186</PETIME>
|
||||
<RSTIME>1277375186</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</HISTORY_RECORDS>
|
||||
</VM>
|
||||
<VM>
|
||||
<ID>7</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>vm-in</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<LAST_POLL>1277729095</LAST_POLL>
|
||||
<STATE>3</STATE>
|
||||
<LCM_STATE>3</LCM_STATE>
|
||||
<RESCHED>0</RESCHED>
|
||||
<STIME>1277375180</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>dummy</DEPLOY_ID>
|
||||
<MEMORY>512</MEMORY>
|
||||
<CPU>1</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<TEMPLATE>
|
||||
<AUTOMATIC_REQUIREMENTS><![CDATA[!(PUBLIC_CLOUD = YES)]]></AUTOMATIC_REQUIREMENTS>
|
||||
<CPU><![CDATA[1]]></CPU>
|
||||
<DISK>
|
||||
<CLONE><![CDATA[YES]]></CLONE>
|
||||
<CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
|
||||
<DATASTORE><![CDATA[default]]></DATASTORE>
|
||||
<DATASTORE_ID><![CDATA[1]]></DATASTORE_ID>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
<DISK_ID><![CDATA[0]]></DISK_ID>
|
||||
<IMAGE><![CDATA[data]]></IMAGE>
|
||||
<IMAGE_ID><![CDATA[0]]></IMAGE_ID>
|
||||
<LN_TARGET><![CDATA[NONE]]></LN_TARGET>
|
||||
<READONLY><![CDATA[NO]]></READONLY>
|
||||
<SAVE><![CDATA[NO]]></SAVE>
|
||||
<SIZE><![CDATA[400]]></SIZE>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/3c1e70af31901a043238e787aba8e5d4]]></SOURCE>
|
||||
<TARGET><![CDATA[hda]]></TARGET>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<TYPE><![CDATA[FILE]]></TYPE>
|
||||
</DISK>
|
||||
<MEMORY><![CDATA[128]]></MEMORY>
|
||||
<VMID><![CDATA[0]]></VMID>
|
||||
</TEMPLATE>
|
||||
<USER_TEMPLATE/>
|
||||
<HISTORY_RECORDS>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277375186</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277375186</PSTIME>
|
||||
<PETIME>1277375186</PETIME>
|
||||
<RSTIME>1277375186</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</HISTORY_RECORDS>
|
||||
</VM>
|
||||
<VM>
|
||||
<ID>8</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>vm-in</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>0</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<LAST_POLL>1277729095</LAST_POLL>
|
||||
<STATE>3</STATE>
|
||||
<LCM_STATE>3</LCM_STATE>
|
||||
<RESCHED>0</RESCHED>
|
||||
<STIME>1277375180</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<DEPLOY_ID>dummy</DEPLOY_ID>
|
||||
<MEMORY>512</MEMORY>
|
||||
<CPU>1</CPU>
|
||||
<NET_TX>12345</NET_TX>
|
||||
<NET_RX>0</NET_RX>
|
||||
<TEMPLATE>
|
||||
<AUTOMATIC_REQUIREMENTS><![CDATA[!(PUBLIC_CLOUD = YES)]]></AUTOMATIC_REQUIREMENTS>
|
||||
<CPU><![CDATA[1]]></CPU>
|
||||
<DISK>
|
||||
<CLONE><![CDATA[YES]]></CLONE>
|
||||
<CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
|
||||
<DATASTORE><![CDATA[default]]></DATASTORE>
|
||||
<DATASTORE_ID><![CDATA[1]]></DATASTORE_ID>
|
||||
<DEV_PREFIX><![CDATA[hd]]></DEV_PREFIX>
|
||||
<DISK_ID><![CDATA[0]]></DISK_ID>
|
||||
<IMAGE><![CDATA[data]]></IMAGE>
|
||||
<IMAGE_ID><![CDATA[0]]></IMAGE_ID>
|
||||
<LN_TARGET><![CDATA[NONE]]></LN_TARGET>
|
||||
<READONLY><![CDATA[NO]]></READONLY>
|
||||
<SAVE><![CDATA[NO]]></SAVE>
|
||||
<SIZE><![CDATA[400]]></SIZE>
|
||||
<SOURCE><![CDATA[/var/lib/one//datastores/1/3c1e70af31901a043238e787aba8e5d4]]></SOURCE>
|
||||
<TARGET><![CDATA[hda]]></TARGET>
|
||||
<TM_MAD><![CDATA[shared]]></TM_MAD>
|
||||
<TYPE><![CDATA[FILE]]></TYPE>
|
||||
</DISK>
|
||||
<MEMORY><![CDATA[128]]></MEMORY>
|
||||
<VMID><![CDATA[0]]></VMID>
|
||||
</TEMPLATE>
|
||||
<USER_TEMPLATE/>
|
||||
<HISTORY_RECORDS>
|
||||
<HISTORY>
|
||||
<SEQ>0</SEQ>
|
||||
<HOSTNAME>dummyhost</HOSTNAME>
|
||||
<HID>0</HID>
|
||||
<STIME>1277375186</STIME>
|
||||
<ETIME>0</ETIME>
|
||||
<PSTIME>1277375186</PSTIME>
|
||||
<PETIME>1277375186</PETIME>
|
||||
<RSTIME>1277375186</RSTIME>
|
||||
<RETIME>0</RETIME>
|
||||
<ESTIME>0</ESTIME>
|
||||
<EETIME>0</EETIME>
|
||||
<REASON>0</REASON>
|
||||
</HISTORY>
|
||||
</HISTORY_RECORDS>
|
||||
</VM>
|
||||
</VM_POOL>
|
||||
46
oca/tests/fixtures/vnet.xml
vendored
Normal file
46
oca/tests/fixtures/vnet.xml
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<VNET>
|
||||
<ID>3</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>Red LAN</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>1</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<CLUSTER_ID>-1</CLUSTER_ID>
|
||||
<CLUSTER/>
|
||||
<BRIDGE>vbr0</BRIDGE>
|
||||
<VLAN>1</VLAN>
|
||||
<PARENT_NETWORK_ID/>
|
||||
<PHYDEV><![CDATA[bond1]]></PHYDEV>
|
||||
<VLAN_ID><![CDATA[1337]]></VLAN_ID>
|
||||
<USED_LEASES>3</USED_LEASES>
|
||||
<TEMPLATE/>
|
||||
<AR_POOL>
|
||||
<AR>
|
||||
<ALLOCATED><![CDATA[ 0 68719479930 1 68719545020]]></ALLOCATED>
|
||||
<AR_ID><![CDATA[0]]></AR_ID>
|
||||
<IP><![CDATA[10.1.0.10]]></IP>
|
||||
<MAC><![CDATA[00:22:44:66:88:aa]]></MAC>
|
||||
<SIZE><![CDATA[507]]></SIZE>
|
||||
<TYPE><![CDATA[IP4]]></TYPE>
|
||||
</AR>
|
||||
<AR>
|
||||
<ALLOCATED><![CDATA[ 0 68719546783]]></ALLOCATED>
|
||||
<AR_ID><![CDATA[1]]></AR_ID>
|
||||
<IP><![CDATA[10.1.2.5]]></IP>
|
||||
<MAC><![CDATA[00:22:44:66:aa:cc]]></MAC>
|
||||
<SIZE><![CDATA[507]]></SIZE>
|
||||
<TYPE><![CDATA[IP4]]></TYPE>
|
||||
</AR>
|
||||
</AR_POOL>
|
||||
</VNET>
|
||||
60
oca/tests/fixtures/vnetpool.xml
vendored
Normal file
60
oca/tests/fixtures/vnetpool.xml
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<VNET_POOL>
|
||||
<VNET>
|
||||
<ID>4</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>Red LAN</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>1</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<CLUSTER_ID>-1</CLUSTER_ID>
|
||||
<CLUSTER/>
|
||||
<BRIDGE>vbr0</BRIDGE>
|
||||
<VLAN>1</VLAN>
|
||||
<PARENT_NETWORK_ID/>
|
||||
<PHYDEV><![CDATA[bond1]]></PHYDEV>
|
||||
<VLAN_ID><![CDATA[1337]]></VLAN_ID>
|
||||
<USED_LEASES>3</USED_LEASES>
|
||||
<TEMPLATE/>
|
||||
<AR_POOL/>
|
||||
</VNET>
|
||||
<VNET>
|
||||
<ID>9</ID>
|
||||
<UID>0</UID>
|
||||
<GID>0</GID>
|
||||
<UNAME>oneadmin</UNAME>
|
||||
<GNAME>oneadmin</GNAME>
|
||||
<NAME>Public</NAME>
|
||||
<PERMISSIONS>
|
||||
<OWNER_U>1</OWNER_U>
|
||||
<OWNER_M>1</OWNER_M>
|
||||
<OWNER_A>0</OWNER_A>
|
||||
<GROUP_U>0</GROUP_U>
|
||||
<GROUP_M>0</GROUP_M>
|
||||
<GROUP_A>0</GROUP_A>
|
||||
<OTHER_U>1</OTHER_U>
|
||||
<OTHER_M>0</OTHER_M>
|
||||
<OTHER_A>0</OTHER_A>
|
||||
</PERMISSIONS>
|
||||
<CLUSTER_ID>-1</CLUSTER_ID>
|
||||
<CLUSTER/>
|
||||
<BRIDGE>vbr0</BRIDGE>
|
||||
<VLAN>1</VLAN>
|
||||
<PARENT_NETWORK_ID/>
|
||||
<PHYDEV><![CDATA[bond1]]></PHYDEV>
|
||||
<VLAN_ID><![CDATA[42]]></VLAN_ID>
|
||||
<USED_LEASES>0</USED_LEASES>
|
||||
<TEMPLATE/>
|
||||
<AR_POOL/>
|
||||
</VNET>
|
||||
</VNET_POOL>
|
||||
25
oca/tests/integration_test_client.py
Normal file
25
oca/tests/integration_test_client.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# vim: set fileencoding=utf8
|
||||
# encoding:utf8
|
||||
#
|
||||
# Author: Matthias Schmitz <matthias@sigxcpu.org>
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
@unittest.skipUnless(os.environ.get('OCA_INT_TESTS', False),
|
||||
"Skipping integration tests")
|
||||
class IntTestClient(unittest.TestCase):
|
||||
def setUp(self):
|
||||
try:
|
||||
del os.environ["ONE_AUTH"]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
self.c = oca.Client(os.environ['OCA_INT_TESTS_ONE_AUTH'],
|
||||
os.environ['OCA_INT_TESTS_ONE_XMLRPC'])
|
||||
|
||||
def test_connection(self):
|
||||
self.assertIn(os.environ['OCA_INT_TESTS'], self.c.version())
|
||||
66
oca/tests/integration_test_template.py
Normal file
66
oca/tests/integration_test_template.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# vim: set fileencoding=utf8
|
||||
# encoding:utf8
|
||||
#
|
||||
# Author: Matthias Schmitz <matthias@sigxcpu.org>
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import oca
|
||||
from oca.exceptions import OpenNebulaException
|
||||
|
||||
|
||||
@unittest.skipUnless(os.environ.get('OCA_INT_TESTS', False),
|
||||
"Skipping integration tests")
|
||||
class IntTestTemplate(unittest.TestCase):
|
||||
def setUp(self):
|
||||
try:
|
||||
del os.environ["ONE_AUTH"]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
self.c = oca.Client(os.environ['OCA_INT_TESTS_ONE_AUTH'], os.environ['OCA_INT_TESTS_ONE_XMLRPC'])
|
||||
|
||||
def tearDown(self):
|
||||
print("teardown")
|
||||
vmp = oca.VirtualMachinePool(self.c)
|
||||
vmp.info()
|
||||
for vm in vmp:
|
||||
if vm.name.startswith('inttest_vm_'):
|
||||
vm.delete()
|
||||
|
||||
def test_allocate(self):
|
||||
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest01</NAME><TEMPLATE/></VMTEMPLATE>')
|
||||
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest02</NAME><TEMPLATE/></VMTEMPLATE>')
|
||||
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest03</NAME><TEMPLATE/></VMTEMPLATE>')
|
||||
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest04</NAME><TEMPLATE/></VMTEMPLATE>')
|
||||
|
||||
def test_allocate_with_same_name(self):
|
||||
with self.assertRaises(OpenNebulaException):
|
||||
templ = oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest01</NAME><TEMPLATE/></VMTEMPLATE>')
|
||||
|
||||
def test_update(self):
|
||||
oca.VmTemplate.allocate(self.c, '<VMTEMPLATE><NAME>inttest_update01</NAME><TEMPLATE/></VMTEMPLATE>')
|
||||
tp = oca.VmTemplatePool(self.c)
|
||||
tp.info()
|
||||
templ = tp.get_by_name('inttest_update01')
|
||||
templ.update('MEMORY=1024 CPU=2')
|
||||
|
||||
def test_delete(self):
|
||||
tp = oca.VmTemplatePool(self.c)
|
||||
tp.info()
|
||||
for tpl in tp:
|
||||
if tpl.name.startswith('inttest'):
|
||||
tpl.delete()
|
||||
|
||||
def test_instantiate(self):
|
||||
templ = oca.VmTemplate.allocate(self.c,
|
||||
'<VMTEMPLATE><NAME>inttest_instantiate_me01</NAME><MEMORY>1234</MEMORY><CPU>2</CPU></VMTEMPLATE>')
|
||||
tp = oca.VmTemplatePool(self.c)
|
||||
tp.info()
|
||||
templ = tp.get_by_name('inttest_instantiate_me01')
|
||||
templ.instantiate('inttest_vm_instantiate_me01')
|
||||
vmpool = oca.VirtualMachinePool(self.c)
|
||||
vmpool.info()
|
||||
vm = vmpool.get_by_name('inttest_vm_instantiate_me01')
|
||||
self.assertEqual(vm.name, 'inttest_vm_instantiate_me01')
|
||||
107
oca/tests/test_client.py
Normal file
107
oca/tests/test_client.py
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import socket
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
from nose.tools import raises
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestClient(unittest.TestCase):
|
||||
def setUp(self):
|
||||
try:
|
||||
del os.environ["ONE_AUTH"]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def test_secret(self):
|
||||
c = oca.Client('test:test')
|
||||
assert c.one_auth == 'test:test'
|
||||
|
||||
def test_one_auth(self):
|
||||
os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/one_auth')
|
||||
try:
|
||||
c = oca.Client()
|
||||
secret = 'test:test'
|
||||
assert c.one_auth == secret
|
||||
finally:
|
||||
os.environ["ONE_AUTH"] = ''
|
||||
|
||||
def test_default_user_path(self):
|
||||
os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/one_auth')
|
||||
c = oca.Client()
|
||||
assert c.one_auth == 'test:test'
|
||||
|
||||
@raises(oca.OpenNebulaException)
|
||||
def test_wrong_default_user_path(self):
|
||||
oca.Client.DEFAULT_ONE_AUTH = '/ad/ads/a/das/d/sad/sad/sa/d/one_auth'
|
||||
c = oca.Client()
|
||||
|
||||
@raises(oca.OpenNebulaException)
|
||||
def test_invalid_secret(self):
|
||||
os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/one_auth')
|
||||
c = oca.Client('testtest')
|
||||
|
||||
def test_addres(self):
|
||||
c = oca.Client('test:test', "http://8.8.8.8:2633/RPC2")
|
||||
assert c.one_address == "http://8.8.8.8:2633/RPC2"
|
||||
|
||||
def test_one_xml_rpc(self):
|
||||
os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/one_auth')
|
||||
os.environ["ONE_XMLRPC"] = "http://8.8.8.8:2633/RPC2"
|
||||
try:
|
||||
c = oca.Client()
|
||||
assert c.one_address == "http://8.8.8.8:2633/RPC2"
|
||||
finally:
|
||||
os.environ["ONE_XMLRPC"] = ''
|
||||
|
||||
def test_defaul_xmlrpc(self):
|
||||
c = oca.Client('test:test')
|
||||
assert c.one_address == oca.Client.DEFAULT_ONE_ADDRESS
|
||||
|
||||
def test_version(self):
|
||||
c = oca.Client('test:test')
|
||||
assert c.one_version is None
|
||||
c.call = Mock(return_value='1.0.0')
|
||||
assert c.version() == '1.0.0'
|
||||
c.call.assert_called_once_with('system.version')
|
||||
assert c.one_version == '1.0.0'
|
||||
|
||||
def test_return_two_values_call(self):
|
||||
c = oca.Client('test:test')
|
||||
c.server.one = Mock()
|
||||
c.server.one.test_method = lambda x: [True, '2', 0]
|
||||
assert c.call('test_method') == '2'
|
||||
|
||||
def test_return_one_value_call(self):
|
||||
c = oca.Client('test:test')
|
||||
c.server.one = Mock()
|
||||
c.server.one.test_method = lambda x: [True, '', 0]
|
||||
assert c.call('test_method') == ''
|
||||
|
||||
@raises(oca.OpenNebulaException)
|
||||
def test_retrurn_error_code_0_call(self):
|
||||
c = oca.Client('test:test')
|
||||
c.server.one = Mock()
|
||||
c.server.one.test_method = lambda x: [False, '2', 1]
|
||||
c.call('test_method')
|
||||
|
||||
@raises(oca.OpenNebulaException)
|
||||
def test_invalid_call(self):
|
||||
c = oca.Client('test:test')
|
||||
c.server.one = Mock()
|
||||
c.server.one.test_method = lambda x: [False, '2']
|
||||
c.call('test_method')
|
||||
|
||||
@raises(socket.error)
|
||||
def test_connection_error(self):
|
||||
c = oca.Client('test:test')
|
||||
c.server.one = Mock()
|
||||
c.server.one.test_method = Mock(side_effect=socket.error(1))
|
||||
c.call('test_method')
|
||||
33
oca/tests/test_cluster.py
Normal file
33
oca/tests/test_cluster.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestCluster(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/cluster.xml')).read()
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=3)
|
||||
assert oca.Cluster.allocate(self.client, 'test') == 3
|
||||
|
||||
def test_repr(self):
|
||||
self.client.call = Mock()
|
||||
cluster = oca.Cluster(self.xml, self.client)
|
||||
assert repr(cluster) == '<oca.Cluster("oneCluster")>'
|
||||
|
||||
def test_convert_types(self):
|
||||
cluster = oca.Cluster(self.xml, None)
|
||||
cluster._convert_types()
|
||||
assert cluster.id == 101
|
||||
assert cluster.name == "oneCluster"
|
||||
assert cluster.host_ids == [2, 3]
|
||||
assert cluster.datastore_ids == [4, 5]
|
||||
assert cluster.vnet_ids == [6, 7]
|
||||
assert cluster.template.reserved_cpu is None
|
||||
21
oca/tests/test_clusterpool.py
Normal file
21
oca/tests/test_clusterpool.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestClusterPool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/clusterpool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.ClusterPool(self.client)
|
||||
pool.info()
|
||||
assert len(pool) == 2
|
||||
assert pool[1].name == "anotherCluster"
|
||||
45
oca/tests/test_datastore.py
Normal file
45
oca/tests/test_datastore.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestDatastore(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/datastore.xml')).read()
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=3)
|
||||
assert oca.Datastore.allocate(self.client, 'test') == 3
|
||||
|
||||
def test_repr(self):
|
||||
self.client.call = Mock()
|
||||
datastore = oca.Datastore(self.xml, self.client)
|
||||
assert repr(datastore) == '<oca.Datastore("Custom-DS")>'
|
||||
|
||||
def test_convert_types(self):
|
||||
cluster = oca.Datastore(self.xml, None)
|
||||
cluster._convert_types()
|
||||
assert cluster.id == 100
|
||||
assert cluster.name == "Custom-DS"
|
||||
assert cluster.uid == 0
|
||||
assert cluster.gid == 0
|
||||
assert cluster.uname == 'oneadmin'
|
||||
assert cluster.gname == 'oneadmin'
|
||||
assert cluster.ds_mad == 'fs'
|
||||
assert cluster.tm_mad == 'ssh'
|
||||
assert cluster.base_path == '/var/lib/one//datastores/100'
|
||||
assert cluster.type == 0
|
||||
assert cluster.disk_type == 0
|
||||
assert cluster.cluster_id == -1
|
||||
assert cluster.cluster == ""
|
||||
assert cluster.total_mb == 9952
|
||||
assert cluster.free_mb == 8999
|
||||
assert cluster.used_mb == 425
|
||||
assert cluster.image_ids == [2, 3]
|
||||
assert cluster.template.disk_type == 'FILE'
|
||||
20
oca/tests/test_datastore_pool.py
Normal file
20
oca/tests/test_datastore_pool.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestDatastorePool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/datastorepool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.DatastorePool(self.client)
|
||||
pool.info()
|
||||
assert len(list(pool)) == 2
|
||||
37
oca/tests/test_group.py
Normal file
37
oca/tests/test_group.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestGroup(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/group.xml')).read()
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=3)
|
||||
assert oca.Group.allocate(self.client, 'test') == 3
|
||||
|
||||
def test_delete(self):
|
||||
self.client.call = Mock()
|
||||
group = oca.Group(self.xml, self.client)
|
||||
group.delete()
|
||||
self.client.call.assert_called_once_with('group.delete', '1')
|
||||
|
||||
def test_repr(self):
|
||||
self.client.call = Mock()
|
||||
group = oca.Group(self.xml, self.client)
|
||||
assert repr(group) == '<oca.Group("users")>'
|
||||
|
||||
def test_convert_types(self):
|
||||
group = oca.Group(self.xml, None)
|
||||
group._convert_types()
|
||||
assert group.id == 1
|
||||
assert group.name == "users"
|
||||
assert group.template.hello == "world"
|
||||
assert group.users == [1, 2]
|
||||
20
oca/tests/test_group_pool.py
Normal file
20
oca/tests/test_group_pool.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestGroupPool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/grouppool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.GroupPool(self.client)
|
||||
pool.info()
|
||||
assert len(pool) == 2
|
||||
80
oca/tests/test_host.py
Normal file
80
oca/tests/test_host.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
from xml.etree import ElementTree as ET
|
||||
from parameterized import parameterized_class
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
@parameterized_class([
|
||||
{'one_version': '4.10.0'},
|
||||
{'one_version': '5.4.0'},
|
||||
{'one_version': '6.0.0'},
|
||||
])
|
||||
class TestHost(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.client.call = Mock(return_value=self.one_version)
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/host.xml')).read()
|
||||
|
||||
if self.one_version >= '5':
|
||||
xml_v5 = ET.fromstring(self.xml)
|
||||
[xml_v5.remove(vn_mad) for vn_mad in xml_v5.findall('VN_MAD')]
|
||||
self.xml = ET.tostring(xml_v5).decode('utf-8')
|
||||
|
||||
def tearDown(self):
|
||||
version = self.client.one_version
|
||||
if version is not None and version >= '5':
|
||||
xml_types = oca.Host.XML_TYPES
|
||||
xml_types['vn_mad'] = oca.pool.extractString
|
||||
|
||||
def test_instantiate(self):
|
||||
h = oca.Host(self.xml, self.client)
|
||||
self.client.call.assert_called_once_with('system.version')
|
||||
expected = 'vn_dummy' if self.one_version == '4.10.0' else None
|
||||
assert (getattr(h, 'vn_mad', None) == expected)
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=7)
|
||||
host_id = oca.Host.allocate(self.client, 'host', 'im_xen',
|
||||
'vmm_xen', 'tm_nfs')
|
||||
assert host_id == 7
|
||||
|
||||
def test_enable(self):
|
||||
h = oca.Host(self.xml, self.client)
|
||||
self.client.call = Mock(return_value='')
|
||||
h.enable()
|
||||
self.client.call.assert_called_once_with('host.enable', '7', True)
|
||||
|
||||
def test_disable(self):
|
||||
h = oca.Host(self.xml, self.client)
|
||||
self.client.call = Mock(return_value='')
|
||||
h.disable()
|
||||
self.client.call.assert_called_once_with('host.enable', '7', False)
|
||||
|
||||
def test_states(self):
|
||||
for i in range(len(oca.Host.HOST_STATES)):
|
||||
h = oca.Host('<HOST><ID>2</ID><STATE>{0}</STATE></HOST>'.format(i),
|
||||
self.client)
|
||||
assert h.str_state == oca.Host.HOST_STATES[i]
|
||||
assert h.short_state == oca.Host.SHORT_HOST_STATES[oca.Host.HOST_STATES[i]]
|
||||
|
||||
def test_repr(self):
|
||||
h = oca.Host(self.xml, self.client)
|
||||
assert h.__repr__() == '<oca.Host("dummyhost")>'
|
||||
|
||||
def test_host_share_repr(self):
|
||||
h = oca.Host(self.xml, self.client)
|
||||
h._convert_types()
|
||||
share = h.host_share
|
||||
assert repr(share) == '<oca.vm.HostShare()>'
|
||||
|
||||
def test_host_vm_ids(self):
|
||||
h = oca.Host(self.xml, self.client)
|
||||
h._convert_types()
|
||||
vm_ids = list(h.vm_ids)
|
||||
assert vm_ids == [82, 84, 85, 95, 96]
|
||||
20
oca/tests/test_host_pool.py
Normal file
20
oca/tests/test_host_pool.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestHostPool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/hostpool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.HostPool(self.client)
|
||||
pool.info()
|
||||
assert len(pool) == 2
|
||||
109
oca/tests/test_image.py
Normal file
109
oca/tests/test_image.py
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
import oca.pool
|
||||
|
||||
IMAGE_TEMPLATE = """NAME = "Ubuntu Desktop"
|
||||
PATH = /home/cloud/images/ubuntu-desktop/disk.0
|
||||
PUBLIC = YES
|
||||
DESCRIPTION = "Ubuntu 10.04 desktop for students.\""""
|
||||
|
||||
DEFAULT_IMG_DATASTORE = 1
|
||||
|
||||
|
||||
class TestImage(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/image.xml')).read()
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=2)
|
||||
assert oca.Image.allocate(self.client, IMAGE_TEMPLATE, DEFAULT_IMG_DATASTORE) == 2
|
||||
|
||||
def test_enable(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
h.enable()
|
||||
self.client.call.assert_called_once_with('image.enable', '1', True)
|
||||
|
||||
def test_disable(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
h.disable()
|
||||
self.client.call.assert_called_once_with('image.enable', '1', False)
|
||||
|
||||
def test_update(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
new_content = 'DEV_PREFIX=hd\nNAME=Debian\nTYPE=OS'
|
||||
h.update(new_content)
|
||||
self.client.call.assert_called_once_with('image.update', '1',
|
||||
new_content)
|
||||
|
||||
def test_publish(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
assert h.publish() is None
|
||||
|
||||
def test_unpublish(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
assert h.unpublish() is None
|
||||
|
||||
def test_set_persistent(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
h.set_persistent()
|
||||
self.client.call.assert_called_once_with('image.persistent',
|
||||
'1', True)
|
||||
|
||||
def test_set_nonpersistent(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
h.set_nonpersistent()
|
||||
self.client.call.assert_called_once_with('image.persistent',
|
||||
'1', False)
|
||||
|
||||
def test_states(self):
|
||||
for i in range(len(oca.Image.IMAGE_STATES)):
|
||||
h = oca.Image('<IMAGE><ID>2</ID><STATE>%s</STATE></IMAGE>' % i,
|
||||
self.client)
|
||||
assert h.str_state == oca.Image.IMAGE_STATES[i]
|
||||
short_image_state = oca.Image.SHORT_IMAGE_STATES[oca.Image.IMAGE_STATES[i]]
|
||||
assert h.short_state == short_image_state
|
||||
|
||||
def test_repr(self):
|
||||
h = oca.Image(self.xml, self.client)
|
||||
assert h.__repr__() == '<oca.Image("MATLAB install CD")>'
|
||||
|
||||
def test_types(self):
|
||||
for i in range(len(oca.Image.IMAGE_TYPES)):
|
||||
h = oca.Image('<IMAGE><ID>2</ID><TYPE>%s</TYPE></IMAGE>' % i,
|
||||
self.client)
|
||||
assert h.str_type == oca.Image.IMAGE_TYPES[i]
|
||||
short_image_type = oca.Image.SHORT_IMAGE_TYPES[oca.Image.IMAGE_TYPES[i]]
|
||||
assert h.short_type == short_image_type
|
||||
|
||||
def test_template(self):
|
||||
i = oca.Image(self.xml, self.client)
|
||||
i._convert_types()
|
||||
assert isinstance(i.template, oca.pool.Template)
|
||||
|
||||
def test_chown(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
h.chown(10, 10)
|
||||
self.client.call.assert_called_once_with('image.chown',
|
||||
'1', 10, 10)
|
||||
|
||||
def test_chmod(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
h = oca.Image(self.xml, self.client)
|
||||
h.chmod(1, 0, 0, -1, -1, -1, -1, -1, -1)
|
||||
self.client.call.assert_called_once_with('image.chmod',
|
||||
'1', 1, 0, 0, -1, -1, -1, -1, -1, -1)
|
||||
22
oca/tests/test_image_pool.py
Normal file
22
oca/tests/test_image_pool.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestImagePool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/imagepool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.xml = self.xml.replace('\n', '')
|
||||
self.xml = self.xml.replace(' ', '')
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.ImagePool(self.client)
|
||||
pool.info()
|
||||
assert len(pool) == 3
|
||||
12
oca/tests/test_integration.py
Normal file
12
oca/tests/test_integration.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
class TestIntegration:
|
||||
# def setUp(self):
|
||||
# self.client = oca.Client("oneadmin:one", "http://localhost:2633/RPC2")
|
||||
# cp = oca.ClusterPool(self.client)
|
||||
# cp.info()
|
||||
# for cluster in cp:
|
||||
# cluster.delete()
|
||||
|
||||
# def test_integration(self):
|
||||
# self.cluster_id = oca.Cluster.allocate(self.client, "IT-Cluster")
|
||||
# #self.datastore_id = oca.
|
||||
pass
|
||||
85
oca/tests/test_template.py
Normal file
85
oca/tests/test_template.py
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestVmTemplate(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/template.xml')).read()
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=3)
|
||||
assert oca.VmTemplate.allocate(self.client, 'name=a') == 3
|
||||
|
||||
def test_delete(self):
|
||||
self.client.call = Mock()
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
template.delete()
|
||||
self.client.call.assert_called_once_with('template.delete', '1')
|
||||
|
||||
def test_update(self):
|
||||
self.client.call = Mock()
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
template.update('name=b')
|
||||
self.client.call.assert_called_once_with('template.update',
|
||||
'1', 'name=b', 0)
|
||||
|
||||
def test_publish(self):
|
||||
self.client.call = Mock()
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
template.publish()
|
||||
self.client.call.assert_called_once_with('template.publish',
|
||||
'1', True)
|
||||
|
||||
def test_unpublish(self):
|
||||
self.client.call = Mock()
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
template.unpublish()
|
||||
self.client.call.assert_called_once_with('template.publish',
|
||||
'1', False)
|
||||
|
||||
def test_chown(self):
|
||||
self.client.call = Mock()
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
template.chown(2, 3)
|
||||
self.client.call.assert_called_once_with('template.chown',
|
||||
'1', 2, 3)
|
||||
|
||||
def test_instantiate_with_default_name(self):
|
||||
self.client.call = Mock(return_value=4)
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
assert template.instantiate() == 4
|
||||
self.client.call.assert_called_once_with('template.instantiate',
|
||||
'1', '', False, '')
|
||||
|
||||
def test_instantiate_with_custom_name(self):
|
||||
self.client.call = Mock(return_value=5)
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
assert template.instantiate('asd') == 5
|
||||
self.client.call.assert_called_once_with('template.instantiate',
|
||||
'1', 'asd', False, '')
|
||||
|
||||
def test_instantiate_with_default_name_and_context(self):
|
||||
self.client.call = Mock(return_value=6)
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
assert template.instantiate('', False, 'VCPU=4') == 6
|
||||
self.client.call.assert_called_once_with('template.instantiate',
|
||||
'1', '', False, 'VCPU=4')
|
||||
|
||||
def test_instantiate_with_custom_name_and_context(self):
|
||||
self.client.call = Mock(return_value=7)
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
assert template.instantiate('asd', False, 'VCPU=4') == 7
|
||||
self.client.call.assert_called_once_with('template.instantiate',
|
||||
'1', 'asd', False, 'VCPU=4')
|
||||
|
||||
def test_repr(self):
|
||||
self.client.call = Mock()
|
||||
template = oca.VmTemplate(self.xml, self.client)
|
||||
assert repr(template) == '<oca.VmTemplate("test1")>'
|
||||
20
oca/tests/test_template_pool.py
Normal file
20
oca/tests/test_template_pool.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestVmTemplatePool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/templatepool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.VmTemplatePool(self.client)
|
||||
pool.info()
|
||||
assert len(pool) == 2
|
||||
40
oca/tests/test_user.py
Normal file
40
oca/tests/test_user.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestUser(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/user.xml')).read()
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=1)
|
||||
assert oca.User.allocate(self.client, 'jon', 'secret') == 1
|
||||
|
||||
def test_repr(self):
|
||||
u = oca.User(self.xml, self.client)
|
||||
assert u.__repr__() == '<oca.User("dan")>'
|
||||
|
||||
def test_change_passwd(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
u = oca.User(self.xml, self.client)
|
||||
u.change_passwd('secret2')
|
||||
self.client.call.assert_called_once_with('user.passwd', '3', 'secret2')
|
||||
|
||||
def test_delete(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
vm = oca.User(self.xml, self.client)
|
||||
vm.delete()
|
||||
self.client.call.assert_called_once_with('user.delete', '3')
|
||||
|
||||
def test_change_group(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
vm = oca.User(self.xml, self.client)
|
||||
vm.chgrp(3)
|
||||
self.client.call.assert_called_once_with('user.chgrp', '3', 3)
|
||||
20
oca/tests/test_user_pool.py
Normal file
20
oca/tests/test_user_pool.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestUserPool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/userpool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.UserPool(self.client)
|
||||
pool.info()
|
||||
assert len(pool) == 2
|
||||
92
oca/tests/test_virtual_network.py
Normal file
92
oca/tests/test_virtual_network.py
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
from xml.etree import ElementTree as ET
|
||||
from parameterized import parameterized_class
|
||||
|
||||
import oca
|
||||
|
||||
VN_TEMPLATE = """NAME = "Red LAN"
|
||||
TYPE = RANGED
|
||||
PUBLIC = NO
|
||||
BRIDGE = vbr0
|
||||
NETWORK_SIZE = C
|
||||
NETWORK_ADDRESS = 192.168.0.0"""
|
||||
|
||||
|
||||
@parameterized_class([
|
||||
{'one_version': '4.10.0'},
|
||||
{'one_version': '5.4.0'},
|
||||
{'one_version': '6.0.0'},
|
||||
])
|
||||
class TestVirtualNetwork(unittest.TestCase):
|
||||
# one_version = '4.10.0'
|
||||
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.client.call = Mock(return_value=self.one_version)
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/vnet.xml')).read()
|
||||
|
||||
if self.one_version >= '5':
|
||||
xml_v5 = ET.fromstring(self.xml)
|
||||
vn_mad = ET.Element('VN_MAD')
|
||||
vn_mad.text = 'vn_dummy'
|
||||
xml_v5.append(vn_mad)
|
||||
self.xml = ET.tostring(xml_v5).decode('utf-8')
|
||||
|
||||
def tearDown(self):
|
||||
version = self.client.one_version
|
||||
if version is not None and version >= '5':
|
||||
xml_types = oca.VirtualNetwork.XML_TYPES
|
||||
del xml_types['vn_mad']
|
||||
|
||||
def test_instantiate(self):
|
||||
h = oca.VirtualNetwork(self.xml, self.client)
|
||||
self.client.call.assert_called_once_with('system.version')
|
||||
expected = None if self.one_version == '4.10.0' else 'vn_dummy'
|
||||
assert (getattr(h, 'vn_mad', None) == expected)
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=2)
|
||||
assert oca.VirtualNetwork.allocate(self.client, VN_TEMPLATE) == 2
|
||||
|
||||
def test_publish(self):
|
||||
h = oca.VirtualNetwork(self.xml, self.client)
|
||||
self.client.call = Mock(return_value='')
|
||||
h._convert_types()
|
||||
h.publish()
|
||||
self.client.call.assert_called_once_with('vn.publish', 3, True)
|
||||
|
||||
def test_unpublish(self):
|
||||
h = oca.VirtualNetwork(self.xml, self.client)
|
||||
self.client.call = Mock(return_value='')
|
||||
h._convert_types()
|
||||
h.unpublish()
|
||||
self.client.call.assert_called_once_with('vn.publish', 3, False)
|
||||
|
||||
def test_repr(self):
|
||||
h = oca.VirtualNetwork(self.xml, self.client)
|
||||
h._convert_types()
|
||||
assert h.__repr__() == '<oca.VirtualNetwork("Red LAN")>'
|
||||
|
||||
def test_chown(self):
|
||||
h = oca.VirtualNetwork(self.xml, self.client)
|
||||
self.client.call = Mock(return_value='')
|
||||
h._convert_types()
|
||||
h.chown(2, 2)
|
||||
self.client.call.assert_called_once_with('vn.chown', 3, 2, 2)
|
||||
|
||||
def test_address_ranges(self):
|
||||
h = oca.VirtualNetwork(self.xml, self.client)
|
||||
h._convert_types()
|
||||
assert (2 == len(h.address_ranges))
|
||||
assert (1 == h.address_ranges[1].id)
|
||||
assert (0 == h.address_ranges[0].id)
|
||||
assert (" 0 68719479930 1 68719545020" == h.address_ranges[0].allocated)
|
||||
assert ("10.1.0.10" == h.address_ranges[0].ip)
|
||||
assert ("00:22:44:66:88:aa" == h.address_ranges[0].mac)
|
||||
assert (507 == h.address_ranges[0].size)
|
||||
assert ("IP4" == h.address_ranges[0].type)
|
||||
21
oca/tests/test_virtual_network_pool.py
Normal file
21
oca/tests/test_virtual_network_pool.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import oca
|
||||
|
||||
|
||||
class TestVirtualNetworkPool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.client.one_version = '4.10.0'
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/vnetpool.xml')).read()
|
||||
|
||||
def test_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.VirtualNetworkPool(self.client)
|
||||
pool.info()
|
||||
assert len(list(pool)) == 2
|
||||
147
oca/tests/test_virtualmachine.py
Normal file
147
oca/tests/test_virtualmachine.py
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
from nose.tools import raises
|
||||
|
||||
import oca
|
||||
import oca.pool
|
||||
|
||||
|
||||
class TestVirtualMachine(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/vm.xml')).read()
|
||||
|
||||
def test_new_with_id(self):
|
||||
vm = oca.VirtualMachine.new_with_id(self.client, 1)
|
||||
assert vm.id == 1
|
||||
|
||||
def test_acces_items_using_brackets(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
assert vm['name'] == 'vm-example'
|
||||
assert vm['ID'] == '6'
|
||||
assert vm['last_poll'] == '1277729095'
|
||||
assert vm['state'] == '3'
|
||||
assert vm['lcm_state'] == '3'
|
||||
assert vm['stime'] == '1277375180'
|
||||
assert vm['etime'] == '0'
|
||||
assert vm['deploy_id'] == 'dummy'
|
||||
|
||||
def test_acces_items_not_using_brackets(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
assert vm.name == 'vm-example'
|
||||
assert vm.ID == '6'
|
||||
assert vm.last_poll == '1277729095'
|
||||
assert vm.state == '3'
|
||||
assert vm.lcm_state == '3'
|
||||
assert vm.stime == '1277375180'
|
||||
assert vm.etime == '0'
|
||||
assert vm.deploy_id == 'dummy'
|
||||
|
||||
@raises(IndexError)
|
||||
def test_raise_exception_Index_Error_when_using_brackets(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm['wrong_name']
|
||||
|
||||
def test_convert_types(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm._convert_types()
|
||||
assert vm.name == 'vm-example'
|
||||
assert vm.id == 6
|
||||
assert vm.last_poll == 1277729095
|
||||
assert vm.state == 3
|
||||
assert vm.lcm_state == 3
|
||||
assert vm.stime == 1277375180
|
||||
assert vm.etime == 0
|
||||
assert vm.deploy_id == 'dummy'
|
||||
assert isinstance(vm.template, oca.pool.Template)
|
||||
|
||||
def test_allocate(self):
|
||||
self.client.call = Mock(return_value=3)
|
||||
assert oca.VirtualMachine.allocate(self.client, '<VM></VM>') == 3
|
||||
|
||||
def test_deploy(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm.deploy(3)
|
||||
self.client.call.assert_called_once_with('vm.deploy', '6', 3)
|
||||
|
||||
def test_migrate(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm.migrate(3)
|
||||
self.client.call.assert_called_once_with('vm.migrate', '6', 3, False)
|
||||
|
||||
def test_live_migrate(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm.live_migrate(3)
|
||||
self.client.call.assert_called_once_with('vm.migrate', '6', 3, True)
|
||||
|
||||
def test_save_disk(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm.save_disk(1, 2)
|
||||
self.client.call.assert_called_once_with('vm.savedisk', '6', 1, 2)
|
||||
|
||||
def test_actions(self):
|
||||
oca.client = oca.Client('test:test')
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
for action in ['shutdown', 'shutdown_hard', 'poweroff', 'poweroff_hard',
|
||||
'hold', 'release', 'stop', 'cancel', 'suspend', 'resume',
|
||||
'reboot', 'finalize', 'delete', 'resched', 'unresched']:
|
||||
self.client.call = Mock(return_value='')
|
||||
getattr(vm, action)()
|
||||
if action in ('shutdown_hard', 'poweroff_hard', 'undeploy_hard'):
|
||||
action = action.replace("_", "-")
|
||||
self.client.call.assert_called_once_with('vm.action', action, '6')
|
||||
|
||||
def test_repr(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
assert vm.__repr__() == '<oca.VirtualMachine("vm-example")>'
|
||||
|
||||
def test_states(self):
|
||||
for i in range(len(oca.VirtualMachine.VM_STATE)):
|
||||
vm = oca.VirtualMachine('<VM><ID>2</ID><STATE>%s</STATE></VM>' % i,
|
||||
self.client)
|
||||
assert vm.str_state == oca.VirtualMachine.VM_STATE[i]
|
||||
state = oca.VirtualMachine.SHORT_VM_STATES[oca.VirtualMachine.VM_STATE[i]]
|
||||
assert vm.short_state == state
|
||||
|
||||
def test_lcm_states(self):
|
||||
for i in range(len(oca.VirtualMachine.LCM_STATE)):
|
||||
xml = '<VM><ID>2</ID><LCM_STATE>%s</LCM_STATE></VM>' % i
|
||||
vm = oca.VirtualMachine(xml, self.client)
|
||||
assert vm.str_lcm_state == oca.VirtualMachine.LCM_STATE[i]
|
||||
lcm = oca.VirtualMachine.SHORT_LCM_STATES[oca.VirtualMachine.LCM_STATE[i]]
|
||||
assert vm.short_lcm_state == lcm
|
||||
|
||||
def test_resubmit(self):
|
||||
self.client.call = Mock(return_value='')
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm.resubmit()
|
||||
self.client.call.assert_called_once_with('vm.action', 'resubmit', '6')
|
||||
|
||||
def test_History_repr(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm._convert_types()
|
||||
history = vm.history_records[0]
|
||||
assert repr(history) == '<oca.vm.History("seq=0")>'
|
||||
|
||||
def test_no_history_records_element(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm.xml.remove(vm.xml.find('HISTORY_RECORDS'))
|
||||
vm._convert_types()
|
||||
assert vm.history_records == []
|
||||
|
||||
def test_user_template_variables(self):
|
||||
vm = oca.VirtualMachine(self.xml, self.client)
|
||||
vm._convert_types()
|
||||
greeting = vm.user_template.greeting
|
||||
assert greeting == "Hello World"
|
||||
|
||||
def test_update(self):
|
||||
pass
|
||||
52
oca/tests/test_virtualmachine_pool.py
Normal file
52
oca/tests/test_virtualmachine_pool.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
from nose.tools import raises
|
||||
|
||||
import oca
|
||||
import oca.pool
|
||||
|
||||
|
||||
class TestVirtualMachinePool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = oca.Client('test:test')
|
||||
self.xml = open(os.path.join(os.path.dirname(oca.__file__),
|
||||
'tests/fixtures/vmpool.xml')).read()
|
||||
|
||||
def test_vm_pool_info(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.VirtualMachinePool(self.client)
|
||||
pool.info()
|
||||
assert len(list(pool)) == 3
|
||||
|
||||
def test_iterate_before_info(self):
|
||||
pool = oca.VirtualMachinePool(self.client)
|
||||
assert list(pool) == []
|
||||
|
||||
def test_get_by_id(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.VirtualMachinePool(self.client)
|
||||
pool.info()
|
||||
assert pool.get_by_id(8).id == 8
|
||||
|
||||
def test_get_by_name(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.VirtualMachinePool(self.client)
|
||||
pool.info()
|
||||
assert pool.get_by_name('vm-in').name == 'vm-in'
|
||||
|
||||
@raises(oca.pool.WrongIdError)
|
||||
def test_wrong_get_by_id(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.VirtualMachinePool(self.client)
|
||||
pool.info()
|
||||
pool.get_by_id(1010011010)
|
||||
|
||||
@raises(oca.pool.WrongNameError)
|
||||
def test_wrong_get_by_name(self):
|
||||
self.client.call = Mock(return_value=self.xml)
|
||||
pool = oca.VirtualMachinePool(self.client)
|
||||
pool.info()
|
||||
pool.get_by_name('wrong-vm-name')
|
||||
Loading…
Add table
Add a link
Reference in a new issue