You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/05/08 14:00:13 UTC
[44/90] [abbrv] [partial] Moved most of the VOs and DAOs from server
package into engine-schema as well
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/migration/DiskOffering21VO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/migration/DiskOffering21VO.java b/engine/schema/src/com/cloud/migration/DiskOffering21VO.java
new file mode 100644
index 0000000..593f7ba
--- /dev/null
+++ b/engine/schema/src/com/cloud/migration/DiskOffering21VO.java
@@ -0,0 +1,257 @@
+// 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.migration;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="disk_offering_21")
+@Inheritance(strategy=InheritanceType.JOINED)
+@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
+public class DiskOffering21VO implements InternalIdentity {
+ public enum Type {
+ Disk,
+ Service
+ };
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ long id;
+
+ @Column(name="domain_id")
+ Long domainId;
+
+ @Column(name="unique_name")
+ private String uniqueName;
+
+ @Column(name="name")
+ private String name = null;
+
+ @Column(name="display_text")
+ private String displayText = null;
+
+ @Column(name="disk_size")
+ long diskSize;
+
+ @Column(name="mirrored")
+ boolean mirrored;
+
+ @Column(name="tags")
+ String tags;
+
+ @Column(name="type")
+ Type type;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name="recreatable")
+ private boolean recreatable;
+
+ @Column(name="use_local_storage")
+ private boolean useLocalStorage;
+
+ @Column(name="system_use")
+ protected boolean systemUse;
+
+
+ public DiskOffering21VO() {
+ }
+
+ public DiskOffering21VO(long domainId, String name, String displayText, long diskSize, boolean mirrored, String tags) {
+ this.domainId = domainId;
+ this.name = name;
+ this.displayText = displayText;
+ this.diskSize = diskSize;
+ this.mirrored = mirrored;
+ this.tags = tags;
+ this.recreatable = false;
+ this.type = Type.Disk;
+ this.useLocalStorage = false;
+ }
+
+ public DiskOffering21VO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage) {
+ this.domainId = null;
+ this.type = Type.Service;
+ this.name = name;
+ this.displayText = displayText;
+ this.mirrored = mirrored;
+ this.tags = tags;
+ this.recreatable = recreatable;
+ this.useLocalStorage = useLocalStorage;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getUniqueName() {
+ return uniqueName;
+ }
+
+ public boolean getSystemUse() {
+ return systemUse;
+ }
+
+ public void setSystemUse(boolean systemUse) {
+ this.systemUse = systemUse;
+ }
+
+ public boolean getUseLocalStorage() {
+ return useLocalStorage;
+ }
+
+ public void setUserLocalStorage(boolean useLocalStorage) {
+ this.useLocalStorage = useLocalStorage;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public boolean isRecreatable() {
+ return recreatable;
+ }
+
+ public void setDomainId(Long domainId) {
+ this.domainId = domainId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDisplayText() {
+ return displayText;
+ }
+ public void setDisplayText(String displayText) {
+ this.displayText = displayText;
+ }
+
+ public long getDiskSizeInBytes() {
+ return diskSize * 1024 * 1024;
+ }
+
+ public void setDiskSize(long diskSize) {
+ this.diskSize = diskSize;
+ }
+
+ public boolean isMirrored() {
+ return mirrored;
+ }
+ public void setMirrored(boolean mirrored) {
+ this.mirrored = mirrored;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ protected void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setUniqueName(String name) {
+ this.uniqueName = name;
+ }
+
+ @Transient
+ public String[] getTagsArray() {
+ String tags = getTags();
+ if (tags == null || tags.isEmpty()) {
+ return new String[0];
+ }
+
+ return tags.split(",");
+ }
+
+ @Transient
+ public boolean containsTag(String... tags) {
+ if (this.tags == null) {
+ return false;
+ }
+
+ for (String tag : tags) {
+ if (!this.tags.matches(tag)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Transient
+ public void setTagsArray(List<String> newTags) {
+ if (newTags.isEmpty()) {
+ setTags(null);
+ return;
+ }
+
+ StringBuilder buf = new StringBuilder();
+ for (String tag : newTags) {
+ buf.append(tag).append(",");
+ }
+
+ buf.delete(buf.length() - 1, buf.length());
+
+ setTags(buf.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/migration/ServiceOffering20Dao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering20Dao.java b/engine/schema/src/com/cloud/migration/ServiceOffering20Dao.java
new file mode 100644
index 0000000..e87b684
--- /dev/null
+++ b/engine/schema/src/com/cloud/migration/ServiceOffering20Dao.java
@@ -0,0 +1,22 @@
+// 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.migration;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface ServiceOffering20Dao extends GenericDao<ServiceOffering20VO, Long> {
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/migration/ServiceOffering20DaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering20DaoImpl.java b/engine/schema/src/com/cloud/migration/ServiceOffering20DaoImpl.java
new file mode 100644
index 0000000..f67949e
--- /dev/null
+++ b/engine/schema/src/com/cloud/migration/ServiceOffering20DaoImpl.java
@@ -0,0 +1,27 @@
+// 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.migration;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+
+@Local(value={ServiceOffering20Dao.class})
+public class ServiceOffering20DaoImpl extends GenericDaoBase<ServiceOffering20VO, Long> implements ServiceOffering20Dao {
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/migration/ServiceOffering20VO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering20VO.java b/engine/schema/src/com/cloud/migration/ServiceOffering20VO.java
new file mode 100644
index 0000000..bed29ec
--- /dev/null
+++ b/engine/schema/src/com/cloud/migration/ServiceOffering20VO.java
@@ -0,0 +1,199 @@
+// 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.migration;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.dc.Vlan;
+import com.cloud.dc.Vlan.VlanType;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="service_offering")
+public class ServiceOffering20VO implements InternalIdentity {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private Long id = null;
+
+ @Column(name="name")
+ private String name = null;
+
+ @Column(name="cpu")
+ private int cpu;
+
+ @Column(name="speed")
+ private int speed;
+
+ @Column(name="ram_size")
+ private int ramSize;
+
+ @Column(name="nw_rate")
+ private int rateMbps;
+
+ @Column(name="mc_rate")
+ private int multicastRateMbps;
+
+ @Column(name="mirrored")
+ private boolean mirroredVolumes;
+
+ @Column(name="ha_enabled")
+ private boolean offerHA;
+
+ @Column(name="display_text")
+ private String displayText = null;
+
+ @Column(name="guest_ip_type")
+ @Enumerated(EnumType.STRING)
+ private Vlan.VlanType guestIpType = Vlan.VlanType.VirtualNetwork;
+
+ @Column(name="use_local_storage")
+ private boolean useLocalStorage;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ protected ServiceOffering20VO() {
+ }
+
+ public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, boolean localStorageRequired) {
+ this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, Vlan.VlanType.VirtualNetwork, localStorageRequired);
+ }
+
+ public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, VlanType guestIpType, boolean useLocalStorage) {
+ this.id = id;
+ this.name = name;
+ this.cpu = cpu;
+ this.ramSize = ramSize;
+ this.speed = speed;
+ this.rateMbps = rateMbps;
+ this.multicastRateMbps = multicastRateMbps;
+ this.offerHA = offerHA;
+ this.displayText = displayText;
+ this.guestIpType = guestIpType;
+ this.useLocalStorage = useLocalStorage;
+ }
+
+ public boolean getOfferHA() {
+ return offerHA;
+ }
+
+ public void setOfferHA(boolean offerHA) {
+ this.offerHA = offerHA;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getCpu() {
+ return cpu;
+ }
+
+ public void setCpu(int cpu) {
+ this.cpu = cpu;
+ }
+
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
+
+ public void setRamSize(int ramSize) {
+ this.ramSize = ramSize;
+ }
+
+ public int getSpeed() {
+ return speed;
+ }
+
+ public int getRamSize() {
+ return ramSize;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public void setMirroredVolumes(boolean mirroredVolumes) {
+ this.mirroredVolumes = mirroredVolumes;
+ }
+
+ public boolean isMirroredVolumes() {
+ return mirroredVolumes;
+ }
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public void setDisplayText(String displayText) {
+ this.displayText = displayText;
+ }
+
+ public void setRateMbps(int rateMbps) {
+ this.rateMbps = rateMbps;
+ }
+
+ public int getRateMbps() {
+ return rateMbps;
+ }
+
+ public void setMulticastRateMbps(int multicastRateMbps) {
+ this.multicastRateMbps = multicastRateMbps;
+ }
+
+ public int getMulticastRateMbps() {
+ return multicastRateMbps;
+ }
+
+ public void setGuestIpType(Vlan.VlanType guestIpType) {
+ this.guestIpType = guestIpType;
+ }
+
+ public Vlan.VlanType getGuestIpType() {
+ return guestIpType;
+ }
+
+ public boolean getUseLocalStorage() {
+ return useLocalStorage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/migration/ServiceOffering21Dao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering21Dao.java b/engine/schema/src/com/cloud/migration/ServiceOffering21Dao.java
new file mode 100644
index 0000000..eece426
--- /dev/null
+++ b/engine/schema/src/com/cloud/migration/ServiceOffering21Dao.java
@@ -0,0 +1,22 @@
+// 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.migration;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface ServiceOffering21Dao extends GenericDao<ServiceOffering21VO, Long> {
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/migration/ServiceOffering21DaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering21DaoImpl.java b/engine/schema/src/com/cloud/migration/ServiceOffering21DaoImpl.java
new file mode 100644
index 0000000..ce24191
--- /dev/null
+++ b/engine/schema/src/com/cloud/migration/ServiceOffering21DaoImpl.java
@@ -0,0 +1,27 @@
+// 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.migration;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+
+@Local(value={ServiceOffering21Dao.class})
+public class ServiceOffering21DaoImpl extends GenericDaoBase<ServiceOffering21VO, Long> implements ServiceOffering21Dao {
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/migration/ServiceOffering21VO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/migration/ServiceOffering21VO.java b/engine/schema/src/com/cloud/migration/ServiceOffering21VO.java
new file mode 100644
index 0000000..d07be64
--- /dev/null
+++ b/engine/schema/src/com/cloud/migration/ServiceOffering21VO.java
@@ -0,0 +1,178 @@
+// 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.migration;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import com.cloud.offering.ServiceOffering;
+
+@Entity
+@Table(name="service_offering_21")
+@DiscriminatorValue(value="Service")
+@PrimaryKeyJoinColumn(name="id")
+public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffering {
+ @Column(name="cpu")
+ private int cpu;
+
+ @Column(name="speed")
+ private int speed;
+
+ @Column(name="ram_size")
+ private int ramSize;
+
+ @Column(name="nw_rate")
+ private Integer rateMbps;
+
+ @Column(name="mc_rate")
+ private Integer multicastRateMbps;
+
+ @Column(name="ha_enabled")
+ private boolean offerHA;
+
+ @Column(name="host_tag")
+ private String hostTag;
+
+ protected ServiceOffering21VO() {
+ super();
+ }
+
+ public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags) {
+ super(name, displayText, false, tags, recreatable, useLocalStorage);
+ this.cpu = cpu;
+ this.ramSize = ramSize;
+ this.speed = speed;
+ this.rateMbps = rateMbps;
+ this.multicastRateMbps = multicastRateMbps;
+ this.offerHA = offerHA;
+ }
+
+ public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags, String hostTag) {
+ this(name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, useLocalStorage, recreatable, tags);
+ this.hostTag = hostTag;
+ }
+
+
+ @Override
+ public boolean getOfferHA() {
+ return offerHA;
+ }
+
+ @Override
+ public boolean getLimitCpuUse() {
+ return false;
+ }
+
+ public void setOfferHA(boolean offerHA) {
+ this.offerHA = offerHA;
+ }
+
+ @Override
+ @Transient
+ public String[] getTagsArray() {
+ String tags = getTags();
+ if (tags == null || tags.length() == 0) {
+ return new String[0];
+ }
+
+ return tags.split(",");
+ }
+
+ @Override
+ public int getCpu() {
+ return cpu;
+ }
+
+ public void setCpu(int cpu) {
+ this.cpu = cpu;
+ }
+
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
+
+ public void setRamSize(int ramSize) {
+ this.ramSize = ramSize;
+ }
+
+ @Override
+ public int getSpeed() {
+ return speed;
+ }
+
+ @Override
+ public int getRamSize() {
+ return ramSize;
+ }
+
+ public void setRateMbps(Integer rateMbps) {
+ this.rateMbps = rateMbps;
+ }
+
+ @Override
+ public Integer getRateMbps() {
+ return rateMbps;
+ }
+
+ public void setMulticastRateMbps(Integer multicastRateMbps) {
+ this.multicastRateMbps = multicastRateMbps;
+ }
+
+ @Override
+ public Integer getMulticastRateMbps() {
+ return multicastRateMbps;
+ }
+
+ public String gethypervisorType() {
+ return null;
+ }
+
+ public void setHostTag(String hostTag) {
+ this.hostTag = hostTag;
+ }
+
+ public String getHostTag() {
+ return hostTag;
+ }
+
+ @Override
+ public boolean getDefaultUse() {
+ return false;
+ }
+
+ @Override
+ public String getSystemVmType() {
+ return null;
+ }
+
+ @Override
+ public String getUuid() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean getVolatileVm() {
+ return false;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/LBHealthCheckPolicyVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/LBHealthCheckPolicyVO.java b/engine/schema/src/com/cloud/network/LBHealthCheckPolicyVO.java
new file mode 100644
index 0000000..ed03a2b
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/LBHealthCheckPolicyVO.java
@@ -0,0 +1,157 @@
+// 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.network;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+import com.cloud.network.rules.HealthCheckPolicy;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = ("load_balancer_healthcheck_policies"))
+@PrimaryKeyJoinColumn(name = "load_balancer_id", referencedColumnName = "id")
+public class LBHealthCheckPolicyVO implements HealthCheckPolicy {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "load_balancer_id")
+ private long loadBalancerId;
+
+ @Column(name = "pingpath")
+ private String pingPath;
+
+ @Column(name = "description")
+ private String description;
+
+ @Column(name = "uuid")
+ private String uuid;
+
+ @Column(name = "response_time")
+ private int responseTime;
+
+ @Column(name = "healthcheck_interval")
+ private int healthcheckInterval;
+
+ @Column(name = "healthcheck_thresshold")
+ private int healthcheckThresshold;
+
+ @Column(name = "unhealth_thresshold")
+ private int unhealthThresshold;
+
+ @Column(name = "revoke")
+ private boolean revoke = false;
+
+ protected LBHealthCheckPolicyVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public LBHealthCheckPolicyVO(long loadBalancerId, String pingPath, String description, int responseTime,
+ int healthcheckInterval, int healthcheckThresshold, int unhealthThresshold) {
+ this.loadBalancerId = loadBalancerId;
+
+ if (pingPath == null || pingPath.isEmpty())
+ this.pingPath = "/";
+ else
+ this.pingPath = pingPath;
+
+ if (responseTime == 0)
+ this.responseTime = 2;
+ else
+ this.responseTime = responseTime;
+
+ if (healthcheckInterval == 0)
+ this.healthcheckInterval = 5;
+ else
+ this.healthcheckInterval = healthcheckInterval;
+
+ if (healthcheckThresshold == 0)
+ this.healthcheckThresshold = 2;
+ else
+ this.healthcheckThresshold = healthcheckThresshold;
+
+ if (unhealthThresshold == 0)
+ this.unhealthThresshold = 1;
+ else
+ this.unhealthThresshold = unhealthThresshold;
+ this.uuid = UUID.randomUUID().toString();
+
+ }
+
+ public int getResponseTime() {
+ return responseTime;
+ }
+
+ public int getHealthcheckInterval() {
+ return healthcheckInterval;
+ }
+
+ public int getHealthcheckThresshold() {
+ return healthcheckThresshold;
+ }
+
+ public int getUnhealthThresshold() {
+ return unhealthThresshold;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getLoadBalancerId() {
+ return loadBalancerId;
+ }
+
+ public String getpingpath() {
+ return pingPath;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public boolean isRevoke() {
+ return revoke;
+ }
+
+ public void setRevoke(boolean revoke) {
+ this.revoke = revoke;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java
new file mode 100644
index 0000000..70eb12d
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java
@@ -0,0 +1,188 @@
+// 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.network;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name=("user_ipv6_address"))
+public class UserIpv6AddressVO implements UserIpv6Address {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ long id;
+
+ @Column(name="ip_address")
+ @Enumerated(value=EnumType.STRING)
+ private String address = null;
+
+ @Column(name="data_center_id", updatable=false)
+ private long dataCenterId;
+
+ @Column(name="vlan_id")
+ private long vlanId;
+
+ @Column(name="state")
+ private State state;
+
+ @Column(name="mac_address")
+ private String macAddress;
+
+ @Column(name="source_network_id")
+ private Long sourceNetworkId;
+
+ @Column(name="network_id")
+ private Long networkId;
+
+ @Column(name="uuid")
+ private String uuid;
+
+ @Column(name="physical_network_id")
+ private Long physicalNetworkId;
+
+ @Column(name="account_id")
+ private Long accountId = null;
+
+ @Column(name="domain_id")
+ private Long domainId = null;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ Date created;
+
+ protected UserIpv6AddressVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public UserIpv6AddressVO(String address, long dataCenterId, String macAddress, long vlanDbId) {
+ this.address = address;
+ this.dataCenterId = dataCenterId;
+ this.vlanId = vlanDbId;
+ this.state = State.Free;
+ this.setMacAddress(macAddress);
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+ @Override
+ public String getAddress() {
+ return address;
+ }
+
+ @Override
+ public long getVlanId() {
+ return vlanId;
+ }
+
+ @Override
+ public State getState() {
+ return state;
+ }
+
+ @Override
+ public Long getNetworkId() {
+ return networkId;
+ }
+
+ @Override
+ public Long getSourceNetworkId() {
+ return sourceNetworkId;
+ }
+
+ @Override
+ public Long getPhysicalNetworkId() {
+ return physicalNetworkId;
+ }
+
+ @Override
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ public void setSourceNetworkId(Long sourceNetworkId) {
+ this.sourceNetworkId = sourceNetworkId;
+ }
+
+ public void setNetworkId(Long networkId) {
+ this.networkId = networkId;
+ }
+
+ public void setPhysicalNetworkId(Long physicalNetworkId) {
+ this.physicalNetworkId = physicalNetworkId;
+ }
+
+ public void setDomainId(Long domainId) {
+ this.domainId = domainId;
+ }
+
+ public void setAccountId(Long accountId) {
+ this.accountId = accountId;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/AutoScalePolicyConditionMapVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScalePolicyConditionMapVO.java b/engine/schema/src/com/cloud/network/as/AutoScalePolicyConditionMapVO.java
new file mode 100644
index 0000000..7d87b27
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/AutoScalePolicyConditionMapVO.java
@@ -0,0 +1,61 @@
+// 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.network.as;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name=("autoscale_policy_condition_map"))
+public class AutoScalePolicyConditionMapVO implements InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="policy_id")
+ private long policyId;
+
+ @Column(name="condition_id")
+ private long conditionId;
+
+ public AutoScalePolicyConditionMapVO() { }
+
+ public AutoScalePolicyConditionMapVO(long policyId, long conditionId) {
+ this.policyId = policyId;
+ this.conditionId = conditionId;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getPolicyId() {
+ return policyId;
+ }
+
+ public long getConditionId() {
+ return conditionId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java
new file mode 100644
index 0000000..f8fbcb4
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java
@@ -0,0 +1,134 @@
+// 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.network.as;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "autoscale_policies")
+@Inheritance(strategy = InheritanceType.JOINED)
+public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ long id;
+
+ @Column(name = "uuid")
+ String uuid;
+
+ @Column(name = "domain_id")
+ private long domainId;
+
+ @Column(name = "account_id")
+ private long accountId;
+
+ @Column(name = "duration")
+ private int duration;
+
+ @Column(name = "quiet_time", updatable = true, nullable = false)
+ private int quietTime;
+
+ @Column(name = "action", updatable = false, nullable = false)
+ private String action;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ protected Date removed;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ protected Date created;
+
+ public AutoScalePolicyVO() {
+ }
+
+ public AutoScalePolicyVO(long domainId, long accountId, int duration, int quietTime, String action) {
+ this.uuid = UUID.randomUUID().toString();
+ this.domainId = domainId;
+ this.accountId = accountId;
+ this.duration = duration;
+ this.quietTime = quietTime;
+ this.action = action;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("AutoScalePolicy[").append("id-").append(id).append("]").toString();
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public int getDuration() {
+ return duration;
+ }
+
+ @Override
+ public int getQuietTime() {
+ return quietTime;
+ }
+
+ @Override
+ public String getAction() {
+ return action;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setDuration(Integer duration) {
+ this.duration = duration;
+ }
+
+ public void setQuietTime(Integer quietTime) {
+ this.quietTime = quietTime;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupPolicyMapVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupPolicyMapVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupPolicyMapVO.java
new file mode 100644
index 0000000..7e1c38a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupPolicyMapVO.java
@@ -0,0 +1,64 @@
+// 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.network.as;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name=("autoscale_vmgroup_policy_map"))
+public class AutoScaleVmGroupPolicyMapVO implements InternalIdentity {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="vmgroup_id")
+ private long vmGroupId;
+
+ @Column(name="policy_id")
+ private long policyId;
+
+ public AutoScaleVmGroupPolicyMapVO() { }
+
+ public AutoScaleVmGroupPolicyMapVO(long vmGroupId, long policyId) {
+ this.vmGroupId = vmGroupId;
+ this.policyId = policyId;
+ }
+
+ public AutoScaleVmGroupPolicyMapVO(long vmgroupId, long policyId, boolean revoke) {
+ this(vmgroupId, policyId);
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getVmGroupId() {
+ return vmGroupId;
+ }
+
+ public long getPolicyId() {
+ return policyId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
new file mode 100644
index 0000000..d1d85f9
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
@@ -0,0 +1,191 @@
+// 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.network.as;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "autoscale_vmgroups")
+@Inheritance(strategy = InheritanceType.JOINED)
+public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ long id;
+
+ @Column(name = "uuid")
+ String uuid;
+
+ @Column(name = "zone_id", updatable = false)
+ private long zoneId;
+
+ @Column(name = "domain_id", updatable = false)
+ private long domainId;
+
+ @Column(name = "account_id")
+ private long accountId;
+
+ @Column(name = "load_balancer_id")
+ private Long loadBalancerId;
+
+ @Column(name = "min_members", updatable = true)
+ private int minMembers;
+
+ @Column(name = "max_members", updatable = true)
+ private int maxMembers;
+
+ @Column(name = "member_port")
+ private int memberPort;
+
+ @Column(name = "interval")
+ private int interval;
+
+ @Column(name = "profile_id")
+ private long profileId;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ protected Date removed;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ protected Date created;
+
+ @Column(name = "state")
+ private String state;
+
+ public AutoScaleVmGroupVO() {
+ }
+
+ public AutoScaleVmGroupVO(long lbRuleId, long zoneId, long domainId, long accountId, int minMembers, int maxMembers, int memberPort, int interval, long profileId, String state) {
+ this.uuid = UUID.randomUUID().toString();
+ this.loadBalancerId = lbRuleId;
+ this.minMembers = minMembers;
+ this.maxMembers = maxMembers;
+ this.memberPort = memberPort;
+ this.profileId = profileId;
+ this.accountId = accountId;
+ this.domainId = domainId;
+ this.zoneId = zoneId;
+ this.state = state;
+ this.interval = interval;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("AutoScaleVmGroupVO[").append("id").append("]").toString();
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ public long getZoneId() {
+ return zoneId;
+ }
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public Long getLoadBalancerId() {
+ return loadBalancerId;
+ }
+
+ @Override
+ public int getMinMembers() {
+ return minMembers;
+ }
+
+ @Override
+ public int getMaxMembers() {
+ return maxMembers;
+ }
+
+ @Override
+ public int getMemberPort() {
+ return memberPort;
+ }
+
+ @Override
+ public int getInterval() {
+ return interval;
+ }
+
+ @Override
+ public long getProfileId() {
+ return profileId;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ @Override
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public void setMinMembers(int minMembers) {
+ this.minMembers = minMembers;
+ }
+
+ public void setMaxMembers(int maxMembers) {
+ this.maxMembers = maxMembers;
+ }
+
+ public void setInterval(Integer interval) {
+ this.interval = interval;
+ }
+
+ public void setLoadBalancerId(Long loadBalancerId) {
+ this.loadBalancerId = loadBalancerId;
+ }
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
new file mode 100644
index 0000000..011be2b
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
@@ -0,0 +1,218 @@
+// 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.network.as;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.net.NetUtils;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "autoscale_vmprofiles")
+@Inheritance(strategy = InheritanceType.JOINED)
+public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ protected long id;
+
+ @Column(name = "uuid")
+ protected String uuid;
+
+ @Column(name = "zone_id", updatable = true, nullable = false)
+ protected Long zoneId;
+
+ @Column(name = "domain_id", updatable = true)
+ private long domainId;
+
+ @Column(name = "account_id")
+ private long accountId;
+
+ @Column(name = "autoscale_user_id")
+ private long autoscaleUserId;
+
+ @Column(name = "service_offering_id", updatable = true, nullable = false)
+ private Long serviceOfferingId;
+
+ @Column(name = "template_id", updatable = true, nullable = false, length = 17)
+ private Long templateId;
+
+ @Column(name = "other_deploy_params", updatable = true, length = 1024)
+ private String otherDeployParams;
+
+ @Column(name = "destroy_vm_grace_period", updatable = true)
+ private Integer destroyVmGraceperiod = NetUtils.DEFAULT_AUTOSCALE_VM_DESTROY_TIME;
+
+ @Column(name = "counter_params", updatable = true)
+ private String counterParams;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ protected Date removed;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ protected Date created;
+
+ public AutoScaleVmProfileVO() {
+ }
+
+ public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, Map counterParamList, Integer destroyVmGraceperiod,
+ long autoscaleUserId) {
+ this.uuid = UUID.randomUUID().toString();
+ this.zoneId = zoneId;
+ this.domainId = domainId;
+ this.accountId = accountId;
+ this.serviceOfferingId = serviceOfferingId;
+ this.templateId = templateId;
+ this.otherDeployParams = otherDeployParams;
+ this.autoscaleUserId = autoscaleUserId;
+ if (destroyVmGraceperiod != null) {
+ this.destroyVmGraceperiod = destroyVmGraceperiod;
+ }
+ setCounterParamsForUpdate(counterParamList);
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("AutoScaleVMProfileVO[").append("id").append(id).append("-").append("templateId").append("-").append(templateId).append("]").toString();
+ }
+
+ @Override
+ public Long getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(Long templateId) {
+ this.templateId = templateId;
+ }
+
+ @Override
+ public Long getServiceOfferingId() {
+ return serviceOfferingId;
+ }
+
+ @Override
+ public String getOtherDeployParams() {
+ return otherDeployParams;
+ }
+
+ public void setOtherDeployParams(String otherDeployParams) {
+ this.otherDeployParams = otherDeployParams;
+ }
+
+ @Override
+ public List<Pair<String, String>> getCounterParams() {
+ List<Pair<String, String>> paramsList = new ArrayList<Pair<String, String>>();
+ if (counterParams != null) {
+ String[] params = counterParams.split("[=&]");
+ for (int i = 0; i < (params.length - 1); i = i + 2) {
+ paramsList.add(new Pair<String, String>(params[i], params[i + 1]));
+ }
+ }
+ return paramsList;
+ }
+
+ public void setCounterParams(String counterParam) {
+ this.counterParams = counterParam;
+ }
+
+ public void setCounterParamsForUpdate(Map counterParamList) {
+ StringBuilder sb = new StringBuilder("");
+ boolean isFirstParam = true;
+ if (counterParamList != null) {
+ Iterator<HashMap<String, String>> iter = counterParamList.values().iterator();
+ while (iter.hasNext()) {
+ HashMap<String, String> paramKVpair = iter.next();
+ if (!isFirstParam) {
+ sb.append("&");
+ }
+ String paramName = paramKVpair.get("name");
+ String paramValue = paramKVpair.get("value");
+ sb.append(paramName + "=" + paramValue);
+ isFirstParam = false;
+ }
+ }
+ /*
+ * setCounterParams(String counterParam)'s String param is caught by UpdateBuilder and stored in an internal
+ * list.
+ * Which is used later to update the db. The variables in a VO object is not used to update the db.
+ * Hence calling the function which is intercepted.
+ */
+ setCounterParams(sb.toString());
+ }
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setAutoscaleUserId(long autoscaleUserId) {
+ this.autoscaleUserId = autoscaleUserId;
+ }
+
+ @Override
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public Integer getDestroyVmGraceperiod() {
+ return destroyVmGraceperiod;
+ }
+
+ public void setDestroyVmGraceperiod(Integer destroyVmGraceperiod) {
+ this.destroyVmGraceperiod = destroyVmGraceperiod;
+ }
+
+ @Override
+ public long getAutoScaleUserId() {
+ return autoscaleUserId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/ConditionVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/ConditionVO.java b/engine/schema/src/com/cloud/network/as/ConditionVO.java
new file mode 100644
index 0000000..bbae72f
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/ConditionVO.java
@@ -0,0 +1,129 @@
+// 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.network.as;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "conditions")
+public class ConditionVO implements Condition, Identity, InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "counter_id")
+ private long counterid;
+
+ @Column(name = "threshold")
+ private long threshold;
+
+ @Column(name = "relational_operator")
+ @Enumerated(value = EnumType.STRING)
+ private Operator relationalOperator;
+
+ @Column(name = "domain_id")
+ protected long domainId;
+
+ @Column(name = "account_id")
+ protected long accountId;
+
+ @Column(name = "uuid")
+ private String uuid;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ Date removed;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ Date created;
+
+ public ConditionVO() {
+ }
+
+ public ConditionVO(long counterid, long threshold, long accountId, long domainId, Operator relationalOperator) {
+ this.counterid = counterid;
+ this.threshold = threshold;
+ this.relationalOperator = relationalOperator;
+ this.accountId = accountId;
+ this.domainId = domainId;
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("Condition[").append("id-").append(id).append("]").toString();
+ }
+
+ @Override
+ public long getCounterid() {
+ return counterid;
+ }
+
+ @Override
+ public long getThreshold() {
+ return threshold;
+ }
+
+ @Override
+ public Operator getRelationalOperator() {
+ return relationalOperator;
+ }
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/CounterVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/CounterVO.java b/engine/schema/src/com/cloud/network/as/CounterVO.java
new file mode 100644
index 0000000..b7b03f7
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/CounterVO.java
@@ -0,0 +1,111 @@
+// 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.network.as;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "counter")
+public class CounterVO implements Counter, Identity, InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "source")
+ @Enumerated(value = EnumType.STRING)
+ private Source source;
+
+ @Column(name = "name")
+ private String name;
+
+ @Column(name = "value")
+ private String value;
+
+ @Column(name = "uuid")
+ private String uuid;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ Date removed;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ Date created;
+
+ public CounterVO() {
+ }
+
+ public CounterVO(Source source, String name, String value) {
+ this.source = source;
+ this.name = name;
+ this.value = value;
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("Counter[").append("id-").append(id).append("]").toString();
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public Source getSource() {
+ return source;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDao.java b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDao.java
new file mode 100644
index 0000000..3025198
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDao.java
@@ -0,0 +1,28 @@
+// 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.network.as.dao;
+
+import java.util.List;
+
+import com.cloud.network.as.AutoScalePolicyConditionMapVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface AutoScalePolicyConditionMapDao extends GenericDao<AutoScalePolicyConditionMapVO, Long> {
+ List<AutoScalePolicyConditionMapVO> listByAll(Long policyId, Long conditionId);
+ public boolean isConditionInUse(Long conditionId);
+ boolean removeByAutoScalePolicyId(long id);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDaoImpl.java b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDaoImpl.java
new file mode 100644
index 0000000..00fee3d
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyConditionMapDaoImpl.java
@@ -0,0 +1,61 @@
+// 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.network.as.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.as.AutoScalePolicyConditionMapVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value={AutoScalePolicyConditionMapDao.class})
+public class AutoScalePolicyConditionMapDaoImpl extends GenericDaoBase<AutoScalePolicyConditionMapVO, Long> implements AutoScalePolicyConditionMapDao {
+
+ private SearchCriteria<AutoScalePolicyConditionMapVO> getSearchCriteria(Long policyId, Long conditionId)
+ {
+ SearchCriteria<AutoScalePolicyConditionMapVO> sc = createSearchCriteria();
+
+ if(policyId != null)
+ sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId);
+
+ if(conditionId != null)
+ sc.addAnd("conditionId", SearchCriteria.Op.EQ, conditionId);
+
+ return sc;
+ }
+
+ @Override
+ public List<AutoScalePolicyConditionMapVO> listByAll(Long policyId, Long conditionId) {
+ return listBy(getSearchCriteria(policyId, conditionId));
+ }
+
+ public boolean isConditionInUse(Long conditionId) {
+ return findOneBy(getSearchCriteria(null, conditionId)) != null;
+ }
+
+ @Override
+ public boolean removeByAutoScalePolicyId(long policyId) {
+ SearchCriteria<AutoScalePolicyConditionMapVO> sc = createSearchCriteria();
+ sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId);
+ return expunge(sc) > 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDao.java b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDao.java
new file mode 100644
index 0000000..0cc2d27
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDao.java
@@ -0,0 +1,24 @@
+// 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.network.as.dao;
+
+import com.cloud.network.as.AutoScalePolicyVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface AutoScalePolicyDao extends GenericDao<AutoScalePolicyVO, Long> {
+ int removeByAccountId(long accountId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java
new file mode 100644
index 0000000..796a9c3
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScalePolicyDaoImpl.java
@@ -0,0 +1,38 @@
+// 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.network.as.dao;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.as.AutoScalePolicyVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = { AutoScalePolicyDao.class })
+public class AutoScalePolicyDaoImpl extends GenericDaoBase<AutoScalePolicyVO, Long> implements AutoScalePolicyDao {
+
+ public int removeByAccountId(long accountId) {
+ SearchCriteria<AutoScalePolicyVO> sc = createSearchCriteria();
+
+ sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
+
+ return remove(sc);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDao.java b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDao.java
new file mode 100644
index 0000000..3fc8a5b
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDao.java
@@ -0,0 +1,28 @@
+// 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.network.as.dao;
+
+import java.util.List;
+
+import com.cloud.network.as.AutoScaleVmGroupVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface AutoScaleVmGroupDao extends GenericDao<AutoScaleVmGroupVO, Long> {
+ List<AutoScaleVmGroupVO> listByAll(Long loadBalancerId, Long profileId);
+ boolean isProfileInUse(long profileId);
+ boolean isAutoScaleLoadBalancer(Long loadBalancerId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDaoImpl.java b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDaoImpl.java
new file mode 100644
index 0000000..4ddd572
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupDaoImpl.java
@@ -0,0 +1,65 @@
+// 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.network.as.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.as.AutoScaleVmGroupVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+
+@Component
+@Local(value = { AutoScaleVmGroupDao.class })
+public class AutoScaleVmGroupDaoImpl extends GenericDaoBase<AutoScaleVmGroupVO, Long> implements AutoScaleVmGroupDao {
+
+ @Override
+ public List<AutoScaleVmGroupVO> listByAll(Long loadBalancerId, Long profileId) {
+ SearchCriteria<AutoScaleVmGroupVO> sc = createSearchCriteria();
+
+ if(loadBalancerId != null)
+ sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
+
+ if(profileId != null)
+ sc.addAnd("profileId", SearchCriteria.Op.EQ, profileId);
+
+ return listBy(sc);
+ }
+
+ @Override
+ public boolean isProfileInUse(long profileId) {
+ SearchCriteria<AutoScaleVmGroupVO> sc = createSearchCriteria();
+ sc.addAnd("profileId", SearchCriteria.Op.EQ, profileId);
+ return findOneBy(sc) != null;
+ }
+
+ @Override
+ public boolean isAutoScaleLoadBalancer(Long loadBalancerId) {
+ GenericSearchBuilder<AutoScaleVmGroupVO, Long> CountByAccount = createSearchBuilder(Long.class);
+ CountByAccount.select(null, Func.COUNT, null);
+ CountByAccount.and("loadBalancerId", CountByAccount.entity().getLoadBalancerId(), SearchCriteria.Op.EQ);
+
+ SearchCriteria<Long> sc = CountByAccount.create();
+ sc.setParameters("loadBalancerId", loadBalancerId);
+ return customSearch(sc, null).get(0) > 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDao.java b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDao.java
new file mode 100644
index 0000000..41d91f7
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDao.java
@@ -0,0 +1,30 @@
+// 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.network.as.dao;
+
+import java.util.List;
+
+import com.cloud.network.as.AutoScaleVmGroupPolicyMapVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface AutoScaleVmGroupPolicyMapDao extends GenericDao<AutoScaleVmGroupPolicyMapVO, Long> {
+ boolean removeByGroupId(long vmGroupId);
+ boolean removeByGroupAndPolicies(long vmGroupId, List<Long> bakupPolicyIds);
+ List<AutoScaleVmGroupPolicyMapVO> listByVmGroupId(long vmGroupId);
+ List<AutoScaleVmGroupPolicyMapVO> listByPolicyId(long policyId);
+ public boolean isAutoScalePolicyInUse(long policyId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDaoImpl.java b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDaoImpl.java
new file mode 100644
index 0000000..ffb3dbc
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmGroupPolicyMapDaoImpl.java
@@ -0,0 +1,77 @@
+// 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.network.as.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.as.AutoScaleVmGroupPolicyMapVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+@Local(value={AutoScaleVmGroupPolicyMapDao.class})
+public class AutoScaleVmGroupPolicyMapDaoImpl extends GenericDaoBase<AutoScaleVmGroupPolicyMapVO, Long> implements AutoScaleVmGroupPolicyMapDao {
+
+ @Override
+ public boolean removeByGroupId(long vmGroupId) {
+ SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = createSearchCriteria();
+ sc.addAnd("vmGroupId", SearchCriteria.Op.EQ, vmGroupId);
+
+ return expunge(sc) > 0;
+ }
+
+ @Override
+ public boolean removeByGroupAndPolicies(long vmGroupId, List<Long> policyIds) {
+ SearchBuilder<AutoScaleVmGroupPolicyMapVO> policySearch = createSearchBuilder();
+ policySearch.and("vmGroupId", policySearch.entity().getVmGroupId(), Op.EQ);
+ policySearch.and("policyIds", policySearch.entity().getPolicyId(), Op.IN);
+ policySearch.done();
+ SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = policySearch.create();
+ sc.setParameters("vmGroupId", vmGroupId);
+ sc.setParameters("policyIds", policyIds);
+ return expunge(sc) > 0;
+ }
+
+ @Override
+ public List<AutoScaleVmGroupPolicyMapVO> listByVmGroupId(long vmGroupId) {
+ SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = createSearchCriteria();
+ sc.addAnd("vmGroupId", SearchCriteria.Op.EQ, vmGroupId);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<AutoScaleVmGroupPolicyMapVO> listByPolicyId(long policyId) {
+ SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = createSearchCriteria();
+ sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId);
+
+ return listBy(sc);
+ }
+
+ @Override
+ public boolean isAutoScalePolicyInUse(long policyId) {
+ SearchCriteria<AutoScaleVmGroupPolicyMapVO> sc = createSearchCriteria();
+ sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId);
+ return findOneBy(sc) != null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java
new file mode 100644
index 0000000..0855bf7
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDao.java
@@ -0,0 +1,25 @@
+// 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.network.as.dao;
+
+import com.cloud.network.as.AutoScaleVmProfileVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface AutoScaleVmProfileDao extends GenericDao<AutoScaleVmProfileVO, Long> {
+
+ int removeByAccountId(long accountId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java
new file mode 100644
index 0000000..5d08491
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/AutoScaleVmProfileDaoImpl.java
@@ -0,0 +1,38 @@
+// 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.network.as.dao;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.as.AutoScaleVmProfileVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = { AutoScaleVmProfileDao.class })
+public class AutoScaleVmProfileDaoImpl extends GenericDaoBase<AutoScaleVmProfileVO, Long> implements AutoScaleVmProfileDao {
+
+ @Override
+ public int removeByAccountId(long accountId) {
+ SearchCriteria<AutoScaleVmProfileVO> sc = createSearchCriteria();
+ sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
+
+ return remove(sc);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/ConditionDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/ConditionDao.java b/engine/schema/src/com/cloud/network/as/dao/ConditionDao.java
new file mode 100644
index 0000000..128920d
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/ConditionDao.java
@@ -0,0 +1,28 @@
+// 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.network.as.dao;
+
+import com.cloud.network.as.ConditionVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface ConditionDao extends GenericDao<ConditionVO, Long> {
+
+ ConditionVO findByCounterId(long ctrId);
+
+ int removeByAccountId(long accountId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/network/as/dao/ConditionDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/dao/ConditionDaoImpl.java b/engine/schema/src/com/cloud/network/as/dao/ConditionDaoImpl.java
new file mode 100644
index 0000000..8235823
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/as/dao/ConditionDaoImpl.java
@@ -0,0 +1,56 @@
+// 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.network.as.dao;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.as.ConditionVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+@Local(value = ConditionDao.class)
+public class ConditionDaoImpl extends GenericDaoBase<ConditionVO, Long> implements ConditionDao {
+ final SearchBuilder<ConditionVO> AllFieldsSearch;
+
+ protected ConditionDaoImpl() {
+ AllFieldsSearch = createSearchBuilder();
+ AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
+ AllFieldsSearch.and("counterId", AllFieldsSearch.entity().getCounterid(), Op.EQ);
+ AllFieldsSearch.done();
+ }
+
+ @Override
+ public ConditionVO findByCounterId(long ctrId) {
+ SearchCriteria<ConditionVO> sc = AllFieldsSearch.create();
+ sc.setParameters("counterId", ctrId);
+ return findOneBy(sc);
+ }
+
+ public int removeByAccountId(long accountId) {
+ SearchCriteria<ConditionVO> sc = createSearchCriteria();
+
+ sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
+
+ return remove(sc);
+ }
+}