Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/client/pom.xml b/client/pom.xml
- index 39d899e..a8f91ec 100644
- --- a/client/pom.xml
- +++ b/client/pom.xml
- @@ -217,6 +217,11 @@
- <artifactId>cloud-engine-storage-volume</artifactId>
- <version>${project.version}</version>
- </dependency>
- + <dependency>
- + <groupId>org.apache.cloudstack</groupId>
- + <artifactId>cloud-plugin-timeofday</artifactId>
- + <version>${project.version}</version>
- + </dependency>
- </dependencies>
- <build>
- <defaultGoal>install</defaultGoal>
- diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
- index a7b2f8b..ca5c75f 100644
- --- a/client/tomcatconf/commands.properties.in
- +++ b/client/tomcatconf/commands.properties.in
- @@ -540,3 +540,6 @@ listRegions=15
- #### Baremetal commands
- addBaremetalHost=1
- +
- +#### plugin (timeofday)
- +getTimeOfDay=15
- diff --git a/plugins/pom.xml b/plugins/pom.xml
- index 60432a6..44b3f75 100755
- --- a/plugins/pom.xml
- +++ b/plugins/pom.xml
- @@ -34,6 +34,7 @@
- <modules>
- <module>api/rate-limit</module>
- <module>api/discovery</module>
- + <module>api/timeofday</module>
- <module>acl/static-role-based</module>
- <module>deployment-planners/user-concentrated-pod</module>
- <module>deployment-planners/user-dispersing</module>
- * NEW FILES *
- plugins/api/timeofday/pom.xml
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>cloud-plugin-timeofday</artifactId>
- <name>Apache CloudStack Plugin - TimeOfDay</name>
- <parent>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloudstack-plugins</artifactId>
- <version>4.1.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <dependencies>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${cs.mysql.version}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- <build>
- <defaultGoal>install</defaultGoal>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- <executions>
- <execution>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </project>
- * New File plugins/api/timeofday/src/com/cloud/test/TimeOfDayManager.java *
- package com.cloud.test;
- import com.cloud.utils.component.PluggableService;
- public interface TimeOfDayManager extends PluggableService { }
- * New File plugins/api/timeofday/src/com/cloud/test/TimeOfDayManagerImpl.java *
- package com.cloud.test;
- import com.cloud.utils.component.PluggableService;
- import java.util.List;
- import java.util.ArrayList;
- import org.apache.log4j.Logger;
- import com.cloud.test.GetTimeOfDayCmd;
- import javax.annotation.PostConstruct;
- import org.springframework.stereotype.Component;
- import javax.ejb.Local;
- @Component
- @Local(value = { TimeOfDayManager.class })
- public class TimeOfDayManagerImpl implements TimeOfDayManager {
- private static final Logger s_logger = Logger.getLogger(TimeOfDayManagerImpl.class);
- public TimeOfDayManagerImpl() {
- super();
- }
- @Override
- public List<Class<?>> getCommands() {
- List<Class<?>> cmdList = new ArrayList<Class<?>>();
- cmdList.add(GetTimeOfDayCmd.class);
- return cmdList;
- }
- }
- * New File plugins/api/timeofday/src/com/cloud/test/GetTimeOfDayCmd.java *
- package com.cloud.test;
- import javax.inject.Inject;
- import org.apache.log4j.Logger;
- import org.apache.cloudstack.api.BaseCmd;
- import org.apache.cloudstack.api.APICommand;
- import org.apache.cloudstack.api.Parameter;
- @APICommand(name = "getTimeOfDay", description="Get Cloudstack's time of day", responseObject = GetTimeOfDayCmdResponse.class, includeInApiDoc=true)
- public class GetTimeOfDayCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(GetTimeOfDayCmd.class.getName());
- private static final String s_name = "gettimeofdayresponse";
- @Parameter(name="example", type=CommandType.STRING, required=false, description="Just an example string that will be uppercased")
- private String example;
- public String getExample() {
- return this.example;
- }
- @Override
- public void execute()
- {
- GetTimeOfDayCmdResponse response = new GetTimeOfDayCmdResponse();
- if ( this.example != null ) {
- response.setExampleEcho(example);
- }
- response.setObjectName("timeofday"); // the inner part of the json structure
- response.setResponseName(getCommandName()); // the outer part of the json structure
- this.setResponseObject(response);
- }
- @Override
- public String getCommandName() {
- return s_name;
- }
- @Override
- public long getEntityOwnerId() {
- return 0;
- }
- }
- * NEW FILE plugins/api/timeofday/src/com/cloud/test/GetTimeOfDayCmdResponse.java *
- package com.cloud.test;
- import org.apache.cloudstack.api.ApiConstants;
- import com.cloud.serializer.Param;
- import com.google.gson.annotations.SerializedName;
- import org.apache.cloudstack.api.BaseResponse;
- import java.util.Date;
- import java.text.SimpleDateFormat;
- @SuppressWarnings("unused")
- public class GetTimeOfDayCmdResponse extends BaseResponse {
- @SerializedName(ApiConstants.IS_ASYNC) @Param(description="true if api is asynchronous")
- private Boolean isAsync;
- @SerializedName("timeOfDay") @Param(description="The time of day from CloudStack")
- private String timeOfDay;
- @SerializedName("exampleEcho") @Param(description="An upper cased string")
- private String exampleEcho;
- public GetTimeOfDayCmdResponse(){
- this.isAsync = false;
- SimpleDateFormat dateformatYYYYMMDD = new SimpleDateFormat("yyyyMMdd");
- this.setTimeOfDay( (new StringBuilder( dateformatYYYYMMDD.format( new Date() ) )).toString() );
- }
- public void setAsync(Boolean isAsync) {
- this.isAsync = isAsync;
- }
- public boolean getAsync() {
- return isAsync;
- }
- public void setTimeOfDay(String timeOfDay) {
- this.timeOfDay = timeOfDay;
- }
- public void setExampleEcho(String exampleEcho) {
- this.exampleEcho = exampleEcho.toUpperCase();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment