mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'origin/4.15'
This commit is contained in:
commit
9f730eabfa
@ -76,6 +76,8 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<
|
||||
|
||||
public Long countTemplatesForAccount(long accountId);
|
||||
|
||||
public List<VMTemplateVO> listUnRemovedTemplatesByStates(VirtualMachineTemplate.State ...states);
|
||||
|
||||
List<VMTemplateVO> findTemplatesToSyncToS3();
|
||||
|
||||
void loadDetails(VMTemplateVO tmpl);
|
||||
|
||||
@ -106,6 +106,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||
// private SearchBuilder<VMTemplateVO> updateStateSearch;
|
||||
private SearchBuilder<VMTemplateVO> AllFieldsSearch;
|
||||
protected SearchBuilder<VMTemplateVO> ParentTemplateIdSearch;
|
||||
private SearchBuilder<VMTemplateVO> InactiveUnremovedTmpltSearch;
|
||||
|
||||
@Inject
|
||||
ResourceTagDao _tagsDao;
|
||||
@ -431,6 +432,11 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||
ParentTemplateIdSearch.and("state", ParentTemplateIdSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
ParentTemplateIdSearch.done();
|
||||
|
||||
InactiveUnremovedTmpltSearch = createSearchBuilder();
|
||||
InactiveUnremovedTmpltSearch.and("state", InactiveUnremovedTmpltSearch.entity().getState(), SearchCriteria.Op.IN);
|
||||
InactiveUnremovedTmpltSearch.and("removed", InactiveUnremovedTmpltSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
InactiveUnremovedTmpltSearch.done();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -938,6 +944,13 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMTemplateVO> listUnRemovedTemplatesByStates(VirtualMachineTemplate.State ...states) {
|
||||
SearchCriteria<VMTemplateVO> sc = InactiveUnremovedTmpltSearch.create();
|
||||
sc.setParameters("state", (Object[]) states);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean remove(Long id) {
|
||||
|
||||
@ -1008,8 +1008,17 @@ public class CommandSetupHelper {
|
||||
final boolean setupDns = dnsProvided || dhcpProvided;
|
||||
|
||||
if (setupDns) {
|
||||
defaultDns1 = guestNic.getIPv4Dns1();
|
||||
defaultDns2 = guestNic.getIPv4Dns2();
|
||||
final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
|
||||
if (guestNic.getIPv4Dns1() != null) {
|
||||
defaultDns1 = guestNic.getIPv4Dns1();
|
||||
} else {
|
||||
defaultDns1 = dcVo.getDns1();
|
||||
}
|
||||
if (guestNic.getIPv4Dns2() != null) {
|
||||
defaultDns2 = guestNic.getIPv4Dns2();
|
||||
} else {
|
||||
defaultDns2 = dcVo.getDns2();
|
||||
}
|
||||
}
|
||||
|
||||
final Nic nic = _nicDao.findByNtwkIdAndInstanceId(network.getId(), router.getId());
|
||||
|
||||
@ -1221,6 +1221,14 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
return new Pair<Long, Answer>(result.first(), result.second()[0]);
|
||||
}
|
||||
|
||||
private void cleanupInactiveTemplates() {
|
||||
List<VMTemplateVO> vmTemplateVOS = _templateDao.listUnRemovedTemplatesByStates(VirtualMachineTemplate.State.Inactive);
|
||||
for (VMTemplateVO template: vmTemplateVOS) {
|
||||
template.setRemoved(new Date());
|
||||
_templateDao.update(template.getId(), template);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupStorage(boolean recurring) {
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("storagemgr.cleanup");
|
||||
@ -1393,6 +1401,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
s_logger.warn("Unable to destroy uploaded template " + template.getUuid() + ". Error details: " + th.getMessage());
|
||||
}
|
||||
}
|
||||
cleanupInactiveTemplates();
|
||||
} finally {
|
||||
scanLock.unlock();
|
||||
}
|
||||
|
||||
@ -18,11 +18,13 @@ package com.cloud.template;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -473,6 +475,18 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean cleanupTemplate(VMTemplateVO template, boolean success) {
|
||||
List<VMTemplateZoneVO> templateZones = templateZoneDao.listByTemplateId(template.getId());
|
||||
List<Long> zoneIds = templateZones.stream().map(VMTemplateZoneVO::getZoneId).collect(Collectors.toList());
|
||||
if (zoneIds.size() > 0) {
|
||||
return success;
|
||||
}
|
||||
template.setRemoved(new Date());
|
||||
template.setState(State.Inactive);
|
||||
templateDao.update(template.getId(), template);
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean delete(TemplateProfile profile) {
|
||||
@ -594,7 +608,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
||||
if (success) {
|
||||
if ((imageStores != null && imageStores.size() > 1) && (profile.getZoneIdList() != null)) {
|
||||
//if template is stored in more than one image stores, and the zone id is not null, then don't delete other templates.
|
||||
return success;
|
||||
return cleanupTemplate(template, success);
|
||||
}
|
||||
|
||||
// delete all cache entries for this template
|
||||
@ -617,6 +631,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
||||
|
||||
// Mark template as Inactive.
|
||||
template.setState(VirtualMachineTemplate.State.Inactive);
|
||||
_tmpltDao.remove(template.getId());
|
||||
_tmpltDao.update(template.getId(), template);
|
||||
|
||||
// Decrement the number of templates and total secondary storage
|
||||
|
||||
@ -99,6 +99,9 @@ setup_router() {
|
||||
if [ -f /etc/cron.daily/logrotate ]; then
|
||||
mv -n /etc/cron.daily/logrotate /etc/cron.hourly 2>&1
|
||||
fi
|
||||
|
||||
# Load modules to support NAT traversal in VR
|
||||
modprobe nf_nat_pptp
|
||||
}
|
||||
|
||||
routing_svcs
|
||||
|
||||
@ -112,6 +112,9 @@ EOF
|
||||
if [ -f /etc/cron.daily/logrotate ]; then
|
||||
mv -n /etc/cron.daily/logrotate /etc/cron.hourly 2>&1
|
||||
fi
|
||||
|
||||
# Load modules to support NAT traversal in VR
|
||||
modprobe nf_nat_pptp
|
||||
}
|
||||
|
||||
routing_svcs
|
||||
|
||||
@ -1322,6 +1322,7 @@ class TestCreateTemplateWithDirectDownload(cloudstackTestCase):
|
||||
"""
|
||||
self.template["checksum"]="{MD5}XXXXXXX"
|
||||
tmpl = Template.register(self.apiclient, self.template, zoneid=self.zone.id, hypervisor=self.hypervisor, randomize_name=False)
|
||||
self.cleanup.append(tmpl)
|
||||
|
||||
try:
|
||||
virtual_machine = VirtualMachine.create(
|
||||
@ -1332,11 +1333,9 @@ class TestCreateTemplateWithDirectDownload(cloudstackTestCase):
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
self.cleanup.append(tmpl)
|
||||
self.cleanup.append(virtual_machine)
|
||||
self.fail("Expected to fail deployment")
|
||||
except Exception as e:
|
||||
self.debug("Expected exception")
|
||||
|
||||
self.cleanup.append(virtual_machine)
|
||||
self.cleanup.append(tmpl)
|
||||
return
|
||||
|
||||
1
ui/.env.local
Normal file
1
ui/.env.local
Normal file
@ -0,0 +1 @@
|
||||
CS_URL=http://10.0.35.240:8080
|
||||
@ -189,8 +189,8 @@ export default {
|
||||
}
|
||||
Login(loginParams)
|
||||
.then((res) => this.loginSuccess(res))
|
||||
.catch(err => this.requestFailed(err))
|
||||
.finally(() => {
|
||||
.catch(err => {
|
||||
this.requestFailed(err)
|
||||
state.loginBtn = false
|
||||
})
|
||||
} else if (customActiveKey === 'saml') {
|
||||
|
||||
@ -231,8 +231,9 @@ public class RedfishClient {
|
||||
for (int attempt = 1; attempt < redfishRequestMaxRetries + 1; attempt++) {
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(WAIT_FOR_REQUEST_RETRY);
|
||||
LOGGER.debug(String.format("Retry HTTP %s request [URL: %s], attempt %d/%d.", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries));
|
||||
LOGGER.debug(String.format("HTTP %s request retry attempt %d/%d [URL: %s].", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries));
|
||||
response = client.execute(httpReq);
|
||||
break;
|
||||
} catch (IOException | InterruptedException e) {
|
||||
if (attempt == redfishRequestMaxRetries) {
|
||||
throw new RedfishException(String.format("Failed to execute HTTP %s request retry attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries,url, e));
|
||||
|
||||
@ -207,4 +207,26 @@ public class RedfishClientTest {
|
||||
Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
|
||||
Mockito.verify(client, Mockito.times(3)).execute(Mockito.any());
|
||||
}
|
||||
|
||||
@Test(expected = RedfishException.class)
|
||||
public void retryHttpRequestExceptionAfterTwoRetries() throws IOException {
|
||||
Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenThrow(IOException.class);
|
||||
|
||||
RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES));
|
||||
newRedfishClientspy.retryHttpRequest(url, httpReq, client);
|
||||
|
||||
Mockito.verify(newRedfishClientspy, Mockito.never()).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
|
||||
Mockito.verify(client, Mockito.never()).execute(Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void retryHttpRequestSuccessAtTheSecondRetry() throws IOException {
|
||||
Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenReturn(httpResponse);
|
||||
|
||||
RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES));
|
||||
newRedfishClientspy.retryHttpRequest(url, httpReq, client);
|
||||
|
||||
Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
|
||||
Mockito.verify(client, Mockito.times(REDFISHT_REQUEST_RETRIES)).execute(Mockito.any());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user