├── .github_changelog_generator
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── NOTICE
├── README.md
├── autonomic-administration-algorithms
├── .gitignore
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── br
│ │ └── com
│ │ └── autonomiccs
│ │ └── autonomic
│ │ └── administration
│ │ └── algorithms
│ │ ├── ClusterAdministrationHeuristicAlgorithm.java
│ │ ├── beans
│ │ ├── ClusterVmProfile.java
│ │ └── HostProfile.java
│ │ ├── impl
│ │ ├── ClusterManagementDummyAlgorithm.java
│ │ ├── ConsolidationAlgorithmBase.java
│ │ ├── ConsolidationScoredPreferenceForBigHosts.java
│ │ ├── ConsolidationScoredPreferenceForSmallHosts.java
│ │ ├── ConsolidationXenHaPreferenceForBigHostsHomogeneousEnvironment.java
│ │ └── VmsDispersionAlgorithmForHomogeneousEnvironment.java
│ │ └── profilers
│ │ └── HostProfiler.java
│ └── test
│ └── java
│ └── br
│ └── com
│ └── autonomiccs
│ └── autonomic
│ └── administration
│ └── algorithms
│ ├── impl
│ ├── ClusterManagementDummyAlgorithmTest.java
│ ├── ConsolidationAlgorithmBaseTest.java
│ ├── ConsolidationAlgorithmsTest.java
│ ├── ConsolidationScoredPreferenceForBigHostsTest.java
│ ├── ConsolidationScoredPreferenceForSmallHostsTest.java
│ ├── ConsolidationXenHaPreferenceForBigHostsHomogeneousEnvironmentTest.java
│ └── VmsDispersionAlgorithmForHomogeneousEnvironmentTest.java
│ └── profilers
│ └── HostProfilerTest.java
├── autonomic-administration-plugin
├── .gitignore
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── br
│ │ │ └── com
│ │ │ └── autonomiccs
│ │ │ └── autonomic
│ │ │ └── administration
│ │ │ └── plugin
│ │ │ ├── AdministrationAgent.java
│ │ │ ├── HypervisorManager.java
│ │ │ ├── hypervisors
│ │ │ ├── HypervisorHost.java
│ │ │ └── xenserver
│ │ │ │ └── XenHypervisor.java
│ │ │ └── services
│ │ │ └── AutonomicClusterManagementService.java
│ └── resources
│ │ └── META-INF
│ │ └── cloudstack
│ │ └── administration
│ │ ├── module.properties
│ │ └── spring-administration-context.xml
│ └── test
│ └── java
│ └── br
│ └── com
│ └── autonomiccs
│ └── autonomic
│ └── administration
│ └── plugin
│ ├── AdministrationAgentTest.java
│ ├── HypervisorManagerTest.java
│ ├── hypervisors
│ └── xenserver
│ │ └── XenHypervisorTest.java
│ └── services
│ └── AutonomicClusterManagementServiceTest.java
├── autonomic-algorithms-commons
├── .gitignore
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── br
│ │ └── com
│ │ └── autonomiccs
│ │ └── autonomic
│ │ └── algorithms
│ │ └── commons
│ │ ├── beans
│ │ ├── CloudResources.java
│ │ ├── ClusterResources.java
│ │ ├── ClusterResourcesAvailableToStart.java
│ │ ├── ClusterResourcesUp.java
│ │ ├── HostResources.java
│ │ └── VmResources.java
│ │ └── services
│ │ ├── CloudResourcesService.java
│ │ ├── ClusterResourcesService.java
│ │ └── HostResourcesService.java
│ └── test
│ └── java
│ └── br
│ └── com
│ └── autonomiccs
│ └── autonomic
│ └── algorithms
│ └── commons
│ └── services
│ ├── CloudResourcesServiceTest.java
│ ├── ClusterResourcesServiceTest.java
│ ├── HostResourcesServiceTest.java
│ └── HostResourcesTestUtils.java
├── autonomic-allocation-algorithms
├── .gitignore
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── br
│ │ └── com
│ │ └── autonomiccs
│ │ └── autonomic
│ │ └── allocation
│ │ └── algorithms
│ │ ├── AllocationAlgorithm.java
│ │ └── impl
│ │ ├── AllocationAlgorithmBase.java
│ │ ├── ScoredClustersAllocationAlgorithmPreferenceForBigHosts.java
│ │ └── ScoredClustersAllocationAlgorithmPreferenceForSmallHosts.java
│ └── test
│ └── java
│ └── br
│ └── com
│ └── autonomiccs
│ └── autonomic
│ └── allocation
│ └── algorithms
│ └── impl
│ ├── AllocationAlgorithmBaseTest.java
│ ├── ClusterUpwardComparatorTest.java
│ ├── HostUpwardComparatorTest.java
│ ├── ScoredClustersAllocationAlgorithm.java
│ ├── ScoredClustersAllocationAlgorithmPreferenceForBigHostsTest.java
│ └── ScoredClustersAllocationAlgorithmPreferenceForSmallHostsTest.java
├── autonomic-plugin-common
├── .gitignore
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── br
│ │ │ └── com
│ │ │ └── autonomiccs
│ │ │ └── autonomic
│ │ │ └── plugin
│ │ │ └── common
│ │ │ ├── beans
│ │ │ └── AutonomiccsSystemVm.java
│ │ │ ├── daos
│ │ │ ├── AutonomiccsSystemVmDao.java
│ │ │ ├── AutonomiccsSystemVmJdbcDao.java
│ │ │ ├── AutonomiccsSystemVmTemplateJdbcDao.java
│ │ │ ├── ClusterJdbcDao.java
│ │ │ ├── GuestOsJdbcDao.java
│ │ │ ├── HostJdbcDao.java
│ │ │ └── configurations
│ │ │ │ ├── ConfigureDatabaseDao.java
│ │ │ │ └── ProvideDataBaseProperties.java
│ │ │ ├── enums
│ │ │ ├── AutonomiccsSystemVmJarsEnum.java
│ │ │ ├── ClusterAdministrationStatus.java
│ │ │ ├── HostAdministrationStatus.java
│ │ │ ├── StartType.java
│ │ │ └── SystemVmType.java
│ │ │ ├── guru
│ │ │ └── AutonomiccsSystemVmsGuru.java
│ │ │ ├── services
│ │ │ ├── AutonomicClusterManagementHeuristicService.java
│ │ │ ├── AutonomiccsServiceOfferingService.java
│ │ │ ├── AutonomiccsSystemVmDeploymentService.java
│ │ │ ├── AutonomiccsSystemVmTemplateService.java
│ │ │ ├── ClusterService.java
│ │ │ ├── GuestOsService.java
│ │ │ ├── HostService.java
│ │ │ ├── PodService.java
│ │ │ ├── StartHostSystemVmService.java
│ │ │ ├── VirtualMachineService.java
│ │ │ └── ZoneService.java
│ │ │ ├── template
│ │ │ └── AutonomiccsSystemVirtualMachinesTemplateRegister.java
│ │ │ └── utils
│ │ │ ├── HostUtils.java
│ │ │ ├── HttpUtils.java
│ │ │ ├── ReflectionUtils.java
│ │ │ ├── ShellCommandUtils.java
│ │ │ ├── SshUtils.java
│ │ │ └── ThreadUtils.java
│ └── resources
│ │ ├── META-INF
│ │ └── cloudstack
│ │ │ └── autonomiccsPlugins
│ │ │ ├── module.properties
│ │ │ └── spring-autonomiccsPlugins-context.xml
│ │ └── id_rsa.ppk
│ └── test
│ └── java
│ └── br
│ └── com
│ └── autonomiccs
│ └── autonomic
│ └── plugin
│ └── common
│ ├── daos
│ ├── AutonomiccsSystemVmJdbcDaoTest.java
│ ├── AutonomiccsSystemVmTemplateJdbcDaoTest.java
│ ├── ClusterJdbcDaoTest.java
│ ├── GuestOsJdbcDaoTest.java
│ ├── HostJdbcDaoTest.java
│ └── configurations
│ │ ├── ConfigureDatabaseDaoTest.java
│ │ └── ProvideDataBasePropertiesTest.java
│ ├── enums
│ └── ClusterAdministrationStatusTest.java
│ ├── guru
│ └── AutonomiccsSystemVmsGuruTest.java
│ ├── services
│ ├── AutonomicClusterManagementHeuristicServiceTest.java
│ ├── AutonomiccsServiceOfferingServiceTest.java
│ ├── AutonomiccsSystemVmDeploymentServiceTest.java
│ ├── AutonomiccsSystemVmTemplateServiceTest.java
│ ├── ClusterServiceTest.java
│ ├── GuestOsServiceTest.java
│ ├── HostServiceTest.java
│ ├── PodServiceTest.java
│ ├── StartHostSystemVmServiceTest.java
│ ├── VirtualMachineServiceTest.java
│ └── ZoneServiceTest.java
│ ├── template
│ └── AutonomiccsSystemVirtualMachinesTemplateRegisterTest.java
│ └── utils
│ ├── HostUtilsTest.java
│ ├── HttpUtilsTest.java
│ ├── ReflectionUtilsTest.java
│ ├── ShellCommandUtilsTest.java
│ ├── SshUtilsTest.java
│ └── ThreadUtilsTest.java
├── pom.xml
├── starthost-plugin
├── .gitignore
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── br
│ │ └── com
│ │ └── autonomiccs
│ │ └── starthost
│ │ ├── plugin
│ │ ├── proxies
│ │ │ ├── ScanDirectAgentToLoadMethodInterceptor.java
│ │ │ ├── ScanDirectAgentToLoadMethodInterceptorWorkAroundForProxy.java
│ │ │ ├── StartHostMethodInterceptor.java
│ │ │ └── StartHostMethodInterceptorWorkAroundForProxy.java
│ │ └── services
│ │ │ └── StartHostService.java
│ │ └── systemVm
│ │ └── AutonomiccsStartHostSystemVmManager.java
│ └── resources
│ ├── META-INF
│ └── cloudstack
│ │ └── starthost
│ │ ├── module.properties
│ │ └── spring-starthost-context.xml
│ ├── application.yml
│ ├── id_rsa.ppk
│ ├── log4j.properties
│ ├── proxyToStartHostConfigurations.xml
│ └── startup
├── tools
├── figures
│ ├── Thumbs.db
│ ├── balancing.jpg
│ ├── consolidation.jpg
│ ├── consolidationManagers.odg
│ ├── frameworkComponents.odg
│ ├── managementAgents.jpg
│ └── scenarios.odg
├── licenses
│ └── licenses-header-template
├── project-logo
│ ├── AutonomiccsProjectFirstFace.png
│ ├── Thumbs.db
│ ├── a.png
│ ├── autonomiccs.png
│ ├── autonomiccsText.png
│ └── autonomiccsWhite.png
└── scripts
│ └── build
│ ├── buildAutonomiccs.sh
│ ├── createAutonomiccsPlatformInstaller.sh
│ ├── emailTemplate
│ └── releaseNewVersionTemplate
│ └── templateInstallationPackage
│ ├── autonomiccsJars
│ ├── moveJars.sh
│ └── removeJars.sh
│ ├── id_rsa
│ ├── install.sh
│ ├── removeCsDatabaseReferences.sql
│ ├── removeReferencesOnCloudStackDB.sh
│ ├── removeSelectProcedure.sql
│ ├── scriptPreffix.sh
│ ├── selectSystemVMsIPs.sql
│ └── unistall.sh
└── wakeonlan-service
├── .gitignore
├── application.yml
├── log4j.properties
├── pom.xml
└── src
├── main
└── java
│ └── br
│ └── com
│ └── autonomiccs
│ └── wakeonlan
│ ├── controller
│ └── WakeOnLanServiceEndPoint.java
│ ├── initialization
│ └── InicializeSystem.java
│ ├── installation
│ └── WakeOnLanInstallation.java
│ ├── jersey
│ └── JerseyConfig.java
│ └── services
│ └── WakeOnLanHostService.java
└── test
└── java
└── br
└── com
└── autonomiccs
└── wakeonlan
├── controller
└── WakeOnLanServiceEndPointTest.java
├── inicialization
└── InicializeSystemTest.java
├── installation
└── WakeOnLanInstallationTest.java
├── jersey
└── JerseyConfigTest.java
└── services
└── WakeOnLanHostServiceTest.java
/.github_changelog_generator:
--------------------------------------------------------------------------------
1 | future-release=1.0.2
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 |
25 | # Mobile Tools for Java (J2ME)
26 | .mtj.tmp/
27 |
28 | # Package Files #
29 | *.jar
30 | *.war
31 | *.ear
32 |
33 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
34 | hs_err_pid*
35 |
36 | #Eclipse files
37 | .project
38 | .settings/*
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Autonomiccs Platform
2 | Copyright (C) 2016 Autonomiccs, Inc.
3 |
4 | This product includes software developed at
5 | Autonomiccs, Inc. (http://autonomiccs.com.br/).
6 |
--------------------------------------------------------------------------------
/autonomic-administration-algorithms/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 | *.classpath
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.jar
31 | *.war
32 | *.ear
33 |
34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35 | hs_err_pid*
36 |
37 | #Eclipse files
38 | .project
39 | .settings/*
--------------------------------------------------------------------------------
/autonomic-administration-algorithms/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 | 4.0.0
27 |
28 | br.com.autonomiccs
29 | autonomic-platform
30 | 1.0.3-SNAPSHOT
31 |
32 | autonomic-administration-algorithms
33 | autonomic-administration-algorithms
34 | 1.0.3-SNAPSHOT
35 |
36 | This project contains the administration algorithms interface and a set of basic algorithms that can be used with the Autonomiccs cloud computing management platform. Those algorithms are used to feed our management agents.
37 |
38 |
39 | br.com.autonomiccs
40 | autonomic-algorithms-commons
41 | ${project.version}
42 |
43 |
44 |
45 |
46 | org.apache.commons
47 | commons-math3
48 | 3.6
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/autonomic-administration-algorithms/src/main/java/br/com/autonomiccs/autonomic/administration/algorithms/beans/ClusterVmProfile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.administration.algorithms.beans;
24 |
25 | /**
26 | * Contains the cluster VMs profile attributes (number of instances, total cpus,
27 | * total cpu speed, memory, cpus profile, cpus speed profile, memory profile).
28 | */
29 | public class ClusterVmProfile {
30 |
31 | private int numberOfInstances;
32 | private int totalCpus;
33 | private int totalCpuSpeed;
34 | private int totalMemory;
35 | private double cpusProfile;
36 | private double cpuSpeedProfile;
37 | private double memoryProfile;
38 |
39 | public int getNumberOfInstances() {
40 | return numberOfInstances;
41 | }
42 | public void setNumberOfInstances(int totalInstances) {
43 | this.numberOfInstances = totalInstances;
44 | }
45 | public int getTotalCpus() {
46 | return totalCpus;
47 | }
48 | public void setTotalCpus(int totalCpus) {
49 | this.totalCpus = totalCpus;
50 | }
51 | public int getTotalCpuSpeed() {
52 | return totalCpuSpeed;
53 | }
54 | public void setTotalCpuSpeed(int totalCpuSpeed) {
55 | this.totalCpuSpeed = totalCpuSpeed;
56 | }
57 | public int getTotalMemory() {
58 | return totalMemory;
59 | }
60 | public void setTotalMemory(int totalMemory) {
61 | this.totalMemory = totalMemory;
62 | }
63 | public double getCpusProfile() {
64 | return cpusProfile;
65 | }
66 | public void setCpusProfile(double cpusProfile) {
67 | this.cpusProfile = cpusProfile;
68 | }
69 | public double getCpuSpeedProfile() {
70 | return cpuSpeedProfile;
71 | }
72 | public void setCpuSpeedProfile(double speedProfile) {
73 | this.cpuSpeedProfile = speedProfile;
74 | }
75 | public double getMemoryProfile() {
76 | return memoryProfile;
77 | }
78 | public void setMemoryProfile(double memoryProfile) {
79 | this.memoryProfile = memoryProfile;
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/autonomic-administration-algorithms/src/main/java/br/com/autonomiccs/autonomic/administration/algorithms/beans/HostProfile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.administration.algorithms.beans;
24 |
25 | /**
26 | * Contains the host profile attributes (number of cpus, cpu speed and memory).
27 | */
28 | public class HostProfile {
29 |
30 | private double cpusProfile;
31 | private double cpuSpeedProfile;
32 | private double memoryProfile;
33 |
34 | public double getCpusProfile() {
35 | return cpusProfile;
36 | }
37 | public void setCpusProfile(double cpusProfile) {
38 | this.cpusProfile = cpusProfile;
39 | }
40 | public double getCpuSpeedProfile() {
41 | return cpuSpeedProfile;
42 | }
43 | public void setCpuSpeedProfile(double cpuSpeedProfile) {
44 | this.cpuSpeedProfile = cpuSpeedProfile;
45 | }
46 | public double getMemoryProfile() {
47 | return memoryProfile;
48 | }
49 | public void setMemoryProfile(double memoryProfile) {
50 | this.memoryProfile = memoryProfile;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/autonomic-administration-algorithms/src/main/java/br/com/autonomiccs/autonomic/administration/algorithms/impl/ConsolidationScoredPreferenceForBigHosts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.administration.algorithms.impl;
24 |
25 | import java.util.List;
26 |
27 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
28 |
29 | /**
30 | * Extends the {@link ConsolidationScoredPreferenceForSmallHosts} overriding {@link #sortHosts(List)}. This
31 | * Class allows to choose hosts with higher amount of resources to stay running;
32 | */
33 | public class ConsolidationScoredPreferenceForBigHosts extends ConsolidationScoredPreferenceForSmallHosts {
34 |
35 | /**
36 | * Sorts the hosts with higher amount of resources as the most suitable to
37 | * stay running. It uses the {@link #sortHostsDownwardScore(List)} method.
38 | */
39 | @Override
40 | protected void sortHosts(List sortedHosts) {
41 | sortHostsDownwardScore(sortedHosts);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/autonomic-administration-algorithms/src/test/java/br/com/autonomiccs/autonomic/administration/algorithms/impl/ConsolidationScoredPreferenceForBigHostsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.administration.algorithms.impl;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | import org.junit.Before;
29 | import org.junit.Test;
30 | import org.mockito.Mockito;
31 |
32 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
33 |
34 | public class ConsolidationScoredPreferenceForBigHostsTest {
35 |
36 | private ConsolidationScoredPreferenceForBigHosts spyAlgorithm;
37 |
38 | @Before
39 | public void setup() {
40 | spyAlgorithm = Mockito.spy(new ConsolidationScoredPreferenceForBigHosts());
41 | }
42 |
43 | @Test
44 | public void sortHostsTest() {
45 | List hosts = new ArrayList();
46 | spyAlgorithm.sortHosts(hosts);
47 | Mockito.verify(spyAlgorithm).sortHostsDownwardScore(hosts);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/autonomic-administration-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 | *.classpath
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.jar
31 | *.war
32 | *.ear
33 |
34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35 | hs_err_pid*
36 |
37 | #Eclipse files
38 | .project
39 | .settings/*
--------------------------------------------------------------------------------
/autonomic-administration-plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 |
26 | 4.0.0
27 |
28 | br.com.autonomiccs
29 | autonomic-platform
30 | 1.0.3-SNAPSHOT
31 |
32 | autonomic-administration-plugin
33 | 1.0.3-SNAPSHOT
34 |
35 | autonomic-administration-plugin
36 | This project contains the agents that are responsible for the management phase of the Autonomiccs cloud computing management platform.
37 |
38 |
39 | br.com.autonomiccs
40 | autonomic-plugin-common
41 | ${project.version}
42 |
43 |
44 |
45 | org.springframework.integration
46 | spring-integration-core
47 | 3.0.7.RELEASE
48 |
49 |
50 |
51 |
52 | org.apache.cloudstack
53 | cloud-api
54 | ${cloudstackVersion}
55 | provided
56 |
57 |
58 |
59 | org.apache.cloudstack
60 | cloud-engine-components-api
61 | ${cloudstackVersion}
62 | provided
63 |
64 |
65 |
66 | cloud-plugin-hypervisor-xenserver
67 | org.apache.cloudstack
68 | ${cloudstackVersion}
69 | provided
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/autonomic-administration-plugin/src/main/java/br/com/autonomiccs/autonomic/administration/plugin/hypervisors/HypervisorHost.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.administration.plugin.hypervisors;
24 |
25 | import com.cloud.host.HostVO;
26 | import com.cloud.hypervisor.Hypervisor.HypervisorType;
27 |
28 | /**
29 | * This interface provides all Host Hypervisors basic operations developed by the Autonomiccs
30 | * platform.
31 | */
32 | public interface HypervisorHost {
33 |
34 | /**
35 | * Shutdown a given {@link HostVO}.
36 | *
37 | * @param hostVo
38 | */
39 | public void shutdownHost(HostVO hostVo);
40 |
41 | /**
42 | * Returns true if the given {@link HypervisorType} all methods from
43 | * {@link HypervisorHost}.
44 | *
45 | * @param hypervisorType
46 | * @return
47 | */
48 | public boolean supportsHypervisor(HypervisorType hypervisorType);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/autonomic-administration-plugin/src/main/resources/META-INF/cloudstack/administration/module.properties:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 | name=administration
22 | parent=autonomiccsPlugins
--------------------------------------------------------------------------------
/autonomic-administration-plugin/src/main/resources/META-INF/cloudstack/administration/spring-administration-context.xml:
--------------------------------------------------------------------------------
1 |
23 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 | *.classpath
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.jar
31 | *.war
32 | *.ear
33 |
34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35 | hs_err_pid*
36 |
37 | #Eclipse files
38 | .project
39 | .settings/*
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 | 4.0.0
26 |
27 | br.com.autonomiccs
28 | autonomic-platform
29 | 1.0.3-SNAPSHOT
30 |
31 | autonomic-algorithms-commons
32 | 1.0.3-SNAPSHOT
33 |
34 | autonomic-algorithms-commons
35 | This project contains a set of utilities that can be used to create autonomic management algorithms to be used with Autonomiccs cloud computing management platform.
36 |
37 |
38 | org.apache.cloudstack
39 | cloud-engine-schema
40 | ${cloudstackVersion}
41 | provided
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/src/main/java/br/com/autonomiccs/autonomic/algorithms/commons/beans/CloudResources.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.algorithms.commons.beans;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * Represents all the resources in the cloud (number of cpus, cpu speed, cpu
30 | * usage, memory, used memory and all the {@link ClusterResources} in this
31 | * cloud.
32 | */
33 | public class CloudResources {
34 |
35 | private int cpus;
36 | private long usedCpu, cpuSpeed, usedMemory, memory;
37 | private List clusters;
38 |
39 | public CloudResources(List clusters, long uMemory, long mem, long uCpu, long cpuFreq, int cpuN) {
40 | this.clusters = clusters;
41 | this.usedMemory = uMemory;
42 | this.memory = mem;
43 | this.usedCpu = uCpu;
44 | this.cpuSpeed = cpuFreq;
45 | this.cpus = cpuN;
46 | }
47 |
48 | public int getCpus() {
49 | return cpus;
50 | }
51 |
52 | public void setCpus(int cpus) {
53 | this.cpus = cpus;
54 | }
55 |
56 | public long getUsedCpu() {
57 | return usedCpu;
58 | }
59 |
60 | public void setUsedCpu(long usedCpu) {
61 | this.usedCpu = usedCpu;
62 | }
63 |
64 | public long getCpuSpeed() {
65 | return cpuSpeed;
66 | }
67 |
68 | public void setCpuSpeed(long cpuSpeed) {
69 | this.cpuSpeed = cpuSpeed;
70 | }
71 |
72 | public long getUsedMemory() {
73 | return usedMemory;
74 | }
75 |
76 | public void setUsedMemory(long usedMemory) {
77 | this.usedMemory = usedMemory;
78 | }
79 |
80 | public long getMemoryInBytes() {
81 | return memory;
82 | }
83 |
84 | public void setMemoryInBytes(long memory) {
85 | this.memory = memory;
86 | }
87 |
88 | public List getClusters() {
89 | return clusters;
90 | }
91 |
92 | public void setClusters(List clusters) {
93 | this.clusters = clusters;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/src/main/java/br/com/autonomiccs/autonomic/algorithms/commons/beans/ClusterResourcesAvailableToStart.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.algorithms.commons.beans;
24 |
25 | import java.util.List;
26 |
27 | /**
28 | * Represents the {@link HostResources} that were deactivated by the {@link ConsolidationManager}; thus they are inactive and available to be started.
29 | */
30 | public class ClusterResourcesAvailableToStart extends ClusterResources {
31 |
32 | private List hostsToStart;
33 |
34 | public ClusterResourcesAvailableToStart(long clusterId, String clusterName, long cpuSpeed, int cpus, long memory, List hostsToStart) {
35 | super(clusterId, clusterName, cpuSpeed, cpus, memory);
36 | this.hostsToStart = hostsToStart;
37 | }
38 |
39 | public List getHostsToStart() {
40 | return hostsToStart;
41 | }
42 |
43 | public void setHostsToStart(List hostsToStart) {
44 | this.hostsToStart = hostsToStart;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/src/main/java/br/com/autonomiccs/autonomic/algorithms/commons/beans/ClusterResourcesUp.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.algorithms.commons.beans;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * This object represents the {@link HostResources} that are running in the
30 | * cluster. TODO ver nome melhor
31 | */
32 | public class ClusterResourcesUp extends ClusterResources {
33 |
34 | private List hostsResources;
35 | private long usedCpu, usedMemory;
36 |
37 | public ClusterResourcesUp(long clusterId, String clusterName, long cpuSpeed, long usedCpu, int cpus, long memory, long usedMemory, List hostsResources) {
38 | super(clusterId, clusterName, cpuSpeed, cpus, memory);
39 | this.hostsResources = hostsResources;
40 | this.usedCpu = usedCpu;
41 | this.usedMemory = usedMemory;
42 | }
43 |
44 | public void setHostsResources(List hostsList) {
45 | this.hostsResources = hostsList;
46 | }
47 |
48 | public List getHostsResources() {
49 | return hostsResources;
50 | }
51 |
52 | /**
53 | * @return sum of each server used Memory (found in capacityDao)
54 | */
55 | public long getUsedMemory() {
56 | return usedMemory;
57 | }
58 |
59 | public void setUsedMemory(long usedMemory) {
60 | this.usedMemory = usedMemory;
61 | }
62 |
63 | /**
64 | * @return sum of each server used CPU (found in capacityDao)
65 | */
66 | public long getUsedCpu() {
67 | return usedCpu;
68 | }
69 |
70 | public void setUsedCpu(long usedCPU) {
71 | this.usedCpu = usedCPU;
72 | }
73 |
74 | @Override
75 | public String toString() {
76 | return super.toString() + ", usedMemory= " + Long.toString(this.usedMemory) + ", usedCpu= " + Long.toString(this.usedCpu);
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/src/main/java/br/com/autonomiccs/autonomic/algorithms/commons/beans/VmResources.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.algorithms.commons.beans;
25 |
26 | /**
27 | * Contains the VM resources (vm id, cpus, cpu speed and memory).
28 | */
29 | public class VmResources implements Cloneable {
30 | private long vmId;
31 | private int cpus;
32 | private long cpuSpeed;
33 | private long memory;
34 |
35 | public VmResources(long id, int cpus, long cpuSpeed, long memory) {
36 | this.vmId = id;
37 | this.cpus = cpus;
38 | this.cpuSpeed = cpuSpeed;
39 | this.memory = memory;
40 | }
41 |
42 | public int getNumberOfCpus() {
43 | return cpus;
44 | }
45 |
46 | public long getVmId() {
47 | return vmId;
48 | }
49 |
50 | public long getCpuSpeed() {
51 | return cpuSpeed;
52 | }
53 |
54 | public long getMemoryInMegaBytes() {
55 | return memory;
56 | }
57 |
58 | public void setVmId(long vmId) {
59 | this.vmId = vmId;
60 | }
61 |
62 | @Override
63 | public Object clone() throws CloneNotSupportedException {
64 | return super.clone();
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/src/main/java/br/com/autonomiccs/autonomic/algorithms/commons/services/CloudResourcesService.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.algorithms.commons.services;
25 |
26 | import java.util.List;
27 |
28 | import org.springframework.stereotype.Component;
29 |
30 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.CloudResources;
31 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.ClusterResourcesUp;
32 |
33 | /**
34 | * Provides operations over {@link CloudResources} objects.
35 | */
36 | @Component
37 | public class CloudResourcesService {
38 |
39 | /**
40 | * Aggregates the amount of resources from all clusters of objects (
41 | * {@link ClusterResourcesUp}), also it creates and returns a
42 | * {@link CloudResources} object.
43 | *
44 | * @param clustersResourcesUp
45 | * @return {@link CloudResources}
46 | */
47 | public CloudResources createCloudResources(List clustersResourcesUp) {
48 | long uMemory = 0, mem = 0, uCpu = 0, cpuFreq = 0;
49 | int cpuN = 0;
50 | for (ClusterResourcesUp currentCluster : clustersResourcesUp) {
51 | uMemory += currentCluster.getUsedMemory();
52 | mem += currentCluster.getMemoryInBytes();
53 | uCpu += currentCluster.getUsedCpu();
54 | cpuFreq += currentCluster.getCpuSpeed();
55 | cpuN += currentCluster.getCpus();
56 | }
57 | return new CloudResources(clustersResourcesUp, uMemory, mem, uCpu, cpuFreq, cpuN);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/autonomic-algorithms-commons/src/test/java/br/com/autonomiccs/autonomic/algorithms/commons/services/HostResourcesTestUtils.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.algorithms.commons.services;
25 |
26 | import java.util.ArrayList;
27 | import java.util.List;
28 | import java.util.Random;
29 |
30 | import org.apache.commons.lang.ObjectUtils;
31 |
32 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
33 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.VmResources;
34 |
35 | public class HostResourcesTestUtils {
36 |
37 | private Random random = new Random();
38 |
39 | protected void createHostWithSmallVms(HostResources host, int amount) {
40 | List vms = createSmallVms(amount);
41 | configuringHostVms(host, vms);
42 | }
43 |
44 | private void configuringHostVms(HostResources host, List vms) {
45 | long usedMemory = 0;
46 | long usedCpuSpeed = 0;
47 | for (VmResources vm : vms) {
48 | usedMemory += vm.getMemoryInMegaBytes();
49 | usedCpuSpeed += vm.getCpuSpeed() * vm.getNumberOfCpus();
50 | }
51 | host.setUsedMemoryInMegaBytes(usedMemory);
52 | host.setVmsResources(vms);
53 | host.setUsedCpu(usedCpuSpeed);
54 | }
55 |
56 | protected List createSmallVms(int amount) {
57 | return replicateVm(amount, createVmResourcesSmall());
58 | }
59 |
60 | private VmResources createVmResourcesSmall() {
61 | return new VmResources(random.nextLong(), 1, 1000l, 512l);
62 | }
63 |
64 | private List replicateVm(int amount, VmResources vm) {
65 | List vms = new ArrayList();
66 | for (int i = 0; i < amount; i++) {
67 | VmResources clonedVm = (VmResources) ObjectUtils.clone(vm);
68 | clonedVm.setVmId(random.nextLong());
69 | vms.add(clonedVm);
70 | }
71 | return vms;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 | *.classpath
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.jar
31 | *.war
32 | *.ear
33 |
34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35 | hs_err_pid*
36 |
37 | #Eclipse files
38 | .project
39 | .settings/*
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 | 4.0.0
26 |
27 | br.com.autonomiccs
28 | autonomic-platform
29 | 1.0.3-SNAPSHOT
30 |
31 | autonomic-allocation-algorithms
32 | 1.0.3-SNAPSHOT
33 |
34 | autonomic-allocation-algorithms
35 | This project contains the allocation algorithms interface and a set of basic allocation algorithms that can be used with the Autonomiccs cloud computing management platform.
36 |
37 |
38 | br.com.autonomiccs
39 | autonomic-algorithms-commons
40 | ${project.version}
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/src/main/java/br/com/autonomiccs/autonomic/allocation/algorithms/AllocationAlgorithm.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.allocation.algorithms;
25 |
26 | import java.util.List;
27 |
28 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.CloudResources;
29 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.ClusterResourcesAvailableToStart;
30 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
31 |
32 | /**
33 | * This interface provides the basic methods that are used by the allocation
34 | * agent of the CloudStack autonomous consolidation plugin.
35 | *
36 | * The implemented algorithm should have some kind of "intelligence" to define
37 | * which servers to power on; first it has to choose a cluster to start the
38 | * process; then it chooses servers to be activated.
39 | */
40 | public interface AllocationAlgorithm {
41 |
42 | /**
43 | * The lower index of the lists the higher priority to receive a VM that is
44 | * being deployed.
45 | *
46 | * @param List
47 | * of clusters
48 | * @return Ordered list of Clusters
49 | */
50 | public List rankClustersToAllocation(List clusters);
51 |
52 | /**
53 | * Checks if it is needed to activate hosts of the cluster on after the
54 | * deployment of a VM.
55 | *
56 | * @param cloudCapacity
57 | * @return True if the available (idle) resources are not sufficient.
58 | */
59 | public boolean needsToActivateHost(CloudResources cloudCapacity);
60 |
61 | /**
62 | * Order the deactivated hosts list, the first ones of the lists will be
63 | * activated first.
64 | *
65 | * @param deactivated
66 | * hosts to be enabled
67 | * @return deactivated hosts ordered to be started
68 | */
69 | public List rankHostsToStart(List hostsResources);
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/src/main/java/br/com/autonomiccs/autonomic/allocation/algorithms/impl/ScoredClustersAllocationAlgorithmPreferenceForBigHosts.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.allocation.algorithms.impl;
25 |
26 | import java.util.Collections;
27 | import java.util.Comparator;
28 | import java.util.List;
29 |
30 | import org.apache.commons.collections.ComparatorUtils;
31 |
32 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
33 |
34 | /**
35 | * This algorithm was designed for the LRG cloud environment. It gives priority to start hosts with
36 | * bigger amount of resources.
37 | */
38 | public class ScoredClustersAllocationAlgorithmPreferenceForBigHosts extends ScoredClustersAllocationAlgorithmPreferenceForSmallHosts {
39 |
40 | /**
41 | * It calls the {@link #sortHostsDownwardScore(List)}
42 | */
43 | @Override
44 | protected void sortHosts(List sortedHosts) {
45 | sortHostsDownwardScore(sortedHosts);
46 | }
47 |
48 | /**
49 | * It sorts hosts by downward score. Hosts with higher score positioned on
50 | * lower indexes of the list.
51 | *
52 | * @param
53 | */
54 | protected void sortHostsDownwardScore(List hosts) {
55 | Collections.sort(hosts, hostReversedComparator);
56 | }
57 |
58 | /**
59 | * This method allows to revert the {@link HostUpwardComparator} logic; thus the logic allows to
60 | * sort hosts with lower score in lower indexes.
61 | */
62 | @SuppressWarnings("unchecked")
63 | protected Comparator hostReversedComparator = ComparatorUtils.reversedComparator(hostUpwardScoreComparator);
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/src/test/java/br/com/autonomiccs/autonomic/allocation/algorithms/impl/ClusterUpwardComparatorTest.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.allocation.algorithms.impl;
25 |
26 | import org.junit.Assert;
27 | import org.junit.Test;
28 | import org.junit.runner.RunWith;
29 | import org.mockito.Mockito;
30 | import org.mockito.runners.MockitoJUnitRunner;
31 |
32 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.ClusterResources;
33 | import br.com.autonomiccs.autonomic.allocation.algorithms.impl.ScoredClustersAllocationAlgorithmPreferenceForSmallHosts.ClusterUpwardComparator;
34 |
35 | @RunWith(MockitoJUnitRunner.class)
36 | public class ClusterUpwardComparatorTest {
37 |
38 | private ClusterUpwardComparator clusterComparator = new ClusterUpwardComparator();
39 |
40 | @Test
41 | public void compareTestH1BiggerThanH2() {
42 | ClusterResources c1 = getScoredClusterMock(1d);
43 | ClusterResources c2 = getScoredClusterMock(0d);
44 | int result = clusterComparator.compare(c1, c2);
45 |
46 | verifyGetScoreExecution(c1, c2);
47 | Assert.assertEquals(1, result);
48 | }
49 |
50 | @Test
51 | public void compareTestH1SmallerThanH2() {
52 | ClusterResources c1 = getScoredClusterMock(0d);
53 | ClusterResources c2 = getScoredClusterMock(1d);
54 | int result = clusterComparator.compare(c1, c2);
55 |
56 | verifyGetScoreExecution(c1, c2);
57 | Assert.assertEquals(-1, result);
58 | }
59 |
60 | private void verifyGetScoreExecution(ClusterResources c1, ClusterResources c2) {
61 | Mockito.verify(c1).getScore();
62 | Mockito.verify(c2).getScore();
63 | }
64 |
65 | private ClusterResources getScoredClusterMock(double score) {
66 | ClusterResources c = Mockito.mock(ClusterResources.class);
67 | Mockito.when(c.getScore()).thenReturn(score);
68 | return c;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/src/test/java/br/com/autonomiccs/autonomic/allocation/algorithms/impl/HostUpwardComparatorTest.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.allocation.algorithms.impl;
25 |
26 | import org.junit.Assert;
27 | import org.junit.Test;
28 | import org.junit.runner.RunWith;
29 | import org.mockito.Mockito;
30 | import org.mockito.runners.MockitoJUnitRunner;
31 |
32 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
33 | import br.com.autonomiccs.autonomic.allocation.algorithms.impl.ScoredClustersAllocationAlgorithmPreferenceForSmallHosts.HostUpwardComparator;
34 |
35 | @RunWith(MockitoJUnitRunner.class)
36 | public class HostUpwardComparatorTest {
37 |
38 | private HostUpwardComparator hostComparator = new HostUpwardComparator();
39 |
40 | @Test
41 | public void compareTestH1BiggerThanH2() {
42 | HostResources h1 = getScoredHostMock(1d);
43 | HostResources h2 = getScoredHostMock(0d);
44 | int result = hostComparator.compare(h1, h2);
45 |
46 | verifyGetScoreExecution(h1, h2);
47 | Assert.assertEquals(1, result);
48 | }
49 |
50 | @Test
51 | public void compareTestH1SmallerThanH2() {
52 | HostResources h1 = getScoredHostMock(0d);
53 | HostResources h2 = getScoredHostMock(1d);
54 | int result = hostComparator.compare(h1, h2);
55 |
56 | verifyGetScoreExecution(h1, h2);
57 | Assert.assertEquals(-1, result);
58 | }
59 |
60 | private void verifyGetScoreExecution(HostResources h1, HostResources h2) {
61 | Mockito.verify(h1).getScore();
62 | Mockito.verify(h2).getScore();
63 | }
64 |
65 | private HostResources getScoredHostMock(double score) {
66 | HostResources h = Mockito.mock(HostResources.class);
67 | Mockito.when(h.getScore()).thenReturn(score);
68 | return h;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/src/test/java/br/com/autonomiccs/autonomic/allocation/algorithms/impl/ScoredClustersAllocationAlgorithm.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.allocation.algorithms.impl;
25 |
26 | import java.util.ArrayList;
27 | import java.util.List;
28 |
29 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.ClusterResourcesAvailableToStart;
30 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
31 |
32 | public abstract class ScoredClustersAllocationAlgorithm {
33 |
34 | protected List createHostsWithScore() {
35 | List hosts = new ArrayList();
36 |
37 | HostResources host1 = new HostResources();
38 | host1.setScore(4.0);
39 | hosts.add(host1);
40 |
41 | HostResources host2 = new HostResources();
42 | host2.setScore(2.0);
43 | hosts.add(host2);
44 |
45 | HostResources host3 = new HostResources();
46 | host3.setScore(1.0);
47 | hosts.add(host3);
48 |
49 | HostResources host4 = new HostResources();
50 | host4.setScore(3.0);
51 | hosts.add(host4);
52 |
53 | return hosts;
54 | }
55 |
56 | protected List createClustersWithScore() {
57 | List clusters = new ArrayList();
58 |
59 | ClusterResourcesAvailableToStart cluster1 = new ClusterResourcesAvailableToStart(1l, "cluster1", 1l, 1, 1l, null);
60 | cluster1.setScore(4.0);
61 | clusters.add(cluster1);
62 |
63 | ClusterResourcesAvailableToStart cluster2 = new ClusterResourcesAvailableToStart(2l, "cluster2", 1l, 1, 1l, null);
64 | cluster2.setScore(1.0);
65 | clusters.add(cluster2);
66 |
67 | ClusterResourcesAvailableToStart cluster3 = new ClusterResourcesAvailableToStart(3l, "cluster3", 1l, 1, 1l, null);
68 | cluster3.setScore(3.0);
69 | clusters.add(cluster3);
70 |
71 | ClusterResourcesAvailableToStart cluster4 = new ClusterResourcesAvailableToStart(4l, "cluster4", 1l, 1, 1l, null);
72 | cluster4.setScore(2.0);
73 | clusters.add(cluster4);
74 |
75 | return clusters;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/autonomic-allocation-algorithms/src/test/java/br/com/autonomiccs/autonomic/allocation/algorithms/impl/ScoredClustersAllocationAlgorithmPreferenceForBigHostsTest.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * This program is part of Autonomiccs "autonomic-platform",
4 | * an open source autonomic cloud computing management platform.
5 | * Copyright (C) 2016 Autonomiccs, Inc.
6 | *
7 | * Licensed to the Autonomiccs, Inc. under one
8 | * or more contributor license agreements. See the NOTICE file
9 | * distributed with this work for additional information
10 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
11 | * to you under the Apache License, Version 2.0 (the
12 | * "License"); you may not use this file except in compliance
13 | * with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing,
18 | * software distributed under the License is distributed on an
19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 | * KIND, either express or implied. See the License for the
21 | * specific language governing permissions and limitations
22 | * under the License.
23 | */
24 | package br.com.autonomiccs.autonomic.allocation.algorithms.impl;
25 |
26 | import java.util.ArrayList;
27 | import java.util.List;
28 |
29 | import org.junit.Assert;
30 | import org.junit.Before;
31 | import org.junit.Test;
32 | import org.junit.runner.RunWith;
33 | import org.mockito.Mockito;
34 | import org.mockito.runners.MockitoJUnitRunner;
35 | import org.powermock.api.mockito.PowerMockito;
36 |
37 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
38 |
39 | @RunWith(MockitoJUnitRunner.class)
40 | public class ScoredClustersAllocationAlgorithmPreferenceForBigHostsTest extends ScoredClustersAllocationAlgorithm {
41 |
42 | private ScoredClustersAllocationAlgorithmPreferenceForBigHosts spyAlgorithm;
43 | private List hosts;
44 |
45 | @Before
46 | public void setup() {
47 | spyAlgorithm = PowerMockito.spy(new ScoredClustersAllocationAlgorithmPreferenceForBigHosts());
48 | hosts = new ArrayList();
49 | }
50 |
51 | @Test
52 | public void sortHostsTest() {
53 | Mockito.doNothing().when(spyAlgorithm).sortHostsDownwardScore(hosts);
54 | spyAlgorithm.sortHosts(hosts);
55 |
56 | Mockito.verify(spyAlgorithm).sortHostsDownwardScore(hosts);
57 | }
58 |
59 | @Test
60 | public void sortHostsDownwardScoreTest() {
61 | List hosts = createHostsWithScore();
62 |
63 | spyAlgorithm.sortHostsDownwardScore(hosts);
64 |
65 | Assert.assertEquals(4.0, hosts.get(0).getScore(), 0);
66 | Assert.assertEquals(3.0, hosts.get(1).getScore(), 0);
67 | Assert.assertEquals(2.0, hosts.get(2).getScore(), 0);
68 | Assert.assertEquals(1.0, hosts.get(3).getScore(), 0);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 | *.classpath
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.jar
31 | *.war
32 | *.ear
33 |
34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35 | hs_err_pid*
36 |
37 | #Eclipse files
38 | .project
39 | .settings/*
--------------------------------------------------------------------------------
/autonomic-plugin-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 | 4.0.0
26 |
27 | br.com.autonomiccs
28 | autonomic-platform
29 | 1.0.3-SNAPSHOT
30 |
31 | autonomic-plugin-common
32 | 1.0.3-SNAPSHOT
33 |
34 | autonomic-plugin-common
35 | This project contains the commons artifacts that can be used by autonomic plugins developed by Autonomiccs.
36 |
37 |
38 |
39 | br.com.autonomiccs
40 | autonomic-administration-algorithms
41 | ${project.version}
42 |
43 |
44 |
45 | org.springframework
46 | spring-jdbc
47 | ${org.springframework.version}
48 |
49 |
50 | org.springframework
51 | spring-tx
52 | ${org.springframework.version}
53 |
54 |
55 |
56 |
57 | org.apache.cloudstack
58 | cloud-framework-db
59 | ${cloudstackVersion}
60 | provided
61 |
62 |
63 | org.apache.cloudstack
64 | cloud-api
65 | ${cloudstackVersion}
66 | provided
67 |
68 |
69 | org.apache.cloudstack
70 | cloud-engine-schema
71 | ${cloudstackVersion}
72 | provided
73 |
74 |
75 | org.apache.cloudstack
76 | cloud-server
77 | ${cloudstackVersion}
78 | provided
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/beans/AutonomiccsSystemVm.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.beans;
24 |
25 | import javax.persistence.Column;
26 | import javax.persistence.DiscriminatorValue;
27 | import javax.persistence.Entity;
28 | import javax.persistence.PrimaryKeyJoinColumn;
29 |
30 | import com.cloud.hypervisor.Hypervisor.HypervisorType;
31 | import com.cloud.vm.VMInstanceVO;
32 |
33 | /**
34 | * This class represents the table 'AutonomiccsSystemVm'.
35 | */
36 | @Entity
37 | @SuppressWarnings("serial")
38 | @PrimaryKeyJoinColumn(name = "id")
39 | @DiscriminatorValue(value = "AutonomiccsSystemVm")
40 | public class AutonomiccsSystemVm extends VMInstanceVO {
41 |
42 | public AutonomiccsSystemVm(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long domainId,
43 | long accountId, long userId, boolean haEnabled) {
44 | super(id, serviceOfferingId, name, name, Type.Instance, templateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
45 | }
46 |
47 | protected AutonomiccsSystemVm() {
48 | super();
49 | }
50 |
51 | @Column(name = "public_ip_address", nullable = false)
52 | private String publicIpAddress;
53 |
54 | @Column(name = "management_ip_address", nullable = false)
55 | private String managementIpAddress;
56 |
57 | /**
58 | * @return a String that represents the column 'public_ip_address'
59 | */
60 | public String getPublicIpAddress() {
61 | return publicIpAddress;
62 | }
63 |
64 | /**
65 | * It sets sets the public IP address at the column 'public_ip_address'
66 | */
67 | public void setPublicIpAddress(String publicIpAddress) {
68 | this.publicIpAddress = publicIpAddress;
69 | }
70 |
71 | /**
72 | * @return a String that represents the column 'management_ip_address'
73 | */
74 | public String getManagementIpAddress() {
75 | return managementIpAddress;
76 | }
77 |
78 | /**
79 | * It sets sets the management IP address at the column 'management_ip_address'
80 | */
81 | public void setManagementIpAddress(String managementIpAddress) {
82 | this.managementIpAddress = managementIpAddress;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/daos/AutonomiccsSystemVmDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos;
24 |
25 | import org.springframework.stereotype.Component;
26 |
27 | import com.cloud.utils.db.GenericDaoBase;
28 |
29 | import br.com.autonomiccs.autonomic.plugin.common.beans.AutonomiccsSystemVm;
30 |
31 | /**
32 | * This DAO is meant to be used to execute a similar flow as the deployment of system VMs in CloudStack, to deploy Autonomiccs system VMs
33 | */
34 | @Component
35 | public class AutonomiccsSystemVmDao extends GenericDaoBase {
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/daos/AutonomiccsSystemVmJdbcDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos;
24 |
25 | import org.springframework.dao.EmptyResultDataAccessException;
26 | import org.springframework.jdbc.core.support.JdbcDaoSupport;
27 |
28 | import br.com.autonomiccs.autonomic.plugin.common.enums.SystemVmType;
29 |
30 | /**
31 | * This class is intended to deal with operations regarding the Autonomiccs system VMs.
32 | */
33 | public class AutonomiccsSystemVmJdbcDao extends JdbcDaoSupport {
34 |
35 | private String sqlGetStartHostServiceVmIdFromPod = "select id from vm_instance where removed is null and pod_id = ? and account_id = 1 and instance_name like ? ";
36 |
37 | /**
38 | * It returns the id from the VM with the StartHost service.
39 | */
40 | public Long getStartHostServiceVmIdFromPod(Long podId, SystemVmType systemVmType) {
41 | try {
42 | return getJdbcTemplate().queryForObject(sqlGetStartHostServiceVmIdFromPod, Long.class, podId, systemVmType.getNamePrefix() + "%");
43 | } catch (EmptyResultDataAccessException e) {
44 | logger.debug(e);
45 | return null;
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/daos/ClusterJdbcDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos;
24 |
25 | import java.util.Date;
26 |
27 | import org.springframework.jdbc.core.support.JdbcDaoSupport;
28 |
29 | import br.com.autonomiccs.autonomic.plugin.common.enums.ClusterAdministrationStatus;
30 |
31 | /**
32 | * This class deals with operations regarding the 'cluster' table.
33 | */
34 | public class ClusterJdbcDao extends JdbcDaoSupport {
35 |
36 | private String sqlGetClusterAdministrationStatus = "SELECT administration_status FROM cluster WHERE id=?;";
37 | private String sqlSetClusterAdministrationStatus = "UPDATE cluster SET administration_status=? WHERE id=?;";
38 |
39 | private String sqlGetClusterLastAdministration = "SELECT last_administration FROM cluster WHERE id=?;";
40 | private String sqlSetClusterLastAdministration = "UPDATE cluster SET last_administration=? WHERE id=?;";
41 |
42 | /**
43 | * It returns the 'last_administration' column of the 'cluster' table.
44 | */
45 | public ClusterAdministrationStatus getClusterAdministrationStatus(long clusterId) {
46 | String statusAsString = getJdbcTemplate().queryForObject(sqlGetClusterAdministrationStatus, String.class, clusterId);
47 | if (statusAsString == null) {
48 | return null;
49 | }
50 | return ClusterAdministrationStatus.valueOf(statusAsString);
51 | }
52 |
53 | /**
54 | * Updates the 'last_administration' column of the 'cluster' table.
55 | */
56 | public void setClusterAdministrationStatus(ClusterAdministrationStatus clusterConsolidationStatus, long clusterId) {
57 | Object[] args = {clusterConsolidationStatus.toString(), clusterId};
58 | getJdbcTemplate().update(sqlSetClusterAdministrationStatus, args);
59 | }
60 |
61 | /**
62 | * It returns the 'last_administration' column of the 'cluster' table.
63 | */
64 | public Date getClusterLastAdminstration(long clusterId) {
65 | return getJdbcTemplate().queryForObject(sqlGetClusterLastAdministration, Date.class, clusterId);
66 | }
67 |
68 | /**
69 | * Updates the 'last_administration' column of the 'cluster' table.
70 | */
71 | public void setClusterLastAdministration(Date date, long clusterId) {
72 | Object[] args = { date, clusterId };
73 | getJdbcTemplate().update(sqlSetClusterLastAdministration, args);
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/daos/GuestOsJdbcDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos;
24 |
25 | import org.springframework.jdbc.core.support.JdbcDaoSupport;
26 |
27 | /**
28 | * This class deals with the access to the "guest_os" data table
29 | */
30 | public class GuestOsJdbcDao extends JdbcDaoSupport {
31 |
32 | /**
33 | * SQL to retrieve the Guest OS ID.
34 | */
35 | private String sqlGetGuestOsId = "select id from guest_os where display_name = ?";
36 |
37 | /**
38 | * Retrieves the ID of a given Guest OS name
39 | * @return guest OS ID
40 | */
41 | public Long getGuestOsUuid(String guestOsName) {
42 | return getJdbcTemplate().queryForObject(sqlGetGuestOsId, Long.class, guestOsName);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/daos/configurations/ProvideDataBaseProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos.configurations;
24 |
25 | import java.util.Properties;
26 |
27 | import org.springframework.context.annotation.Bean;
28 | import org.springframework.context.annotation.Configuration;
29 |
30 | import com.cloud.utils.db.DbProperties;
31 |
32 | /**
33 | * Provide database.properties files to be accessible to the Autonomiccs plugins application context
34 | */
35 | @Configuration
36 | public class ProvideDataBaseProperties {
37 |
38 | /**
39 | * It exports "database.properties" object to the Autonomiccs plugins application context
40 | */
41 | @Bean(name = "db.properties")
42 | public Properties getPropertiesFileFromApacheCloudStack() {
43 | return DbProperties.getDbProperties();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/enums/AutonomiccsSystemVmJarsEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.enums;
24 |
25 | import java.io.File;
26 |
27 | /**
28 | * This class serves as an abstraction unit for the jars that are needed by
29 | * Autonomiccs platform in order to deploy and configure its system VM.
30 | */
31 | public enum AutonomiccsSystemVmJarsEnum {
32 | JADE("jade/jade-plataform-agents.jar"), WAKEONLAN("wakeonlan/wakeonlan-service.jar");
33 |
34 | private static final String AUTONOMICCS_JARS_BASE_FOLDER = "/var/lib/autonomiccs/jars/";
35 | private final String fileName;
36 |
37 | private AutonomiccsSystemVmJarsEnum(String fileName) {
38 | this.fileName = fileName;
39 | }
40 |
41 | /**
42 | * @return The jar file correspondent to the abstraction.
43 | */
44 | public File getJarFile() {
45 | return new File(AUTONOMICCS_JARS_BASE_FOLDER + fileName);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/enums/ClusterAdministrationStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.enums;
24 |
25 | /**
26 | * A cluster can be in one of two administration status: {@link #InProgress} or
27 | * {@link #Done}. That means, the agents has already worked on it, or the agent has already finished its work there.
28 | */
29 | public enum ClusterAdministrationStatus {
30 |
31 | Done, InProgress;
32 |
33 | /**
34 | * Returns true if the cluster consolidation status is equals to
35 | * {@link #InProgress}.
36 | * @return true if the administrationStatus is {@link #InProgress}
37 | */
38 | public static boolean isClusterBeingManaged(ClusterAdministrationStatus administrationStatus) {
39 | return administrationStatus == InProgress;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/enums/HostAdministrationStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.enums;
24 |
25 | /**
26 | * Consolidation status of the cluster (Consolidating, ConsolidationFailed or Consolidated)
27 | * */
28 | public enum HostAdministrationStatus {
29 |
30 | FailedToShutDown,
31 | ShutDownToConsolidate,
32 | FailedToStart,
33 | Up;
34 | }
35 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/enums/StartType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.enums;
24 |
25 | /**
26 | * A host can have one of two possible start type: 'WakeOnLan' and 'Script'.
27 | */
28 | public enum StartType {
29 | WakeOnLan, Script;
30 | }
31 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/enums/SystemVmType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.enums;
24 |
25 | /**
26 | * This enumeration has all of the Autonomiccs system virtual machines types.
27 | */
28 | public enum SystemVmType {
29 |
30 | ClusterManagerAgent("CM-A"),
31 | ClusterManagerStartHostService("CM-SHS");
32 |
33 | private String namePrefix;
34 |
35 | private SystemVmType(String namePrefix) {
36 | this.namePrefix = namePrefix;
37 | }
38 |
39 | public String getNamePrefix() {
40 | return namePrefix;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/services/ClusterService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import java.util.List;
26 |
27 | import org.springframework.beans.factory.annotation.Autowired;
28 | import org.springframework.stereotype.Service;
29 |
30 | import com.cloud.dc.ClusterVO;
31 | import com.cloud.dc.dao.ClusterDao;
32 |
33 | /**
34 | * This class is intended to execute clusters operations; that means, searching, a single clusters,
35 | * a set of clusters, updating data in the database and others. To interact with the database this
36 | * class will use DAOs objects to interact with tables such as the "cluster" table.
37 | */
38 | @Service
39 | public class ClusterService {
40 |
41 | @Autowired
42 | private ClusterDao clusterDao;
43 |
44 | /**
45 | * It returns all clusters in the Pod with the given id.
46 | */
47 | public List listAllClustersFromPod(long podId) {
48 | return clusterDao.listByPodId(podId);
49 | }
50 |
51 | /**
52 | * It returns the {@link ClusterVO} with the given id.
53 | */
54 | public ClusterVO findById(long clusterId) {
55 | return clusterDao.findById(clusterId);
56 | }
57 |
58 | /**
59 | * It returns all clusters in the Zone with the given id.
60 | */
61 | public List listAllClustersOnZone(Long zoneId) {
62 | return clusterDao.listClustersByDcId(zoneId);
63 | }
64 |
65 | /**
66 | * It returns all clusters in the cloud.
67 | */
68 | public List listAllClusters() {
69 | return clusterDao.listAll();
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/services/GuestOsService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import org.springframework.beans.factory.annotation.Autowired;
26 | import org.springframework.stereotype.Service;
27 |
28 | import br.com.autonomiccs.autonomic.plugin.common.daos.GuestOsJdbcDao;
29 |
30 | /**
31 | * This class is meant to deal with Guest Operating systems configurations.
32 | */
33 | @Service
34 | public class GuestOsService {
35 |
36 | @Autowired
37 | private GuestOsJdbcDao guestOsJdbcDao;
38 |
39 | /**
40 | * Retrieves from the database the Guest OS ID.
41 | *
42 | * @return guest OS ID
43 | */
44 | public Long getGuestOsUuid(String guestOsName) {
45 | return this.guestOsJdbcDao.getGuestOsUuid(guestOsName);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/services/PodService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import java.util.List;
26 |
27 | import org.springframework.beans.factory.annotation.Autowired;
28 | import org.springframework.stereotype.Service;
29 |
30 | import br.com.autonomiccs.autonomic.plugin.common.daos.HostJdbcDao;
31 |
32 | import com.cloud.dc.HostPodVO;
33 | import com.cloud.dc.dao.HostPodDao;
34 |
35 | /**
36 | * This class is used to manage Pod object into the database.
37 | */
38 | @Service
39 | public class PodService {
40 |
41 | @Autowired
42 | private HostPodDao hostPodDao;
43 |
44 | @Autowired
45 | private HostJdbcDao hostJdbcDao;
46 |
47 | /**
48 | * List all Pods from a given zone.
49 | * @return {@link List} all pods of the given zone.
50 | */
51 | public List getAllPodsEnabledFromZone(long zoneId) {
52 | return hostPodDao.listByDataCenterId(zoneId);
53 | }
54 |
55 | /**
56 | * It returns a Pod ({@link HostPodVO}) with the given id.
57 | */
58 | public HostPodVO findPodById(Long podId) {
59 | return hostPodDao.findById(podId);
60 | }
61 |
62 | /**
63 | * It returns true if there is at least one host deactivated by the Autonomiccs platform at the
64 | * pod with the given id.
65 | */
66 | public boolean isThereAnyHostOnPodDeactivatedByOurManager(long id) {
67 | return hostJdbcDao.isThereAnyHostOnPodDeactivatedByOurManager(id);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/services/VirtualMachineService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import org.springframework.beans.factory.annotation.Autowired;
26 | import org.springframework.stereotype.Service;
27 |
28 | import com.cloud.vm.VMInstanceVO;
29 | import com.cloud.vm.dao.VMInstanceDao;
30 |
31 | @Service
32 | public class VirtualMachineService {
33 |
34 | @Autowired
35 | private VMInstanceDao vmInstanceDao;
36 |
37 | public VMInstanceVO searchVmInstanceById(Long vmId) {
38 | return vmInstanceDao.findById(vmId);
39 | }
40 |
41 | public void update(long id, VMInstanceVO vmInstance) {
42 | vmInstanceDao.update(id, vmInstance);
43 | }
44 |
45 | public void remove(long id) {
46 | vmInstanceDao.remove(id);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/services/ZoneService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import java.util.List;
26 |
27 | import org.springframework.beans.factory.annotation.Autowired;
28 | import org.springframework.stereotype.Service;
29 |
30 | import com.cloud.dc.DataCenterVO;
31 | import com.cloud.dc.dao.DataCenterDao;
32 |
33 | /**
34 | * This class is intended to manage Zones configurations.
35 | */
36 | @Service
37 | public class ZoneService {
38 |
39 | @Autowired
40 | private DataCenterDao dataCenterDao;
41 |
42 | /**
43 | * It will list all of the enabled zones of the cloud environment.
44 | *
45 | * @return List that represents of of the enabled zones in the cloud
46 | */
47 | public List listAllZonesEnabled() {
48 | return dataCenterDao.listEnabledZones();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/utils/HttpUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.utils;
24 |
25 | import java.io.IOException;
26 | import java.io.StringWriter;
27 | import java.net.HttpURLConnection;
28 | import java.net.URL;
29 |
30 | import org.apache.commons.io.IOUtils;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 | import org.springframework.stereotype.Component;
34 |
35 | /**
36 | * Realizes http requests
37 | */
38 | @Component
39 | public class HttpUtils {
40 |
41 | private Logger logger = LoggerFactory.getLogger(getClass());
42 |
43 | /**
44 | * Send an HTTP get request to systemVM wake the host up.
45 | *
46 | * @param systemVmIp
47 | * The management IP address from systemVM.
48 | * @param hostMac
49 | * The MAC address from host that will be waked up.
50 | * @return
51 | * The response from HTTP get or the error code.
52 | */
53 | public String wakeHaltedHostUsingHttpGet(String systemVmIp, String hostMac) {
54 | try {
55 | URL url = new URL(String.format("http://%s:8080/boot/wakeonlan/%s", systemVmIp, hostMac));
56 | return executeHttpGetRequest(url);
57 | } catch (IOException e) {
58 | logger.debug(String.format("Error while calling Wakeonlan service for host mac address[%s]", hostMac), e);
59 | return e.getMessage();
60 | }
61 | }
62 |
63 | /**
64 | * It executes the GET request to a given URL; the result of the request is returned as a String.
65 | */
66 | public String executeHttpGetRequest(URL url) throws IOException {
67 | HttpURLConnection con = (HttpURLConnection)url.openConnection();
68 | con.setRequestMethod("GET");
69 | int responseCode = con.getResponseCode();
70 | if (responseCode != 200) {
71 | return String.format("Error in HTTP GET : code [%d]", responseCode);
72 | }
73 | StringWriter output = new StringWriter();
74 | IOUtils.copy(con.getInputStream(), output);
75 | return output.toString();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/utils/ReflectionUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.utils;
24 |
25 | import java.lang.reflect.Field;
26 |
27 | import org.apache.cxf.common.util.ReflectionUtil;
28 | import org.springframework.stereotype.Component;
29 |
30 | import com.cloud.utils.exception.CloudRuntimeException;
31 |
32 | /**
33 | * This class provides support for changing fields values with reflection.
34 | */
35 | @Component
36 | public class ReflectionUtils {
37 |
38 | /**
39 | * It sets the given field with value. If it fails to set a value of declared field and the
40 | * {@link IllegalArgumentException} or {@link IllegalAccessException} are thrown, it throws
41 | * {@link CloudRuntimeException}
42 | *
43 | * @throws CloudRuntimeException
44 | */
45 | public void setFieldIntoObject(Object object, String fieldName, Object value) {
46 | Field declaredField = getDeclaredField(object, fieldName);
47 | if (declaredField == null) {
48 | throw new CloudRuntimeException(String.format("Field [fieldName=%s] does not exists into object [%s].", fieldName, object));
49 | }
50 | declaredField.setAccessible(true);
51 | try {
52 | declaredField.set(object, value);
53 | } catch (IllegalArgumentException | IllegalAccessException e) {
54 | throw new CloudRuntimeException(String.format("Fail to set field [fieldName=%s] into object [%s] with the value [%s].", fieldName, object, value), e);
55 | }
56 | }
57 |
58 | /**
59 | * It returns the object {@link Field} with the given field name.
60 | */
61 | protected Field getDeclaredField(Object o, String fieldName) {
62 | Field declaredField = ReflectionUtil.getDeclaredField(o.getClass(), fieldName);
63 | if (declaredField != null) {
64 | return declaredField;
65 | }
66 | return ReflectionUtil.getDeclaredField(o.getClass().getSuperclass(), fieldName);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/utils/ShellCommandUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.utils;
24 |
25 | import java.io.IOException;
26 | import java.io.StringWriter;
27 | import java.io.Writer;
28 |
29 | import org.apache.commons.io.IOUtils;
30 | import org.slf4j.Logger;
31 | import org.slf4j.LoggerFactory;
32 | import org.springframework.stereotype.Component;
33 |
34 | /**
35 | * Utility to execute shell commands
36 | */
37 | @Component
38 | public class ShellCommandUtils {
39 |
40 | protected Logger logger = LoggerFactory.getLogger(this.getClass());
41 |
42 | /**
43 | * It executes the specified shell command and wait for the
44 | * end of command execution to continue with the application
45 | * flow.
46 | *
47 | * If an exception happens, it will get logged and the flow of execution continues.
48 | * This method will not break the flow of execution if an expected exception happens.
49 | *
50 | * @param command
51 | * The command that will be executed.
52 | * @return
53 | * A String
that is the result from
54 | * command executed.
55 | */
56 | public String executeCommand(String command) {
57 | Writer output = new StringWriter();
58 | try {
59 | Process p = Runtime.getRuntime().exec(command);
60 | p.waitFor();
61 | IOUtils.copy(p.getInputStream(), output);
62 | } catch (IOException | InterruptedException e) {
63 | logger.error(String.format("An error happened while executing command[%s]", command), e);
64 | }
65 | return output.toString();
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/java/br/com/autonomiccs/autonomic/plugin/common/utils/ThreadUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.utils;
24 |
25 | import org.springframework.stereotype.Component;
26 |
27 | import com.cloud.utils.exception.CloudRuntimeException;
28 |
29 | /**
30 | * Util operations over threads (for example, sleep)
31 | */
32 | @Component
33 | public class ThreadUtils {
34 |
35 | private final static long ONE_SECOND_IN_MILLISECONDS = 1000l;
36 |
37 | /**
38 | * The thread executing this method sleeps a given amount of seconds.
39 | * If an {@link InterruptedException} occurs, we do not swallow the exception;
40 | * we want to throw a runtime exception and we also do as described
41 | * in http://www.ibm.com/developerworks/library/j-jtp05236/ to restore the interrupt context.
42 | */
43 | public void sleepThread(int secondsToSleep) {
44 | try {
45 | Thread.sleep(secondsToSleep * ONE_SECOND_IN_MILLISECONDS);
46 | } catch (InterruptedException e) {
47 | Thread.currentThread().interrupt();
48 | throw new CloudRuntimeException(e);
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/resources/META-INF/cloudstack/autonomiccsPlugins/module.properties:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 | name=autonomiccsPlugins
22 | parent=core
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/main/resources/id_rsa.ppk:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | 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
51 | -----END RSA PRIVATE KEY-----
52 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/daos/AutonomiccsSystemVmJdbcDaoTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Before;
27 | import org.junit.Test;
28 | import org.junit.runner.RunWith;
29 | import org.mockito.Mockito;
30 | import org.mockito.runners.MockitoJUnitRunner;
31 | import org.powermock.api.mockito.PowerMockito;
32 | import org.springframework.dao.EmptyResultDataAccessException;
33 | import org.springframework.jdbc.core.JdbcTemplate;
34 |
35 | import br.com.autonomiccs.autonomic.plugin.common.enums.SystemVmType;
36 |
37 | @RunWith(MockitoJUnitRunner.class)
38 | public class AutonomiccsSystemVmJdbcDaoTest {
39 |
40 | private String sqlGetStartHostServiceVmIdFromPod = "select id from vm_instance where removed is null and pod_id = ? and account_id = 1 and instance_name like ? ";
41 | private AutonomiccsSystemVmJdbcDao spy;
42 | private JdbcTemplate jdbcTemplate;
43 |
44 | @Before
45 | public void setup() throws Exception {
46 | spy = PowerMockito.spy(new AutonomiccsSystemVmJdbcDao());
47 | jdbcTemplate = Mockito.mock(JdbcTemplate.class);
48 | spy.setJdbcTemplate(jdbcTemplate);
49 | }
50 |
51 | @Test
52 | public void getStartHostServiceVmIdFromPodTest() {
53 | Mockito.doReturn(0l).when(jdbcTemplate).queryForObject(Mockito.anyString(), Mockito.eq(Long.class), Mockito.anyLong(), Mockito.anyString());
54 |
55 | long result = spy.getStartHostServiceVmIdFromPod(0l, SystemVmType.ClusterManagerAgent);
56 |
57 | Mockito.verify(jdbcTemplate).queryForObject(Mockito.eq(sqlGetStartHostServiceVmIdFromPod), Mockito.eq(Long.class), Mockito.anyLong(), Mockito.anyString());
58 | Assert.assertEquals(0l, result);
59 | }
60 |
61 | @Test
62 | public void getStartHostServiceVmIdFromPodTestWithException() throws Exception {
63 | Mockito.doThrow(EmptyResultDataAccessException.class).when(jdbcTemplate).queryForObject(Mockito.anyString(), Mockito.eq(Long.class), Mockito.anyLong(),
64 | Mockito.anyString());
65 |
66 | Assert.assertEquals(null, spy.getStartHostServiceVmIdFromPod(0l, SystemVmType.ClusterManagerAgent));
67 | Mockito.verify(jdbcTemplate).queryForObject(Mockito.eq(sqlGetStartHostServiceVmIdFromPod), Mockito.eq(Long.class), Mockito.anyLong(), Mockito.anyString());
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/daos/GuestOsJdbcDaoTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Before;
27 | import org.junit.Test;
28 | import org.junit.runner.RunWith;
29 | import org.mockito.Mockito;
30 | import org.mockito.runners.MockitoJUnitRunner;
31 | import org.powermock.api.mockito.PowerMockito;
32 | import org.springframework.jdbc.core.JdbcTemplate;
33 |
34 | @RunWith(MockitoJUnitRunner.class)
35 | public class GuestOsJdbcDaoTest {
36 |
37 | private String sqlGetGuestOsId = "select id from guest_os where display_name = ?";
38 | private GuestOsJdbcDao spy;
39 |
40 | @Before
41 | public void setup() {
42 | spy = PowerMockito.spy(new GuestOsJdbcDao());
43 | }
44 |
45 | @Test
46 | public void getGuestOsUuidTest() {
47 | JdbcTemplate jdbcTemplate = Mockito.mock(JdbcTemplate.class);
48 | spy.setJdbcTemplate(jdbcTemplate);
49 |
50 | Mockito.doReturn(321l).when(jdbcTemplate).queryForObject(Mockito.eq(sqlGetGuestOsId), Mockito.eq(Long.class), Mockito.eq("guesOsName"));
51 |
52 | long result = spy.getGuestOsUuid("guesOsName");
53 |
54 | Mockito.verify(jdbcTemplate).queryForObject(Mockito.eq(sqlGetGuestOsId), Mockito.eq(Long.class), Mockito.eq("guesOsName"));
55 | Assert.assertEquals(321l, result);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/daos/configurations/ProvideDataBasePropertiesTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.daos.configurations;
24 |
25 | import java.util.Properties;
26 |
27 | import org.junit.Assert;
28 | import org.junit.Before;
29 | import org.junit.Test;
30 | import org.junit.runner.RunWith;
31 | import org.mockito.Mockito;
32 | import org.powermock.api.mockito.PowerMockito;
33 | import org.powermock.core.classloader.annotations.PrepareForTest;
34 | import org.powermock.modules.junit4.PowerMockRunner;
35 |
36 | import com.cloud.utils.db.DbProperties;
37 |
38 | @RunWith(PowerMockRunner.class)
39 | @PrepareForTest(DbProperties.class)
40 | public class ProvideDataBasePropertiesTest {
41 |
42 | private ProvideDataBaseProperties spy;
43 |
44 | @Before
45 | public void setup() {
46 | spy = Mockito.spy(new ProvideDataBaseProperties());
47 | }
48 |
49 | @Test
50 | public void getPropertiesFileFromApacheCloudStackTest() throws Exception {
51 | Properties properties = Mockito.mock(Properties.class);
52 | PowerMockito.mockStatic(DbProperties.class);
53 |
54 | PowerMockito.doReturn(properties).when(DbProperties.class, "getDbProperties");
55 |
56 | Properties result = spy.getPropertiesFileFromApacheCloudStack();
57 |
58 | PowerMockito.verifyStatic();
59 | DbProperties.getDbProperties();
60 | Assert.assertEquals(properties, result);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/enums/ClusterAdministrationStatusTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.enums;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.mockito.runners.MockitoJUnitRunner;
29 |
30 | @RunWith(MockitoJUnitRunner.class)
31 | public class ClusterAdministrationStatusTest {
32 |
33 | @Test
34 | public void isClusterBeingManagedTestInProgress() {
35 | boolean result = ClusterAdministrationStatus.isClusterBeingManaged(ClusterAdministrationStatus.InProgress);
36 | Assert.assertEquals(true, result);
37 | }
38 |
39 | @Test
40 | public void isClusterBeingManagedTestDone() {
41 | boolean result = ClusterAdministrationStatus.isClusterBeingManaged(ClusterAdministrationStatus.Done);
42 | Assert.assertEquals(false, result);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/services/ClusterServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | import org.junit.Assert;
29 | import org.junit.Test;
30 | import org.junit.runner.RunWith;
31 | import org.mockito.InjectMocks;
32 | import org.mockito.Mock;
33 | import org.mockito.Mockito;
34 | import org.mockito.Spy;
35 | import org.mockito.runners.MockitoJUnitRunner;
36 |
37 | import com.cloud.dc.ClusterVO;
38 | import com.cloud.dc.dao.ClusterDao;
39 |
40 | @RunWith(MockitoJUnitRunner.class)
41 | public class ClusterServiceTest {
42 |
43 | @Spy
44 | @InjectMocks
45 | private ClusterService spy;
46 | @Mock
47 | private ClusterDao clusterDao;
48 |
49 | private List clusters = new ArrayList<>();
50 |
51 | @Test
52 | public void listAllClustersFromPodTest() {
53 | Mockito.doReturn(clusters).when(clusterDao).listByPodId(Mockito.anyLong());
54 |
55 | List result = spy.listAllClustersFromPod(0l);
56 |
57 | Mockito.verify(clusterDao).listByPodId(Mockito.anyLong());
58 | Assert.assertEquals(clusters, result);
59 | }
60 |
61 | @Test
62 | public void findByIdTest() {
63 | ClusterVO cluster = new ClusterVO();
64 | Mockito.doReturn(cluster).when(clusterDao).findById(Mockito.anyLong());
65 |
66 | ClusterVO result = spy.findById(0l);
67 |
68 | Mockito.verify(clusterDao).findById(Mockito.anyLong());
69 | Assert.assertEquals(cluster, result);
70 | }
71 |
72 | @Test
73 | public void listAllClustersOnZoneTest() {
74 | Mockito.doReturn(clusters).when(clusterDao).listClustersByDcId(Mockito.anyLong());
75 |
76 | List result = spy.listAllClustersOnZone(0l);
77 |
78 | Mockito.verify(clusterDao).listClustersByDcId(Mockito.anyLong());
79 | Assert.assertEquals(clusters, result);
80 | }
81 |
82 | @Test
83 | public void listAllClustersTest() {
84 | Mockito.doReturn(clusters).when(clusterDao).listAll();
85 |
86 | List result = spy.listAllClusters();
87 |
88 | Mockito.verify(clusterDao).listAll();
89 | Assert.assertEquals(clusters, result);
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/services/GuestOsServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.mockito.InjectMocks;
29 | import org.mockito.Mock;
30 | import org.mockito.Mockito;
31 | import org.mockito.Spy;
32 | import org.mockito.runners.MockitoJUnitRunner;
33 |
34 | import br.com.autonomiccs.autonomic.plugin.common.daos.GuestOsJdbcDao;
35 |
36 | @RunWith(MockitoJUnitRunner.class)
37 | public class GuestOsServiceTest {
38 |
39 | @Spy
40 | @InjectMocks
41 | private GuestOsService spy;
42 | @Mock
43 | private GuestOsJdbcDao guestOsJdbcDao;
44 |
45 | @Test
46 | public void getGuestOsUuidTest() {
47 | Mockito.doReturn(0l).when(guestOsJdbcDao).getGuestOsUuid(Mockito.anyString());
48 |
49 | long result = spy.getGuestOsUuid("guestOsName");
50 |
51 | Mockito.verify(guestOsJdbcDao).getGuestOsUuid(Mockito.anyString());
52 | Assert.assertEquals(0l, result);
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/services/VirtualMachineServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.mockito.InjectMocks;
29 | import org.mockito.Mock;
30 | import org.mockito.Mockito;
31 | import org.mockito.Spy;
32 | import org.mockito.runners.MockitoJUnitRunner;
33 |
34 | import com.cloud.vm.VMInstanceVO;
35 | import com.cloud.vm.dao.VMInstanceDao;
36 |
37 | @RunWith(MockitoJUnitRunner.class)
38 | public class VirtualMachineServiceTest {
39 |
40 | @Spy
41 | @InjectMocks
42 | private VirtualMachineService spy;
43 | @Mock
44 | private VMInstanceDao vmInstanceDao;
45 |
46 | @Test
47 | public void searchVmInstanceByIdTest() {
48 | VMInstanceVO vm = Mockito.mock(VMInstanceVO.class);
49 | Mockito.doReturn(vm).when(vmInstanceDao).findById(Mockito.anyLong());
50 |
51 | VMInstanceVO result = spy.searchVmInstanceById(0l);
52 |
53 | Mockito.verify(vmInstanceDao).findById(Mockito.anyLong());
54 | Assert.assertEquals(vm, result);
55 | }
56 |
57 | @Test
58 | public void updateTest() {
59 | VMInstanceVO vm = Mockito.mock(VMInstanceVO.class);
60 | Mockito.doReturn(true).when(vmInstanceDao).update(Mockito.anyLong(), Mockito.any(VMInstanceVO.class));
61 |
62 | spy.update(0l, vm);
63 |
64 | Mockito.verify(vmInstanceDao).update(Mockito.anyLong(), Mockito.any(VMInstanceVO.class));
65 | }
66 |
67 | @Test
68 | public void removeTest() {
69 | Mockito.doReturn(true).when(vmInstanceDao).remove(Mockito.anyLong());
70 | spy.remove(0l);
71 | Mockito.verify(vmInstanceDao).remove(Mockito.anyLong());
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/services/ZoneServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.services;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | import org.junit.Test;
29 | import org.junit.runner.RunWith;
30 | import org.mockito.InjectMocks;
31 | import org.mockito.Mock;
32 | import org.mockito.Mockito;
33 | import org.mockito.Spy;
34 | import org.mockito.runners.MockitoJUnitRunner;
35 | import org.junit.Assert;
36 | import com.cloud.dc.DataCenterVO;
37 | import com.cloud.dc.dao.DataCenterDao;
38 |
39 | @RunWith(MockitoJUnitRunner.class)
40 | public class ZoneServiceTest {
41 |
42 | @Spy
43 | @InjectMocks
44 | private ZoneService spy;
45 | @Mock
46 | private DataCenterDao dataCenterDao;
47 |
48 | @Test
49 | public void listAllZonesEnabledTest() {
50 | List dataCenters = new ArrayList<>();
51 | Mockito.doReturn(dataCenters).when(dataCenterDao).listEnabledZones();
52 |
53 | List result = spy.listAllZonesEnabled();
54 |
55 | Mockito.verify(dataCenterDao).listEnabledZones();
56 | Assert.assertEquals(dataCenters, result);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/utils/ReflectionUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.utils;
24 |
25 | import java.lang.reflect.Field;
26 |
27 | import org.junit.Assert;
28 | import org.junit.Before;
29 | import org.junit.Test;
30 | import org.junit.runner.RunWith;
31 | import org.mockito.Mockito;
32 | import org.mockito.runners.MockitoJUnitRunner;
33 |
34 | import com.cloud.utils.exception.CloudRuntimeException;
35 |
36 | import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
37 |
38 | @RunWith(MockitoJUnitRunner.class)
39 | public class ReflectionUtilsTest {
40 |
41 | private ReflectionUtils spy;
42 |
43 | @Before
44 | public void setup() {
45 | spy = Mockito.spy(new ReflectionUtils());
46 | }
47 |
48 | @Test
49 | public void setFieldIntoObjectTest() throws Exception {
50 | HostResources host = new HostResources();
51 | String expectedName = "name";
52 | spy.setFieldIntoObject(host, "hostName", expectedName);
53 | Mockito.verify(spy).getDeclaredField(Mockito.any(), Mockito.anyString());
54 | Assert.assertEquals(expectedName, host.getHostName());
55 | }
56 |
57 | @Test(expected = CloudRuntimeException.class)
58 | public void setFieldIntoObjectTestExpectCloudRuntimeExceptionWithIllegalArgumentException() throws Exception {
59 | spy.setFieldIntoObject(new HostResources(), "hostName", 0l);
60 | Mockito.verify(spy).getDeclaredField(Mockito.any(), Mockito.anyString());
61 | }
62 |
63 | @Test(expected = CloudRuntimeException.class)
64 | public void setFieldIntoObjectTestExpectCloudRuntimeExceptionFieldDoesNotExists() throws Exception {
65 | spy.setFieldIntoObject(new HostResources(), "fieldThatDoesNotExists", "name");
66 | Mockito.verify(spy).getDeclaredField(Mockito.any(), Mockito.anyString());
67 | }
68 |
69 | @Test
70 | public void getDeclaredFieldTestFieldNotExistsIntoObject() throws Exception {
71 | Field result = spy.getDeclaredField(HostResources.class, "fieldThatDoesNotExist");
72 | Assert.assertEquals(null, result);
73 | }
74 |
75 | @Test
76 | public void getDeclaredFieldTestFieldExistsIntoObject() throws Exception {
77 | Field result = spy.getDeclaredField(new HostResources(), "hostName");
78 | Assert.assertEquals("private java.lang.String br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources.hostName", result.toString());
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/autonomic-plugin-common/src/test/java/br/com/autonomiccs/autonomic/plugin/common/utils/ThreadUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.autonomic.plugin.common.utils;
24 |
25 | import org.junit.Before;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.mockito.Mockito;
29 | import org.powermock.api.mockito.PowerMockito;
30 | import org.powermock.core.classloader.annotations.PrepareForTest;
31 | import org.powermock.modules.junit4.PowerMockRunner;
32 |
33 | import com.cloud.utils.exception.CloudRuntimeException;
34 |
35 | @PrepareForTest(ThreadUtils.class)
36 | @RunWith(PowerMockRunner.class)
37 | public class ThreadUtilsTest {
38 |
39 | private final static long ONE_SECOND_IN_MILLISECONDS = 1000l;
40 | private ThreadUtils spy;
41 |
42 | @Before
43 | public void setup() {
44 | spy = Mockito.spy(new ThreadUtils());
45 | PowerMockito.mockStatic(Thread.class);
46 | }
47 |
48 | @Test
49 | public void sleepThreadTest() throws InterruptedException {
50 | PowerMockito.doNothing().when(Thread.class);
51 | Thread.sleep(Mockito.anyLong());
52 |
53 | spy.sleepThread(2);
54 |
55 | PowerMockito.verifyStatic();
56 | Thread.sleep(Mockito.eq(2 * ONE_SECOND_IN_MILLISECONDS));
57 | }
58 |
59 | @Test(expected = CloudRuntimeException.class)
60 | public void sleepThreadTestCatchInterruptedException() throws InterruptedException {
61 |
62 | PowerMockito.doThrow(new InterruptedException()).when(Thread.class);
63 | Thread.sleep(Mockito.anyLong());
64 |
65 | spy.sleepThread(2);
66 |
67 | PowerMockito.verifyStatic();
68 | Thread.sleep(Mockito.eq(2 * ONE_SECOND_IN_MILLISECONDS));
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/starthost-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 | *.classpath
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.jar
31 | *.war
32 | *.ear
33 |
34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35 | hs_err_pid*
36 |
37 | #Eclipse files
38 | .project
39 | .settings/*
--------------------------------------------------------------------------------
/starthost-plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
25 | 4.0.0
26 |
27 | br.com.autonomiccs
28 | autonomic-platform
29 | 1.0.3-SNAPSHOT
30 |
31 | starthost-plugin
32 | 1.0.3-SNAPSHOT
33 |
34 | starthost-plugin
35 | This project is responsible for intercepting all of the requests to deploy and start virtual machines (VMs) and then ensuring that we have enough resources to those VMs. If there is not enough resource on the environment, it will activated hosts that were deactivated before, to ensure that the VMs can be started.
36 |
37 |
38 |
39 | br.com.autonomiccs
40 | autonomic-plugin-common
41 | ${project.version}
42 |
43 |
44 | br.com.autonomiccs
45 | autonomic-allocation-algorithms
46 | ${project.version}
47 |
48 |
49 |
50 |
51 | org.apache.cloudstack
52 | cloud-engine-schema
53 | ${cloudstackVersion}
54 | provided
55 |
56 |
57 | org.apache.cloudstack
58 | cloud-engine-components-api
59 | ${cloudstackVersion}
60 | provided
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/starthost-plugin/src/main/java/br/com/autonomiccs/starthost/plugin/proxies/ScanDirectAgentToLoadMethodInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.starthost.plugin.proxies;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | import org.aopalliance.intercept.MethodInterceptor;
29 | import org.aopalliance.intercept.MethodInvocation;
30 | import org.apache.commons.collections.CollectionUtils;
31 | import org.springframework.beans.factory.InitializingBean;
32 | import org.springframework.beans.factory.annotation.Autowired;
33 | import org.springframework.stereotype.Component;
34 |
35 | import com.cloud.host.HostVO;
36 |
37 | import br.com.autonomiccs.autonomic.plugin.common.services.HostService;
38 |
39 | @Component
40 | public class ScanDirectAgentToLoadMethodInterceptor implements MethodInterceptor, InitializingBean {
41 |
42 | private static ScanDirectAgentToLoadMethodInterceptor scanDirectAgentToLoadMethodInterceptor;
43 |
44 | @Autowired
45 | private HostService hostService;
46 |
47 | @Override
48 | public Object invoke(MethodInvocation methodInvocation) throws Throwable {
49 | Object result = methodInvocation.proceed();
50 | if(result == null){
51 | return result;
52 | }
53 | @SuppressWarnings("unchecked")
54 | List hosts = (List)result;
55 | if (CollectionUtils.isEmpty(hosts)) {
56 | return hosts;
57 | }
58 | List onlyActiveHosts = new ArrayList<>();
59 | for (HostVO host : hosts) {
60 | if(hostService.isHostDown(host.getId())){
61 | continue;
62 | }
63 | onlyActiveHosts.add(host);
64 | }
65 | return onlyActiveHosts;
66 | }
67 |
68 | @Override
69 | public void afterPropertiesSet() throws Exception {
70 | scanDirectAgentToLoadMethodInterceptor = this;
71 | }
72 |
73 | public static ScanDirectAgentToLoadMethodInterceptor getScanDirectAgentToLoadMethodInterceptor() {
74 | return scanDirectAgentToLoadMethodInterceptor;
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/starthost-plugin/src/main/java/br/com/autonomiccs/starthost/plugin/proxies/ScanDirectAgentToLoadMethodInterceptorWorkAroundForProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.starthost.plugin.proxies;
24 |
25 | import org.aopalliance.intercept.MethodInterceptor;
26 | import org.aopalliance.intercept.MethodInvocation;
27 |
28 | public class ScanDirectAgentToLoadMethodInterceptorWorkAroundForProxy implements MethodInterceptor {
29 |
30 | @Override
31 | public Object invoke(MethodInvocation invocation) throws Throwable {
32 | return ScanDirectAgentToLoadMethodInterceptor.getScanDirectAgentToLoadMethodInterceptor().invoke(invocation);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/starthost-plugin/src/main/java/br/com/autonomiccs/starthost/plugin/proxies/StartHostMethodInterceptorWorkAroundForProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.starthost.plugin.proxies;
24 |
25 | import org.aopalliance.intercept.MethodInterceptor;
26 | import org.aopalliance.intercept.MethodInvocation;
27 | import org.apache.log4j.Logger;
28 | import org.springframework.beans.factory.InitializingBean;
29 |
30 | public class StartHostMethodInterceptorWorkAroundForProxy implements MethodInterceptor, InitializingBean {
31 |
32 | private final Logger logger = Logger.getLogger(getClass());
33 |
34 | @Override
35 | public void afterPropertiesSet() throws Exception {
36 | logger.info("Start host proxy workaround initialized.");
37 | }
38 |
39 | @Override
40 | public Object invoke(MethodInvocation invocation) throws Throwable {
41 | return StartHostMethodInterceptor.getStartHostMethodInterceptor().invoke(invocation);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/starthost-plugin/src/main/resources/META-INF/cloudstack/starthost/module.properties:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 | name=starthost
22 | parent=autonomiccsPlugins
--------------------------------------------------------------------------------
/starthost-plugin/src/main/resources/META-INF/cloudstack/starthost/spring-starthost-context.xml:
--------------------------------------------------------------------------------
1 |
23 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/starthost-plugin/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 | server.port: 8080
22 |
23 | logging.file: /var/log/StartUp.log
24 | logging.config: log4j.properties
25 |
26 |
--------------------------------------------------------------------------------
/starthost-plugin/src/main/resources/id_rsa.ppk:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | 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
51 | -----END RSA PRIVATE KEY-----
52 |
--------------------------------------------------------------------------------
/starthost-plugin/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 | log4j.rootLogger=INFO,ConsoleAppender,FileAppender
22 |
23 | log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
24 | log4j.appender.ConsoleAppender.layout=org.apache.log4j.PatternLayout
25 | log4j.appender.ConsoleAppender.layout.ConversionPattern=%-7p %d [%t] %c [%X{userName}] [%X{accessToken}] - %m%n
26 |
27 | log4j.appender.FileAppender=org.apache.log4j.RollingFileAppender
28 | log4j.appender.FileAppender.File=/var/log/StartUp.log
29 | log4j.appender.FileAppender.layout=org.apache.log4j.PatternLayout
30 | log4j.appender.FileAppender.layout.ConversionPattern=%-7p %d [%t] %c [%X{userName}] [%X{accessToken}] - %m%n
--------------------------------------------------------------------------------
/starthost-plugin/src/main/resources/startup:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | # /etc/init.d/startup
3 |
4 | # This program is part of Autonomiccs "autonomic-platform",
5 | # an open source autonomic cloud computing management platform.
6 | # Copyright (C) 2016 Autonomiccs, Inc.
7 | #
8 | # Licensed to the Autonomiccs, Inc. under one
9 | # or more contributor license agreements. See the NOTICE file
10 | # distributed with this work for additional information
11 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
12 | # to you under the Apache License, Version 2.0 (the
13 | # "License"); you may not use this file except in compliance
14 | # with the License. You may obtain a copy of the License at
15 | #
16 | # http://www.apache.org/licenses/LICENSE-2.0
17 | #
18 | # Unless required by applicable law or agreed to in writing,
19 | # software distributed under the License is distributed on an
20 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 | # KIND, either express or implied. See the License for the
22 | # specific language governing permissions and limitations
23 | # under the License.
24 |
25 | case "$1" in
26 | start)
27 | java -jar /root/startupHost.jar
28 | ;;
29 | stop)
30 | ;;
31 | *)
32 | echo "Usage: /etc/init.d/startup {start|stop}"
33 | exit 1
34 | ;;
35 | esac
36 |
37 | exit 0
38 |
39 |
--------------------------------------------------------------------------------
/tools/figures/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/figures/Thumbs.db
--------------------------------------------------------------------------------
/tools/figures/balancing.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/figures/balancing.jpg
--------------------------------------------------------------------------------
/tools/figures/consolidation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/figures/consolidation.jpg
--------------------------------------------------------------------------------
/tools/figures/consolidationManagers.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/figures/consolidationManagers.odg
--------------------------------------------------------------------------------
/tools/figures/frameworkComponents.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/figures/frameworkComponents.odg
--------------------------------------------------------------------------------
/tools/figures/managementAgents.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/figures/managementAgents.jpg
--------------------------------------------------------------------------------
/tools/figures/scenarios.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/figures/scenarios.odg
--------------------------------------------------------------------------------
/tools/project-logo/AutonomiccsProjectFirstFace.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/project-logo/AutonomiccsProjectFirstFace.png
--------------------------------------------------------------------------------
/tools/project-logo/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/project-logo/Thumbs.db
--------------------------------------------------------------------------------
/tools/project-logo/a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/project-logo/a.png
--------------------------------------------------------------------------------
/tools/project-logo/autonomiccs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/project-logo/autonomiccs.png
--------------------------------------------------------------------------------
/tools/project-logo/autonomiccsText.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/project-logo/autonomiccsText.png
--------------------------------------------------------------------------------
/tools/project-logo/autonomiccsWhite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Autonomiccs/autonomiccs-platform/98fa5be6748c20fc5a78ed8bfa86989b4c3180c1/tools/project-logo/autonomiccsWhite.png
--------------------------------------------------------------------------------
/tools/scripts/build/buildAutonomiccs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This program is part of Autonomiccs "autonomic-platform",
3 | # an open source autonomic cloud computing management platform.
4 | # Copyright (C) 2016 Autonomiccs, Inc.
5 | #
6 | # Licensed to the Autonomiccs, Inc. under one
7 | # or more contributor license agreements. See the NOTICE file
8 | # distributed with this work for additional information
9 | # regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | # to you under the Apache License, Version 2.0 (the
11 | # "License"); you may not use this file except in compliance
12 | # with the License. You may obtain a copy of the License at
13 | #
14 | # http://www.apache.org/licenses/LICENSE-2.0
15 | #
16 | # Unless required by applicable law or agreed to in writing,
17 | # software distributed under the License is distributed on an
18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | # KIND, either express or implied. See the License for the
20 | # specific language governing permissions and limitations
21 | # under the License.
22 |
23 | ###########################################################################################################
24 | ## This script is used to build Autonomiccs platform.
25 | ## It assumes that you have the dependencies of CloudStack that it uses already installed in your maven local repository.
26 | ###########################################################################################################
27 |
28 | CLOUDSTACK_DEPENDENCY_PATH="org/apache/cloudstack"
29 | MAVEN_REPOSITORY_PATH=$(mvn help:evaluate -Dexpression=settings.localRepository | grep -v '\[INFO\]')
30 |
31 | [ ! -d "$MAVEN_REPOSITORY_PATH/$CLOUDSTACK_DEPENDENCY_PATH" ] && echo 'We could not find the CloudStack jars directory ' && echo "you should first build the CloudStack, then the Autonomiccs platform" && exit 1
32 | CURRENT_DIR=$(pwd)
33 |
34 | if [[ "$CURRENT_DIR" == *build ]]
35 | then
36 | cd ../../../
37 | echo "Starting the build of the Autonomiccs platform using Maven"
38 | mvn clean install
39 | else
40 | echo "You should execute the build script within the build folder."
41 | exit 1
42 | fi
43 |
--------------------------------------------------------------------------------
/tools/scripts/build/emailTemplate/releaseNewVersionTemplate:
--------------------------------------------------------------------------------
1 | The release of autonomiccs-platform version #version is closed.
2 | Autonomiccs community thank you all for your effort and time that were used to create the autonomiccs-platform (#version).
3 | Today (#date), I (Jenkins) have just finished the release process, and the autonomiccs-platform #version was closed and released.
4 | Thank you again, and congratulations to everybody that worked toward this new release.
5 |
6 | The autonomiccs-platform #version was closed with the commit #commitId.
7 | Also, the zip containing the version is available at: http://builds.autonomiccs.com.br/stables/autonomiccsPlatformInstallationPackage-#version.zip
8 | For your convenience, the CHANGELOG was attached as a PDF in this e-mail.
9 |
10 | --
11 | Jenkins
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/autonomiccsJars/moveJars.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This program is part of Autonomiccs "autonomic-platform",
3 | # an open source autonomic cloud computing management platform.
4 | # Copyright (C) 2016 Autonomiccs, Inc.
5 | #
6 | # Licensed to the Autonomiccs, Inc. under one
7 | # or more contributor license agreements. See the NOTICE file
8 | # distributed with this work for additional information
9 | # regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | # to you under the Apache License, Version 2.0 (the
11 | # "License"); you may not use this file except in compliance
12 | # with the License. You may obtain a copy of the License at
13 | #
14 | # http://www.apache.org/licenses/LICENSE-2.0
15 | #
16 | # Unless required by applicable law or agreed to in writing,
17 | # software distributed under the License is distributed on an
18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | # KIND, either express or implied. See the License for the
20 | # specific language governing permissions and limitations
21 | # under the License.
22 |
23 | # Autonomiccs jars
24 | cp autonomiccsJars/autonomic*.jar /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/
25 | cp autonomiccsJars/starthost-plugin*.jar /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/
26 |
27 | # Autonomiccs platform dependencies.
28 | cp autonomiccsJars/dependencies/*.jar /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/
29 |
30 | # Creation of a folder to hold the jar files that needs to get transfered to VMs.
31 | baseAutonomiccsJarFolder="/var/lib/autonomiccs/jars/";
32 |
33 | wakeOnLanFolder="${baseAutonomiccsJarFolder}wakeonlan/";
34 |
35 | wakeOnLanFileName="wakeonlan-service";
36 |
37 | wakeOnLanRegex="autonomiccsJars/$wakeOnLanFileName-*.jar";
38 |
39 | mkdir -p $wakeOnLanFolder;
40 |
41 | cp $wakeOnLanRegex "$wakeOnLanFolder$wakeOnLanNewFileName.jar";
42 |
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/autonomiccsJars/removeJars.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This program is part of Autonomiccs "autonomic-platform",
3 | # an open source autonomic cloud computing management platform.
4 | # Copyright (C) 2016 Autonomiccs, Inc.
5 | #
6 | # Licensed to the Autonomiccs, Inc. under one
7 | # or more contributor license agreements. See the NOTICE file
8 | # distributed with this work for additional information
9 | # regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | # to you under the Apache License, Version 2.0 (the
11 | # "License"); you may not use this file except in compliance
12 | # with the License. You may obtain a copy of the License at
13 | #
14 | # http://www.apache.org/licenses/LICENSE-2.0
15 | #
16 | # Unless required by applicable law or agreed to in writing,
17 | # software distributed under the License is distributed on an
18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | # KIND, either express or implied. See the License for the
20 | # specific language governing permissions and limitations
21 | # under the License.
22 |
23 | # Removing Autonomiccs jars
24 | rm -f /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/autonomic*.jar;
25 | rm -f /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/starthost-plugin*.jar
26 |
27 | # Removing Autonomiccs dependencies
28 | rm -f /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/commons-math3-3.6.jar
29 | rm -f /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/spring-jdbc-3.2.12.RELEASE.jar;
30 | rm -f /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/spring-integration-core-3.0.7.RELEASE.jar;
31 | rm -f /usr/share/cloudstack-management/webapps/client/WEB-INF/lib/spring-tx-3.2.12.RELEASE.jar;
32 |
33 | # Removing Autonomiccs jars that are sent to VMs
34 | rm -f /var/lib/autonomiccs
35 |
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/id_rsa:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | 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
51 | -----END RSA PRIVATE KEY-----
52 |
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This program is part of Autonomiccs "autonomic-platform",
3 | # an open source autonomic cloud computing management platform.
4 | # Copyright (C) 2016 Autonomiccs, Inc.
5 | #
6 | # Licensed to the Autonomiccs, Inc. under one
7 | # or more contributor license agreements. See the NOTICE file
8 | # distributed with this work for additional information
9 | # regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | # to you under the Apache License, Version 2.0 (the
11 | # "License"); you may not use this file except in compliance
12 | # with the License. You may obtain a copy of the License at
13 | #
14 | # http://www.apache.org/licenses/LICENSE-2.0
15 | #
16 | # Unless required by applicable law or agreed to in writing,
17 | # software distributed under the License is distributed on an
18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | # KIND, either express or implied. See the License for the
20 | # specific language governing permissions and limitations
21 | # under the License.
22 | ##########################################################################################################
23 | ## This script needs the program called "jar", it comes with the JDK.
24 | ## Be sure to export/install it properly before executing this script
25 | ##########################################################################################################
26 |
27 | preffixParam1="CloudStack is running, please stop the CloudStack service before installing Autonomiccs platform!";
28 | preffixParam2="Install aborted!";
29 | ./scriptPreffix.sh $preffixParam1 $preffixParam2 || exit 1;
30 |
31 | echo "Installing ...";
32 |
33 | SPRINGXML="META-INF/cloudstack/bootstrap/spring-bootstrap-context-inheritable.xml";
34 |
35 | echo "CloudStack jars files are in the default directory [/usr/share/cloudstack-management/webapps/client/WEB-INF/lib/]? (y/n)"
36 | read USERINPUT;
37 | if [ $USERINPUT == "y" ]; then
38 | CSDIR="/usr/share/cloudstack-management/webapps/client/WEB-INF/lib/";
39 | else
40 | echo "Please insert a directory path that the CloudStack jars are located";
41 | read CSDIR;
42 | fi
43 | if [ ! -d "$CSDIR" ]; then
44 | echo "Directory [$CSDIR] does not exist!";
45 | exit 1;
46 | fi
47 |
48 | echo "Working on directory [$CSDIR]";
49 |
50 | CLOUDCORE=$(ls $CSDIR | grep cloud-core);
51 | if [ -z $CLOUDCORE ]; then
52 | echo "Could not find any jar named cloud-core in the given path [$CSDIR]!";
53 | exit 1;
54 | fi
55 |
56 | echo "Copying a backup file of [$CSDIR$CLOUDCORE] file to the current directory";
57 | cp $CSDIR$CLOUDCORE $CLOUDCORE || exit 1;
58 | cp $CLOUDCORE $CLOUDCORE.bkp || exit 1;
59 |
60 | jar uf $CLOUDCORE $SPRINGXML || exit 1;
61 | chmod 644 $CLOUDCORE || exit 1;
62 |
63 | cp $CLOUDCORE $CSDIR$CLOUDCORE;
64 |
65 | chmod u+x autonomiccsJars/moveJars.sh || exit 1;
66 | autonomiccsJars/moveJars.sh || exit 1;
67 |
68 | echo "Autonomiccs platform installed with success!";
69 |
70 |
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/removeReferencesOnCloudStackDB.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This program is part of Autonomiccs "autonomic-platform",
3 | # an open source autonomic cloud computing management platform.
4 | # Copyright (C) 2016 Autonomiccs, Inc.
5 | #
6 | # Licensed to the Autonomiccs, Inc. under one
7 | # or more contributor license agreements. See the NOTICE file
8 | # distributed with this work for additional information
9 | # regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | # to you under the Apache License, Version 2.0 (the
11 | # "License"); you may not use this file except in compliance
12 | # with the License. You may obtain a copy of the License at
13 | #
14 | # http://www.apache.org/licenses/LICENSE-2.0
15 | #
16 | # Unless required by applicable law or agreed to in writing,
17 | # software distributed under the License is distributed on an
18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | # KIND, either express or implied. See the License for the
20 | # specific language governing permissions and limitations
21 | # under the License.
22 |
23 | echo "Removing Autonomiccs platform data and data-structure (tables, columns and rows) of the the ACS database";
24 |
25 | echo "Please inform the ACS database host-name";
26 | read HOST;
27 |
28 | echo "Please inform the ACS database port.";
29 | read PORT;
30 |
31 | echo "Please inform the database user";
32 | read USER;
33 |
34 | echo "Please inform the database password";
35 | read PASSWORD;
36 |
37 | IPS=$(mysql -N -h "$HOST" -P "$PORT" -u "$USER" "-p$PASSWORD" --delimiter="//" "cloud" < "selectSystemVMsIPs.sql");
38 | echo "System VMs IPs:";
39 | echo "$IPS";
40 | for IP in $IPS
41 | do
42 | echo "Shuting down System VM [ip=$IP]";
43 | ssh -oStrictHostKeyChecking=no -i id_rsa root@$IP 'halt -p'
44 | done
45 | mysql -h "$HOST" -P "$PORT" -u "$USER" "-p$PASSWORD" "cloud" < "removeSelectProcedure.sql";
46 | mysql -h "$HOST" -P "$PORT" -u "$USER" "-p$PASSWORD" --delimiter="//" "cloud" < "removeCsDatabaseReferences.sql";
47 | if [ "$?" -eq 0 ]; then
48 | echo "Autonomiccs platform references of the ACS database have been removed!";
49 | else
50 | echo "Failed to execute removeCsDatabaseReferences.sql query to remove Autonomiccs platform database structures!";
51 | exit 1;
52 | fi
53 |
54 | exit 0;
55 |
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/removeSelectProcedure.sql:
--------------------------------------------------------------------------------
1 | -- This program is part of Autonomiccs "autonomic-platform",
2 | -- an open source autonomic cloud computing management platform.
3 | -- Copyright (C) 2016 Autonomiccs, Inc.
4 | --
5 | -- Licensed to the Autonomiccs, Inc. under one
6 | -- or more contributor license agreements. See the NOTICE file
7 | -- distributed with this work for additional information
8 | -- regarding copyright ownership. The Autonomiccs, Inc. licenses this file
9 | -- to you under the Apache License, Version 2.0 (the
10 | -- "License"); you may not use this file except in compliance
11 | -- with the License. You may obtain a copy of the License at
12 | --
13 | -- http://www.apache.org/licenses/LICENSE-2.0
14 | --
15 | -- Unless required by applicable law or agreed to in writing,
16 | -- software distributed under the License is distributed on an
17 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | -- KIND, either express or implied. See the License for the
19 | -- specific language governing permissions and limitations
20 | -- under the License.
21 |
22 | DROP PROCEDURE select_system_VMs;
23 |
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/scriptPreffix.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This program is part of Autonomiccs "autonomic-platform",
3 | # an open source autonomic cloud computing management platform.
4 | # Copyright (C) 2016 Autonomiccs, Inc.
5 | #
6 | # Licensed to the Autonomiccs, Inc. under one
7 | # or more contributor license agreements. See the NOTICE file
8 | # distributed with this work for additional information
9 | # regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | # to you under the Apache License, Version 2.0 (the
11 | # "License"); you may not use this file except in compliance
12 | # with the License. You may obtain a copy of the License at
13 | #
14 | # http://www.apache.org/licenses/LICENSE-2.0
15 | #
16 | # Unless required by applicable law or agreed to in writing,
17 | # software distributed under the License is distributed on an
18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | # KIND, either express or implied. See the License for the
20 | # specific language governing permissions and limitations
21 | # under the License.
22 |
23 | if [ "$EUID" -ne 0 ] then
24 | echo "Please run as root";
25 | exit 1;
26 | fi
27 |
28 | CSSTATUS=$(service cloudstack-management status);
29 | if [[ $CSSTATUS == *"is running"* ]]; then
30 | echo $1;
31 | echo $2;
32 | exit 1;
33 | fi
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/selectSystemVMsIPs.sql:
--------------------------------------------------------------------------------
1 | -- This program is part of Autonomiccs "autonomic-platform",
2 | -- an open source autonomic cloud computing management platform.
3 | -- Copyright (C) 2016 Autonomiccs, Inc.
4 | --
5 | -- Licensed to the Autonomiccs, Inc. under one
6 | -- or more contributor license agreements. See the NOTICE file
7 | -- distributed with this work for additional information
8 | -- regarding copyright ownership. The Autonomiccs, Inc. licenses this file
9 | -- to you under the Apache License, Version 2.0 (the
10 | -- "License"); you may not use this file except in compliance
11 | -- with the License. You may obtain a copy of the License at
12 | --
13 | -- http://www.apache.org/licenses/LICENSE-2.0
14 | --
15 | -- Unless required by applicable law or agreed to in writing,
16 | -- software distributed under the License is distributed on an
17 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | -- KIND, either express or implied. See the License for the
19 | -- specific language governing permissions and limitations
20 | -- under the License.
21 |
22 | CREATE PROCEDURE select_system_VMs() BEGIN
23 | IF EXISTS( SELECT * FROM information_schema.COLUMNS WHERE table_name = 'AutonomiccsSystemVm' AND column_name = 'management_ip_address' and table_schema ='cloud' )
24 | THEN
25 | SELECT management_ip_address FROM AutonomiccsSystemVm WHERE management_ip_address IS NOT NULL;
26 | ELSE
27 | select c.id as management_ip_address from cluster c where 1=0;
28 | END IF;
29 | END;
30 |
31 | CALL select_system_VMs();
32 |
--------------------------------------------------------------------------------
/tools/scripts/build/templateInstallationPackage/unistall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This program is part of Autonomiccs "autonomic-platform",
3 | # an open source autonomic cloud computing management platform.
4 | # Copyright (C) 2016 Autonomiccs, Inc.
5 | #
6 | # Licensed to the Autonomiccs, Inc. under one
7 | # or more contributor license agreements. See the NOTICE file
8 | # distributed with this work for additional information
9 | # regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | # to you under the Apache License, Version 2.0 (the
11 | # "License"); you may not use this file except in compliance
12 | # with the License. You may obtain a copy of the License at
13 | #
14 | # http://www.apache.org/licenses/LICENSE-2.0
15 | #
16 | # Unless required by applicable law or agreed to in writing,
17 | # software distributed under the License is distributed on an
18 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | # KIND, either express or implied. See the License for the
20 | # specific language governing permissions and limitations
21 | # under the License.
22 |
23 | preffixParam1="CloudStack is running, please stop the CloudStack service before being able to uninstall Autonomiccs platform!";
24 | preffixParam2="Uninstall aborted!";
25 | ./scriptPreffix.sh $preffixParam1 $preffixParam2 || exit 1;
26 |
27 | echo "Uninstalling ...";
28 | echo "CloudStack jars files are in the default directory [/usr/share/cloudstack-management/webapps/client/WEB-INF/lib/]? (y/n)"
29 | read USERINPUT
30 | if [[ $USERINPUT == "y" ]]; then
31 | CSDIR="/usr/share/cloudstack-management/webapps/client/WEB-INF/lib/";
32 | else
33 | echo "Please insert a directory path that the CloudStack classpath jars are located.";
34 | read CSDIR;
35 | fi
36 | if [ ! -d "$CSDIR" ]; then
37 | echo "Directory [$CSDI] doesn't exist!";
38 | echo "Uninstall aborted!"
39 | exit 1;
40 | fi
41 |
42 | echo "Working on directory [$CSDIR]";
43 |
44 | BASEDIR=$(pwd);
45 | CLOUDCOREBackUp=$(ls cloud-core*.bkp);
46 | CloudCoreOriginalName=$(ls $CSDIR | grep cloud-core);
47 | if [[ -z $CLOUDCOREBackUp ]]; then
48 | echo "Could not find any backup of the cloud-core jar at path [$BASEDIR]!";
49 | exit 1;
50 | fi
51 | echo "Moving the $CLOUDCOREBackUp jar file to [$CSDIR]";
52 | cp $CLOUDCOREBackUp $CSDIR$CloudCoreOriginalName || exit 1;
53 |
54 | echo "Removing all Autonomiccs platform jars from [$CSDIR]";
55 | chmod u+x autonomiccsJars/removeJars.sh || exit 1;
56 | autonomiccsJars/removeJars.sh || exit 1;
57 |
58 | chmod u+x removeReferencesOnCloudStackDB.sh;
59 | ./removeReferencesOnCloudStackDB.sh || exit 1;
60 |
61 | echo "The uninstall of Autonomiccs platform was complete with success.";
62 |
63 |
--------------------------------------------------------------------------------
/wakeonlan-service/.gitignore:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The ASF licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http:www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 |
22 | /target/
23 | *.class
24 | *.classpath
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.jar
31 | *.war
32 | *.ear
33 |
34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35 | hs_err_pid*
36 |
37 | #Eclipse files
38 | .project
39 | .settings/*
--------------------------------------------------------------------------------
/wakeonlan-service/application.yml:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 | server.port: 8080
22 |
23 | logging.file: /var/log/StartUp.log
24 | logging.config: log4j.properties
25 |
26 |
--------------------------------------------------------------------------------
/wakeonlan-service/log4j.properties:
--------------------------------------------------------------------------------
1 | # This program is part of Autonomiccs "autonomic-platform",
2 | # an open source autonomic cloud computing management platform.
3 | # Copyright (C) 2016 Autonomiccs, Inc.
4 | #
5 | # Licensed to the Autonomiccs, Inc. under one
6 | # or more contributor license agreements. See the NOTICE file
7 | # distributed with this work for additional information
8 | # regarding copyright ownership. The The Autonomiccs, Inc. licenses this file
9 | # to you under the Apache License, Version 2.0 (the
10 | # "License"); you may not use this file except in compliance
11 | # with the License. You may obtain a copy of the License at
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 | # Unless required by applicable law or agreed to in writing,
16 | # software distributed under the License is distributed on an
17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | # KIND, either express or implied. See the License for the
19 | # specific language governing permissions and limitations
20 | # under the License.
21 | log4j.rootLogger=INFO,ERROR,ConsoleAppender,FileAppender
22 |
23 | log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
24 | log4j.appender.ConsoleAppender.layout=org.apache.log4j.PatternLayout
25 | log4j.appender.ConsoleAppender.layout.ConversionPattern=%-7p %d [%t] %c [%X{userName}] [%X{accessToken}] - %m%n
26 |
27 | log4j.appender.FileAppender=org.apache.log4j.RollingFileAppender
28 | log4j.appender.FileAppender.File=/var/log/StartUp.log
29 | log4j.appender.FileAppender.layout=org.apache.log4j.PatternLayout
30 | log4j.appender.FileAppender.layout.ConversionPattern=%-7p %d [%t] %c [%X{userName}] [%X{accessToken}] - %m%n
--------------------------------------------------------------------------------
/wakeonlan-service/src/main/java/br/com/autonomiccs/wakeonlan/controller/WakeOnLanServiceEndPoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.controller;
24 |
25 | import javax.ws.rs.GET;
26 | import javax.ws.rs.Path;
27 | import javax.ws.rs.PathParam;
28 |
29 | import org.slf4j.Logger;
30 | import org.slf4j.LoggerFactory;
31 | import org.springframework.beans.factory.annotation.Autowired;
32 | import org.springframework.stereotype.Component;
33 |
34 | import br.com.autonomiccs.wakeonlan.services.WakeOnLanHostService;
35 |
36 | /**
37 | * This class listens the /boot/wakeonlan/macaddress endpoint url
38 | * and calls the {@link WakeOnLanHostService} when endpoint is accessed
39 | */
40 | @Path("/")
41 | @Component
42 | public class WakeOnLanServiceEndPoint {
43 |
44 | @Autowired
45 | private WakeOnLanHostService startHostService;
46 |
47 | private final Logger logger = LoggerFactory.getLogger(this.getClass());
48 |
49 | /**
50 | * It executes the Wake on LAN command in the virtual machine to start up
51 | * the host specified by MAC.
52 | *
53 | * @param mac
54 | * The MAC address of the host that you will wake up
55 | * @return
56 | * A String
that contains the result text from wake on lan
57 | */
58 | @GET
59 | @Path("wakeonlan/{mac}")
60 | public String startHost(@PathParam("mac") String mac) {
61 | logger.info("Waking up host: " + mac);
62 | return startHostService.startHost(mac);
63 | }
64 | }
--------------------------------------------------------------------------------
/wakeonlan-service/src/main/java/br/com/autonomiccs/wakeonlan/initialization/InicializeSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.initialization;
24 |
25 | import org.springframework.boot.SpringApplication;
26 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
27 | import org.springframework.boot.autoconfigure.SpringBootApplication;
28 | import org.springframework.context.ConfigurableApplicationContext;
29 | import org.springframework.context.annotation.Bean;
30 | import org.springframework.context.annotation.ComponentScan;
31 | import org.springframework.context.annotation.Configuration;
32 |
33 | import br.com.autonomiccs.autonomic.plugin.common.utils.ShellCommandUtils;
34 |
35 | /**
36 | * This class initializes and configures the application
37 | */
38 |
39 | @Configuration
40 | @SpringBootApplication
41 | @EnableAutoConfiguration
42 | @ComponentScan("br.com.autonomiccs.wakeonlan")
43 | public class InicializeSystem {
44 |
45 | public static void main(String[] args) {
46 | ConfigurableApplicationContext applicationContext = SpringApplication.run(InicializeSystem.class, args);
47 | applicationContext.close();
48 | }
49 |
50 | /**
51 | * It creates a {@link ShellCommandUtils} object
52 | *
53 | * @return {@link ShellCommandUtils}
54 | */
55 | @Bean
56 | public ShellCommandUtils createShellCommandUtils() {
57 | return new ShellCommandUtils();
58 | }
59 | }
--------------------------------------------------------------------------------
/wakeonlan-service/src/main/java/br/com/autonomiccs/wakeonlan/installation/WakeOnLanInstallation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.installation;
24 |
25 | import java.io.File;
26 |
27 | import org.slf4j.Logger;
28 | import org.slf4j.LoggerFactory;
29 | import org.springframework.beans.factory.InitializingBean;
30 | import org.springframework.beans.factory.annotation.Autowired;
31 | import org.springframework.stereotype.Component;
32 |
33 | import br.com.autonomiccs.autonomic.plugin.common.utils.ShellCommandUtils;
34 |
35 | /**
36 | * This class have the necessary methods to install the wake on LAN command in the host
37 | */
38 | @Component
39 | public class WakeOnLanInstallation implements InitializingBean {
40 |
41 | protected Logger logger = LoggerFactory.getLogger(this.getClass());
42 |
43 | @Autowired
44 | protected ShellCommandUtils shellCommandUtils;
45 |
46 | private final String wakeOnLanCommand = "/usr/bin/wakeonlan";
47 |
48 | private final String aptitudeInstallWakeOnLan = "aptitude -y install wakeonlan";
49 |
50 | /**
51 | * It tries to install the wake on LAN program in the host;
52 | * if the wake on LAN is already installed, it does nothing, otherwise it installs the wake on
53 | * LAN.
54 | */
55 | protected void installWakeOnLan() {
56 | logger.info("Checking if wakeonlan is installed.");
57 | File file = new File(wakeOnLanCommand);
58 | boolean isWakeOnLanInstalled = file.exists();
59 | if (isWakeOnLanInstalled) {
60 | logger.info("Wakeonlan is already installed.");
61 | return;
62 | }
63 | logger.info("Wakeonlan is not installed.");
64 | logger.info("Installing wakeonlan.");
65 | String logInstallation = shellCommandUtils.executeCommand(String.format("%s", aptitudeInstallWakeOnLan));
66 | logger.info(logInstallation);
67 | logger.info("Installation finished.");
68 | }
69 |
70 | @Override
71 | public void afterPropertiesSet() throws Exception {
72 | installWakeOnLan();
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/wakeonlan-service/src/main/java/br/com/autonomiccs/wakeonlan/jersey/JerseyConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.jersey;
24 |
25 | import javax.ws.rs.ApplicationPath;
26 |
27 | import org.glassfish.jersey.server.ResourceConfig;
28 | import org.springframework.stereotype.Component;
29 |
30 | /**
31 | * This class provides the package(s) in which the rest resources are.
32 | */
33 | @Component
34 | @ApplicationPath("/boot")
35 | public class JerseyConfig extends ResourceConfig {
36 | public JerseyConfig() {
37 | this.packages("br.com.autonomiccs.wakeonlan.controller");
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/wakeonlan-service/src/main/java/br/com/autonomiccs/wakeonlan/services/WakeOnLanHostService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.services;
24 |
25 | import org.springframework.beans.factory.annotation.Autowired;
26 | import org.springframework.stereotype.Service;
27 |
28 | import br.com.autonomiccs.autonomic.plugin.common.utils.ShellCommandUtils;
29 |
30 | /**
31 | * This class executes the wake on LAN command line in the virtual
32 | * machine that runs this application
33 | */
34 | @Service
35 | public class WakeOnLanHostService {
36 |
37 | @Autowired
38 | protected ShellCommandUtils shellCommandUtils;
39 |
40 | private final String wakeOnLanCommand = "/usr/bin/wakeonlan";
41 |
42 | /**
43 | * It executes the Wake on LAN command in the virtual machine to start up
44 | * the host that has the given MAC.
45 | *
46 | * @param mac
47 | * The MAC address of the machine to wake up
48 | * @return
49 | * A String
that contains the result text from wake on LAN command
50 | */
51 | public String startHost(String mac) {
52 | return shellCommandUtils.executeCommand(String.format("%s %s", wakeOnLanCommand, mac));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/wakeonlan-service/src/test/java/br/com/autonomiccs/wakeonlan/controller/WakeOnLanServiceEndPointTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.controller;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.mockito.InjectMocks;
29 | import org.mockito.Mockito;
30 | import org.mockito.Spy;
31 | import org.mockito.runners.MockitoJUnitRunner;
32 |
33 | import br.com.autonomiccs.wakeonlan.services.WakeOnLanHostService;
34 |
35 | @RunWith(MockitoJUnitRunner.class)
36 | public class WakeOnLanServiceEndPointTest {
37 |
38 | @InjectMocks
39 | private WakeOnLanServiceEndPoint wakeOnLanServiceEndPoint;
40 | @Spy
41 | private WakeOnLanHostService startHostService;
42 |
43 | @Test
44 | public void consultarTest() {
45 | String macTest = "mac teste";
46 | String returnExpected = "ok";
47 | Mockito.doReturn(returnExpected).when(startHostService).startHost(Mockito.anyString());
48 |
49 | String returnOfCommand = wakeOnLanServiceEndPoint.startHost(macTest);
50 |
51 | Assert.assertEquals(returnExpected, returnOfCommand);
52 | Mockito.verify(startHostService).startHost(macTest);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/wakeonlan-service/src/test/java/br/com/autonomiccs/wakeonlan/inicialization/InicializeSystemTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.inicialization;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.powermock.api.mockito.PowerMockito;
29 | import org.powermock.core.classloader.annotations.PrepareForTest;
30 | import org.powermock.modules.junit4.PowerMockRunner;
31 | import org.springframework.boot.SpringApplication;
32 | import org.springframework.context.ConfigurableApplicationContext;
33 |
34 | import br.com.autonomiccs.autonomic.plugin.common.utils.ShellCommandUtils;
35 | import br.com.autonomiccs.wakeonlan.initialization.InicializeSystem;
36 |
37 | @RunWith(PowerMockRunner.class)
38 | @PrepareForTest(SpringApplication.class)
39 | public class InicializeSystemTest {
40 |
41 | @Test
42 | public void createShellCommandUtilsTest() {
43 | InicializeSystem inicializeSystem = new InicializeSystem();
44 | ShellCommandUtils returnedObj = inicializeSystem.createShellCommandUtils();
45 |
46 | Assert.assertNotNull(returnedObj);
47 | Assert.assertEquals(ShellCommandUtils.class, returnedObj.getClass());
48 | }
49 |
50 | @Test
51 | public void mainTest() throws Exception {
52 | String[] args = new String[] {};
53 | ConfigurableApplicationContext context = PowerMockito.mock(ConfigurableApplicationContext.class);
54 | PowerMockito.spy(SpringApplication.class);
55 | PowerMockito.doReturn(context).when(SpringApplication.class, InicializeSystem.class, args);
56 |
57 | InicializeSystem.main(new String[] {});
58 |
59 | PowerMockito.verifyStatic();
60 | SpringApplication.run(InicializeSystem.class, args);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/wakeonlan-service/src/test/java/br/com/autonomiccs/wakeonlan/jersey/JerseyConfigTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.jersey;
24 |
25 | import java.util.Iterator;
26 | import java.util.Set;
27 |
28 | import org.junit.Assert;
29 | import org.junit.Test;
30 | import org.junit.runner.RunWith;
31 | import org.mockito.runners.MockitoJUnitRunner;
32 |
33 | @RunWith(MockitoJUnitRunner.class)
34 | public class JerseyConfigTest {
35 |
36 | @Test
37 | public void jerseyConfigTest() {
38 | JerseyConfig jerseyConfig = new JerseyConfig();
39 | Set> set = jerseyConfig.getClasses();
40 | Iterator> iter = set.iterator();
41 | Assert.assertEquals(1, set.size());
42 | Assert.assertEquals("class br.com.autonomiccs.wakeonlan.controller.WakeOnLanServiceEndPoint", iter.next().toString());
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/wakeonlan-service/src/test/java/br/com/autonomiccs/wakeonlan/services/WakeOnLanHostServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is part of Autonomiccs "autonomic-platform",
3 | * an open source autonomic cloud computing management platform.
4 | * Copyright (C) 2016 Autonomiccs, Inc.
5 | *
6 | * Licensed to the Autonomiccs, Inc. under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The Autonomiccs, Inc. licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 | package br.com.autonomiccs.wakeonlan.services;
24 |
25 | import org.junit.Assert;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.mockito.Mockito;
29 | import org.mockito.runners.MockitoJUnitRunner;
30 |
31 | import br.com.autonomiccs.autonomic.plugin.common.utils.ShellCommandUtils;
32 | import br.com.autonomiccs.wakeonlan.services.WakeOnLanHostService;
33 |
34 | @RunWith(MockitoJUnitRunner.class)
35 | public class WakeOnLanHostServiceTest {
36 |
37 | @Test
38 | public void startHostTest() throws Exception {
39 | String mac = "4f:2e:34:d9:fe:76";
40 | String commandToBeExecuted = String.format("%s %s", "/usr/bin/wakeonlan", mac);
41 |
42 | ShellCommandUtils shellCommandUtils = Mockito.mock(ShellCommandUtils.class);
43 | Mockito.when(shellCommandUtils.executeCommand(commandToBeExecuted)).thenReturn("test");
44 |
45 | WakeOnLanHostService service = new WakeOnLanHostService();
46 | service.shellCommandUtils = shellCommandUtils;
47 |
48 | String commandReturn = service.startHost(mac);
49 |
50 | Assert.assertEquals("test", commandReturn);
51 | Mockito.verify(shellCommandUtils).executeCommand(commandToBeExecuted);
52 | }
53 | }
--------------------------------------------------------------------------------