Skip to content

Commit 18e496b

Browse files
committed
rebase to master
1 parent 8eca741 commit 18e496b

4 files changed

Lines changed: 56 additions & 45 deletions

File tree

server/test/com/cloud/vm/UserVmManagerTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.cloud.exception.ResourceUnavailableException;
3636
import com.cloud.storage.StorageManager;
3737
import com.cloud.storage.VMTemplateVO;
38+
import com.cloud.storage.VolumeManager;
3839
import com.cloud.storage.VolumeVO;
3940
import com.cloud.storage.dao.VMTemplateDao;
4041
import com.cloud.storage.dao.VolumeDao;
@@ -53,7 +54,7 @@ public class UserVmManagerTest {
5354

5455
@Spy UserVmManagerImpl _userVmMgr = new UserVmManagerImpl();
5556
@Mock VirtualMachineManager _itMgr;
56-
@Mock StorageManager _storageMgr;
57+
@Mock VolumeManager _storageMgr;
5758
@Mock Account _account;
5859
@Mock AccountManager _accountMgr;
5960
@Mock AccountDao _accountDao;
@@ -76,7 +77,7 @@ public void setup(){
7677
_userVmMgr._templateDao = _templateDao;
7778
_userVmMgr._volsDao = _volsDao;
7879
_userVmMgr._itMgr = _itMgr;
79-
_userVmMgr._storageMgr = _storageMgr;
80+
_userVmMgr.volumeMgr = _storageMgr;
8081
_userVmMgr._accountDao = _accountDao;
8182
_userVmMgr._userDao = _userDao;
8283
_userVmMgr._accountMgr = _accountMgr;
@@ -116,7 +117,7 @@ public void testRestoreVMF2() throws ResourceUnavailableException, Insufficient
116117
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
117118
when(_volumeMock.getId()).thenReturn(3L);
118119
doNothing().when(_volsDao).detachVolume(anyLong());
119-
when(_storageMgr.destroyVolume(_volumeMock)).thenReturn(true);
120+
120121
when(_templateMock.getUuid()).thenReturn("e0552266-7060-11e2-bbaa-d55f5db67735");
121122

122123
_userVmMgr.restoreVMInternal(_account, _vmMock, null);
@@ -141,7 +142,7 @@ public void testRestoreVMF3() throws ResourceUnavailableException, Insufficient
141142
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
142143
when(_volumeMock.getId()).thenReturn(3L);
143144
doNothing().when(_volsDao).detachVolume(anyLong());
144-
when(_storageMgr.destroyVolume(_volumeMock)).thenReturn(true);
145+
145146
when(_templateMock.getUuid()).thenReturn("e0552266-7060-11e2-bbaa-d55f5db67735");
146147

147148
_userVmMgr.restoreVMInternal(_account, _vmMock, null);
@@ -171,7 +172,7 @@ public void testRestoreVMF4() throws ResourceUnavailableException, Insufficient
171172
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
172173
when(_volumeMock.getId()).thenReturn(3L);
173174
doNothing().when(_volsDao).detachVolume(anyLong());
174-
when(_storageMgr.destroyVolume(_volumeMock)).thenReturn(true);
175+
175176
when(_templateMock.getUuid()).thenReturn("b1a3626e-72e0-4697-8c7c-a110940cc55d");
176177

177178
_userVmMgr.restoreVMInternal(_account, _vmMock, 14L);

setup/db/create-schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ CREATE TABLE `cloud`.`vm_template` (
10491049
`source_template_id` bigint unsigned COMMENT 'Id of the original template, if this template is created from snapshot',
10501050
`template_tag` varchar(255) COMMENT 'template tag',
10511051
`sort_key` int(32) NOT NULL default 0 COMMENT 'sort key used for customising sort method',
1052+
`image_data_store_id` bigint unsigned,
10521053
PRIMARY KEY (`id`),
10531054
INDEX `i_vm_template__removed`(`removed`),
10541055
CONSTRAINT `uc_vm_template__uuid` UNIQUE (`uuid`)

setup/db/db/schema-40to410.sql

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use cloud;
2323

24-
alter table vm_template add image_data_store_id bigint unsigned;
2524
alter table vm_template add size bigint unsigned;
2625
alter table vm_template add state varchar(255);
2726
alter table vm_template add update_count bigint unsigned;
@@ -58,45 +57,6 @@ alter table cluster add column owner varchar(255);
5857
alter table cluster add column created datetime COMMENT 'date created';
5958
alter table cluster add column lastUpdated datetime COMMENT 'last updated';
6059
alter table cluster add column engine_state varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'the engine state of the zone';
61-
CREATE TABLE `cloud`.`object_datastore_ref` (
62-
`id` bigint unsigned NOT NULL auto_increment,
63-
`datastore_id` bigint unsigned NOT NULL,
64-
`datastore_role` varchar(255) NOT NULL,
65-
`object_id` bigint unsigned NOT NULL,
66-
`object_type` varchar(255) NOT NULL,
67-
`created` DATETIME NOT NULL,
68-
`last_updated` DATETIME,
69-
`job_id` varchar(255),
70-
`download_pct` int(10) unsigned,
71-
`download_state` varchar(255),
72-
`error_str` varchar(255),
73-
`local_path` varchar(255),
74-
`install_path` varchar(255),
75-
`size` bigint unsigned COMMENT 'the size of the template on the pool',
76-
`state` varchar(255) NOT NULL,
77-
`update_count` bigint unsigned NOT NULL,
78-
`updated` DATETIME,
79-
PRIMARY KEY (`id`)
80-
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
81-
82-
CREATE TABLE `cloud`.`data_store_provider` (
83-
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
84-
`name` varchar(255) NOT NULL COMMENT 'name of primary data store provider',
85-
`uuid` varchar(255) NOT NULL COMMENT 'uuid of primary data store provider',
86-
PRIMARY KEY(`id`)
87-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
88-
89-
CREATE TABLE `cloud`.`image_data_store` (
90-
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
91-
`name` varchar(255) NOT NULL COMMENT 'name of data store',
92-
`image_provider_id` bigint unsigned NOT NULL COMMENT 'id of image_data_store_provider',
93-
`protocol` varchar(255) NOT NULL COMMENT 'protocol of data store',
94-
`data_center_id` bigint unsigned COMMENT 'datacenter id of data store',
95-
`scope` varchar(255) COMMENT 'scope of data store',
96-
`uuid` varchar(255) COMMENT 'uuid of data store',
97-
PRIMARY KEY(`id`),
98-
CONSTRAINT `fk_tags__image_data_store_provider_id` FOREIGN KEY(`image_provider_id`) REFERENCES `data_store_provider`(`id`)
99-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10060

10161
CREATE TABLE `cloud`.`vm_compute_tags` (
10262
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',

setup/db/db/schema-410to420.sql

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,55 @@ UPDATE `cloud`.`hypervisor_capabilities` SET `max_hosts_per_cluster`=32 WHERE `h
2424
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '5.1', 128, 0, 32);
2525
DELETE FROM `cloud`.`configuration` where name='vmware.percluster.host.max';
2626
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'AgentManager', 'xen.nics.max', '7', 'Maximum allowed nics for Vms created on Xen');
27+
alter table template_host_ref add state varchar(255);
28+
alter table template_host_ref add update_count bigint unsigned;
29+
alter table template_host_ref add updated datetime;
30+
alter table volume_host_ref add state varchar(255);
31+
alter table volume_host_ref add update_count bigint unsigned;
32+
alter table volume_host_ref add updated datetime;
33+
alter table template_spool_ref add updated datetime;
34+
CREATE TABLE `cloud`.`object_datastore_ref` (
35+
`id` bigint unsigned NOT NULL auto_increment,
36+
`datastore_uuid` varchar(255) NOT NULL,
37+
`datastore_role` varchar(255) NOT NULL,
38+
`object_uuid` varchar(255) NOT NULL,
39+
`object_type` varchar(255) NOT NULL,
40+
`created` DATETIME NOT NULL,
41+
`last_updated` DATETIME,
42+
`job_id` varchar(255),
43+
`download_pct` int(10) unsigned,
44+
`download_state` varchar(255),
45+
`url` varchar(255),
46+
`format` varchar(255),
47+
`checksum` varchar(255),
48+
`error_str` varchar(255),
49+
`local_path` varchar(255),
50+
`install_path` varchar(255),
51+
`size` bigint unsigned COMMENT 'the size of the template on the pool',
52+
`state` varchar(255) NOT NULL,
53+
`update_count` bigint unsigned NOT NULL,
54+
`updated` DATETIME,
55+
PRIMARY KEY (`id`)
56+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
57+
58+
CREATE TABLE `cloud`.`data_store_provider` (
59+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
60+
`name` varchar(255) NOT NULL COMMENT 'name of primary data store provider',
61+
`uuid` varchar(255) NOT NULL COMMENT 'uuid of primary data store provider',
62+
PRIMARY KEY(`id`)
63+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
64+
65+
CREATE TABLE `cloud`.`image_data_store` (
66+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
67+
`name` varchar(255) NOT NULL COMMENT 'name of data store',
68+
`image_provider_id` bigint unsigned NOT NULL COMMENT 'id of image_data_store_provider',
69+
`protocol` varchar(255) NOT NULL COMMENT 'protocol of data store',
70+
`data_center_id` bigint unsigned COMMENT 'datacenter id of data store',
71+
`scope` varchar(255) COMMENT 'scope of data store',
72+
`uuid` varchar(255) COMMENT 'uuid of data store',
73+
PRIMARY KEY(`id`),
74+
CONSTRAINT `fk_tags__image_data_store_provider_id` FOREIGN KEY(`image_provider_id`) REFERENCES `data_store_provider`(`id`)
75+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2776

2877

2978
ALTER TABLE `cloud`.`service_offering` ADD COLUMN `is_volatile` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the vm needs to be volatile, i.e., on every reboot of vm from API root disk is discarded and creates a new root disk';

0 commit comments

Comments
 (0)