Skip to content

Commit c8f7c0d

Browse files
committed
Merge remote-tracking branch 'origin/4.15'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2 parents 843dfaf + 3f84b9a commit c8f7c0d

13 files changed

Lines changed: 115 additions & 52 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ public class ApiConstants {
256256
public static final String OLD_FORMAT = "oldformat";
257257
public static final String OP = "op";
258258
public static final String OS_CATEGORY_ID = "oscategoryid";
259+
public static final String OS_CATEGORY_NAME = "oscategoryname";
259260
public static final String OS_ID = "osid";
260261
public static final String OS_TYPE_ID = "ostypeid";
261262
public static final String OS_DISPLAY_NAME = "osdisplayname";

api/src/main/java/org/apache/cloudstack/api/response/UsageRecordResponse.java

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.response;
1818

19-
import com.google.gson.annotations.SerializedName;
19+
import java.util.LinkedHashSet;
20+
import java.util.Set;
2021

2122
import org.apache.cloudstack.api.ApiConstants;
22-
23-
import com.cloud.serializer.Param;
2423
import org.apache.cloudstack.api.BaseResponseWithTagInformation;
2524

26-
import java.util.LinkedHashSet;
27-
import java.util.Set;
25+
import com.cloud.serializer.Param;
26+
import com.google.gson.annotations.SerializedName;
2827

2928
@SuppressWarnings("unused")
3029
public class UsageRecordResponse extends BaseResponseWithTagInformation implements ControlledEntityResponse {
@@ -89,8 +88,20 @@ public class UsageRecordResponse extends BaseResponseWithTagInformation implemen
8988
private String templateId;
9089

9190
@SerializedName(ApiConstants.OS_TYPE_ID)
92-
@Param(description = "virtual machine os type id")
93-
private Long osTypeId;
91+
@Param(description = "virtual machine os type ID")
92+
private String osTypeId;
93+
94+
@SerializedName(ApiConstants.OS_DISPLAY_NAME)
95+
@Param(description = "virtual machine os display name")
96+
private String osDisplayName;
97+
98+
@SerializedName(ApiConstants.OS_CATEGORY_ID)
99+
@Param(description = "virtual machine guest os category ID")
100+
private String osCategoryId;
101+
102+
@SerializedName(ApiConstants.OS_CATEGORY_NAME)
103+
@Param(description = "virtual machine os category name")
104+
private String osCategoryName;
94105

95106
@SerializedName("usageid")
96107
@Param(description = "id of the resource")
@@ -206,10 +217,22 @@ public void setTemplateId(String templateId) {
206217
this.templateId = templateId;
207218
}
208219

209-
public void setOsTypeId(Long osTypeId) {
220+
public void setOsTypeId(String osTypeId) {
210221
this.osTypeId = osTypeId;
211222
}
212223

224+
public void setOsDisplayName(String osDisplayName) {
225+
this.osDisplayName = osDisplayName;
226+
}
227+
228+
public void setOsCategoryId(String osCategoryId) {
229+
this.osCategoryId = osCategoryId;
230+
}
231+
232+
public void setOsCategoryName(String osCategoryName) {
233+
this.osCategoryName = osCategoryName;
234+
}
235+
213236
public void setUsageId(String usageId) {
214237
this.usageId = usageId;
215238
}

engine/schema/src/main/resources/META-INF/db/schema-41500to41510.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@
1919
-- Schema upgrade from 4.15.0.0 to 4.15.1.0
2020
--;
2121

22+
-- Correct guest OS names
23+
UPDATE `cloud`.`guest_os` SET display_name='Fedora Linux (32 bit)' WHERE id=320;
24+
UPDATE `cloud`.`guest_os` SET display_name='Mandriva Linux (32 bit)' WHERE id=323;
25+
UPDATE `cloud`.`guest_os` SET display_name='OpenSUSE Linux (32 bit)' WHERE id=327;

python/lib/cloudutils/serviceConfig.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,12 @@ def config(self):
535535
cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'")
536536
cfo.addEntry("LIBVIRTD_ARGS", "-l")
537537
cfo.save()
538+
if os.path.exists("/lib/systemd/system/libvirtd.socket"):
539+
bash("/bin/systemctl mask libvirtd.socket");
540+
bash("/bin/systemctl mask libvirtd-ro.socket");
541+
bash("/bin/systemctl mask libvirtd-admin.socket");
542+
bash("/bin/systemctl mask libvirtd-tls.socket");
543+
bash("/bin/systemctl mask libvirtd-tcp.socket");
538544

539545
filename = "/etc/libvirt/qemu.conf"
540546

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@
306306
import com.cloud.storage.GuestOS;
307307
import com.cloud.storage.GuestOSCategoryVO;
308308
import com.cloud.storage.GuestOSHypervisor;
309+
import com.cloud.storage.GuestOsCategory;
309310
import com.cloud.storage.ImageStore;
310311
import com.cloud.storage.Snapshot;
311312
import com.cloud.storage.SnapshotVO;
@@ -315,6 +316,8 @@
315316
import com.cloud.storage.VMTemplateVO;
316317
import com.cloud.storage.Volume;
317318
import com.cloud.storage.VolumeVO;
319+
import com.cloud.storage.dao.GuestOSCategoryDao;
320+
import com.cloud.storage.dao.GuestOSDao;
318321
import com.cloud.storage.dao.VolumeDao;
319322
import com.cloud.storage.snapshot.SnapshotPolicy;
320323
import com.cloud.storage.snapshot.SnapshotSchedule;
@@ -394,6 +397,10 @@ public class ApiResponseHelper implements ResponseGenerator {
394397
private VMSnapshotDao vmSnapshotDao;
395398
@Inject
396399
private BackupOfferingDao backupOfferingDao;
400+
@Inject
401+
private GuestOSCategoryDao _guestOsCategoryDao;
402+
@Inject
403+
private GuestOSDao _guestOsDao;
397404

398405
@Override
399406
public UserResponse createUserResponse(User user) {
@@ -3401,7 +3408,16 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord, Map<String, Se
34013408
resourceType = ResourceTag.ResourceObjectType.UserVm;
34023409
usageRecResponse.setUsageId(vm.getUuid());
34033410
resourceId = vm.getId();
3404-
usageRecResponse.setOsTypeId(vm.getGuestOSId());
3411+
final GuestOS guestOS = _guestOsDao.findById(vm.getGuestOSId());
3412+
if (guestOS != null) {
3413+
usageRecResponse.setOsTypeId(guestOS.getUuid());
3414+
usageRecResponse.setOsDisplayName(guestOS.getDisplayName());
3415+
final GuestOsCategory guestOsCategory = _guestOsCategoryDao.findById(guestOS.getCategoryId());
3416+
if (guestOsCategory != null) {
3417+
usageRecResponse.setOsCategoryId(guestOsCategory.getUuid());
3418+
usageRecResponse.setOsCategoryName(guestOsCategory.getName());
3419+
}
3420+
}
34053421
}
34063422
//Hypervisor Type
34073423
usageRecResponse.setType(usageRecord.getType());
@@ -3962,7 +3978,6 @@ public NicResponse createNicResponse(Nic result) {
39623978
NicResponse response = new NicResponse();
39633979
NetworkVO network = _entityMgr.findById(NetworkVO.class, result.getNetworkId());
39643980
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, result.getInstanceId());
3965-
UserVmJoinVO userVm = _entityMgr.findById(UserVmJoinVO.class, result.getInstanceId());
39663981
List<NicExtraDhcpOptionVO> nicExtraDhcpOptionVOs = _nicExtraDhcpOptionDao.listByNicId(result.getId());
39673982

39683983
// The numbered comments are to keep track of the data returned from here and UserVmJoinDaoImpl.setUserVmResponse()
@@ -3976,15 +3991,13 @@ public NicResponse createNicResponse(Nic result) {
39763991
response.setVmId(vm.getUuid());
39773992
}
39783993

3979-
if (userVm != null){
3980-
if (userVm.getTrafficType() != null) {
3981-
/*4: trafficType*/
3982-
response.setTrafficType(userVm.getTrafficType().toString());
3983-
}
3984-
if (userVm.getGuestType() != null) {
3985-
/*5: guestType*/
3986-
response.setType(userVm.getGuestType().toString());
3987-
}
3994+
if (network.getTrafficType() != null) {
3995+
/*4: trafficType*/
3996+
response.setTrafficType(network.getTrafficType().toString());
3997+
}
3998+
if (network.getGuestType() != null) {
3999+
/*5: guestType*/
4000+
response.setType(network.getGuestType().toString());
39884001
}
39894002
/*6: ipAddress*/
39904003
response.setIpaddress(result.getIPv4Address());
@@ -3993,9 +4006,7 @@ public NicResponse createNicResponse(Nic result) {
39934006
/*8: netmask*/
39944007
response.setNetmask(result.getIPv4Netmask());
39954008
/*9: networkName*/
3996-
if(userVm != null && userVm.getNetworkName() != null) {
3997-
response.setNetworkName(userVm.getNetworkName());
3998-
}
4009+
response.setNetworkName(network.getName());
39994010
/*10: macAddress*/
40004011
response.setMacAddress(result.getMacAddress());
40014012
/*11: IPv6Address*/

server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626

2727
import javax.inject.Inject;
2828

29-
import com.cloud.configuration.Config;
30-
import com.cloud.deployasis.dao.TemplateDeployAsIsDetailsDao;
31-
import com.cloud.storage.dao.VMTemplateDetailsDao;
32-
import com.cloud.utils.db.Transaction;
33-
import com.cloud.utils.db.TransactionCallback;
34-
import com.cloud.utils.db.TransactionStatus;
3529
import org.apache.cloudstack.agent.directdownload.CheckUrlAnswer;
3630
import org.apache.cloudstack.agent.directdownload.CheckUrlCommand;
3731
import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
@@ -62,14 +56,17 @@
6256
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
6357
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
6458
import org.apache.cloudstack.utils.security.DigestHelper;
59+
import org.apache.commons.collections.CollectionUtils;
6560
import org.apache.log4j.Logger;
6661

6762
import com.cloud.agent.AgentManager;
6863
import com.cloud.agent.api.Answer;
6964
import com.cloud.alert.AlertManager;
65+
import com.cloud.configuration.Config;
7066
import com.cloud.configuration.Resource.ResourceType;
7167
import com.cloud.dc.DataCenterVO;
7268
import com.cloud.dc.dao.DataCenterDao;
69+
import com.cloud.deployasis.dao.TemplateDeployAsIsDetailsDao;
7370
import com.cloud.event.EventTypes;
7471
import com.cloud.event.UsageEventUtils;
7572
import com.cloud.exception.InvalidParameterValueException;
@@ -87,6 +84,7 @@
8784
import com.cloud.storage.VMTemplateVO;
8885
import com.cloud.storage.VMTemplateZoneVO;
8986
import com.cloud.storage.dao.VMTemplateDao;
87+
import com.cloud.storage.dao.VMTemplateDetailsDao;
9088
import com.cloud.storage.dao.VMTemplateZoneDao;
9189
import com.cloud.storage.download.DownloadMonitor;
9290
import com.cloud.template.VirtualMachineTemplate.State;
@@ -95,6 +93,9 @@
9593
import com.cloud.utils.UriUtils;
9694
import com.cloud.utils.db.DB;
9795
import com.cloud.utils.db.EntityManager;
96+
import com.cloud.utils.db.Transaction;
97+
import com.cloud.utils.db.TransactionCallback;
98+
import com.cloud.utils.db.TransactionStatus;
9899
import com.cloud.utils.exception.CloudRuntimeException;
99100

100101
public class HypervisorTemplateAdapter extends TemplateAdapterBase {
@@ -169,6 +170,12 @@ private Long performDirectDownloadUrlValidation(final String format, final Strin
169170
return ans.getTemplateSize();
170171
}
171172

173+
private void checkZoneImageStores(final List<Long> zoneIdList) {
174+
if (zoneIdList != null && CollectionUtils.isEmpty(storeMgr.getImageStoresByScope(new ZoneScope(zoneIdList.get(0))))) {
175+
throw new InvalidParameterValueException("Failed to find a secondary storage in the specified zone.");
176+
}
177+
}
178+
172179
@Override
173180
public TemplateProfile prepare(RegisterIsoCmd cmd) throws ResourceAllocationException {
174181
TemplateProfile profile = super.prepare(cmd);
@@ -637,29 +644,17 @@ public boolean delete(TemplateProfile profile) {
637644
public TemplateProfile prepareDelete(DeleteTemplateCmd cmd) {
638645
TemplateProfile profile = super.prepareDelete(cmd);
639646
VMTemplateVO template = profile.getTemplate();
640-
List<Long> zoneIdList = profile.getZoneIdList();
641-
642647
if (template.getTemplateType() == TemplateType.SYSTEM) {
643648
throw new InvalidParameterValueException("The DomR template cannot be deleted.");
644649
}
645-
646-
if (zoneIdList != null && (storeMgr.getImageStoreWithFreeCapacity(zoneIdList.get(0)) == null)) {
647-
throw new InvalidParameterValueException("Failed to find a secondary storage in the specified zone.");
648-
}
649-
650+
checkZoneImageStores(profile.getZoneIdList());
650651
return profile;
651652
}
652653

653654
@Override
654655
public TemplateProfile prepareDelete(DeleteIsoCmd cmd) {
655656
TemplateProfile profile = super.prepareDelete(cmd);
656-
List<Long> zoneIdList = profile.getZoneIdList();
657-
658-
if (zoneIdList != null &&
659-
(storeMgr.getImageStoreWithFreeCapacity(zoneIdList.get(0)) == null)) {
660-
throw new InvalidParameterValueException("Failed to find a secondary storage in the specified zone.");
661-
}
662-
657+
checkZoneImageStores(profile.getZoneIdList());
663658
return profile;
664659
}
665660
}

test/integration/smoke/test_vm_life_cycle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ def test_03_migrate_detached_volume(self):
13631363

13641364
Volume.migrate(self.apiclient, storageid=target_pool.id, volumeid=volume1.id)
13651365

1366-
vol = Volume.list(self.apiclient, volume=volume1.id)[0]
1366+
vol = Volume.list(self.apiclient, id=volume1.id)[0]
13671367

13681368
self.assertEqual(vol.storageid, target_pool.id, "Storage pool was not the same as expected")
13691369

ui/src/components/view/DetailSettings.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ export default {
176176
})
177177
this.disableSettings = (this.$route.meta.name === 'vm' && this.resource.state !== 'Stopped')
178178
},
179+
filterOrReadOnlyDetails () {
180+
for (var i = 0; i < this.details.length; i++) {
181+
if (!this.allowEditOfDetail(this.details[i].name)) {
182+
this.details.splice(i, 1)
183+
}
184+
}
185+
},
179186
allowEditOfDetail (name) {
180187
if (this.resource.readonlyuidetails) {
181188
if (this.resource.readonlyuidetails.split(',').map(item => item.trim()).includes(name)) {
@@ -257,13 +264,16 @@ export default {
257264
}
258265
this.error = false
259266
this.details.push({ name: this.newKey, value: this.newValue })
267+
this.filterOrReadOnlyDetails()
260268
this.runApi()
261269
},
262270
updateDetail (index) {
271+
this.filterOrReadOnlyDetails()
263272
this.runApi()
264273
},
265274
deleteDetail (index) {
266275
this.details.splice(index, 1)
276+
this.filterOrReadOnlyDetails()
267277
this.runApi()
268278
},
269279
onShowAddDetail () {

ui/src/components/view/InfoCard.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ export default {
713713
},
714714
data () {
715715
return {
716-
name: '',
717716
ipaddress: '',
718717
resourceType: '',
719718
annotationType: '',
@@ -769,10 +768,14 @@ export default {
769768
created () {
770769
this.setData()
771770
},
771+
computed: {
772+
name () {
773+
return this.resource.displayname || this.resource.displaytext || this.resource.name || this.resource.username ||
774+
this.resource.ipaddress || this.resource.virtualmachinename || this.resource.templatetype
775+
}
776+
},
772777
methods: {
773778
setData () {
774-
this.name = this.resource.displayname || this.resource.displaytext || this.resource.name || this.resource.username ||
775-
this.resource.ipaddress || this.resource.virtualmachinename || this.resource.templatetype
776779
if (this.resource.nic && this.resource.nic.length > 0) {
777780
this.ipaddress = this.resource.nic.filter(e => { return e.ipaddress }).map(e => { return e.ipaddress }).join(', ')
778781
} else {

ui/src/components/widgets/Breadcrumb.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
{{ $t(item.meta.title) }}
2727
</router-link>
2828
<span v-else-if="$route.params.id">
29-
<label v-if="'name' in resource">
30-
<span v-if="['USER.LOGIN', 'USER.LOGOUT', 'ROUTER.HEALTH.CHECKS', 'FIREWALL.CLOSE', 'ALERT.SERVICE.DOMAINROUTER'].includes(resource.name)">{{ $t(resource.name.toLowerCase()) }}</span>
31-
<span v-else>{{ resource.name }}</span>
29+
<label
30+
v-if="'name' in resource &&
31+
['USER.LOGIN', 'USER.LOGOUT', 'ROUTER.HEALTH.CHECKS', 'FIREWALL.CLOSE', 'ALERT.SERVICE.DOMAINROUTER'].includes(resource.name)">
32+
<span>
33+
{{ $t(resource.name.toLowerCase()) }}
34+
</span>
3235
</label>
3336
<label v-else>
34-
{{ resource.name || resource.displayname || resource.displaytext || resource.hostname || resource.username || resource.ipaddress || $route.params.id }}
37+
{{ resource.displayname || resource.displaytext || resource.name || resource.hostname || resource.username || resource.ipaddress || $route.params.id }}
3538
</label>
3639
</span>
3740
<span v-else>

0 commit comments

Comments
 (0)