mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
merge compiles
This commit is contained in:
parent
7f3a748d6c
commit
14bd345f1f
@ -1,4 +1,4 @@
|
||||
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
||||
<!-- 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
|
||||
@ -430,21 +430,6 @@
|
||||
'${db.cloud.password}';</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>grant-user-cloud-usage-all</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<username>root</username>
|
||||
<password>${db.root.password}</password>
|
||||
<url>jdbc:mysql://${db.cloud.host}:${db.cloud.port}</url>
|
||||
<sqlCommand>GRANT ALL ON cloud_usage.* to
|
||||
${db.cloud.username}@`%` identified by
|
||||
'${db.cloud.password}';</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>grant-user-cloud-bridge</id>
|
||||
<phase>process-test-resources</phase>
|
||||
@ -507,9 +492,9 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<autocommit>true</autocommit>
|
||||
<srcFiles>
|
||||
<srcFile>${basedir}/developer-prefill.sql</srcFile>
|
||||
</srcFiles>
|
||||
<srcFiles>
|
||||
<srcFile>${basedir}/developer-prefill.sql</srcFile>
|
||||
</srcFiles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@ -518,56 +503,58 @@
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<!-- Simulator profile -->
|
||||
<profile>
|
||||
<id>simulator</id>
|
||||
<activation>
|
||||
<property><name>deploydb-simulator</name></property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>read-project-properties</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<files>
|
||||
<file>${project.parent.basedir}/utils/conf/db.properties</file>
|
||||
<file>${project.parent.basedir}/utils/conf/db.properties.override</file>
|
||||
</files>
|
||||
<quiet>true</quiet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sql-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${cs.mysql.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<driver>org.gjt.mm.mysql.Driver</driver>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306/simulator</url>
|
||||
<username>${db.simulator.username}</username>
|
||||
<password>${db.simulator.password}</password>
|
||||
<skip>${maven.test.skip}</skip>
|
||||
<forceMojoExecution>true</forceMojoExecution>
|
||||
</configuration>
|
||||
<executions>
|
||||
<!-- Simulator profile -->
|
||||
<profile>
|
||||
<id>simulator</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>deploydb-simulator</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>drop-database</id>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>read-project-properties</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<files>
|
||||
<file>${project.parent.basedir}/utils/conf/db.properties</file>
|
||||
<file>${project.parent.basedir}/utils/conf/db.properties.override</file>
|
||||
</files>
|
||||
<quiet>true</quiet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sql-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${cs.mysql.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<driver>org.gjt.mm.mysql.Driver</driver>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306/simulator</url>
|
||||
<username>${db.simulator.username}</username>
|
||||
<password>${db.simulator.password}</password>
|
||||
<skip>${maven.test.skip}</skip>
|
||||
<forceMojoExecution>true</forceMojoExecution>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>drop-database</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
@ -575,12 +562,12 @@
|
||||
<configuration>
|
||||
<username>root</username>
|
||||
<password>${db.root.password}</password>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>drop database if exists `simulator`</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>create-database</id>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>drop database if exists `simulator`</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>create-database</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
@ -588,51 +575,51 @@
|
||||
<configuration>
|
||||
<username>root</username>
|
||||
<password>${db.root.password}</password>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>create database `simulator`</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>grant-user-cloud</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<username>root</username>
|
||||
<password>${db.root.password}</password>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>GRANT ALL ON simulator.* to
|
||||
${db.simulator.username}@`localhost` identified by
|
||||
'${db.simulator.password}';</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>grant-user-cloud-all</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<username>root</username>
|
||||
<password>${db.root.password}</password>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>GRANT ALL ON simulator.* to
|
||||
${db.simulator.username}@`%` identified by
|
||||
'${db.simulator.password}';</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>create-schema</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<srcFiles>
|
||||
<srcFile>${basedir}/target/db/create-schema-simulator.sql</srcFile>
|
||||
<srcFile>${basedir}/target/db/templates.simulator.sql</srcFile>
|
||||
</srcFiles>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>create database `simulator`</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>grant-user-cloud</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<username>root</username>
|
||||
<password>${db.root.password}</password>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>GRANT ALL ON simulator.* to
|
||||
${db.simulator.username}@`localhost` identified by
|
||||
'${db.simulator.password}';</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>grant-user-cloud-all</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<username>root</username>
|
||||
<password>${db.root.password}</password>
|
||||
<url>jdbc:mysql://${db.simulator.host}:3306</url>
|
||||
<sqlCommand>GRANT ALL ON simulator.* to
|
||||
${db.simulator.username}@`%` identified by
|
||||
'${db.simulator.password}';</sqlCommand>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>create-schema</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<srcFiles>
|
||||
<srcFile>${basedir}/target/db/create-schema-simulator.sql</srcFile>
|
||||
<srcFile>${basedir}/target/db/templates.simulator.sql</srcFile>
|
||||
</srcFiles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
@ -20,6 +20,11 @@
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-utils</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-api</artifactId>
|
||||
|
||||
@ -21,8 +21,6 @@ package org.apache.cloudstack.engine.service.api;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.POST;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
|
||||
@ -42,10 +40,8 @@ public interface ProvisioningService {
|
||||
|
||||
StorageEntity registerStorage(String name, List<String> tags, Map<String, String> details);
|
||||
|
||||
@POST
|
||||
ZoneEntity registerZone(String zoneUuid, String name, String owner, List<String> tags, Map<String, String> details);
|
||||
|
||||
@POST
|
||||
PodEntity registerPod(String podUuid, String name, String owner, String zoneUuid, List<String> tags, Map<String, String> details);
|
||||
|
||||
ClusterEntity registerCluster(String clusterUuid, String name, String owner, List<String> tags, Map<String, String> details);
|
||||
|
||||
@ -159,30 +159,30 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
|
||||
@Column(name="uuid")
|
||||
protected String uuid = UUID.randomUUID().toString();
|
||||
|
||||
|
||||
//orchestration columns
|
||||
@Column(name="owner")
|
||||
private String owner = null;
|
||||
|
||||
|
||||
@Column(name="speed")
|
||||
private int speed;
|
||||
|
||||
|
||||
@Transient
|
||||
List<String> computeTags;
|
||||
|
||||
|
||||
@Transient
|
||||
List<String> rootDiskTags;
|
||||
|
||||
|
||||
@Column(name="hostname")
|
||||
private String hostname = null;
|
||||
|
||||
@Column(name="displayname")
|
||||
private String displayname = null;
|
||||
|
||||
|
||||
@Transient
|
||||
List<String> networkIds;
|
||||
|
||||
|
||||
|
||||
|
||||
public VMEntityVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
@ -227,8 +227,8 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
|
||||
this.limitCpuUse = limitResourceUse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected VMEntityVO() {
|
||||
}
|
||||
@ -501,60 +501,66 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
public void setSpeed(int speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public List<String> getComputeTags() {
|
||||
return computeTags;
|
||||
}
|
||||
public List<String> getComputeTags() {
|
||||
return computeTags;
|
||||
}
|
||||
|
||||
public void setComputeTags(List<String> computeTags) {
|
||||
this.computeTags = computeTags;
|
||||
}
|
||||
public void setComputeTags(List<String> computeTags) {
|
||||
this.computeTags = computeTags;
|
||||
}
|
||||
|
||||
public List<String> getRootDiskTags() {
|
||||
return rootDiskTags;
|
||||
}
|
||||
public List<String> getRootDiskTags() {
|
||||
return rootDiskTags;
|
||||
}
|
||||
|
||||
public void setRootDiskTags(List<String> rootDiskTags) {
|
||||
this.rootDiskTags = rootDiskTags;
|
||||
}
|
||||
public void setRootDiskTags(List<String> rootDiskTags) {
|
||||
this.rootDiskTags = rootDiskTags;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
public String getDisplayname() {
|
||||
return displayname;
|
||||
}
|
||||
public String getDisplayname() {
|
||||
return displayname;
|
||||
}
|
||||
|
||||
public void setDisplayname(String displayname) {
|
||||
this.displayname = displayname;
|
||||
}
|
||||
public void setDisplayname(String displayname) {
|
||||
this.displayname = displayname;
|
||||
}
|
||||
|
||||
public List<String> getNetworkIds() {
|
||||
return networkIds;
|
||||
}
|
||||
public List<String> getNetworkIds() {
|
||||
return networkIds;
|
||||
}
|
||||
|
||||
public void setNetworkIds(List<String> networkIds) {
|
||||
this.networkIds = networkIds;
|
||||
}
|
||||
public void setNetworkIds(List<String> networkIds) {
|
||||
this.networkIds = networkIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDiskOfferingId() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,14 +26,14 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.org.Managed.ManagedState;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Managed.ManagedState;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.StateMachine;
|
||||
@ -46,52 +46,52 @@ public class ClusterVO implements Cluster, Identity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
long id;
|
||||
|
||||
|
||||
@Column(name="name")
|
||||
String name;
|
||||
|
||||
|
||||
@Column(name="guid")
|
||||
String guid;
|
||||
|
||||
|
||||
@Column(name="data_center_id")
|
||||
long dataCenterId;
|
||||
|
||||
|
||||
@Column(name="pod_id")
|
||||
long podId;
|
||||
|
||||
|
||||
@Column(name="hypervisor_type")
|
||||
String hypervisorType;
|
||||
|
||||
@Column(name="cluster_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
Cluster.ClusterType clusterType;
|
||||
|
||||
|
||||
@Column(name="allocation_state")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
AllocationState allocationState;
|
||||
|
||||
|
||||
@Column(name="managed_state")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
ManagedState managedState;
|
||||
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
@Column(name="uuid")
|
||||
String uuid;
|
||||
|
||||
|
||||
//orchestration
|
||||
|
||||
|
||||
@Column(name="owner")
|
||||
private String owner = null;
|
||||
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
protected Date created;
|
||||
|
||||
@Column(name="lastUpdated", updatable=true)
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
protected Date lastUpdated;
|
||||
|
||||
|
||||
/**
|
||||
* Note that state is intentionally missing the setter. Any updates to
|
||||
* the state machine needs to go through the DAO object because someone
|
||||
@ -101,59 +101,66 @@ public class ClusterVO implements Cluster, Identity {
|
||||
@StateMachine(state=State.class, event=Event.class)
|
||||
@Column(name="state", updatable=true, nullable=false, length=32)
|
||||
protected State state = null;
|
||||
|
||||
|
||||
|
||||
|
||||
public ClusterVO() {
|
||||
clusterType = Cluster.ClusterType.CloudManaged;
|
||||
allocationState = Grouping.AllocationState.Enabled;
|
||||
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Disabled;
|
||||
clusterType = Cluster.ClusterType.CloudManaged;
|
||||
allocationState = Grouping.AllocationState.Enabled;
|
||||
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
|
||||
public ClusterVO(long dataCenterId, long podId, String name) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
this.podId = podId;
|
||||
this.name = name;
|
||||
this.clusterType = Cluster.ClusterType.CloudManaged;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.managedState = ManagedState.Managed;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Disabled;
|
||||
this.clusterType = Cluster.ClusterType.CloudManaged;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.managedState = ManagedState.Managed;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Cluster.ClusterType getClusterType() {
|
||||
return clusterType;
|
||||
return clusterType;
|
||||
}
|
||||
|
||||
|
||||
public void setClusterType(Cluster.ClusterType clusterType) {
|
||||
this.clusterType = clusterType;
|
||||
this.clusterType = clusterType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AllocationState getAllocationState() {
|
||||
return allocationState;
|
||||
return allocationState;
|
||||
}
|
||||
|
||||
|
||||
public void setAllocationState(AllocationState allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
this.allocationState = allocationState;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ManagedState getManagedState() {
|
||||
return managedState;
|
||||
}
|
||||
@ -170,7 +177,7 @@ public class ClusterVO implements Cluster, Identity {
|
||||
public int hashCode() {
|
||||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ClusterVO)) {
|
||||
@ -179,19 +186,20 @@ public class ClusterVO implements Cluster, Identity {
|
||||
ClusterVO that = (ClusterVO)obj;
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return HypervisorType.getType(hypervisorType);
|
||||
return HypervisorType.getType(hypervisorType);
|
||||
}
|
||||
|
||||
public void setHypervisorType(String hy) {
|
||||
hypervisorType = hy;
|
||||
public void setHypervisorType(String hy) {
|
||||
hypervisorType = hy;
|
||||
}
|
||||
|
||||
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
@ -203,33 +211,33 @@ public class ClusterVO implements Cluster, Identity {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,10 +29,10 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.org.Grouping;
|
||||
@ -43,107 +43,107 @@ import com.cloud.utils.db.StateMachine;
|
||||
@Entity
|
||||
@Table(name="data_center")
|
||||
public class DataCenterVO implements DataCenter, Identity {
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="name")
|
||||
private String name = null;
|
||||
|
||||
|
||||
@Column(name="name")
|
||||
private String name = null;
|
||||
|
||||
@Column(name="description")
|
||||
private String description = null;
|
||||
|
||||
|
||||
@Column(name="dns1")
|
||||
private String dns1 = null;
|
||||
|
||||
|
||||
@Column(name="dns2")
|
||||
private String dns2 = null;
|
||||
|
||||
|
||||
@Column(name="internal_dns1")
|
||||
private String internalDns1 = null;
|
||||
|
||||
|
||||
@Column(name="internal_dns2")
|
||||
private String internalDns2 = null;
|
||||
|
||||
|
||||
@Column(name="router_mac_address", updatable = false, nullable=false)
|
||||
private String routerMacAddress = "02:00:00:00:00:01";
|
||||
|
||||
|
||||
@Column(name="guest_network_cidr")
|
||||
private String guestNetworkCidr = null;
|
||||
|
||||
|
||||
@Column(name="domain_id")
|
||||
private Long domainId = null;
|
||||
|
||||
@Column(name="domain")
|
||||
private String domain;
|
||||
|
||||
|
||||
@Column(name="networktype")
|
||||
@Enumerated(EnumType.STRING)
|
||||
NetworkType networkType;
|
||||
|
||||
|
||||
@Column(name="dns_provider")
|
||||
private String dnsProvider;
|
||||
|
||||
|
||||
@Column(name="dhcp_provider")
|
||||
private String dhcpProvider;
|
||||
|
||||
|
||||
@Column(name="gateway_provider")
|
||||
private String gatewayProvider;
|
||||
|
||||
|
||||
@Column(name="vpn_provider")
|
||||
private String vpnProvider;
|
||||
|
||||
|
||||
@Column(name="userdata_provider")
|
||||
private String userDataProvider;
|
||||
|
||||
|
||||
@Column(name="lb_provider")
|
||||
private String loadBalancerProvider;
|
||||
|
||||
|
||||
@Column(name="firewall_provider")
|
||||
private String firewallProvider;
|
||||
|
||||
|
||||
@Column(name="mac_address", nullable=false)
|
||||
@TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
|
||||
private long macAddress = 1;
|
||||
|
||||
@Column(name="zone_token")
|
||||
private String zoneToken;
|
||||
|
||||
|
||||
@Column(name="zone_token")
|
||||
private String zoneToken;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
|
||||
// This is a delayed load value. If the value is null,
|
||||
// then this field has not been loaded yet.
|
||||
// Call the dao to load it.
|
||||
@Transient
|
||||
Map<String, String> details;
|
||||
|
||||
|
||||
@Column(name="allocation_state")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
AllocationState allocationState;
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name="is_security_group_enabled")
|
||||
boolean securityGroupEnabled;
|
||||
|
||||
|
||||
@Column(name="is_local_storage_enabled")
|
||||
boolean localStorageEnabled;
|
||||
|
||||
|
||||
//orchestration
|
||||
@Column(name="owner")
|
||||
private String owner = null;
|
||||
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
protected Date created;
|
||||
|
||||
@Column(name="lastUpdated", updatable=true)
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
protected Date lastUpdated;
|
||||
|
||||
|
||||
/**
|
||||
* Note that state is intentionally missing the setter. Any updates to
|
||||
* the state machine needs to go through the DAO object because someone
|
||||
@ -199,13 +199,13 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
public void setFirewallProvider(String firewallProvider) {
|
||||
this.firewallProvider = firewallProvider;
|
||||
}
|
||||
|
||||
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
|
||||
this.id = id;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
}
|
||||
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled) {
|
||||
this.name = name;
|
||||
@ -221,7 +221,7 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.securityGroupEnabled = securityGroupEnabled;
|
||||
this.localStorageEnabled = localStorageEnabled;
|
||||
|
||||
|
||||
if (zoneType == NetworkType.Advanced) {
|
||||
loadBalancerProvider = Provider.VirtualRouter.getName();
|
||||
firewallProvider = Provider.VirtualRouter.getName();
|
||||
@ -242,7 +242,7 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getVpnProvider() {
|
||||
return vpnProvider;
|
||||
@ -260,27 +260,27 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
public void setUserDataProvider(String userDataProvider) {
|
||||
this.userDataProvider = userDataProvider;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getGuestNetworkCidr()
|
||||
{
|
||||
return guestNetworkCidr;
|
||||
return guestNetworkCidr;
|
||||
}
|
||||
|
||||
|
||||
public void setGuestNetworkCidr(String guestNetworkCidr)
|
||||
{
|
||||
this.guestNetworkCidr = guestNetworkCidr;
|
||||
this.guestNetworkCidr = guestNetworkCidr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
@ -289,12 +289,12 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
public String getRouterMacAddress() {
|
||||
return routerMacAddress;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
@ -310,43 +310,43 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
return internalDns2;
|
||||
}
|
||||
|
||||
protected DataCenterVO() {
|
||||
protected DataCenterVO() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDns1(String dns1) {
|
||||
this.dns1 = dns1;
|
||||
}
|
||||
|
||||
public void setDns2(String dns2) {
|
||||
this.dns2 = dns2;
|
||||
}
|
||||
|
||||
public void setInternalDns1(String dns3) {
|
||||
this.internalDns1 = dns3;
|
||||
}
|
||||
|
||||
public void setInternalDns2(String dns4) {
|
||||
this.internalDns2 = dns4;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDns1(String dns1) {
|
||||
this.dns1 = dns1;
|
||||
}
|
||||
|
||||
public void setDns2(String dns2) {
|
||||
this.dns2 = dns2;
|
||||
}
|
||||
|
||||
public void setInternalDns1(String dns3) {
|
||||
this.internalDns1 = dns3;
|
||||
}
|
||||
|
||||
public void setInternalDns2(String dns4) {
|
||||
this.internalDns2 = dns4;
|
||||
}
|
||||
|
||||
public void setRouterMacAddress(String routerMacAddress) {
|
||||
this.routerMacAddress = routerMacAddress;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
@ -355,7 +355,7 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
|
||||
public void setNetworkType(NetworkType zoneNetworkType) {
|
||||
this.networkType = zoneNetworkType;
|
||||
}
|
||||
@ -364,16 +364,16 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
public NetworkType getNetworkType() {
|
||||
return networkType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSecurityGroupEnabled() {
|
||||
return securityGroupEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setSecurityGroupEnabled(boolean enabled) {
|
||||
this.securityGroupEnabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLocalStorageEnabled() {
|
||||
return localStorageEnabled;
|
||||
@ -392,32 +392,33 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
public void setDetails(Map<String, String> details2) {
|
||||
details = details2;
|
||||
}
|
||||
|
||||
|
||||
public String getDetail(String name) {
|
||||
assert (details != null) : "Did you forget to load the details?";
|
||||
|
||||
|
||||
return details != null ? details.get(name) : null;
|
||||
}
|
||||
|
||||
|
||||
public void setDetail(String name, String value) {
|
||||
assert (details != null) : "Did you forget to load the details?";
|
||||
|
||||
|
||||
details.put(name, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AllocationState getAllocationState() {
|
||||
return allocationState;
|
||||
return allocationState;
|
||||
}
|
||||
|
||||
|
||||
public void setAllocationState(AllocationState allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
this.allocationState = allocationState;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof DataCenterVO)) {
|
||||
@ -429,25 +430,25 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
|
||||
@Override
|
||||
public String getZoneToken() {
|
||||
return zoneToken;
|
||||
}
|
||||
|
||||
public void setZoneToken(String zoneToken) {
|
||||
this.zoneToken = zoneToken;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
return zoneToken;
|
||||
}
|
||||
|
||||
public void setZoneToken(String zoneToken) {
|
||||
this.zoneToken = zoneToken;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public long getMacAddress() {
|
||||
return macAddress;
|
||||
@ -457,23 +458,23 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,10 +26,10 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
@ -39,52 +39,52 @@ import com.cloud.utils.db.StateMachine;
|
||||
@Entity
|
||||
@Table(name = "host_pod_ref")
|
||||
public class HostPodVO implements Pod, Identity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
long id;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
long id;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name = null;
|
||||
@Column(name = "name")
|
||||
private String name = null;
|
||||
|
||||
@Column(name = "data_center_id")
|
||||
private long dataCenterId;
|
||||
|
||||
@Column(name = "gateway")
|
||||
private String gateway;
|
||||
@Column(name = "data_center_id")
|
||||
private long dataCenterId;
|
||||
|
||||
@Column(name = "gateway")
|
||||
private String gateway;
|
||||
|
||||
@Column(name = "cidr_address")
|
||||
private String cidrAddress;
|
||||
@Column(name = "cidr_address")
|
||||
private String cidrAddress;
|
||||
|
||||
@Column(name = "cidr_size")
|
||||
private int cidrSize;
|
||||
@Column(name = "cidr_size")
|
||||
private int cidrSize;
|
||||
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@Column(name="allocation_state")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
AllocationState allocationState;
|
||||
|
||||
@Column(name = "external_dhcp")
|
||||
private Boolean externalDhcp;
|
||||
|
||||
@Column(name = "external_dhcp")
|
||||
private Boolean externalDhcp;
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
@Column(name = "uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name = "uuid")
|
||||
private String uuid;
|
||||
|
||||
//orchestration
|
||||
@Column(name="owner")
|
||||
private String owner = null;
|
||||
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
protected Date created;
|
||||
|
||||
@Column(name="lastUpdated", updatable=true)
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
protected Date lastUpdated;
|
||||
|
||||
|
||||
/**
|
||||
* Note that state is intentionally missing the setter. Any updates to
|
||||
* the state machine needs to go through the DAO object because someone
|
||||
@ -95,147 +95,152 @@ public class HostPodVO implements Pod, Identity {
|
||||
@Column(name="state", updatable=true, nullable=false, length=32)
|
||||
protected State state = null;
|
||||
|
||||
public HostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
|
||||
this.name = name;
|
||||
this.dataCenterId = dcId;
|
||||
this.gateway = gateway;
|
||||
this.cidrAddress = cidrAddress;
|
||||
this.cidrSize = cidrSize;
|
||||
this.description = description;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.externalDhcp = false;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
public HostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
|
||||
this.name = name;
|
||||
this.dataCenterId = dcId;
|
||||
this.gateway = gateway;
|
||||
this.cidrAddress = cidrAddress;
|
||||
this.cidrSize = cidrSize;
|
||||
this.description = description;
|
||||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.externalDhcp = false;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
/*
|
||||
* public HostPodVO(String name, long dcId) { this(null, name, dcId); }
|
||||
*/
|
||||
protected HostPodVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
/*
|
||||
* public HostPodVO(String name, long dcId) { this(null, name, dcId); }
|
||||
*/
|
||||
protected HostPodVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
@Override
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public void setDataCenterId(long dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
}
|
||||
public void setDataCenterId(long dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getCidrAddress() {
|
||||
return cidrAddress;
|
||||
}
|
||||
return cidrAddress;
|
||||
}
|
||||
|
||||
public void setCidrAddress(String cidrAddress) {
|
||||
this.cidrAddress = cidrAddress;
|
||||
}
|
||||
public void setCidrAddress(String cidrAddress) {
|
||||
this.cidrAddress = cidrAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getCidrSize() {
|
||||
return cidrSize;
|
||||
}
|
||||
return cidrSize;
|
||||
}
|
||||
|
||||
public void setCidrSize(int cidrSize) {
|
||||
this.cidrSize = cidrSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCidrSize(int cidrSize) {
|
||||
this.cidrSize = cidrSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AllocationState getAllocationState() {
|
||||
return allocationState;
|
||||
return allocationState;
|
||||
}
|
||||
|
||||
|
||||
public void setAllocationState(AllocationState allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
this.allocationState = allocationState;
|
||||
}
|
||||
|
||||
// Use for comparisons only.
|
||||
public HostPodVO(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
// Use for comparisons only.
|
||||
public HostPodVO(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
public boolean getExternalDhcp() {
|
||||
return externalDhcp;
|
||||
}
|
||||
|
||||
public void setExternalDhcp(boolean use) {
|
||||
externalDhcp = use;
|
||||
}
|
||||
|
||||
@Override
|
||||
return NumbersUtil.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getExternalDhcp() {
|
||||
return externalDhcp;
|
||||
}
|
||||
|
||||
public void setExternalDhcp(boolean use) {
|
||||
externalDhcp = use;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof HostPodVO) {
|
||||
return id == ((HostPodVO)obj).id;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj instanceof HostPodVO) {
|
||||
return id == ((HostPodVO)obj).id;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,10 +37,10 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
@ -134,20 +134,20 @@ public class HostVO implements Host, Identity {
|
||||
|
||||
@Column(name="setup")
|
||||
private boolean setup = false;
|
||||
|
||||
|
||||
@Column(name="resource_state", nullable=false)
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private ResourceState resourceState;
|
||||
|
||||
@Column(name="hypervisor_version")
|
||||
private String hypervisorVersion;
|
||||
|
||||
|
||||
@Column(name="update_count", updatable = true, nullable=false)
|
||||
protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code.
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
|
||||
|
||||
// This is a delayed load value. If the value is null,
|
||||
// then this field has not been loaded yet.
|
||||
// Call host dao to load it.
|
||||
@ -367,15 +367,15 @@ public class HostVO implements Host, Identity {
|
||||
|
||||
@Column(name=GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
|
||||
//orchestration
|
||||
@Column(name="owner")
|
||||
private String owner = null;
|
||||
|
||||
|
||||
@Column(name="lastUpdated", updatable=true)
|
||||
@Temporal(value=TemporalType.TIMESTAMP)
|
||||
protected Date lastUpdated;
|
||||
|
||||
|
||||
/**
|
||||
* Note that state is intentionally missing the setter. Any updates to
|
||||
* the state machine needs to go through the DAO object because someone
|
||||
@ -719,61 +719,61 @@ public class HostVO implements Host, Identity {
|
||||
return hypervisorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
// TODO, I tempoerary disable it as it breaks GenericSearchBuild when @Transient is applied
|
||||
// @Transient
|
||||
public Status getState() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
// TODO, I tempoerary disable it as it breaks GenericSearchBuild when @Transient is applied
|
||||
// @Transient
|
||||
public Status getState() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceState getResourceState() {
|
||||
return resourceState;
|
||||
}
|
||||
|
||||
|
||||
public void setResourceState(ResourceState state) {
|
||||
resourceState = state;
|
||||
resourceState = state;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isInMaintenanceStates() {
|
||||
return (getResourceState() == ResourceState.Maintenance || getResourceState() == ResourceState.ErrorInMaintenance
|
||||
|| getResourceState() == ResourceState.PrepareForMaintenance);
|
||||
}
|
||||
|
||||
|
||||
public long getUpdated() {
|
||||
return updated;
|
||||
return updated;
|
||||
}
|
||||
|
||||
public long incrUpdated() {
|
||||
updated++;
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
public long incrUpdated() {
|
||||
updated++;
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
public Date getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public State getOrchestrationState() {
|
||||
return state;
|
||||
}
|
||||
public State getOrchestrationState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,14 +29,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.image.format.ISO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.domain.DomainVO;
|
||||
@ -48,9 +46,9 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.VMTemplateZoneVO;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateZoneVO;
|
||||
import com.cloud.storage.dao.VMTemplateDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateDetailsDao;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
@ -59,8 +57,6 @@ import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ComponentInject;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
@ -68,8 +64,8 @@ import com.cloud.utils.db.GenericSearchBuilder;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
@ -78,10 +74,10 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
||||
|
||||
|
||||
VMTemplateZoneDao _templateZoneDao = null;
|
||||
|
||||
|
||||
VMTemplateDetailsDao _templateDetailsDao = null;
|
||||
|
||||
|
||||
|
||||
ConfigurationDao _configDao = null;
|
||||
|
||||
HostDao _hostDao = null;
|
||||
@ -674,15 +670,17 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
||||
}
|
||||
// for now, defaulting pageSize to a large val if null; may need to
|
||||
// revisit post 2.2RC2
|
||||
if (isIso && templateZonePairList.size() < (pageSize != null ? pageSize : 500) && templateFilter != TemplateFilter.community
|
||||
&& !(templateFilter == TemplateFilter.self && !BaseCmd.isRootAdmin(caller.getType()))) { // evaluates
|
||||
// to
|
||||
// true
|
||||
// If
|
||||
// root
|
||||
// admin
|
||||
// and
|
||||
// filter=self
|
||||
if (isIso &&
|
||||
templateZonePairList.size() < (pageSize != null ? pageSize : 500) &&
|
||||
templateFilter != TemplateFilter.community &&
|
||||
!(templateFilter == TemplateFilter.self) /* TODO: Fix this! && !BaseCmd.isRootAdmin(caller.getType())*/) { // evaluates
|
||||
// to
|
||||
// true
|
||||
// If
|
||||
// root
|
||||
// admin
|
||||
// and
|
||||
// filter=self
|
||||
|
||||
List<ImageDataVO> publicIsos = publicIsoSearch(bootable, false, tags);
|
||||
List<ImageDataVO> userIsos = userIsoSearch(false);
|
||||
@ -855,6 +853,7 @@ public class ImageDataDaoImpl extends GenericDaoBase<ImageDataVO, Long> implemen
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageDataVO findSystemVMTemplate(long zoneId, HypervisorType hType) {
|
||||
SearchCriteria<ImageDataVO> sc = tmpltTypeHyperSearch.create();
|
||||
sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
|
||||
|
||||
@ -33,11 +33,12 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@ -77,7 +78,7 @@ public class ImageDataVO implements Identity {
|
||||
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
@Column(name = GenericDao.CREATED_COLUMN)
|
||||
private Date created = null;
|
||||
private final Date created = null;
|
||||
|
||||
@Column(name = GenericDao.REMOVED)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@ -178,7 +179,7 @@ public class ImageDataVO implements Identity {
|
||||
public boolean requiresHvm() {
|
||||
return requiresHvm;
|
||||
}
|
||||
|
||||
|
||||
public void setRequireHvm(boolean hvm) {
|
||||
this.requiresHvm = hvm;
|
||||
}
|
||||
@ -234,7 +235,7 @@ public class ImageDataVO implements Identity {
|
||||
public long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
|
||||
public void setAccountId(long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@ -32,11 +32,11 @@ import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.Unknown;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.fsm.StateObject;
|
||||
@ -124,9 +124,9 @@ public class VolumeVO implements Identity, StateObject<Volume.State> {
|
||||
|
||||
@Column(name = "update_count", updatable = true, nullable = false)
|
||||
protected long updatedCount; // This field should be updated everytime the
|
||||
// state is updated. There's no set method in
|
||||
// the vo object because it is done with in the
|
||||
// dao code.
|
||||
// state is updated. There's no set method in
|
||||
// the vo object because it is done with in the
|
||||
// dao code.
|
||||
|
||||
@Column(name = "recreatable")
|
||||
boolean recreatable;
|
||||
@ -345,6 +345,7 @@ public class VolumeVO implements Identity, StateObject<Volume.State> {
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Volume.State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
package org.apache.cloudstack.storage.datastore.db;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@ -30,12 +29,10 @@ import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.storage.datastore.DataStoreStatus;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@ -98,7 +95,7 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
|
||||
@Column(name = "cluster_id")
|
||||
private Long clusterId;
|
||||
|
||||
|
||||
@Column(name = "configurator_key")
|
||||
private String key;
|
||||
|
||||
@ -118,6 +115,7 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
@ -125,7 +123,7 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
public String getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
|
||||
public void setPoolType(String protocol) {
|
||||
this.poolType = protocol;
|
||||
}
|
||||
@ -181,7 +179,7 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
public String getHostAddress() {
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setHostAddress(String host) {
|
||||
this.hostAddress = host;
|
||||
}
|
||||
@ -225,7 +223,7 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
@ -237,13 +235,13 @@ public class PrimaryDataStoreVO implements Identity {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -21,22 +21,23 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.acl.APIAccessChecker;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
@ -60,6 +61,7 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
||||
private static List<String> s_allCommands = null;
|
||||
|
||||
protected @Inject AccountManager _accountMgr;
|
||||
@Inject protected List<PluggableService> _services;
|
||||
|
||||
protected StaticRoleBasedAPIAccessChecker() {
|
||||
super();
|
||||
@ -77,10 +79,10 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
||||
boolean commandExists = s_allCommands.contains(apiCommandName);
|
||||
|
||||
if(commandExists && user != null){
|
||||
Long accountId = user.getAccountId();
|
||||
Account userAccount = _accountMgr.getAccount(accountId);
|
||||
short accountType = userAccount.getType();
|
||||
return isCommandAvailableForAccount(accountType, apiCommandName);
|
||||
Long accountId = user.getAccountId();
|
||||
Account userAccount = _accountMgr.getAccount(accountId);
|
||||
short accountType = userAccount.getType();
|
||||
return isCommandAvailableForAccount(accountType, apiCommandName);
|
||||
}
|
||||
|
||||
return commandExists;
|
||||
@ -109,13 +111,8 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIA
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
|
||||
// Read command properties files to build the static map per role.
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
List<PluggableService> services = locator.getAllPluggableServices();
|
||||
services.add((PluggableService) ComponentLocator.getComponent(ManagementServer.Name));
|
||||
|
||||
List<String> configFiles = new ArrayList<String>();
|
||||
for (PluggableService service : services) {
|
||||
for (PluggableService service : _services) {
|
||||
configFiles.addAll(Arrays.asList(service.getPropertiesFiles()));
|
||||
}
|
||||
|
||||
|
||||
@ -30,10 +30,11 @@ import javax.naming.directory.InitialDirContext;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import javax.naming.directory.SearchResult;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants.LDAPParams;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bouncycastle.util.encoders.Base64;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants.LDAPParams;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.server.ManagementServer;
|
||||
import com.cloud.user.UserAccount;
|
||||
@ -49,7 +50,7 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
|
||||
|
||||
private ConfigurationDao _configDao;
|
||||
private UserAccountDao _userAccountDao;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters ) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -74,14 +75,14 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
|
||||
String bindPasswd = _configDao.getValue(LDAPParams.passwd.toString());
|
||||
String trustStore = _configDao.getValue(LDAPParams.truststore.toString());
|
||||
String trustStorePassword = _configDao.getValue(LDAPParams.truststorepass.toString());
|
||||
|
||||
|
||||
try {
|
||||
// get all params
|
||||
Hashtable<String, String> env = new Hashtable<String, String>(11);
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
|
||||
String protocol = "ldap://" ;
|
||||
if (new Boolean(useSSL)){
|
||||
env.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
env.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
protocol="ldaps://" ;
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||
@ -93,10 +94,10 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
|
||||
env.put(Context.SECURITY_CREDENTIALS, bindPasswd);
|
||||
}
|
||||
else {
|
||||
// Use anonymous authentication
|
||||
env.put(Context.SECURITY_AUTHENTICATION, "none");
|
||||
// Use anonymous authentication
|
||||
env.put(Context.SECURITY_AUTHENTICATION, "none");
|
||||
}
|
||||
// Create the initial context
|
||||
// Create the initial context
|
||||
DirContext ctx = new InitialDirContext(env);
|
||||
// use this context to search
|
||||
|
||||
@ -104,7 +105,7 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
|
||||
queryFilter = queryFilter.replaceAll("\\%u", username);
|
||||
queryFilter = queryFilter.replaceAll("\\%n", user.getFirstname() + " " + user.getLastname());
|
||||
queryFilter = queryFilter.replaceAll("\\%e", user.getEmail());
|
||||
|
||||
|
||||
|
||||
SearchControls sc = new SearchControls();
|
||||
String[] searchFilter = { "dn" };
|
||||
@ -112,22 +113,22 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
|
||||
sc.setReturningAttributes(searchFilter);
|
||||
sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||
sc.setCountLimit(1);
|
||||
|
||||
|
||||
// Search for objects with those matching attributes
|
||||
NamingEnumeration<SearchResult> answer = ctx.search(searchBase, queryFilter, sc);
|
||||
SearchResult sr = (SearchResult)answer.next();
|
||||
SearchResult sr = answer.next();
|
||||
String cn = sr.getName();
|
||||
answer.close();
|
||||
ctx.close();
|
||||
|
||||
|
||||
s_logger.info("DN from LDAP =" + cn);
|
||||
|
||||
|
||||
// check the password
|
||||
env = new Hashtable<String, String>(11);
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
|
||||
protocol = "ldap://" ;
|
||||
if (new Boolean(useSSL)){
|
||||
env.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
env.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
protocol="ldaps://" ;
|
||||
}
|
||||
env.put(Context.PROVIDER_URL, protocol + url + ":" + port);
|
||||
@ -136,22 +137,23 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
|
||||
// Create the initial context
|
||||
ctx = new InitialDirContext(env);
|
||||
ctx.close();
|
||||
|
||||
|
||||
} catch (NamingException ne) {
|
||||
ne.printStackTrace();
|
||||
s_logger.warn("Authentication failed due to " + ne.getMessage());
|
||||
return false;
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
s_logger.warn("Unknown error encountered " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// authenticate
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
@ -161,16 +163,16 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encode(String password) {
|
||||
// Password is not used, so set to a random string
|
||||
try {
|
||||
SecureRandom randomGen = SecureRandom.getInstance("SHA1PRNG");
|
||||
byte bytes[] = new byte[20];
|
||||
randomGen.nextBytes(bytes);
|
||||
return Base64.encode(bytes).toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new CloudRuntimeException("Failed to generate random password",e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String encode(String password) {
|
||||
// Password is not used, so set to a random string
|
||||
try {
|
||||
SecureRandom randomGen = SecureRandom.getInstance("SHA1PRNG");
|
||||
byte bytes[] = new byte[20];
|
||||
randomGen.nextBytes(bytes);
|
||||
return Base64.encode(bytes).toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new CloudRuntimeException("Failed to generate random password",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,6 +85,11 @@
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
|
||||
@ -52,16 +52,29 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.cloudstack.acl.APIAccessChecker;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.*;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
||||
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
|
||||
import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
|
||||
import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
|
||||
import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
|
||||
import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
|
||||
import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
|
||||
import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
|
||||
import org.apache.cloudstack.api.response.ExceptionResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.apache.http.ConnectionClosedException;
|
||||
import org.apache.http.HttpException;
|
||||
import org.apache.http.HttpRequest;
|
||||
@ -69,6 +82,7 @@ import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpServerConnection;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.apache.http.entity.BasicHttpEntity;
|
||||
import org.apache.http.impl.DefaultHttpResponseFactory;
|
||||
import org.apache.http.impl.DefaultHttpServerConnection;
|
||||
@ -89,18 +103,9 @@ import org.apache.http.protocol.ResponseContent;
|
||||
import org.apache.http.protocol.ResponseDate;
|
||||
import org.apache.http.protocol.ResponseServer;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
|
||||
import org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd;
|
||||
import org.apache.cloudstack.api.command.user.project.ListProjectsCmd;
|
||||
import org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd;
|
||||
import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
|
||||
import com.cloud.api.response.ApiResponseSerializer;
|
||||
import org.apache.cloudstack.api.response.ExceptionResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
@ -123,18 +128,15 @@ import com.cloud.user.UserAccount;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CSExceptionErrorCode;
|
||||
import com.cloud.uuididentity.dao.IdentityDao;
|
||||
|
||||
import org.reflections.Reflections;
|
||||
|
||||
public class ApiServer implements HttpRequestHandler {
|
||||
private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
|
||||
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
|
||||
@ -143,18 +145,18 @@ public class ApiServer implements HttpRequestHandler {
|
||||
public static String jsonContentType = "text/javascript";
|
||||
private ApiDispatcher _dispatcher;
|
||||
|
||||
@Inject private AccountManager _accountMgr = null;
|
||||
@Inject private DomainManager _domainMgr = null;
|
||||
@Inject private AsyncJobManager _asyncMgr = null;
|
||||
@Inject(adapter = APIAccessChecker.class)
|
||||
protected Adapters<APIAccessChecker> _apiAccessCheckers;
|
||||
@Inject private final AccountManager _accountMgr = null;
|
||||
@Inject private final DomainManager _domainMgr = null;
|
||||
@Inject private final AsyncJobManager _asyncMgr = null;
|
||||
@Inject private ConfigurationDao _configDao;
|
||||
@Inject protected List<APIAccessChecker> _apiAccessCheckers;
|
||||
|
||||
private Account _systemAccount = null;
|
||||
private User _systemUser = null;
|
||||
private static int _workerCount = 0;
|
||||
private static ApiServer s_instance = null;
|
||||
private static final DateFormat _dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
private Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String, Class<?>>();
|
||||
private final Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String, Class<?>>();
|
||||
|
||||
private static ExecutorService _executor = new ThreadPoolExecutor(10, 150, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("ApiServer"));
|
||||
|
||||
@ -164,20 +166,13 @@ public class ApiServer implements HttpRequestHandler {
|
||||
|
||||
public static void initApiServer(String[] apiConfig) {
|
||||
if (s_instance == null) {
|
||||
//Injecting will create ApiServer object with all its
|
||||
//vars injected as well, no need to do the following:
|
||||
//s_instance = new ApiServer();
|
||||
s_instance = ComponentLocator.inject(ApiServer.class);
|
||||
s_instance = new ApiServer();
|
||||
s_instance = ComponentContext.inject(s_instance);
|
||||
s_instance.init(apiConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public static ApiServer getInstance() {
|
||||
// Assumption: CloudStartupServlet would initialize ApiServer
|
||||
// initApiServer(null);
|
||||
if (s_instance == null) {
|
||||
s_logger.fatal("ApiServer instance failed to initialize");
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
@ -188,11 +183,9 @@ public class ApiServer implements HttpRequestHandler {
|
||||
_systemAccount = _accountMgr.getSystemAccount();
|
||||
_systemUser = _accountMgr.getSystemUser();
|
||||
_dispatcher = ApiDispatcher.getInstance();
|
||||
|
||||
|
||||
Integer apiPort = null; // api port, null by default
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
|
||||
SearchCriteria<ConfigurationVO> sc = configDao.createSearchCriteria();
|
||||
SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
|
||||
sc.addAnd("name", SearchCriteria.Op.EQ, "integration.api.port");
|
||||
List<ConfigurationVO> values = _configDao.search(sc, null);
|
||||
if ((values != null) && (values.size() > 0)) {
|
||||
@ -215,8 +208,8 @@ public class ApiServer implements HttpRequestHandler {
|
||||
_apiNameCmdClassMap.put(apiName, cmdClass);
|
||||
}
|
||||
|
||||
encodeApiResponse = Boolean.valueOf(configDao.getValue(Config.EncodeApiResponse.key()));
|
||||
String jsonType = configDao.getValue(Config.JavaScriptDefaultContentType.key());
|
||||
encodeApiResponse = Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key()));
|
||||
String jsonType = _configDao.getValue(Config.JavaScriptDefaultContentType.key());
|
||||
if (jsonType != null) {
|
||||
jsonContentType = jsonType;
|
||||
}
|
||||
@ -357,29 +350,29 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof InvalidParameterValueException) {
|
||||
InvalidParameterValueException ref = (InvalidParameterValueException)ex;
|
||||
ServerApiException e = new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage());
|
||||
InvalidParameterValueException ref = (InvalidParameterValueException)ex;
|
||||
ServerApiException e = new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage());
|
||||
// copy over the IdentityProxy information as well and throw the serverapiexception.
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
// Iterate through entire arraylist and copy over each proxy id.
|
||||
for (int i = 0 ; i < idList.size(); i++) {
|
||||
e.addProxyObject(idList.get(i));
|
||||
}
|
||||
// Iterate through entire arraylist and copy over each proxy id.
|
||||
for (int i = 0 ; i < idList.size(); i++) {
|
||||
e.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
// Also copy over the cserror code and the function/layer in which it was thrown.
|
||||
e.setCSErrorCode(ref.getCSErrorCode());
|
||||
e.setCSErrorCode(ref.getCSErrorCode());
|
||||
throw e;
|
||||
} else if (ex instanceof PermissionDeniedException) {
|
||||
PermissionDeniedException ref = (PermissionDeniedException)ex;
|
||||
ServerApiException e = new ServerApiException(BaseCmd.ACCOUNT_ERROR, ex.getMessage());
|
||||
PermissionDeniedException ref = (PermissionDeniedException)ex;
|
||||
ServerApiException e = new ServerApiException(BaseCmd.ACCOUNT_ERROR, ex.getMessage());
|
||||
// copy over the IdentityProxy information as well and throw the serverapiexception.
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
// Iterate through entire arraylist and copy over each proxy id.
|
||||
for (int i = 0 ; i < idList.size(); i++) {
|
||||
e.addProxyObject(idList.get(i));
|
||||
}
|
||||
// Iterate through entire arraylist and copy over each proxy id.
|
||||
for (int i = 0 ; i < idList.size(); i++) {
|
||||
e.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
e.setCSErrorCode(ref.getCSErrorCode());
|
||||
throw e;
|
||||
@ -514,15 +507,15 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
for (ResponseObject response : responses) {
|
||||
for (ResponseObject response : responses) {
|
||||
if (response.getObjectId() != null && objectJobMap.containsKey(response.getObjectId())) {
|
||||
AsyncJob job = objectJobMap.get(response.getObjectId());
|
||||
response.setJobId(job.getUuid());
|
||||
response.setJobStatus(job.getStatus());
|
||||
}
|
||||
response.setJobStatus(job.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildAuditTrail(StringBuffer auditTrailSb, String command, String result) {
|
||||
if (result == null) {
|
||||
@ -553,7 +546,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
|
||||
// if userId not null, that mean that user is logged in
|
||||
if (userId != null) {
|
||||
User user = ApiDBUtils.findUserById(userId);
|
||||
User user = ApiDBUtils.findUserById(userId);
|
||||
if (!isCommandAvailable(user, commandName)) {
|
||||
s_logger.warn("The given command:" + commandName + " does not exist or it is not available for user");
|
||||
throw new ServerApiException(BaseCmd.UNSUPPORTED_ACTION_ERROR, "The given command does not exist or it is not available for user");
|
||||
@ -688,7 +681,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public Long fetchDomainId(String domainUUID){
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
IdentityDao identityDao = locator.getDao(IdentityDao.class);
|
||||
@ -739,19 +732,19 @@ public class ApiServer implements HttpRequestHandler {
|
||||
if(user.getUuid() != null){
|
||||
session.setAttribute("user_UUID", user.getUuid());
|
||||
}
|
||||
|
||||
|
||||
session.setAttribute("username", userAcct.getUsername());
|
||||
session.setAttribute("firstname", userAcct.getFirstname());
|
||||
session.setAttribute("lastname", userAcct.getLastname());
|
||||
session.setAttribute("accountobj", account);
|
||||
session.setAttribute("account", account.getAccountName());
|
||||
|
||||
|
||||
session.setAttribute("domainid", account.getDomainId());
|
||||
DomainVO domain = (DomainVO) _domainMgr.getDomain(account.getDomainId());
|
||||
if(domain.getUuid() != null){
|
||||
session.setAttribute("domain_UUID", domain.getUuid());
|
||||
}
|
||||
|
||||
|
||||
session.setAttribute("type", Short.valueOf(account.getType()).toString());
|
||||
session.setAttribute("registrationtoken", userAcct.getRegistrationToken());
|
||||
session.setAttribute("registered", new Boolean(userAcct.isRegistered()).toString());
|
||||
@ -855,8 +848,8 @@ public class ApiServer implements HttpRequestHandler {
|
||||
|
||||
_params = new BasicHttpParams();
|
||||
_params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 30000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
|
||||
.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
|
||||
.setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");
|
||||
.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
|
||||
.setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");
|
||||
|
||||
// Set up the HTTP protocol processor
|
||||
BasicHttpProcessor httpproc = new BasicHttpProcessor();
|
||||
@ -968,41 +961,41 @@ public class ApiServer implements HttpRequestHandler {
|
||||
// Exception. When invoked from ApiServlet's processRequest(), this can be
|
||||
// a standard exception like NumberFormatException. We'll leave the standard ones alone.
|
||||
if (ex != null) {
|
||||
if (ex instanceof ServerApiException || ex instanceof PermissionDeniedException
|
||||
|| ex instanceof InvalidParameterValueException) {
|
||||
// Cast the exception appropriately and retrieve the IdentityProxy
|
||||
if (ex instanceof ServerApiException) {
|
||||
ServerApiException ref = (ServerApiException) ex;
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
for (int i=0; i < idList.size(); i++) {
|
||||
apiResponse.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
// Also copy over the cserror code and the function/layer in which it was thrown.
|
||||
apiResponse.setCSErrorCode(ref.getCSErrorCode());
|
||||
} else if (ex instanceof PermissionDeniedException) {
|
||||
PermissionDeniedException ref = (PermissionDeniedException) ex;
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
for (int i=0; i < idList.size(); i++) {
|
||||
apiResponse.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
// Also copy over the cserror code and the function/layer in which it was thrown.
|
||||
apiResponse.setCSErrorCode(ref.getCSErrorCode());
|
||||
} else if (ex instanceof InvalidParameterValueException) {
|
||||
InvalidParameterValueException ref = (InvalidParameterValueException) ex;
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
for (int i=0; i < idList.size(); i++) {
|
||||
apiResponse.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
// Also copy over the cserror code and the function/layer in which it was thrown.
|
||||
apiResponse.setCSErrorCode(ref.getCSErrorCode());
|
||||
}
|
||||
}
|
||||
if (ex instanceof ServerApiException || ex instanceof PermissionDeniedException
|
||||
|| ex instanceof InvalidParameterValueException) {
|
||||
// Cast the exception appropriately and retrieve the IdentityProxy
|
||||
if (ex instanceof ServerApiException) {
|
||||
ServerApiException ref = (ServerApiException) ex;
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
for (int i=0; i < idList.size(); i++) {
|
||||
apiResponse.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
// Also copy over the cserror code and the function/layer in which it was thrown.
|
||||
apiResponse.setCSErrorCode(ref.getCSErrorCode());
|
||||
} else if (ex instanceof PermissionDeniedException) {
|
||||
PermissionDeniedException ref = (PermissionDeniedException) ex;
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
for (int i=0; i < idList.size(); i++) {
|
||||
apiResponse.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
// Also copy over the cserror code and the function/layer in which it was thrown.
|
||||
apiResponse.setCSErrorCode(ref.getCSErrorCode());
|
||||
} else if (ex instanceof InvalidParameterValueException) {
|
||||
InvalidParameterValueException ref = (InvalidParameterValueException) ex;
|
||||
ArrayList<String> idList = ref.getIdProxyList();
|
||||
if (idList != null) {
|
||||
for (int i=0; i < idList.size(); i++) {
|
||||
apiResponse.addProxyObject(idList.get(i));
|
||||
}
|
||||
}
|
||||
// Also copy over the cserror code and the function/layer in which it was thrown.
|
||||
apiResponse.setCSErrorCode(ref.getCSErrorCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
SerializationContext.current().setUuidTranslation(true);
|
||||
responseText = ApiResponseSerializer.toSerializedString(apiResponse, responseType);
|
||||
|
||||
@ -27,15 +27,15 @@ import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.network.CreateStorageNetworkIpRangeCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.DeleteStorageNetworkIpRangeCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.ListStorageNetworkIpRangeCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.UpdateStorageNetworkIpRangeCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.network.DeleteStorageNetworkIpRangeCmd;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.StorageNetworkIpRange;
|
||||
import com.cloud.dc.StorageNetworkIpAddressVO;
|
||||
import com.cloud.dc.StorageNetworkIpRange;
|
||||
import com.cloud.dc.StorageNetworkIpRangeVO;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.StorageNetworkIpAddressDao;
|
||||
@ -43,12 +43,11 @@ import com.cloud.dc.dao.StorageNetworkIpRangeDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteriaService;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
@ -56,329 +55,332 @@ import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
|
||||
@Component
|
||||
@Local(value = {StorageNetworkManager.class, StorageNetworkService.class})
|
||||
@Local(value = { StorageNetworkManager.class, StorageNetworkService.class })
|
||||
public class StorageNetworkManagerImpl implements StorageNetworkManager, StorageNetworkService {
|
||||
private static final Logger s_logger = Logger.getLogger(StorageNetworkManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
@Inject
|
||||
StorageNetworkIpAddressDao _sNwIpDao;
|
||||
@Inject
|
||||
StorageNetworkIpRangeDao _sNwIpRangeDao;
|
||||
private static final Logger s_logger = Logger.getLogger(StorageNetworkManagerImpl.class);
|
||||
|
||||
String _name;
|
||||
@Inject
|
||||
StorageNetworkIpAddressDao _sNwIpDao;
|
||||
@Inject
|
||||
StorageNetworkIpRangeDao _sNwIpRangeDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
HostPodDao _podDao;
|
||||
@Inject
|
||||
SecondaryStorageVmDao _ssvmDao;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
return true;
|
||||
}
|
||||
@Inject
|
||||
HostPodDao _podDao;
|
||||
@Inject
|
||||
SecondaryStorageVmDao _ssvmDao;
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean start() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkOverlapPrivateIpRange(long podId, String startIp, String endIp) {
|
||||
HostPodVO pod = _podDao.findById(podId);
|
||||
if (pod == null) {
|
||||
throw new CloudRuntimeException("Cannot find pod " + podId);
|
||||
}
|
||||
String[] IpRange = pod.getDescription().split("-");
|
||||
if ((IpRange[0] == null || IpRange[1] == null) || (!NetUtils.isValidIp(IpRange[0]) || !NetUtils.isValidIp(IpRange[1]))) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkOverlapPrivateIpRange(long podId, String startIp, String endIp) {
|
||||
HostPodVO pod = _podDao.findById(podId);
|
||||
if (pod == null) {
|
||||
throw new CloudRuntimeException("Cannot find pod " + podId);
|
||||
}
|
||||
String[] IpRange = pod.getDescription().split("-");
|
||||
if ((IpRange[0] == null || IpRange[1] == null) || (!NetUtils.isValidIp(IpRange[0]) || !NetUtils.isValidIp(IpRange[1]))) {
|
||||
return;
|
||||
}
|
||||
if (NetUtils.ipRangesOverlap(startIp, endIp, IpRange[0], IpRange[1])) {
|
||||
throw new InvalidParameterValueException("The Storage network Start IP and endIP address range overlap with private IP :" + IpRange[0] + ":" + IpRange[1]);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkOverlapStorageIpRange(long podId, String startIp, String endIp) {
|
||||
List<StorageNetworkIpRangeVO> curRanges = _sNwIpRangeDao.listByPodId(podId);
|
||||
for (StorageNetworkIpRangeVO range : curRanges) {
|
||||
if (NetUtils.ipRangesOverlap(startIp, endIp, range.getStartIp(), range.getEndIp())) {
|
||||
throw new InvalidParameterValueException("The Storage network Start IP and endIP address range overlap with private IP :" + range.getStartIp() + " - " + range.getEndIp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createStorageIpEntires(Transaction txn, long rangeId, String startIp, String endIp, long zoneId) throws SQLException {
|
||||
}
|
||||
|
||||
private void checkOverlapStorageIpRange(long podId, String startIp, String endIp) {
|
||||
List<StorageNetworkIpRangeVO> curRanges = _sNwIpRangeDao.listByPodId(podId);
|
||||
for (StorageNetworkIpRangeVO range : curRanges) {
|
||||
if (NetUtils.ipRangesOverlap(startIp, endIp, range.getStartIp(), range.getEndIp())) {
|
||||
throw new InvalidParameterValueException("The Storage network Start IP and endIP address range overlap with private IP :" + range.getStartIp() + " - " + range.getEndIp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createStorageIpEntires(Transaction txn, long rangeId, String startIp, String endIp, long zoneId) throws SQLException {
|
||||
long startIPLong = NetUtils.ip2Long(startIp);
|
||||
long endIPLong = NetUtils.ip2Long(endIp);
|
||||
String insertSql = "INSERT INTO `cloud`.`op_dc_storage_network_ip_address` (range_id, ip_address, mac_address, taken) VALUES (?, ?, (select mac_address from `cloud`.`data_center` where id=?), ?)";
|
||||
String updateSql = "UPDATE `cloud`.`data_center` set mac_address = mac_address+1 where id=?";
|
||||
PreparedStatement stmt = null;
|
||||
Connection conn = txn.getConnection();
|
||||
|
||||
while (startIPLong <= endIPLong) {
|
||||
stmt = conn.prepareStatement(insertSql);
|
||||
stmt.setLong(1, rangeId);
|
||||
stmt.setString(2, NetUtils.long2Ip(startIPLong++));
|
||||
stmt.setLong(3, zoneId);
|
||||
stmt.setNull(4, java.sql.Types.DATE);
|
||||
String insertSql = "INSERT INTO `cloud`.`op_dc_storage_network_ip_address` (range_id, ip_address, mac_address, taken) VALUES (?, ?, (select mac_address from `cloud`.`data_center` where id=?), ?)";
|
||||
String updateSql = "UPDATE `cloud`.`data_center` set mac_address = mac_address+1 where id=?";
|
||||
PreparedStatement stmt = null;
|
||||
Connection conn = txn.getConnection();
|
||||
|
||||
while (startIPLong <= endIPLong) {
|
||||
stmt = conn.prepareStatement(insertSql);
|
||||
stmt.setLong(1, rangeId);
|
||||
stmt.setString(2, NetUtils.long2Ip(startIPLong++));
|
||||
stmt.setLong(3, zoneId);
|
||||
stmt.setNull(4, java.sql.Types.DATE);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
|
||||
|
||||
stmt = txn.prepareStatement(updateSql);
|
||||
stmt.setLong(1, zoneId);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public StorageNetworkIpRange updateIpRange(UpdateStorageNetworkIpRangeCmd cmd) {
|
||||
Integer vlan = cmd.getVlan();
|
||||
Long rangeId = cmd.getId();
|
||||
String startIp = cmd.getStartIp();
|
||||
String endIp = cmd.getEndIp();
|
||||
String netmask = cmd.getNetmask();
|
||||
|
||||
if (netmask != null && !NetUtils.isValidNetmask(netmask)) {
|
||||
throw new CloudRuntimeException("Invalid netmask:" + netmask);
|
||||
}
|
||||
|
||||
if (_sNwIpDao.countInUseIpByRangeId(rangeId) > 0) {
|
||||
throw new CloudRuntimeException("Cannot update the range," + getInUseIpAddress(rangeId));
|
||||
}
|
||||
|
||||
StorageNetworkIpRangeVO range = _sNwIpRangeDao.findById(rangeId);
|
||||
if (range == null) {
|
||||
throw new CloudRuntimeException("Cannot find storage ip range " + rangeId);
|
||||
}
|
||||
|
||||
if (startIp != null || endIp != null) {
|
||||
long podId = range.getPodId();
|
||||
startIp = startIp == null ? range.getStartIp() : startIp;
|
||||
endIp = endIp == null ? range.getEndIp() : endIp;
|
||||
checkOverlapPrivateIpRange(podId, startIp, endIp);
|
||||
checkOverlapStorageIpRange(podId, startIp, endIp);
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
try {
|
||||
range = _sNwIpRangeDao.acquireInLockTable(range.getId());
|
||||
if (range == null) {
|
||||
throw new CloudRuntimeException("Cannot acquire lock on storage ip range " + rangeId);
|
||||
}
|
||||
StorageNetworkIpRangeVO vo = _sNwIpRangeDao.createForUpdate();
|
||||
if (vlan != null) {
|
||||
vo.setVlan(vlan);
|
||||
}
|
||||
if (startIp != null) {
|
||||
vo.setStartIp(startIp);
|
||||
}
|
||||
if (endIp != null) {
|
||||
vo.setEndIp(endIp);
|
||||
}
|
||||
if (netmask != null) {
|
||||
vo.setNetmask(netmask);
|
||||
}
|
||||
_sNwIpRangeDao.update(rangeId, vo);
|
||||
} finally {
|
||||
if (range != null) {
|
||||
_sNwIpRangeDao.releaseFromLockTable(range.getId());
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
|
||||
return _sNwIpRangeDao.findById(rangeId);
|
||||
Integer vlan = cmd.getVlan();
|
||||
Long rangeId = cmd.getId();
|
||||
String startIp = cmd.getStartIp();
|
||||
String endIp = cmd.getEndIp();
|
||||
String netmask = cmd.getNetmask();
|
||||
|
||||
if (netmask != null && !NetUtils.isValidNetmask(netmask)) {
|
||||
throw new CloudRuntimeException("Invalid netmask:" + netmask);
|
||||
}
|
||||
|
||||
if (_sNwIpDao.countInUseIpByRangeId(rangeId) > 0) {
|
||||
throw new CloudRuntimeException("Cannot update the range," + getInUseIpAddress(rangeId));
|
||||
}
|
||||
|
||||
StorageNetworkIpRangeVO range = _sNwIpRangeDao.findById(rangeId);
|
||||
if (range == null) {
|
||||
throw new CloudRuntimeException("Cannot find storage ip range " + rangeId);
|
||||
}
|
||||
|
||||
if (startIp != null || endIp != null) {
|
||||
long podId = range.getPodId();
|
||||
startIp = startIp == null ? range.getStartIp() : startIp;
|
||||
endIp = endIp == null ? range.getEndIp() : endIp;
|
||||
checkOverlapPrivateIpRange(podId, startIp, endIp);
|
||||
checkOverlapStorageIpRange(podId, startIp, endIp);
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
try {
|
||||
range = _sNwIpRangeDao.acquireInLockTable(range.getId());
|
||||
if (range == null) {
|
||||
throw new CloudRuntimeException("Cannot acquire lock on storage ip range " + rangeId);
|
||||
}
|
||||
StorageNetworkIpRangeVO vo = _sNwIpRangeDao.createForUpdate();
|
||||
if (vlan != null) {
|
||||
vo.setVlan(vlan);
|
||||
}
|
||||
if (startIp != null) {
|
||||
vo.setStartIp(startIp);
|
||||
}
|
||||
if (endIp != null) {
|
||||
vo.setEndIp(endIp);
|
||||
}
|
||||
if (netmask != null) {
|
||||
vo.setNetmask(netmask);
|
||||
}
|
||||
_sNwIpRangeDao.update(rangeId, vo);
|
||||
} finally {
|
||||
if (range != null) {
|
||||
_sNwIpRangeDao.releaseFromLockTable(range.getId());
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
|
||||
return _sNwIpRangeDao.findById(rangeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public StorageNetworkIpRange createIpRange(CreateStorageNetworkIpRangeCmd cmd) throws SQLException {
|
||||
Long podId = cmd.getPodId();
|
||||
String startIp = cmd.getStartIp();
|
||||
String endIp = cmd.getEndIp();
|
||||
Integer vlan = cmd.getVlan();
|
||||
String netmask = cmd.getNetmask();
|
||||
|
||||
if (endIp == null) {
|
||||
endIp = startIp;
|
||||
}
|
||||
|
||||
if (!NetUtils.isValidNetmask(netmask)) {
|
||||
throw new CloudRuntimeException("Invalid netmask:" + netmask);
|
||||
}
|
||||
|
||||
HostPodVO pod = _podDao.findById(podId);
|
||||
if (pod == null) {
|
||||
throw new CloudRuntimeException("Cannot find pod " + podId);
|
||||
}
|
||||
Long zoneId = pod.getDataCenterId();
|
||||
|
||||
List<NetworkVO> nws = _networkDao.listByZoneAndTrafficType(zoneId, TrafficType.Storage);
|
||||
if (nws.size() == 0) {
|
||||
throw new CloudRuntimeException("Cannot find storage network in zone " + zoneId);
|
||||
}
|
||||
if (nws.size() > 1) {
|
||||
throw new CloudRuntimeException("Find more than one storage network in zone " + zoneId + "," + nws.size() + " found");
|
||||
}
|
||||
NetworkVO nw = nws.get(0);
|
||||
|
||||
checkOverlapPrivateIpRange(podId, startIp, endIp);
|
||||
checkOverlapStorageIpRange(podId, startIp, endIp);
|
||||
@Override
|
||||
@DB
|
||||
public StorageNetworkIpRange createIpRange(CreateStorageNetworkIpRangeCmd cmd) throws SQLException {
|
||||
Long podId = cmd.getPodId();
|
||||
String startIp = cmd.getStartIp();
|
||||
String endIp = cmd.getEndIp();
|
||||
Integer vlan = cmd.getVlan();
|
||||
String netmask = cmd.getNetmask();
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
StorageNetworkIpRangeVO range = null;
|
||||
if (endIp == null) {
|
||||
endIp = startIp;
|
||||
}
|
||||
|
||||
txn.start();
|
||||
range = new StorageNetworkIpRangeVO(zoneId, podId, nw.getId(), startIp, endIp, vlan, netmask, cmd.getGateWay());
|
||||
_sNwIpRangeDao.persist(range);
|
||||
try {
|
||||
createStorageIpEntires(txn, range.getId(), startIp, endIp, zoneId);
|
||||
} catch (SQLException e) {
|
||||
txn.rollback();
|
||||
StringBuilder err = new StringBuilder();
|
||||
err.append("Create storage network range failed.");
|
||||
err.append("startIp=" + startIp);
|
||||
err.append("endIp=" + endIp);
|
||||
err.append("netmask=" + netmask);
|
||||
err.append("zoneId=" + zoneId);
|
||||
s_logger.debug(err.toString(), e);
|
||||
throw e;
|
||||
}
|
||||
if (!NetUtils.isValidNetmask(netmask)) {
|
||||
throw new CloudRuntimeException("Invalid netmask:" + netmask);
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
private String getInUseIpAddress(long rangeId) {
|
||||
List<String> ips = _sNwIpDao.listInUseIpByRangeId(rangeId);
|
||||
StringBuilder res = new StringBuilder();
|
||||
res.append("Below IP of range " + rangeId + " is still in use:");
|
||||
for (String ip : ips) {
|
||||
res.append(ip).append(",");
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
HostPodVO pod = _podDao.findById(podId);
|
||||
if (pod == null) {
|
||||
throw new CloudRuntimeException("Cannot find pod " + podId);
|
||||
}
|
||||
Long zoneId = pod.getDataCenterId();
|
||||
|
||||
List<NetworkVO> nws = _networkDao.listByZoneAndTrafficType(zoneId, TrafficType.Storage);
|
||||
if (nws.size() == 0) {
|
||||
throw new CloudRuntimeException("Cannot find storage network in zone " + zoneId);
|
||||
}
|
||||
if (nws.size() > 1) {
|
||||
throw new CloudRuntimeException("Find more than one storage network in zone " + zoneId + "," + nws.size() + " found");
|
||||
}
|
||||
NetworkVO nw = nws.get(0);
|
||||
|
||||
checkOverlapPrivateIpRange(podId, startIp, endIp);
|
||||
checkOverlapStorageIpRange(podId, startIp, endIp);
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
StorageNetworkIpRangeVO range = null;
|
||||
|
||||
txn.start();
|
||||
range = new StorageNetworkIpRangeVO(zoneId, podId, nw.getId(), startIp, endIp, vlan, netmask, cmd.getGateWay());
|
||||
_sNwIpRangeDao.persist(range);
|
||||
try {
|
||||
createStorageIpEntires(txn, range.getId(), startIp, endIp, zoneId);
|
||||
} catch (SQLException e) {
|
||||
txn.rollback();
|
||||
StringBuilder err = new StringBuilder();
|
||||
err.append("Create storage network range failed.");
|
||||
err.append("startIp=" + startIp);
|
||||
err.append("endIp=" + endIp);
|
||||
err.append("netmask=" + netmask);
|
||||
err.append("zoneId=" + zoneId);
|
||||
s_logger.debug(err.toString(), e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
private String getInUseIpAddress(long rangeId) {
|
||||
List<String> ips = _sNwIpDao.listInUseIpByRangeId(rangeId);
|
||||
StringBuilder res = new StringBuilder();
|
||||
res.append("Below IP of range " + rangeId + " is still in use:");
|
||||
for (String ip : ips) {
|
||||
res.append(ip).append(",");
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void deleteIpRange(DeleteStorageNetworkIpRangeCmd cmd) {
|
||||
long rangeId = cmd.getId();
|
||||
StorageNetworkIpRangeVO range = _sNwIpRangeDao.findById(rangeId);
|
||||
if (range == null) {
|
||||
throw new CloudRuntimeException("Can not find storage network ip range " + rangeId);
|
||||
}
|
||||
|
||||
if (_sNwIpDao.countInUseIpByRangeId(rangeId) > 0) {
|
||||
throw new CloudRuntimeException(getInUseIpAddress(rangeId));
|
||||
}
|
||||
long rangeId = cmd.getId();
|
||||
StorageNetworkIpRangeVO range = _sNwIpRangeDao.findById(rangeId);
|
||||
if (range == null) {
|
||||
throw new CloudRuntimeException("Can not find storage network ip range " + rangeId);
|
||||
}
|
||||
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
try {
|
||||
range = _sNwIpRangeDao.acquireInLockTable(rangeId);
|
||||
if (range == null) {
|
||||
String msg = "Unable to acquire lock on storage network ip range id=" + rangeId + ", delete failed";
|
||||
s_logger.warn(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
/* entries in op_dc_storage_network_ip_address will be deleted automatically due to fk_storage_ip_address__range_id constraint key */
|
||||
_sNwIpRangeDao.remove(rangeId);
|
||||
} finally {
|
||||
if (range != null) {
|
||||
_sNwIpRangeDao.releaseFromLockTable(rangeId);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
if (_sNwIpDao.countInUseIpByRangeId(rangeId) > 0) {
|
||||
throw new CloudRuntimeException(getInUseIpAddress(rangeId));
|
||||
}
|
||||
|
||||
final Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
try {
|
||||
range = _sNwIpRangeDao.acquireInLockTable(rangeId);
|
||||
if (range == null) {
|
||||
String msg = "Unable to acquire lock on storage network ip range id=" + rangeId + ", delete failed";
|
||||
s_logger.warn(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
/*
|
||||
* entries in op_dc_storage_network_ip_address will be deleted automatically due to
|
||||
* fk_storage_ip_address__range_id constraint key
|
||||
*/
|
||||
_sNwIpRangeDao.remove(rangeId);
|
||||
} finally {
|
||||
if (range != null) {
|
||||
_sNwIpRangeDao.releaseFromLockTable(rangeId);
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageNetworkIpRange> listIpRange(ListStorageNetworkIpRangeCmd cmd) {
|
||||
Long rangeId = cmd.getRangeId();
|
||||
Long podId = cmd.getPodId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
List result = null;
|
||||
if (rangeId != null) {
|
||||
result = _sNwIpRangeDao.listByRangeId(rangeId);
|
||||
} else if (podId != null) {
|
||||
result = _sNwIpRangeDao.listByPodId(podId);
|
||||
} else if (zoneId != null) {
|
||||
result = _sNwIpRangeDao.listByDataCenterId(zoneId);
|
||||
} else {
|
||||
result = _sNwIpRangeDao.listAll();
|
||||
}
|
||||
|
||||
return (List<StorageNetworkIpRange>)result;
|
||||
}
|
||||
Long rangeId = cmd.getRangeId();
|
||||
Long podId = cmd.getPodId();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
|
||||
@Override
|
||||
public void releaseIpAddress(String ip) {
|
||||
_sNwIpDao.releaseIpAddress(ip);
|
||||
}
|
||||
|
||||
@Override
|
||||
List result = null;
|
||||
if (rangeId != null) {
|
||||
result = _sNwIpRangeDao.listByRangeId(rangeId);
|
||||
} else if (podId != null) {
|
||||
result = _sNwIpRangeDao.listByPodId(podId);
|
||||
} else if (zoneId != null) {
|
||||
result = _sNwIpRangeDao.listByDataCenterId(zoneId);
|
||||
} else {
|
||||
result = _sNwIpRangeDao.listAll();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseIpAddress(String ip) {
|
||||
_sNwIpDao.releaseIpAddress(ip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageNetworkIpAddressVO acquireIpAddress(long podId) {
|
||||
List<StorageNetworkIpRangeVO> ranges = _sNwIpRangeDao.listByPodId(podId);
|
||||
for (StorageNetworkIpRangeVO r : ranges) {
|
||||
try {
|
||||
r = _sNwIpRangeDao.acquireInLockTable(r.getId());
|
||||
if (r == null) {
|
||||
String msg = "Unable to acquire lock on storage network ip range id=" + r.getId() + ", delete failed";
|
||||
s_logger.warn(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
StorageNetworkIpAddressVO ip = _sNwIpDao.takeIpAddress(r.getId());
|
||||
if (ip != null) {
|
||||
return ip;
|
||||
}
|
||||
} finally {
|
||||
if (r != null) {
|
||||
_sNwIpRangeDao.releaseFromLockTable(r.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
List<StorageNetworkIpRangeVO> ranges = _sNwIpRangeDao.listByPodId(podId);
|
||||
for (StorageNetworkIpRangeVO r : ranges) {
|
||||
try {
|
||||
r = _sNwIpRangeDao.acquireInLockTable(r.getId());
|
||||
if (r == null) {
|
||||
String msg = "Unable to acquire lock on storage network ip range id=" + r.getId() + ", delete failed";
|
||||
s_logger.warn(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
StorageNetworkIpAddressVO ip = _sNwIpDao.takeIpAddress(r.getId());
|
||||
if (ip != null) {
|
||||
return ip;
|
||||
}
|
||||
} finally {
|
||||
if (r != null) {
|
||||
_sNwIpRangeDao.releaseFromLockTable(r.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isStorageIpRangeAvailable(long zoneId) {
|
||||
SearchCriteriaService<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = SearchCriteria2.create(StorageNetworkIpRangeVO.class);
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, zoneId);
|
||||
List<StorageNetworkIpRangeVO> entries = sc.list();
|
||||
return entries.size() > 0;
|
||||
SearchCriteriaService<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = SearchCriteria2.create(StorageNetworkIpRangeVO.class);
|
||||
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, zoneId);
|
||||
List<StorageNetworkIpRangeVO> entries = sc.list();
|
||||
return entries.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public List<SecondaryStorageVmVO> getSSVMWithNoStorageNetwork(long zoneId) {
|
||||
List<SecondaryStorageVmVO> ssvms = _ssvmDao.getSecStorageVmListInStates(null, zoneId, VirtualMachine.State.Starting, VirtualMachine.State.Running, VirtualMachine.State.Stopping);
|
||||
return ssvms;
|
||||
List<SecondaryStorageVmVO> ssvms = _ssvmDao.getSecStorageVmListInStates(null, zoneId, VirtualMachine.State.Starting, VirtualMachine.State.Running, VirtualMachine.State.Stopping);
|
||||
return ssvms;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isAnyStorageIpInUseInZone(long zoneId) {
|
||||
List<StorageNetworkIpRangeVO> ranges = _sNwIpRangeDao.listByDataCenterId(zoneId);
|
||||
for (StorageNetworkIpRangeVO r : ranges) {
|
||||
if (_sNwIpDao.countInUseIpByRangeId(r.getId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
List<StorageNetworkIpRangeVO> ranges = _sNwIpRangeDao.listByDataCenterId(zoneId);
|
||||
for (StorageNetworkIpRangeVO r : ranges) {
|
||||
if (_sNwIpDao.countInUseIpByRangeId(r.getId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,10 +22,11 @@ import java.util.Random;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
@ -61,21 +62,21 @@ import com.cloud.utils.net.NetUtils;
|
||||
@Local(value = NetworkDao.class)
|
||||
@DB(txn = false)
|
||||
public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements NetworkDao {
|
||||
final SearchBuilder<NetworkVO> AllFieldsSearch;
|
||||
final SearchBuilder<NetworkVO> AccountSearch;
|
||||
final SearchBuilder<NetworkVO> RelatedConfigSearch;
|
||||
final SearchBuilder<NetworkVO> AccountNetworkSearch;
|
||||
final SearchBuilder<NetworkVO> ZoneBroadcastUriSearch;
|
||||
final SearchBuilder<NetworkVO> ZoneSecurityGroupSearch;
|
||||
final GenericSearchBuilder<NetworkVO, Integer> CountBy;
|
||||
final SearchBuilder<NetworkVO> PhysicalNetworkSearch;
|
||||
final SearchBuilder<NetworkVO> SecurityGroupSearch;
|
||||
final GenericSearchBuilder<NetworkVO, Long> NetworksRegularUserCanCreateSearch;
|
||||
private final GenericSearchBuilder<NetworkVO, Integer> NetworksCount;
|
||||
final SearchBuilder<NetworkVO> SourceNATSearch;
|
||||
final GenericSearchBuilder<NetworkVO, Long> CountByZoneAndURI;
|
||||
final GenericSearchBuilder<NetworkVO, Long> VpcNetworksCount;
|
||||
final SearchBuilder<NetworkVO> OfferingAccountNetworkSearch;
|
||||
SearchBuilder<NetworkVO> AllFieldsSearch;
|
||||
SearchBuilder<NetworkVO> AccountSearch;
|
||||
SearchBuilder<NetworkVO> RelatedConfigSearch;
|
||||
SearchBuilder<NetworkVO> AccountNetworkSearch;
|
||||
SearchBuilder<NetworkVO> ZoneBroadcastUriSearch;
|
||||
SearchBuilder<NetworkVO> ZoneSecurityGroupSearch;
|
||||
GenericSearchBuilder<NetworkVO, Integer> CountBy;
|
||||
SearchBuilder<NetworkVO> PhysicalNetworkSearch;
|
||||
SearchBuilder<NetworkVO> SecurityGroupSearch;
|
||||
GenericSearchBuilder<NetworkVO, Long> NetworksRegularUserCanCreateSearch;
|
||||
GenericSearchBuilder<NetworkVO, Integer> NetworksCount;
|
||||
SearchBuilder<NetworkVO> SourceNATSearch;
|
||||
GenericSearchBuilder<NetworkVO, Long> CountByZoneAndURI;
|
||||
GenericSearchBuilder<NetworkVO, Long> VpcNetworksCount;
|
||||
SearchBuilder<NetworkVO> OfferingAccountNetworkSearch;
|
||||
|
||||
ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
|
||||
NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class);
|
||||
@ -85,13 +86,13 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
NetworkOfferingDaoImpl _ntwkOffDao = ComponentLocator.inject(NetworkOfferingDaoImpl.class);
|
||||
|
||||
|
||||
final TableGenerator _tgMacAddress;
|
||||
TableGenerator _tgMacAddress;
|
||||
Random _rand = new Random(System.currentTimeMillis());
|
||||
long _prefix = 0x2;
|
||||
|
||||
public NetworkDaoImpl() {
|
||||
}
|
||||
|
||||
|
||||
@PostConstruct
|
||||
protected void init() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
@ -150,7 +151,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
CountByZoneAndURI.and("guestType", CountByZoneAndURI.entity().getGuestType(), Op.EQ);
|
||||
|
||||
CountByZoneAndURI.done();
|
||||
|
||||
|
||||
ZoneSecurityGroupSearch = createSearchBuilder();
|
||||
ZoneSecurityGroupSearch.and("dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ);
|
||||
SearchBuilder<NetworkServiceMapVO> offJoin = _ntwkSvcMap.createSearchBuilder();
|
||||
@ -174,12 +175,12 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
join3.and("service", join3.entity().getService(), Op.EQ);
|
||||
SecurityGroupSearch.join("services", join3, SecurityGroupSearch.entity().getId(), join3.entity().getNetworkId(), JoinBuilder.JoinType.INNER);
|
||||
SecurityGroupSearch.done();
|
||||
|
||||
|
||||
NetworksCount = createSearchBuilder(Integer.class);
|
||||
NetworksCount.select(null, Func.COUNT, NetworksCount.entity().getId());
|
||||
NetworksCount.and("networkOfferingId", NetworksCount.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
|
||||
NetworksCount.done();
|
||||
|
||||
|
||||
NetworksRegularUserCanCreateSearch = createSearchBuilder(Long.class);
|
||||
NetworksRegularUserCanCreateSearch.and("aclType", NetworksRegularUserCanCreateSearch.entity().getAclType(), Op.EQ);
|
||||
NetworksRegularUserCanCreateSearch.select(null, Func.COUNT, NetworksRegularUserCanCreateSearch.entity().getId());
|
||||
@ -193,7 +194,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
NetworksRegularUserCanCreateSearch.done();
|
||||
|
||||
_tgMacAddress = _tgs.get("macAddress");
|
||||
|
||||
|
||||
SourceNATSearch = createSearchBuilder();
|
||||
SourceNATSearch.and("account", SourceNATSearch.entity().getAccountId(), Op.EQ);
|
||||
SourceNATSearch.and("datacenter", SourceNATSearch.entity().getDataCenterId(), Op.EQ);
|
||||
@ -202,7 +203,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
join6.and("service", join6.entity().getService(), Op.EQ);
|
||||
SourceNATSearch.join("services", join6, SourceNATSearch.entity().getId(), join6.entity().getNetworkId(), JoinBuilder.JoinType.INNER);
|
||||
SourceNATSearch.done();
|
||||
|
||||
|
||||
VpcNetworksCount = createSearchBuilder(Long.class);
|
||||
VpcNetworksCount.and("vpcId", VpcNetworksCount.entity().getVpcId(), Op.EQ);
|
||||
VpcNetworksCount.select(null, Func.COUNT, VpcNetworksCount.entity().getId());
|
||||
@ -229,11 +230,11 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
if (type != null) {
|
||||
sc.setParameters("guestType", type);
|
||||
}
|
||||
|
||||
|
||||
if (isSystem != null) {
|
||||
sc.setJoinParameters("offerings", "isSystem", isSystem);
|
||||
}
|
||||
|
||||
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
@ -360,7 +361,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
SearchCriteria<Long> sc = CountByZoneAndURI.create();
|
||||
sc.setParameters("dataCenterId", zoneId);
|
||||
sc.setParameters("broadcastUri", broadcastUri);
|
||||
|
||||
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
@ -409,7 +410,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
public void clearCheckForGc(long networkId) {
|
||||
_opDao.clearCheckForGc(networkId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCheckForGc(long networkId) {
|
||||
_opDao.setCheckForGc(networkId);
|
||||
@ -431,8 +432,8 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
NetworkDomainVO domain = new NetworkDomainVO(networkId, domainId, subdomainAccess);
|
||||
_domainsDao.persist(domain);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getNetworkCountByVpcId(long vpcId) {
|
||||
SearchCriteria<Integer> sc = CountBy.create();
|
||||
@ -440,7 +441,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
List<Integer> results = customSearch(sc, null);
|
||||
return results.get(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listSecurityGroupEnabledNetworks() {
|
||||
@ -500,7 +501,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
|
||||
return listBy(sc, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getNetworkCountByNetworkOffId(long networkOfferingId) {
|
||||
SearchCriteria<Integer> sc = NetworksCount.create();
|
||||
@ -508,7 +509,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
List<Integer> count = customSearch(sc, null);
|
||||
return count.get(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long countNetworksUserCanCreate(long ownerId) {
|
||||
SearchCriteria<Long> sc = NetworksRegularUserCanCreateSearch.create();
|
||||
@ -517,8 +518,8 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
sc.setJoinParameters("ntwkOff", "specifyVlan", false);
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listSourceNATEnabledNetworks(long accountId, long dataCenterId, Network.GuestType type) {
|
||||
SearchCriteria<NetworkVO> sc = SourceNATSearch.create();
|
||||
@ -528,7 +529,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
sc.setJoinParameters("services", "service", Service.SourceNat.getName());
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listByVpc(long vpcId) {
|
||||
SearchCriteria<NetworkVO> sc = AllFieldsSearch.create();
|
||||
@ -549,6 +550,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean remove(Long id) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
@ -585,7 +587,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
|
||||
public List<NetworkVO> listRedundantNetworks() {
|
||||
SearchCriteria<NetworkVO> sc = AllFieldsSearch.create();
|
||||
sc.setJoinParameters("offerings", "isRedundant", true);
|
||||
|
||||
|
||||
return listBy(sc, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,18 +35,16 @@ import javax.persistence.InheritanceType;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name="firewall_rules")
|
||||
@Inheritance(strategy=InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name="purpose", discriminatorType=DiscriminatorType.STRING, length=32)
|
||||
public class FirewallRuleVO implements FirewallRule {
|
||||
protected final FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao = ComponentLocator.inject(FirewallRulesCidrsDaoImpl.class);
|
||||
@Inject protected FirewallRulesCidrsDao _firewallRulesCidrsDao;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,35 @@
|
||||
// under the License.
|
||||
package com.cloud.server;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationVO;
|
||||
import com.cloud.configuration.Resource;
|
||||
@ -45,7 +74,11 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.guru.*;
|
||||
import com.cloud.network.guru.ControlNetworkGuru;
|
||||
import com.cloud.network.guru.DirectPodBasedNetworkGuru;
|
||||
import com.cloud.network.guru.PodBasedNetworkGuru;
|
||||
import com.cloud.network.guru.PublicNetworkGuru;
|
||||
import com.cloud.network.guru.StorageNetworkGuru;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offerings.NetworkOfferingServiceMapVO;
|
||||
@ -63,7 +96,6 @@ import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.PasswordGenerator;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
@ -71,20 +103,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.uuididentity.dao.IdentityDao;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Component
|
||||
public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
@ -230,7 +248,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
|
||||
// store the public and private keys in the database
|
||||
updateKeyPairs();
|
||||
|
||||
|
||||
// generate a random password for system vm
|
||||
updateSystemvmPassword();
|
||||
|
||||
@ -504,29 +522,29 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
if (!userid.startsWith("cloud")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Boolean.valueOf(_configDao.getValue("system.vm.random.password"))) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
String already = _configDao.getValue("system.vm.password");
|
||||
if (already == null) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
String rpassword = PasswordGenerator.generatePresharedKey(8);
|
||||
String wSql = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) "
|
||||
+ "VALUES ('Hidden','DEFAULT', 'management-server','system.vm.password', '" + rpassword
|
||||
+ "','randmon password generated each management server starts for system vm')";
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql);
|
||||
stmt.executeUpdate(wSql);
|
||||
s_logger.info("Updated systemvm password in database");
|
||||
} catch (SQLException e) {
|
||||
s_logger.error("Cannot retrieve systemvm password", e);
|
||||
}
|
||||
}
|
||||
String already = _configDao.getValue("system.vm.password");
|
||||
if (already == null) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
String rpassword = PasswordGenerator.generatePresharedKey(8);
|
||||
String wSql = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) "
|
||||
+ "VALUES ('Hidden','DEFAULT', 'management-server','system.vm.password', '" + rpassword
|
||||
+ "','randmon password generated each management server starts for system vm')";
|
||||
PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql);
|
||||
stmt.executeUpdate(wSql);
|
||||
s_logger.info("Updated systemvm password in database");
|
||||
} catch (SQLException e) {
|
||||
s_logger.error("Cannot retrieve systemvm password", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void updateKeyPairs() {
|
||||
@ -541,10 +559,10 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
String already = _configDao.getValue("ssh.privatekey");
|
||||
String homeDir = null;
|
||||
homeDir = Script.runSimpleBashScript("echo ~" + username);
|
||||
if (homeDir == null) {
|
||||
if (homeDir == null) {
|
||||
throw new CloudRuntimeException("Cannot get home directory for account: " + username);
|
||||
}
|
||||
|
||||
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Processing updateKeyPairs");
|
||||
}
|
||||
@ -622,11 +640,11 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
}
|
||||
s_logger.info("Going to update systemvm iso with generated keypairs if needed");
|
||||
try {
|
||||
injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
|
||||
injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
|
||||
} catch (CloudRuntimeException e) {
|
||||
if (!devel) {
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
if (!devel) {
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -892,7 +910,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
|
||||
defaultSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled);
|
||||
defaultSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedSGNetworkOffering);
|
||||
|
||||
|
||||
for (Service service : defaultSharedSGNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
@ -967,7 +985,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
|
||||
// Offering #6
|
||||
NetworkOfferingVO defaultNetworkOfferingForVpcNetworks = new NetworkOfferingVO(
|
||||
NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
|
||||
@ -978,7 +996,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
|
||||
defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled);
|
||||
defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks);
|
||||
|
||||
|
||||
Map<Network.Service, Network.Provider> defaultVpcNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Dhcp, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Dns, Provider.VPCVirtualRouter);
|
||||
@ -990,14 +1008,14 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
defaultVpcNetworkOfferingProviders.put(Service.StaticNat, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.PortForwarding, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProviders.put(Service.Vpn, Provider.VPCVirtualRouter);
|
||||
|
||||
|
||||
for (Service service : defaultVpcNetworkOfferingProviders.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(defaultNetworkOfferingForVpcNetworks.getId(), service, defaultVpcNetworkOfferingProviders.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
|
||||
// Offering #7
|
||||
NetworkOfferingVO defaultNetworkOfferingForVpcNetworksNoLB = new NetworkOfferingVO(
|
||||
NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
|
||||
@ -1008,7 +1026,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
|
||||
defaultNetworkOfferingForVpcNetworksNoLB.setState(NetworkOffering.State.Enabled);
|
||||
defaultNetworkOfferingForVpcNetworksNoLB = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworksNoLB);
|
||||
|
||||
|
||||
Map<Network.Service, Network.Provider> defaultVpcNetworkOfferingProvidersNoLB = new HashMap<Network.Service, Network.Provider>();
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dhcp, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dns, Provider.VPCVirtualRouter);
|
||||
@ -1019,16 +1037,16 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.StaticNat, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.PortForwarding, Provider.VPCVirtualRouter);
|
||||
defaultVpcNetworkOfferingProvidersNoLB.put(Service.Vpn, Provider.VPCVirtualRouter);
|
||||
|
||||
|
||||
for (Service service : defaultVpcNetworkOfferingProvidersNoLB.keySet()) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO
|
||||
(defaultNetworkOfferingForVpcNetworksNoLB.getId(), service, defaultVpcNetworkOfferingProvidersNoLB.get(service));
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -36,46 +36,47 @@ import com.cloud.utils.SerialVersionUID;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
public class CloudStartupServlet extends HttpServlet implements ServletContextListener {
|
||||
public static final Logger s_logger = Logger.getLogger(CloudStartupServlet.class.getName());
|
||||
|
||||
static final long serialVersionUID = SerialVersionUID.CloudStartupServlet;
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
initLog4j();
|
||||
public static final Logger s_logger = Logger.getLogger(CloudStartupServlet.class.getName());
|
||||
|
||||
// Save Configuration Values
|
||||
ConfigurationServer c = (ConfigurationServer)ComponentContext.getCompanent(ConfigurationServer.class);
|
||||
try {
|
||||
c.persistDefaultValues();
|
||||
s_locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
ManagementServer ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name);
|
||||
ms.enableAdminUser("password");
|
||||
ApiServer.initApiServer(ms.getPropertiesFiles());
|
||||
} catch (InvalidParameterValueException ipve) {
|
||||
s_logger.error("Exception starting management server ", ipve);
|
||||
throw new ServletException (ipve.getMessage());
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Exception starting management server ", e);
|
||||
throw new ServletException (e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try {
|
||||
init();
|
||||
} catch (ServletException e) {
|
||||
s_logger.error("Exception starting management server ", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
}
|
||||
|
||||
private void initLog4j() {
|
||||
static final long serialVersionUID = SerialVersionUID.CloudStartupServlet;
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
initLog4j();
|
||||
|
||||
// Save Configuration Values
|
||||
ConfigurationServer c = ComponentContext.getCompanent(ConfigurationServer.class);
|
||||
try {
|
||||
c.persistDefaultValues();
|
||||
|
||||
ManagementServer ms = ComponentContext.getCompanent(ManagementServer.class);
|
||||
ms.startup();
|
||||
ms.enableAdminUser("password");
|
||||
ApiServer.initApiServer(ms.getPropertiesFiles());
|
||||
} catch (InvalidParameterValueException ipve) {
|
||||
s_logger.error("Exception starting management server ", ipve);
|
||||
throw new ServletException (ipve.getMessage());
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Exception starting management server ", e);
|
||||
throw new ServletException (e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try {
|
||||
init();
|
||||
} catch (ServletException e) {
|
||||
s_logger.error("Exception starting management server ", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
}
|
||||
|
||||
private void initLog4j() {
|
||||
File file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
|
||||
if (file != null) {
|
||||
s_logger.info("log4j configuration found at " + file.getAbsolutePath());
|
||||
@ -87,5 +88,5 @@ public class CloudStartupServlet extends HttpServlet implements ServletContextLi
|
||||
PropertyConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.VolumeHostVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -29,85 +31,85 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
@Local(value={VolumeHostDao.class})
|
||||
public class VolumeHostDaoImpl extends GenericDaoBase<VolumeHostVO, Long> implements VolumeHostDao {
|
||||
|
||||
protected final SearchBuilder<VolumeHostVO> HostVolumeSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> ZoneVolumeSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> VolumeSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> HostSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> HostDestroyedSearch;
|
||||
|
||||
VolumeHostDaoImpl(){
|
||||
HostVolumeSearch = createSearchBuilder();
|
||||
HostVolumeSearch.and("host_id", HostVolumeSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostVolumeSearch.and("volume_id", HostVolumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||
HostVolumeSearch.and("destroyed", HostVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
HostVolumeSearch.done();
|
||||
|
||||
ZoneVolumeSearch = createSearchBuilder();
|
||||
ZoneVolumeSearch.and("zone_id", ZoneVolumeSearch.entity().getZoneId(), SearchCriteria.Op.EQ);
|
||||
ZoneVolumeSearch.and("volume_id", ZoneVolumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||
ZoneVolumeSearch.and("destroyed", ZoneVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
ZoneVolumeSearch.done();
|
||||
|
||||
HostSearch = createSearchBuilder();
|
||||
HostSearch.and("host_id", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.and("destroyed", HostSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
VolumeSearch = createSearchBuilder();
|
||||
VolumeSearch.and("volume_id", VolumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||
VolumeSearch.and("destroyed", VolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
VolumeSearch.done();
|
||||
|
||||
HostDestroyedSearch = createSearchBuilder();
|
||||
HostDestroyedSearch.and("host_id", HostDestroyedSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostDestroyedSearch.and("destroyed", HostDestroyedSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
HostDestroyedSearch.done();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public VolumeHostVO findByHostVolume(long hostId, long volumeId) {
|
||||
SearchCriteria<VolumeHostVO> sc = HostVolumeSearch.create();
|
||||
sc.setParameters("host_id", hostId);
|
||||
sc.setParameters("volume_id", volumeId);
|
||||
protected final SearchBuilder<VolumeHostVO> HostVolumeSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> ZoneVolumeSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> VolumeSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> HostSearch;
|
||||
protected final SearchBuilder<VolumeHostVO> HostDestroyedSearch;
|
||||
|
||||
VolumeHostDaoImpl(){
|
||||
HostVolumeSearch = createSearchBuilder();
|
||||
HostVolumeSearch.and("host_id", HostVolumeSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostVolumeSearch.and("volume_id", HostVolumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||
HostVolumeSearch.and("destroyed", HostVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
HostVolumeSearch.done();
|
||||
|
||||
ZoneVolumeSearch = createSearchBuilder();
|
||||
ZoneVolumeSearch.and("zone_id", ZoneVolumeSearch.entity().getZoneId(), SearchCriteria.Op.EQ);
|
||||
ZoneVolumeSearch.and("volume_id", ZoneVolumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||
ZoneVolumeSearch.and("destroyed", ZoneVolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
ZoneVolumeSearch.done();
|
||||
|
||||
HostSearch = createSearchBuilder();
|
||||
HostSearch.and("host_id", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.and("destroyed", HostSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
VolumeSearch = createSearchBuilder();
|
||||
VolumeSearch.and("volume_id", VolumeSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
|
||||
VolumeSearch.and("destroyed", VolumeSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
VolumeSearch.done();
|
||||
|
||||
HostDestroyedSearch = createSearchBuilder();
|
||||
HostDestroyedSearch.and("host_id", HostDestroyedSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostDestroyedSearch.and("destroyed", HostDestroyedSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
HostDestroyedSearch.done();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public VolumeHostVO findByHostVolume(long hostId, long volumeId) {
|
||||
SearchCriteria<VolumeHostVO> sc = HostVolumeSearch.create();
|
||||
sc.setParameters("host_id", hostId);
|
||||
sc.setParameters("volume_id", volumeId);
|
||||
sc.setParameters("destroyed", false);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeHostVO findVolumeByZone(long volumeId, long zoneId) {
|
||||
SearchCriteria<VolumeHostVO> sc = ZoneVolumeSearch.create();
|
||||
sc.setParameters("zone_id", zoneId);
|
||||
sc.setParameters("volume_id", volumeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeHostVO findVolumeByZone(long volumeId, long zoneId) {
|
||||
SearchCriteria<VolumeHostVO> sc = ZoneVolumeSearch.create();
|
||||
sc.setParameters("zone_id", zoneId);
|
||||
sc.setParameters("volume_id", volumeId);
|
||||
sc.setParameters("destroyed", false);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeHostVO findByVolumeId(long volumeId) {
|
||||
SearchCriteria<VolumeHostVO> sc = VolumeSearch.create();
|
||||
sc.setParameters("volume_id", volumeId);
|
||||
sc.setParameters("destroyed", false);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeHostVO findByVolumeId(long volumeId) {
|
||||
SearchCriteria<VolumeHostVO> sc = VolumeSearch.create();
|
||||
sc.setParameters("volume_id", volumeId);
|
||||
sc.setParameters("destroyed", false);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<VolumeHostVO> listBySecStorage(long ssHostId) {
|
||||
SearchCriteria<VolumeHostVO> sc = HostSearch.create();
|
||||
sc.setParameters("host_id", ssHostId);
|
||||
sc.setParameters("destroyed", false);
|
||||
return listAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeHostVO> listDestroyed(long hostId){
|
||||
SearchCriteria<VolumeHostVO> sc = HostDestroyedSearch.create();
|
||||
sc.setParameters("host_id", hostId);
|
||||
sc.setParameters("destroyed", true);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
@Override
|
||||
public List<VolumeHostVO> listBySecStorage(long ssHostId) {
|
||||
SearchCriteria<VolumeHostVO> sc = HostSearch.create();
|
||||
sc.setParameters("host_id", ssHostId);
|
||||
sc.setParameters("destroyed", false);
|
||||
return listAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VolumeHostVO> listDestroyed(long hostId){
|
||||
SearchCriteria<VolumeHostVO> sc = HostDestroyedSearch.create();
|
||||
sc.setParameters("host_id", hostId);
|
||||
sc.setParameters("destroyed", true);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,8 +20,8 @@ import java.net.URLEncoder;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -39,20 +39,18 @@ import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.dao.UserAccountJoinDao;
|
||||
import com.cloud.api.query.vo.ControlledViewEntity;
|
||||
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
|
||||
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.ResourceLimit;
|
||||
@ -115,7 +113,6 @@ import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
@ -232,7 +229,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
|
||||
UserVO _systemUser;
|
||||
AccountVO _systemAccount;
|
||||
|
||||
|
||||
@Inject
|
||||
List<SecurityChecker> _securityCheckers;
|
||||
int _cleanupInterval;
|
||||
@ -285,6 +282,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountVO getSystemAccount() {
|
||||
if (_systemAccount == null) {
|
||||
_systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
|
||||
@ -382,7 +380,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
|
||||
if (!granted) {
|
||||
assert false : "How can all of the security checkers pass on checking this check: " + entity;
|
||||
throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to " + entity);
|
||||
throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to " + entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,7 +442,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
user.setState(State.disabled.toString());
|
||||
}
|
||||
_userAccountDao.update(id, user);
|
||||
txn.commit();
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Failed to update login attempts for user with id " + id );
|
||||
}
|
||||
@ -492,7 +490,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
@Override
|
||||
public boolean deleteAccount(AccountVO account, long callerUserId, Account caller) {
|
||||
long accountId = account.getId();
|
||||
|
||||
|
||||
//delete the account record
|
||||
if (!_accountDao.remove(accountId)) {
|
||||
s_logger.error("Unable to delete account " + accountId);
|
||||
@ -510,7 +508,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
public boolean cleanupAccount(AccountVO account, long callerUserId, Account caller) {
|
||||
long accountId = account.getId();
|
||||
boolean accountCleanupNeeded = false;
|
||||
|
||||
|
||||
try {
|
||||
//cleanup the users from the account
|
||||
List<UserVO> users = _userDao.listByAccount(accountId);
|
||||
@ -520,10 +518,10 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
accountCleanupNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//delete the account from project accounts
|
||||
_projectAccountDao.removeAccountFromProjects(accountId);
|
||||
|
||||
|
||||
// delete all vm groups belonging to accont
|
||||
List<InstanceGroupVO> groups = _vmGroupDao.listByAccountId(accountId);
|
||||
for (InstanceGroupVO group : groups) {
|
||||
@ -601,7 +599,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
s_logger.warn("Failed to cleanup remote access vpn resources as a part of account id=" + accountId + " cleanup due to Exception: ", ex);
|
||||
accountCleanupNeeded = true;
|
||||
}
|
||||
|
||||
|
||||
// Cleanup security groups
|
||||
int numRemoved = _securityGroupDao.removeByAccountId(accountId);
|
||||
s_logger.info("deleteAccount: Deleted " + numRemoved + " network groups for account " + accountId);
|
||||
@ -624,7 +622,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Delete all VPCs
|
||||
boolean vpcsDeleted = true;
|
||||
s_logger.debug("Deleting vpcs for account " + account.getId());
|
||||
@ -646,8 +644,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
for (IpAddress ip : ipsToRelease) {
|
||||
s_logger.debug("Releasing ip " + ip + " as a part of account id=" + accountId + " cleanup");
|
||||
if (!_networkMgr.disassociatePublicIpAddress(ip.getId(), callerUserId, caller)) {
|
||||
s_logger.warn("Failed to release ip address " + ip + " as a part of account id=" + accountId + " clenaup");
|
||||
accountCleanupNeeded = true;
|
||||
s_logger.warn("Failed to release ip address " + ip + " as a part of account id=" + accountId + " clenaup");
|
||||
accountCleanupNeeded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -776,7 +774,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
if (userName.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Username is empty");
|
||||
}
|
||||
|
||||
|
||||
if (firstName.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Firstname is empty");
|
||||
}
|
||||
@ -905,21 +903,21 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
if (firstName.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Firstname is empty");
|
||||
}
|
||||
|
||||
|
||||
user.setFirstname(firstName);
|
||||
}
|
||||
if (lastName != null) {
|
||||
if (lastName.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Lastname is empty");
|
||||
}
|
||||
|
||||
|
||||
user.setLastname(lastName);
|
||||
}
|
||||
if (userName != null) {
|
||||
if (userName.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Username is empty");
|
||||
}
|
||||
|
||||
|
||||
// don't allow to have same user names in the same domain
|
||||
List<UserVO> duplicatedUsers = _userDao.findUsersByName(userName);
|
||||
for (UserVO duplicatedUser : duplicatedUsers) {
|
||||
@ -933,18 +931,18 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
|
||||
user.setUsername(userName);
|
||||
}
|
||||
|
||||
|
||||
if (password != null) {
|
||||
String encodedPassword = null;
|
||||
for (Enumeration<UserAuthenticator> en = _userAuthenticators.enumeration(); en.hasMoreElements();) {
|
||||
UserAuthenticator authenticator = en.nextElement();
|
||||
for (Iterator<UserAuthenticator> en = _userAuthenticators.iterator(); en.hasNext();) {
|
||||
UserAuthenticator authenticator = en.next();
|
||||
encodedPassword = authenticator.encode(password);
|
||||
if (encodedPassword != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (encodedPassword == null) {
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
}
|
||||
user.setPassword(encodedPassword);
|
||||
}
|
||||
@ -1293,11 +1291,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
// check if the given account name is unique in this domain for updating
|
||||
Account duplicateAcccount = _accountDao.findActiveAccount(newAccountName, domainId);
|
||||
if (duplicateAcccount != null && duplicateAcccount.getId() != account.getId()) {// allow
|
||||
// same
|
||||
// account
|
||||
// to
|
||||
// update
|
||||
// itself
|
||||
// same
|
||||
// account
|
||||
// to
|
||||
// update
|
||||
// itself
|
||||
throw new InvalidParameterValueException("There already exists an account with the name:" + newAccountName + " in the domain:" + domainId + " with existing account id:"
|
||||
+ duplicateAcccount.getId());
|
||||
}
|
||||
@ -1697,15 +1695,15 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
|
||||
String encodedPassword = null;
|
||||
for (Enumeration<UserAuthenticator> en = _userAuthenticators.enumeration(); en.hasMoreElements();) {
|
||||
UserAuthenticator authenticator = en.nextElement();
|
||||
for (Iterator<UserAuthenticator> en = _userAuthenticators.iterator(); en.hasNext();) {
|
||||
UserAuthenticator authenticator = en.next();
|
||||
encodedPassword = authenticator.encode(password);
|
||||
if (encodedPassword != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (encodedPassword == null) {
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
throw new CloudRuntimeException("Failed to encode password");
|
||||
}
|
||||
|
||||
UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone));
|
||||
@ -2088,7 +2086,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
@Override
|
||||
public void buildACLSearchParameters(Account caller, Long id, String accountName, Long projectId, List<Long>
|
||||
permittedAccounts, Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject,
|
||||
boolean listAll, boolean forProjectInvitation) {
|
||||
boolean listAll, boolean forProjectInvitation) {
|
||||
Long domainId = domainIdRecursiveListProject.first();
|
||||
|
||||
if (domainId != null) {
|
||||
@ -2166,7 +2164,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void buildACLViewSearchBuilder(SearchBuilder<? extends ControlledViewEntity> sb, Long domainId,
|
||||
boolean isRecursive, List<Long> permittedAccounts, ListProjectResourcesCriteria listProjectResourcesCriteria) {
|
||||
|
||||
@ -2210,7 +2208,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAccount getUserByApiKey(String apiKey) {
|
||||
return _userAccountDao.getUserByApiKey(apiKey);
|
||||
}
|
||||
public UserAccount getUserByApiKey(String apiKey) {
|
||||
return _userAccountDao.getUserByApiKey(apiKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,6 @@ import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
|
||||
@ -23,7 +23,8 @@ import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.IdentityService;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.uuididentity.dao.IdentityDao;
|
||||
|
||||
@ -31,37 +32,39 @@ import com.cloud.uuididentity.dao.IdentityDao;
|
||||
@Local(value = { IdentityService.class })
|
||||
public class IdentityServiceImpl implements Manager, IdentityService {
|
||||
private String _name;
|
||||
|
||||
@Inject private IdentityDao _identityDao;
|
||||
|
||||
|
||||
@Inject private IdentityDao _identityDao;
|
||||
|
||||
@Override
|
||||
public Long getIdentityId(String tableName, String identityString) {
|
||||
return _identityDao.getIdentityId(tableName, identityString);
|
||||
return _identityDao.getIdentityId(tableName, identityString);
|
||||
}
|
||||
|
||||
public String getIdentityUuid(String tableName, String identityString) {
|
||||
return _identityDao.getIdentityUuid(tableName, identityString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
_name = name;
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String getIdentityUuid(String tableName, String identityString) {
|
||||
return _identityDao.getIdentityUuid(tableName, identityString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
_name = name;
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -156,6 +156,7 @@ DROP TABLE IF EXISTS `cloud`.`autoscale_vmprofiles`;
|
||||
DROP TABLE IF EXISTS `cloud`.`autoscale_policies`;
|
||||
DROP TABLE IF EXISTS `cloud`.`counter`;
|
||||
DROP TABLE IF EXISTS `cloud`.`conditions`;
|
||||
DROP TABLE IF EXISTS `cloud`.`inline_load_balancer_nic_map`;
|
||||
|
||||
CREATE TABLE `cloud`.`version` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// under the License.
|
||||
package com.cloud.utils;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -151,4 +151,17 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
|
||||
public static int formatForOutput(String text, int start, int columns, char separator) {
|
||||
if (start >= text.length()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int end = start + columns;
|
||||
if (end > text.length()) {
|
||||
end = text.length();
|
||||
}
|
||||
String searchable = text.substring(start, end);
|
||||
int found = searchable.lastIndexOf(separator);
|
||||
return found > 0 ? found : end - start;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user