Skip to content

Commit b464a20

Browse files
author
Jayapal
committed
CLOUDSTACK-4736: Monitoring services in VR
1 parent 8081337 commit b464a20

12 files changed

Lines changed: 822 additions & 35 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.agent.api.to;
18+
19+
import org.apache.cloudstack.api.InternalIdentity;
20+
21+
public class MonitorServiceTO implements InternalIdentity {
22+
long id;
23+
String service;
24+
String processname;
25+
String serviceName;
26+
String servicePath;
27+
String pidFile;
28+
boolean isDefault;
29+
30+
protected MonitorServiceTO() {
31+
}
32+
33+
public MonitorServiceTO (String service, String processname, String serviceName, String servicepath, String pidFile, boolean isDefault) {
34+
this.service = service;
35+
this.processname = processname;
36+
this.serviceName = serviceName;
37+
this.servicePath = servicepath;
38+
this.pidFile = pidFile;
39+
this.isDefault = isDefault;
40+
}
41+
42+
43+
44+
public boolean isDefault() {
45+
return isDefault;
46+
}
47+
48+
public String getPidFile() {
49+
return pidFile;
50+
}
51+
52+
@Override
53+
public long getId() {
54+
return id;
55+
}
56+
57+
58+
public String getService() {
59+
return service;
60+
}
61+
62+
public String getServiceName() {
63+
return serviceName;
64+
}
65+
66+
public String getServicePath() {
67+
return servicePath;
68+
}
69+
70+
public String getProcessname() {
71+
return processname;
72+
}
73+
74+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package com.cloud.network;
19+
import org.apache.cloudstack.acl.ControlledEntity;
20+
import org.apache.cloudstack.api.Identity;
21+
import org.apache.cloudstack.api.InternalIdentity;
22+
23+
24+
/**
25+
* Nic represents one nic on the VM.
26+
*/
27+
public interface MonitoringService extends ControlledEntity, Identity, InternalIdentity {
28+
/**
29+
* @return id in the CloudStack database
30+
*/
31+
enum Service {
32+
Dhcp,
33+
LoadBalancing,
34+
Ssh,
35+
Webserver,
36+
}
37+
long getId();
38+
String getService();
39+
String getServiceName();
40+
String getPidFile();
41+
String getServicePath();
42+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.agent.api.routing;
18+
19+
import java.util.HashSet;
20+
import java.util.List;
21+
import java.util.Set;
22+
import com.cloud.agent.api.to.MonitorServiceTO;
23+
24+
/**
25+
*
26+
* AccessDetails allow different components to put in information about
27+
* how to access the components inside the command.
28+
*/
29+
public class SetMonitorServiceCommand extends NetworkElementCommand {
30+
MonitorServiceTO[] services;
31+
32+
protected SetMonitorServiceCommand() {
33+
}
34+
35+
public SetMonitorServiceCommand(List<MonitorServiceTO> services) {
36+
this.services = services.toArray(new MonitorServiceTO[services.size()]);
37+
}
38+
39+
public MonitorServiceTO[] getRules() {
40+
return services;
41+
}
42+
43+
public String getConfiguration() {
44+
45+
StringBuilder sb = new StringBuilder();
46+
for (MonitorServiceTO service: services) {
47+
sb.append("[").append(service.getService()).append("]").append(":");
48+
sb.append("processname=").append(service.getProcessname()).append(":");
49+
sb.append("servicename=").append(service.getServiceName()).append(":");
50+
sb.append("pidfile=").append(service.getPidFile()).append(":");
51+
sb.append(",");
52+
}
53+
54+
return sb.toString();
55+
}
56+
}

engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
<bean id="externalPublicIpStatisticsDaoImpl" class="com.cloud.usage.dao.ExternalPublicIpStatisticsDaoImpl" />
156156
<bean id="firewallRulesCidrsDaoImpl" class="com.cloud.network.dao.FirewallRulesCidrsDaoImpl" />
157157
<bean id="firewallRulesDaoImpl" class="com.cloud.network.dao.FirewallRulesDaoImpl" />
158+
<bean id="MonitoringServiceDaoImpl" class="com.cloud.network.dao.MonitoringServiceDaoImpl" />
158159
<bean id="globalLoadBalancerDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerDaoImpl" />
159160
<bean id="globalLoadBalancerLbRuleMapDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerLbRuleMapDaoImpl" />
160161
<bean id="guestOSCategoryDaoImpl" class="com.cloud.storage.dao.GuestOSCategoryDaoImpl" />
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package com.cloud.network.dao;
19+
20+
import com.cloud.utils.db.GenericDao;
21+
22+
import java.util.List;
23+
24+
public interface MonitoringServiceDao extends GenericDao<MonitoringServiceVO, Long> {
25+
26+
List<MonitoringServiceVO> listAllServices();
27+
List<MonitoringServiceVO> listDefaultServices(boolean isDefault);
28+
29+
MonitoringServiceVO getServiceByName(String service);
30+
31+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
19+
20+
package com.cloud.network.dao;
21+
22+
import com.cloud.utils.db.GenericDaoBase;
23+
import com.cloud.utils.db.SearchBuilder;
24+
import com.cloud.utils.db.SearchCriteria;
25+
import org.springframework.stereotype.Component;
26+
27+
import javax.ejb.Local;
28+
import java.util.List;
29+
30+
@Component
31+
@Local(value=MonitoringServiceDao.class)
32+
public class MonitoringServiceDaoImpl extends GenericDaoBase<MonitoringServiceVO, Long> implements MonitoringServiceDao {
33+
private final SearchBuilder<MonitoringServiceVO> AllFieldsSearch;
34+
35+
public MonitoringServiceDaoImpl() {
36+
super();
37+
AllFieldsSearch = createSearchBuilder();
38+
AllFieldsSearch.and("isDefault", AllFieldsSearch.entity().getDefault(), SearchCriteria.Op.EQ);
39+
AllFieldsSearch.and("service", AllFieldsSearch.entity().getService(), SearchCriteria.Op.EQ);
40+
AllFieldsSearch.and("processname", AllFieldsSearch.entity().getProcessname(), SearchCriteria.Op.EQ);
41+
AllFieldsSearch.and("servicename", AllFieldsSearch.entity().getServiceName(), SearchCriteria.Op.EQ);
42+
AllFieldsSearch.and("servicepath", AllFieldsSearch.entity().getServicePath(), SearchCriteria.Op.EQ);
43+
AllFieldsSearch.and("servicePidFile", AllFieldsSearch.entity().getPidFile(), SearchCriteria.Op.EQ);
44+
45+
AllFieldsSearch.done();
46+
}
47+
48+
49+
50+
@Override
51+
public List<MonitoringServiceVO> listAllServices() {
52+
return null;
53+
}
54+
55+
@Override
56+
public List<MonitoringServiceVO> listDefaultServices(boolean isDefault) {
57+
SearchCriteria<MonitoringServiceVO> sc = AllFieldsSearch.create();
58+
sc.setParameters("isDefault", isDefault);
59+
return listBy(sc);
60+
}
61+
62+
@Override
63+
public MonitoringServiceVO getServiceByName(String service) {
64+
SearchCriteria<MonitoringServiceVO> sc = AllFieldsSearch.create();
65+
sc.setParameters("service", service);
66+
return findOneBy(sc);
67+
}
68+
}

0 commit comments

Comments
 (0)