From 5363b2782d906a6c6067eb840392f959ed4dfe4b Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 18 Jul 2017 20:23:07 -0400 Subject: [CCSDK-6] Populate seed code Add seed code for sli/adaptors repository Update code to use org.onap.ccsdk.sli.core Change-Id: I477c7a24f2cc1fed8fb0975fe9f33733411c27f9 Signed-off-by: Dan Timoney --- .../sdnc/ra/equip/comp/EquipmentReader.java | 32 +++++++++ .../org/openecomp/sdnc/ra/equip/dao/ServerDao.java | 30 ++++++++ .../openecomp/sdnc/ra/equip/dao/ServerDaoImpl.java | 64 +++++++++++++++++ .../openecomp/sdnc/ra/equip/dao/VpePortDao.java | 32 +++++++++ .../sdnc/ra/equip/dao/VpePortDaoImpl.java | 81 ++++++++++++++++++++++ .../openecomp/sdnc/ra/equip/dao/VplspePortDao.java | 30 ++++++++ .../sdnc/ra/equip/dao/VplspePortDaoImpl.java | 70 +++++++++++++++++++ .../sdnc/ra/equip/data/EquipmentData.java | 31 +++++++++ .../sdnc/ra/equip/data/EquipmentLevel.java | 26 +++++++ 9 files changed, 396 insertions(+) create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/comp/EquipmentReader.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDao.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDaoImpl.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDao.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDaoImpl.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDao.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDaoImpl.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentData.java create mode 100644 resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentLevel.java (limited to 'resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip') diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/comp/EquipmentReader.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/comp/EquipmentReader.java new file mode 100644 index 00000000..a380594b --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/comp/EquipmentReader.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.comp; + +import java.util.List; +import java.util.Map; + +import org.openecomp.sdnc.ra.equip.data.EquipmentData; + +public interface EquipmentReader { + + List readEquipment(Map equipmentConstraints); +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDao.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDao.java new file mode 100644 index 00000000..44873873 --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDao.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.dao; + +import java.util.List; +import java.util.Map; + +public interface ServerDao { + + List> getServerData(String aicSiteId); +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDaoImpl.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDaoImpl.java new file mode 100644 index 00000000..e1bc2a5a --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/ServerDaoImpl.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.dao; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; + +public class ServerDaoImpl implements ServerDao { + + private static final Logger log = LoggerFactory.getLogger(ServerDaoImpl.class); + + private static final String GET_SERVER_COUNT_SQL = "SELECT count(*) FROM PSERVER WHERE aic_site_id = ?"; + + private JdbcTemplate jdbcTemplate; + + @Override + public List> getServerData(String aicSiteId) { + List> ll = new ArrayList>(); + Map sd = new HashMap(); + sd.put("aic-site-id", aicSiteId); + sd.put("server-id", aicSiteId + "/Server1"); + sd.put("server-model", "Unknown"); + sd.put("server-count", getServerCount(aicSiteId)); + ll.add(sd); + return ll; + } + + private int getServerCount(String aicSiteId) { + int n = jdbcTemplate.queryForInt(GET_SERVER_COUNT_SQL, aicSiteId); + + log.info("Number of servers in " + aicSiteId + ": " + n); + + return n; + } + + public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDao.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDao.java new file mode 100644 index 00000000..4a0f6b8c --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDao.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.dao; + +import java.util.List; +import java.util.Map; + +public interface VpePortDao { + + List> getVpePortData(String aicSiteId); + + List> getVpePortData(String aicSiteId, String vpeName); +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDaoImpl.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDaoImpl.java new file mode 100644 index 00000000..d25fe9c4 --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VpePortDaoImpl.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; + +public class VpePortDaoImpl implements VpePortDao { + + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(VpePortDaoImpl.class); + + private static final String GET_SQL = "SELECT * FROM VPE_POOL WHERE aic_site_id = ?"; + private static final String GET2_SQL = "SELECT * FROM VPE_POOL WHERE vpe_name = ?"; + private static final String GET3_SQL = + "SELECT * FROM VPE_POOL WHERE substring(aic_site_id, 1, 8) = substring(?, 1, 8)"; + + private JdbcTemplate jdbcTemplate; + + @Override + public List> getVpePortData(String aicSiteId) { + return jdbcTemplate.query(GET_SQL, new Object[] { aicSiteId }, new VpePortRowMapper()); + } + + @Override + public List> getVpePortData(String aicSiteId, String vpeName) { + String sql = vpeName != null ? GET2_SQL : GET3_SQL; + Object[] param = new Object[] { vpeName != null ? vpeName : aicSiteId }; + + return jdbcTemplate.query(sql, param, new VpePortRowMapper()); + } + + private static class VpePortRowMapper implements RowMapper> { + + @Override + public Map mapRow(ResultSet rs, int rowNum) throws SQLException { + Map mm = new HashMap(); + mm.put("vpe-id", rs.getString("vpe_name")); + mm.put("aic-site-id", rs.getString("aic_site_id")); + mm.put("availability-zone", rs.getString("availability_zone")); + mm.put("image-file-name", rs.getString("image_filename")); + mm.put("vendor", rs.getString("vendor")); + mm.put("provisioning-status", rs.getString("provisioning_status")); + mm.put("physical-interface-name", rs.getString("physical_intf_name")); + mm.put("physical-interface-speed", rs.getLong("physical_intf_speed")); + mm.put("physical-interface-speed-unit", rs.getString("physical_intf_units")); + return mm; + } + } + + public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDao.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDao.java new file mode 100644 index 00000000..879a233d --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDao.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.dao; + +import java.util.List; +import java.util.Map; + +public interface VplspePortDao { + + List> getVplspePortData(String aicSiteId); +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDaoImpl.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDaoImpl.java new file mode 100644 index 00000000..bad64641 --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/dao/VplspePortDaoImpl.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; + +public class VplspePortDaoImpl implements VplspePortDao { + + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(VplspePortDaoImpl.class); + + private static final String GET_SQL = "SELECT * FROM VPLSPE_POOL WHERE aic_site_id = ?"; + + private JdbcTemplate jdbcTemplate; + + @Override + public List> getVplspePortData(String aicSiteId) { + List> ll = + jdbcTemplate.query(GET_SQL, new Object[] { aicSiteId }, new RowMapper>() { + + @Override + public Map mapRow(ResultSet rs, int rowNum) throws SQLException { + Map mm = new HashMap(); + mm.put("vplspe-id", rs.getString("vplspe_name")); + mm.put("aic-site-id", rs.getString("aic_site_id")); + mm.put("availability-zone", rs.getString("availability_zone")); + mm.put("image-file-name", rs.getString("image_filename")); + mm.put("vendor", rs.getString("vendor")); + mm.put("provisioning-status", rs.getString("provisioning_status")); + mm.put("physical-interface-name", rs.getString("physical_intf_name")); + mm.put("physical-interface-speed", rs.getLong("physical_intf_speed")); + mm.put("physical-interface-speed-unit", rs.getString("physical_intf_units")); + return mm; + } + }); + return ll; + } + + public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentData.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentData.java new file mode 100644 index 00000000..d485224b --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentData.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.data; + +import java.util.Map; + +public class EquipmentData { + + public String equipmentId; + public EquipmentLevel equipmentLevel; + public Map data; +} diff --git a/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentLevel.java b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentLevel.java new file mode 100644 index 00000000..44ae593a --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/openecomp/sdnc/ra/equip/data/EquipmentLevel.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.ra.equip.data; + +public enum EquipmentLevel { + Port, Device, Server, Site +} -- cgit 1.2.3-korg