rohityadavcloud commented on code in PR #7289:
URL: https://github.com/apache/cloudstack/pull/7289#discussion_r1116781807
##########
api/src/main/java/org/apache/cloudstack/api/APICommand.java:
##########
@@ -50,4 +49,5 @@
RoleType[] authorized() default {};
Class<?>[] entityType() default {};
+
Review Comment:
nit - unnecessary change, you may want to use `git add -p` to check what's
being commited.
##########
api/src/main/java/org/apache/cloudstack/api/command/user/vmschedule/CreateVMScheduleCmd.java:
##########
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.vmschedule;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.user.Account;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.response.VMScheduleResponse;
+import org.apache.log4j.Logger;
+
+@APICommand(name = CreateVMScheduleCmd.APINAME,
+ description = "Creates Schedule for a VM",
+ responseObject = VMScheduleResponse.class,
+ since = "4.18.0",
Review Comment:
The since may be version 4.19.0
##########
api/src/main/java/org/apache/cloudstack/api/command/user/vmschedule/CreateVMScheduleCmd.java:
##########
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.vmschedule;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.user.Account;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.response.VMScheduleResponse;
+import org.apache.log4j.Logger;
+
+@APICommand(name = CreateVMScheduleCmd.APINAME,
+ description = "Creates Schedule for a VM",
+ responseObject = VMScheduleResponse.class,
+ since = "4.18.0",
+ requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+ authorized = {RoleType.Admin, RoleType.ResourceAdmin,
RoleType.DomainAdmin, RoleType.User})
+public class CreateVMScheduleCmd extends BaseAsyncCreateCmd {
+ public static final String APINAME = "createVMSchedule";
+ public static final Logger s_logger =
Logger.getLogger(CreateVMScheduleCmd.class.getName());
Review Comment:
nit - Logger is provided the class itself (.getName() isn't useful/necessary)
##########
engine/schema/src/main/resources/META-INF/db/schema-41720to41800.sql:
##########
@@ -1569,4 +1569,20 @@ CREATE VIEW `cloud`.`user_view` AS
left join
`cloud`.`async_job` ON async_job.instance_id = user.id
and async_job.instance_type = 'User'
- and async_job.job_status = 0;
\ No newline at end of file
+ and async_job.job_status = 0;
+
+--- Create table for Virtual Machine Schedule Entity
+
+CREATE TABLE IF NOT EXISTS `cloud`.`vm_schedule` (
Review Comment:
note - after 4.18 is released, this would need to be moved to a new sql
upgrade path (4.18->4.19)
##########
engine/schema/src/main/java/com/cloud/vm/schedule/VMScheduleVO.java:
##########
@@ -0,0 +1,135 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm.schedule;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Column;
+import javax.persistence.Enumerated;
+import javax.persistence.EnumType;
+import javax.persistence.GenerationType;
+import java.util.UUID;
+
+@Entity
+@Table(name = "vm_schedule")
+public class VMScheduleVO implements VMSchedule {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "uuid")
+ private String uuid;
+
+ @Column(name = "name")
+ private String name;
+
+ @Column(name = "vm_id")
+ long vmId;
Review Comment:
`private` ?
##########
server/src/main/java/com/cloud/vm/schedule/VMScheduleManagerImpl.java:
##########
@@ -0,0 +1,43 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.vm.schedule;
+
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.component.PluggableService;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
+
+import java.util.List;
+
+public class VMScheduleManagerImpl extends ManagerBase implements
VMScheduleManager, Configurable, PluggableService {
+
+ @Override
+ public String getConfigComponentName() {
+ return null;
+ }
+
+ @Override
+ public ConfigKey<?>[] getConfigKeys() {
+ return new ConfigKey[0];
+ }
+
+ @Override
+ public List<Class<?>> getCommands() {
+ return null;
Review Comment:
This can export all the API classes you've created.
##########
engine/schema/src/main/resources/META-INF/db/schema-41720to41800.sql:
##########
@@ -1569,4 +1569,20 @@ CREATE VIEW `cloud`.`user_view` AS
left join
`cloud`.`async_job` ON async_job.instance_id = user.id
and async_job.instance_type = 'User'
- and async_job.job_status = 0;
\ No newline at end of file
+ and async_job.job_status = 0;
+
+--- Create table for Virtual Machine Schedule Entity
+
+CREATE TABLE IF NOT EXISTS `cloud`.`vm_schedule` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `uuid` varchar(40) UNIQUE COMMENT 'UUID for the VM Schedule',
+ `name` varchar(255) COMMENT 'name of VM Schedule',
+ `action` varchar(40) NOT NULL COMMENT 'action Scheduled on VM',
+ `period` varchar(255) NOT NULL COMMENT 'period Scheduled on VM',
+ `timezone` varchar(40) COMMENT 'timezone of VM',
+ `tag` varchar(40) COMMENT 'Tag Value of VM Schedule',
+ `vm_id` bigint(20) unsigned NOT NULL COMMENT 'virtual machine id',
+ FOREIGN KEY (vm_id) REFERENCES `cloud`.`vm_instance`(`id`),
Review Comment:
tip - you may want an index on vm ID for quick search
##########
api/src/main/java/org/apache/cloudstack/api/command/user/vmschedule/CreateVMScheduleCmd.java:
##########
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.vmschedule;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.user.Account;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.response.VMScheduleResponse;
+import org.apache.log4j.Logger;
+
+@APICommand(name = CreateVMScheduleCmd.APINAME,
+ description = "Creates Schedule for a VM",
+ responseObject = VMScheduleResponse.class,
+ since = "4.18.0",
+ requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+ authorized = {RoleType.Admin, RoleType.ResourceAdmin,
RoleType.DomainAdmin, RoleType.User})
+public class CreateVMScheduleCmd extends BaseAsyncCreateCmd {
+ public static final String APINAME = "createVMSchedule";
+ public static final Logger s_logger =
Logger.getLogger(CreateVMScheduleCmd.class.getName());
+
+ // ///////////////////////////////////////////////////
Review Comment:
nit - comment `// ` can be removed
##########
engine/schema/src/main/java/com/cloud/vm/schedule/VMScheduleVO.java:
##########
@@ -0,0 +1,135 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm.schedule;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Column;
+import javax.persistence.Enumerated;
+import javax.persistence.EnumType;
+import javax.persistence.GenerationType;
+import java.util.UUID;
+
+@Entity
+@Table(name = "vm_schedule")
+public class VMScheduleVO implements VMSchedule {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "uuid")
+ private String uuid;
+
+ @Column(name = "name")
+ private String name;
+
+ @Column(name = "vm_id")
+ long vmId;
+
+ @Column(name = "state")
+ @Enumerated(value = EnumType.STRING)
+ State state = State.Disabled;
Review Comment:
`private` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]