From 980a550119d7cefa1aa33a36fd3e8663a77d4aa0 Mon Sep 17 00:00:00 2001 From: wuchen Date: Tue, 14 Jul 2020 15:53:40 +0800 Subject: [PATCH] release 1.0.24 code --- connectors/http-connector/pom.xml | 2 +- connectors/httpclient/pom.xml | 2 +- connectors/jersey2/pom.xml | 2 +- connectors/okhttp/pom.xml | 2 +- connectors/pom.xml | 2 +- connectors/resteasy/pom.xml | 2 +- core-functional-test/pom.xml | 2 +- core-integration-test/pom.xml | 2 +- core-sample/pom.xml | 2 +- core-test/pom.xml | 2 +- .../cloudeye/CloudEyeAlarmServiceTest.java | 20 ++- core/pom.xml | 2 +- .../api/cloudeye/AlarmService.java | 9 +- .../cloudeye/domain/CloudEyeAlarmAction.java | 6 +- .../domain/CloudEyeAlarmCondition.java | 10 +- .../domain/CloudEyeCreateAlarmReq.java | 74 ++++++++++ .../cloudeye/domain/CloudEyeMetric.java | 7 + .../domain/CloudEyeMetricDemension.java | 6 +- .../internal/CloudEyeAlarmServiceImpl.java | 9 +- .../v1/contants/InterruptionPolicyEnum.java | 13 ++ .../ecs/v1/domain/ServerExtendParam.java | 131 ++++++++++++++++-- .../v1_1/contants/InterruptionPolicyEnum.java | 13 ++ .../ecs/v1_1/domain/ServerExtendParam.java | 29 ++++ distribution/pom.xml | 2 +- pom.xml | 2 +- 25 files changed, 324 insertions(+), 29 deletions(-) create mode 100644 core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeCreateAlarmReq.java create mode 100644 core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/contants/InterruptionPolicyEnum.java create mode 100644 core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/contants/InterruptionPolicyEnum.java diff --git a/connectors/http-connector/pom.xml b/connectors/http-connector/pom.xml index 90c5e6f..2cea86c 100644 --- a/connectors/http-connector/pom.xml +++ b/connectors/http-connector/pom.xml @@ -20,7 +20,7 @@ com.huawei.openstack4j.connectors openstack4j-connectors - 1.0.23 + 1.0.24 OpenStack4j HttpURL Connector openstack4j-http-connector diff --git a/connectors/httpclient/pom.xml b/connectors/httpclient/pom.xml index 58ebe32..00323c4 100644 --- a/connectors/httpclient/pom.xml +++ b/connectors/httpclient/pom.xml @@ -19,7 +19,7 @@ com.huawei.openstack4j.connectors openstack4j-connectors - 1.0.23 + 1.0.24 4.0.0 openstack4j-httpclient diff --git a/connectors/jersey2/pom.xml b/connectors/jersey2/pom.xml index 5bd16f0..0c1dd76 100644 --- a/connectors/jersey2/pom.xml +++ b/connectors/jersey2/pom.xml @@ -19,7 +19,7 @@ com.huawei.openstack4j.connectors openstack4j-connectors - 1.0.23 + 1.0.24 4.0.0 openstack4j-jersey2 diff --git a/connectors/okhttp/pom.xml b/connectors/okhttp/pom.xml index b25dd7e..e8e34c5 100644 --- a/connectors/okhttp/pom.xml +++ b/connectors/okhttp/pom.xml @@ -19,7 +19,7 @@ com.huawei.openstack4j.connectors openstack4j-connectors - 1.0.23 + 1.0.24 4.0.0 openstack4j-okhttp diff --git a/connectors/pom.xml b/connectors/pom.xml index e3a5e6b..a348433 100644 --- a/connectors/pom.xml +++ b/connectors/pom.xml @@ -19,7 +19,7 @@ com.huawei openstack4j-parent - 1.0.23 + 1.0.24 4.0.0 com.huawei.openstack4j.connectors diff --git a/connectors/resteasy/pom.xml b/connectors/resteasy/pom.xml index 3b078c8..1110969 100644 --- a/connectors/resteasy/pom.xml +++ b/connectors/resteasy/pom.xml @@ -19,7 +19,7 @@ com.huawei.openstack4j.connectors openstack4j-connectors - 1.0.23 + 1.0.24 4.0.0 openstack4j-resteasy diff --git a/core-functional-test/pom.xml b/core-functional-test/pom.xml index 0474bbf..13aa7b0 100644 --- a/core-functional-test/pom.xml +++ b/core-functional-test/pom.xml @@ -4,7 +4,7 @@ com.huawei openstack4j-parent - 1.0.23 + 1.0.24 openstack4j-core-functional-test OpenStack4j Core Functional Test Cases diff --git a/core-integration-test/pom.xml b/core-integration-test/pom.xml index 48f97c2..a13ad80 100644 --- a/core-integration-test/pom.xml +++ b/core-integration-test/pom.xml @@ -19,7 +19,7 @@ com.huawei openstack4j-parent - 1.0.23 + 1.0.24 4.0.0 openstack4j-core-integration-test diff --git a/core-sample/pom.xml b/core-sample/pom.xml index d98df14..cf33824 100644 --- a/core-sample/pom.xml +++ b/core-sample/pom.xml @@ -4,7 +4,7 @@ com.huawei openstack4j-parent - 1.0.23 + 1.0.24 openstack-core-sample OpenStack4j Sample diff --git a/core-test/pom.xml b/core-test/pom.xml index e2b186b..b71f604 100644 --- a/core-test/pom.xml +++ b/core-test/pom.xml @@ -19,7 +19,7 @@ com.huawei openstack4j-parent - 1.0.23 + 1.0.24 4.0.0 openstack4j-core-test diff --git a/core-test/src/main/java/com/huawei/openstack4j/api/cloudeye/CloudEyeAlarmServiceTest.java b/core-test/src/main/java/com/huawei/openstack4j/api/cloudeye/CloudEyeAlarmServiceTest.java index a977767..b05dd5b 100644 --- a/core-test/src/main/java/com/huawei/openstack4j/api/cloudeye/CloudEyeAlarmServiceTest.java +++ b/core-test/src/main/java/com/huawei/openstack4j/api/cloudeye/CloudEyeAlarmServiceTest.java @@ -19,8 +19,11 @@ import static org.testng.Assert.assertNotNull; import static org.testng.AssertJUnit.assertTrue; +import java.util.ArrayList; import java.util.List; +import com.huawei.openstack4j.model.cloudeye.AlarmType; +import com.huawei.openstack4j.openstack.cloudeye.domain.*; import org.testng.annotations.Test; import com.huawei.openstack4j.api.AbstractTest; @@ -30,7 +33,7 @@ import com.huawei.openstack4j.model.common.ActionResponse; import com.huawei.openstack4j.openstack.cloudeye.internal.AlarmFilterOptions; -@Test(groups = "cloudeye", suiteName = "cloudeye/Alarms") + @Test(groups = "cloudeye", suiteName = "cloudeye/Alarms") public class CloudEyeAlarmServiceTest extends AbstractTest { private static final String JSON_ALARMS = "/cloudeye/list_alarms.json"; public static final String ALARM_ID = "al1483387711418ZNpR8DX3g"; @@ -88,5 +91,20 @@ public void deleteAlarmTest() throws Exception { assertTrue(ptrRestoreActionResponse.isSuccess()); } + public void createAlarmTest() throws Exception { + CloudEyeMetricDemension dimension = new CloudEyeMetricDemension("instance_id", "1234567899_id"); + List dimensions = new ArrayList<>(); + dimensions.add(dimension); + CloudEyeMetric metric = new CloudEyeMetric("cpu_util", "%", "SYS.ECS", dimensions); + CloudEyeAlarmCondition condition = new CloudEyeAlarmCondition(300, "average", ">", 12, "%", 3); + CloudEyeAlarmAction action = new CloudEyeAlarmAction(AlarmType.NOTIFICATION, new ArrayList()); + List actions = new ArrayList<>(); + actions.add(action); + CloudEyeCreateAlarmReq alarm = new CloudEyeCreateAlarmReq("alarm_test", "alarm_desc", metric, condition, actions, actions, + actions, true, false, 2); + + ActionResponse ptrRestoreActionResponse = osv3().cloudEye().alarms().create(alarm); + assertTrue(ptrRestoreActionResponse.isSuccess()); + } } diff --git a/core/pom.xml b/core/pom.xml index da0be3d..919e2ef 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -20,7 +20,7 @@ com.huawei openstack4j-parent - 1.0.23 + 1.0.24 4.0.0 openstack4j-core diff --git a/core/src/main/java/com/huawei/openstack4j/api/cloudeye/AlarmService.java b/core/src/main/java/com/huawei/openstack4j/api/cloudeye/AlarmService.java index 531e47f..1708e9f 100644 --- a/core/src/main/java/com/huawei/openstack4j/api/cloudeye/AlarmService.java +++ b/core/src/main/java/com/huawei/openstack4j/api/cloudeye/AlarmService.java @@ -20,10 +20,17 @@ import com.huawei.openstack4j.common.RestService; import com.huawei.openstack4j.model.cloudeye.Alarm; import com.huawei.openstack4j.model.common.ActionResponse; +import com.huawei.openstack4j.openstack.cloudeye.domain.CloudEyeCreateAlarmReq; import com.huawei.openstack4j.openstack.cloudeye.internal.AlarmFilterOptions; public interface AlarmService extends RestService { - + + /** + * @param alarm The alarm info for creating + * @return + */ + ActionResponse create(CloudEyeCreateAlarmReq alarm); + /** * list alarm * @return diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmAction.java b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmAction.java index b649ed2..d9fdff4 100644 --- a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmAction.java +++ b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmAction.java @@ -28,11 +28,15 @@ @ToString @Builder(toBuilder = true) @NoArgsConstructor -@AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) public class CloudEyeAlarmAction implements AlarmAction{ private static final long serialVersionUID = 5604518526573924452L; AlarmType type; List notificationlist; + + public CloudEyeAlarmAction(AlarmType type, List notificationlist) { + this.type = type; + this.notificationlist = notificationlist; + } } diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmCondition.java b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmCondition.java index 14e10e3..82f445d 100644 --- a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmCondition.java +++ b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeAlarmCondition.java @@ -26,7 +26,6 @@ @ToString @Builder(toBuilder = true) @NoArgsConstructor -@AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) public class CloudEyeAlarmCondition implements Condition { private static final long serialVersionUID = 5719142668031530589L; @@ -37,5 +36,14 @@ public class CloudEyeAlarmCondition implements Condition { Number value; String unit; Integer count; + + public CloudEyeAlarmCondition (Integer period, String filter, String comparisonOperator, Number value, String unit, Integer count) { + this.period = period; + this.filter = filter; + this.comparisonOperator = comparisonOperator; + this.value = value; + this.unit = unit; + this.count = count; + } } diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeCreateAlarmReq.java b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeCreateAlarmReq.java new file mode 100644 index 0000000..671b9ef --- /dev/null +++ b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeCreateAlarmReq.java @@ -0,0 +1,74 @@ + /******************************************************************************* + * Copyright 2018 Huawei Technologies Co.,Ltd. + * + * Licensed 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.huawei.openstack4j.openstack.cloudeye.domain; + + import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import com.fasterxml.jackson.annotation.JsonProperty; + import com.huawei.openstack4j.model.ModelEntity; + import lombok.*; + + import java.util.List; + + @Getter + @ToString + @Builder(toBuilder = true) + @NoArgsConstructor + @JsonIgnoreProperties(ignoreUnknown = true) + public class CloudEyeCreateAlarmReq implements ModelEntity { + private static final long serialVersionUID = -1524440551458098127L; + + @JsonProperty("alarm_name") + String alarmName; + + @JsonProperty("alarm_description") + String alarmDescription; + + CloudEyeMetric metric; + + CloudEyeAlarmCondition condition; + + @JsonProperty("alarm_actions") + List alarmActions; + + @JsonProperty("insufficientdata_actions") + List insufficientdataActions; + + @JsonProperty("ok_actions") + List okActions; + + @JsonProperty("alarm_enabled") + Boolean alarmEnabled; + + @JsonProperty("alarm_action_enabled") + Boolean alarmActionEnabled; + + @JsonProperty("alarm_level") + Integer alarmLevel; + + public CloudEyeCreateAlarmReq (String alarmName, String alarmDescription, CloudEyeMetric metric, CloudEyeAlarmCondition condition, List alarmActions, List insufficientdataActions, + List okActions, Boolean alarmEnabled, Boolean alarmActionEnabled, Integer alarmLevel) { + this.alarmName = alarmName; + this.alarmDescription = alarmDescription; + this.metric = metric; + this.condition = condition; + this.alarmActions = alarmActions; + this.insufficientdataActions = insufficientdataActions; + this.okActions = okActions; + this.alarmActionEnabled = alarmActionEnabled; + this.alarmEnabled = alarmEnabled; + this.alarmLevel = alarmLevel; + } + } diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetric.java b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetric.java index 2515bba..3f48021 100644 --- a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetric.java +++ b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetric.java @@ -68,4 +68,11 @@ public List value() { return list; } } + + public CloudEyeMetric(String metricName, String unit, String namespace, List dimensions) { + this.metricName = metricName; + this.unit = unit; + this.namespace = namespace; + this.dimensions = dimensions; + } } diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetricDemension.java b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetricDemension.java index 59fd82e..b1a5dca 100644 --- a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetricDemension.java +++ b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/domain/CloudEyeMetricDemension.java @@ -24,11 +24,15 @@ @ToString @Builder(toBuilder = true) @NoArgsConstructor -@AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) public class CloudEyeMetricDemension implements MetricDimensions { private static final long serialVersionUID = -959253863059879414L; String name; String value; + + public CloudEyeMetricDemension(String name, String value) { + this.name = name; + this.value = value; + } } diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/internal/CloudEyeAlarmServiceImpl.java b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/internal/CloudEyeAlarmServiceImpl.java index 6c157f5..def6c58 100644 --- a/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/internal/CloudEyeAlarmServiceImpl.java +++ b/core/src/main/java/com/huawei/openstack4j/openstack/cloudeye/internal/CloudEyeAlarmServiceImpl.java @@ -26,8 +26,15 @@ import com.huawei.openstack4j.model.cloudeye.Alarm; import com.huawei.openstack4j.model.common.ActionResponse; import com.huawei.openstack4j.openstack.cloudeye.domain.CloudEyeAlarm; +import com.huawei.openstack4j.openstack.cloudeye.domain.CloudEyeCreateAlarmReq; -public class CloudEyeAlarmServiceImpl extends BaseCloudEyeServices implements AlarmService { + public class CloudEyeAlarmServiceImpl extends BaseCloudEyeServices implements AlarmService { + + @Override + public ActionResponse create(CloudEyeCreateAlarmReq alarm) { + checkNotNull(alarm); + return postWithResponse(PATH_ALARMS).entity(alarm).execute(); + } @Override public List list() { diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/contants/InterruptionPolicyEnum.java b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/contants/InterruptionPolicyEnum.java new file mode 100644 index 0000000..983de29 --- /dev/null +++ b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/contants/InterruptionPolicyEnum.java @@ -0,0 +1,13 @@ +package com.huawei.openstack4j.openstack.ecs.v1.contants; + +public enum InterruptionPolicyEnum { + /** + * Enum IMMEDIATE for value: "immediate" + */ + immediate, + /** + * Enum DELAY for value: "delay" + */ + delay + +} diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/domain/ServerExtendParam.java b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/domain/ServerExtendParam.java index 43cbbf5..c324129 100644 --- a/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/domain/ServerExtendParam.java +++ b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1/domain/ServerExtendParam.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; +import com.huawei.openstack4j.openstack.ecs.v1.contants.InterruptionPolicyEnum; import com.huawei.openstack4j.openstack.ecs.v1.contants.ServerChargingMode; @JsonRootName("server") @@ -68,6 +69,34 @@ public class ServerExtendParam { @JsonProperty("spotPrice") String spotPrice; + /** + * 购买的竞价实例时长。 + * 约束: + * 仅interruption_policy=immediate 时该字段有效 。 + * spot_duration_hours大于0。最大值由预测系统给出可以从flavor的extra_specs的cond:spot_block:operation:longest_duration_hours字段中查询。 + */ + @JsonProperty("spot_duration_hours") + Integer spotDurationHours; + + /** + * 表示购买的“竞价实例时长”的个数 + * 约束: + * 仅spot_duration_hours>0 时该字段有效。 + * spot_duration_hours小于6时,spot_duration_count值必须为1。 + * spot_duration_hours等于6时,spot_duration_count大于等于1。 + * spot_duration_count的最大值由预测系统给出可以从flavor的extra_specs的cond:spot_block:operation:longest_duration_count字段中查询。 + */ + @JsonProperty("spot_duration_count") + Integer spotDurationCount; + + /** + * 竞价实例中断策略,当前支持immediate。 + * 约束: + * 当interruption_policy=immediate时表示释放策略为立即释放。 + */ + @JsonProperty("interruption_policy") + InterruptionPolicyEnum interruptionPolicy; + @java.beans.ConstructorProperties({ "chargingMode", "regionId", "autoRecovery", "enterpriseProjectId"}) public ServerExtendParam(ServerChargingMode chargingMode, String regionId, Boolean autoRecovery, String enterpriseProjectId) { this.chargingMode = chargingMode; @@ -86,6 +115,20 @@ public ServerExtendParam(ServerChargingMode chargingMode, String regionId, Boole this.spotPrice = spotPrice; } + @java.beans.ConstructorProperties({"chargingMode", "regionId", "autoRecovery", "enterpriseProjectId", "marketType", "spotPrice", "spotDurationHours", "spotDurationCount", "interruptionPolicy"}) + public ServerExtendParam(ServerChargingMode chargingMode, String regionId, Boolean autoRecovery, String enterpriseProjectId, + String marketType, String spotPrice, Integer spotDurationHours, Integer spotDurationCount, InterruptionPolicyEnum interruptionPolicy) { + this.chargingMode = chargingMode; + this.regionId = regionId; + this.autoRecovery = autoRecovery; + this.enterpriseProjectId = enterpriseProjectId; + this.marketType = marketType; + this.spotPrice = spotPrice; + this.spotDurationHours = spotDurationHours; + this.spotDurationCount = spotDurationCount; + this.interruptionPolicy = interruptionPolicy; + } + public ServerExtendParam() { } @@ -117,12 +160,42 @@ public String getSpotPrice() { return spotPrice; } - @Override - public String toString() { - return "ServerExtendParam(chargingMode=" + this.getChargingMode() + ", regionId=" + this.getRegionId() - + ", autoRecovery=" + this.getAutoRecovery() + ", enterpriseProjectId=" + this.getEnterpriseProjectId() - + ", marketType=" + this.getMarketType() + ", spotPrice=" + this.getSpotPrice() + ")"; - } + public Integer getSpotDurationHours() { + return spotDurationHours; + } + + public Integer getSpotDurationCount() { + return spotDurationCount; + } + + public InterruptionPolicyEnum getInterruptionPolicy() { + return interruptionPolicy; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("ServerExtendParam(chargingMode="); + builder.append(this.getChargingMode()); + builder.append(", regionId="); + builder.append(this.getRegionId()); + builder.append(", autoRecovery="); + builder.append(this.getAutoRecovery()); + builder.append(", enterpriseProjectId="); + builder.append(this.getEnterpriseProjectId()); + builder.append(", marketType="); + builder.append(this.getMarketType()); + builder.append(", spotPrice="); + builder.append(this.getSpotPrice()); + builder.append(", spotDurationHours="); + builder.append(this.getSpotDurationHours()); + builder.append(", spotDurationCount="); + builder.append(this.getSpotDurationCount()); + builder.append(", interruptionPolicy="); + builder.append(this.getInterruptionPolicy()); + builder.append(")"); + return builder.toString(); + } public ServerExtendParamBuilder toBuilder() { return new ServerExtendParamBuilder().chargingMode(this.chargingMode).regionId(this.regionId) @@ -136,6 +209,10 @@ public static class ServerExtendParamBuilder { private String enterpriseProjectId; private String marketType; private String spotPrice; + Integer spotDurationHours; + Integer spotDurationCount; + InterruptionPolicyEnum interruptionPolicy; + ServerExtendParamBuilder() { } @@ -169,9 +246,25 @@ public ServerExtendParam.ServerExtendParamBuilder spotPrice(String spotPrice) { return this; } + public ServerExtendParam.ServerExtendParamBuilder spotDurationHours(Integer spotDurationHours) { + this.spotDurationHours = spotDurationHours; + return this; + } + + public ServerExtendParam.ServerExtendParamBuilder spotDurationCount(Integer spotDurationCount) { + this.spotDurationCount = spotDurationCount; + return this; + } + + public ServerExtendParam.ServerExtendParamBuilder interruptionPolicy(InterruptionPolicyEnum interruptionPolicy) { + this.interruptionPolicy = interruptionPolicy; + return this; + } + public ServerExtendParam build() { if (null != marketType) { - return new ServerExtendParam(chargingMode, regionId, autoRecovery, enterpriseProjectId, marketType, spotPrice); + return new ServerExtendParam(chargingMode, regionId, autoRecovery, enterpriseProjectId, + marketType, spotPrice, spotDurationHours, spotDurationCount, interruptionPolicy); } else { return new ServerExtendParam(chargingMode, regionId, autoRecovery, enterpriseProjectId); } @@ -180,9 +273,27 @@ public ServerExtendParam build() { @Override public String toString() { - return "ServerExtendParam.ServerExtendParamBuilder(chargingMode=" + this.chargingMode + ", regionId=" - + this.regionId + ", autoRecovery=" + this.autoRecovery + ", enterpriseProjectId=" + this.enterpriseProjectId - + ", marketType=" + this.marketType + ", spotPrice=" + this.spotPrice + ")"; + StringBuilder builder = new StringBuilder(); + builder.append("ServerExtendParam.ServerExtendParamBuilder(chargingMode="); + builder.append(this.chargingMode); + builder.append(", regionId="); + builder.append(this.regionId); + builder.append(", autoRecovery="); + builder.append(this.autoRecovery); + builder.append(", enterpriseProjectId="); + builder.append(this.enterpriseProjectId); + builder.append(", marketType="); + builder.append(this.marketType); + builder.append(", spotPrice="); + builder.append(this.spotPrice); + builder.append(", spotDurationHours="); + builder.append(this.spotDurationHours); + builder.append(", spotDurationCount="); + builder.append(this.spotDurationCount); + builder.append(", interruptionPolicy="); + builder.append(this.interruptionPolicy); + builder.append(")"); + return builder.toString(); } } } diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/contants/InterruptionPolicyEnum.java b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/contants/InterruptionPolicyEnum.java new file mode 100644 index 0000000..dadcb88 --- /dev/null +++ b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/contants/InterruptionPolicyEnum.java @@ -0,0 +1,13 @@ +package com.huawei.openstack4j.openstack.ecs.v1_1.contants; + +public enum InterruptionPolicyEnum { + /** + * Enum IMMEDIATE for value: "immediate" + */ + immediate, + /** + * Enum DELAY for value: "delay" + */ + delay + +} diff --git a/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/domain/ServerExtendParam.java b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/domain/ServerExtendParam.java index aa5a90c..a7c3f87 100644 --- a/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/domain/ServerExtendParam.java +++ b/core/src/main/java/com/huawei/openstack4j/openstack/ecs/v1_1/domain/ServerExtendParam.java @@ -15,6 +15,7 @@ *******************************************************************************/ package com.huawei.openstack4j.openstack.ecs.v1_1.domain; +import com.huawei.openstack4j.openstack.ecs.v1_1.contants.InterruptionPolicyEnum; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -113,4 +114,32 @@ public class ServerExtendParam { */ @JsonProperty("spotPrice") String spotPrice; + + /** + * 购买的竞价实例时长。 + * 约束: + * 仅interruption_policy=immediate 时该字段有效 。 + * spot_duration_hours大于0。最大值由预测系统给出可以从flavor的extra_specs的cond:spot_block:operation:longest_duration_hours字段中查询。 + */ + @JsonProperty("spot_duration_hours") + Integer spotDurationHours; + + /** + * 表示购买的“竞价实例时长”的个数 + * 约束: + * 仅spot_duration_hours>0 时该字段有效。 + * spot_duration_hours小于6时,spot_duration_count值必须为1。 + * spot_duration_hours等于6时,spot_duration_count大于等于1。 + * spot_duration_count的最大值由预测系统给出可以从flavor的extra_specs的cond:spot_block:operation:longest_duration_count字段中查询。 + */ + @JsonProperty("spot_duration_count") + Integer spotDurationCount; + + /** + * 竞价实例中断策略,当前支持immediate。 + * 约束: + * 当interruption_policy=immediate时表示释放策略为立即释放。 + */ + @JsonProperty("interruption_policy") + InterruptionPolicyEnum interruptionPolicy; } diff --git a/distribution/pom.xml b/distribution/pom.xml index 63b8c8b..de42ff6 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -20,7 +20,7 @@ com.huawei openstack4j-parent - 1.0.23 + 1.0.24 4.0.0 openstack4j diff --git a/pom.xml b/pom.xml index bb647fe..56b8eb3 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.0.0 com.huawei openstack4j-parent - 1.0.23 + 1.0.24 OpenStack4j Parent OpenStack Java API http://github.com/ContainX/openstack4j/