add two tables for gre controller

This commit is contained in:
tuna 2013-07-17 15:37:38 +07:00
parent 3a9c9bd717
commit 12a4d30007
6 changed files with 317 additions and 0 deletions

View File

@ -0,0 +1,26 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.ovs.dao;
import java.util.List;
import com.cloud.utils.db.GenericDao;
public interface OvsDeviceDao extends GenericDao<OvsDeviceVO, Long> {
List<OvsDeviceVO> listByPhysicalNetwork(long physicalNetworkId);
}

View File

@ -0,0 +1,49 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.ovs.dao;
import java.util.List;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;
@Component
@Local(value=OvsDeviceDao.class)
public class OvsDeviceDaoImpl extends GenericDaoBase<OvsDeviceVO, Long> implements OvsDeviceDao {
protected final SearchBuilder<OvsDeviceVO> physicalNetworkIdSearch;
public OvsDeviceDaoImpl() {
physicalNetworkIdSearch = createSearchBuilder();
physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);
physicalNetworkIdSearch.done();
}
@Override
public List<OvsDeviceVO> listByPhysicalNetwork(long physicalNetworkId) {
SearchCriteria<OvsDeviceVO> sc = physicalNetworkIdSearch.create();
sc.setParameters("physicalNetworkId", physicalNetworkId);
return search(sc, null);
}
}

View File

@ -0,0 +1,88 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.ovs.dao;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name="ovs_devices")
public class OvsDeviceVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
private long id;
@Column(name="uuid")
private String uuid;
@Column(name="host_id")
private long hostId;
@Column(name="physical_network_id")
private long physicalNetworkId;
@Column(name="device_name")
private String deviceName;
public OvsDeviceVO() {
this.uuid = UUID.randomUUID().toString();
}
public OvsDeviceVO(long hostId, long physicalNetworkId,
String deviceName) {
super();
this.hostId = hostId;
this.physicalNetworkId = physicalNetworkId;
this.deviceName = deviceName;
this.uuid = UUID.randomUUID().toString();
}
public long getId() {
return id;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public long getPhysicalNetworkId() {
return physicalNetworkId;
}
public long getHostId() {
return hostId;
}
public String getDeviceName() {
return deviceName;
}
}

View File

@ -0,0 +1,24 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.ovs.dao;
import com.cloud.utils.db.GenericDao;
public interface OvsNicMappingDao extends GenericDao<OvsNicMappingVO, Long> {
public OvsNicMappingVO findByNicUuid(String nicUuid);
}

View File

@ -0,0 +1,47 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.ovs.dao;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;
@Component
@Local(value=OvsNicMappingDao.class)
public class OvsNicMappingDaoImpl extends GenericDaoBase<OvsNicMappingVO, Long> implements OvsNicMappingDao{
protected final SearchBuilder<OvsNicMappingVO> nicSearch;
public OvsNicMappingDaoImpl() {
nicSearch = createSearchBuilder();
nicSearch.and("nicUuid", nicSearch.entity().getNicUuid(), Op.EQ);
nicSearch.done();
}
@Override
public OvsNicMappingVO findByNicUuid(String nicUuid) {
SearchCriteria<OvsNicMappingVO> sc = nicSearch.create();
sc.setParameters("nicUuid", nicUuid);
return findOneBy(sc);
}
}

View File

@ -0,0 +1,83 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.ovs.dao;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name="ovs_nic_map")
public class OvsNicMappingVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
private long id;
@Column(name="logicalswitch")
private String logicalSwitchUuid;
@Column(name="logicalswitchport")
private String logicalSwitchPortUuid;
@Column(name="nic")
private String nicUuid;
public OvsNicMappingVO() {
}
public OvsNicMappingVO (String logicalSwitchUuid, String logicalSwitchPortUuid, String nicUuid) {
this.logicalSwitchUuid = logicalSwitchUuid;
this.logicalSwitchPortUuid = logicalSwitchPortUuid;
this.nicUuid = nicUuid;
}
public String getLogicalSwitchUuid() {
return logicalSwitchUuid;
}
public void setLogicalSwitchUuid(String logicalSwitchUuid) {
this.logicalSwitchUuid = logicalSwitchUuid;
}
public String getLogicalSwitchPortUuid() {
return logicalSwitchPortUuid;
}
public void setLogicalSwitchPortUuid(String logicalSwitchPortUuid) {
this.logicalSwitchPortUuid = logicalSwitchPortUuid;
}
public String getNicUuid() {
return nicUuid;
}
public void setNicUuid(String nicUuid) {
this.nicUuid = nicUuid;
}
public long getId() {
return id;
}
}