diff options
18 files changed, 362 insertions, 250 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java index 24d6ed11..b09c50d7 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java @@ -57,7 +57,7 @@ public class DownloadCsarManager { /** * Download from given URL. - * + * * @param url String * @return */ @@ -67,49 +67,53 @@ public class DownloadCsarManager { /** * Download from given URL to given file location. - * + * * @param url String * @param filepath String * @return */ public static String download(String url, String filepath) { String status = ""; - try { - CloseableHttpClient client = HttpClients.createDefault(); + try (CloseableHttpClient client = HttpClients.createDefault()){ HttpGet httpget = new HttpGet(url); CloseableHttpResponse response = client.execute(httpget); HttpEntity entity = response.getEntity(); - InputStream is = entity.getContent(); - if(filepath == null) { - filepath = getFilePath(response); // NOSONAR - } + try(InputStream is = entity.getContent()) { + if(filepath == null) { + filepath = getFilePath(response); // NOSONAR + } - File file = new File(filepath); - file.getParentFile().mkdirs(); - FileOutputStream fileout = new FileOutputStream(file); + File file = new File(filepath); + file.getParentFile().mkdirs(); + try(FileOutputStream fileout = new FileOutputStream(file)){ - byte[] buffer = new byte[CACHE]; - int ch; - while((ch = is.read(buffer)) != -1) { - fileout.write(buffer, 0, ch); + byte[] buffer = new byte[CACHE]; + int ch; + while((ch = is.read(buffer)) != -1) { + fileout.write(buffer, 0, ch); + } + fileout.flush(); + status = Constant.DOWNLOADCSAR_SUCCESS; + } catch(Exception e) { + status = Constant.DOWNLOADCSAR_FAIL; + LOG.error("Download csar file failed! " + e.getMessage(), e); + } + } catch(Exception e) { + status = Constant.DOWNLOADCSAR_FAIL; + LOG.error("Download csar file failed! " + e.getMessage(), e); } - is.close(); - fileout.flush(); - fileout.close(); - client.close(); - status = Constant.DOWNLOADCSAR_SUCCESS; - } catch(Exception e) { status = Constant.DOWNLOADCSAR_FAIL; LOG.error("Download csar file failed! " + e.getMessage(), e); } + return status; } /** * Retrieve file path from given response. - * + * * @param response HttpResponse * @return */ @@ -127,7 +131,7 @@ public class DownloadCsarManager { /** * Retrieve file name from given response. - * + * * @param response HttpResponse * @return */ @@ -152,7 +156,7 @@ public class DownloadCsarManager { /** * Provides random file name. - * + * * @return */ public static String getRandomFileName() { @@ -161,7 +165,7 @@ public class DownloadCsarManager { /** * unzip CSAR packge - * + * * @param fileName filePath * @return * @throws IOException @@ -188,17 +192,17 @@ public class DownloadCsarManager { if(parent != null && (!parent.exists())) { parent.mkdirs(); } - FileOutputStream fos = new FileOutputStream(file); - BufferedOutputStream bos = new BufferedOutputStream(fos, BUFFER); + try(FileOutputStream fos = new FileOutputStream(file)){ + try(BufferedOutputStream bos = new BufferedOutputStream(fos, BUFFER)){ - int count; - byte data[] = new byte[BUFFER]; - while((count = bis.read(data, 0, BUFFER)) != -1) { - bos.write(data, 0, count); + int count; + byte data[] = new byte[BUFFER]; + while((count = bis.read(data, 0, BUFFER)) != -1) { + bos.write(data, 0, count); + } + bos.flush(); + } } - bos.flush(); - bos.close(); - bis.close(); } status = Constant.UNZIP_SUCCESS; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgs.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgs.java index 49e9500f..73c6548b 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgs.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ExceptionArgs.java @@ -16,16 +16,23 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient; +import java.io.Serializable; + /** * ROA exception handling parameters. * <br/> * <p> * </p> - * + * * @author * @version 28-May-2016 */ -public class ExceptionArgs { +public class ExceptionArgs implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7411730460834659138L; /** * Exception descriptions. @@ -51,7 +58,7 @@ public class ExceptionArgs { * Constructor<br/> * <p> * </p> - * + * * @since */ public ExceptionArgs() { @@ -62,7 +69,7 @@ public class ExceptionArgs { * Constructor<br/> * <p> * </p> - * + * * @since * @param descArgs: descriptions. * @param reasonArgs: reasons. diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ServiceException.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ServiceException.java index af8086b7..136df51c 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ServiceException.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ServiceException.java @@ -22,7 +22,7 @@ import java.text.MessageFormat; * The base class for all common exception.<br/> * <p> * </p> - * + * * @author * @version 28-May-2016 */ @@ -43,7 +43,7 @@ public class ServiceException extends Exception { */ private String id = DEFAULT_ID; - private Object[] args = null; + private Object[] args = null; // NOSONAR private int httpCode = 500; @@ -54,7 +54,7 @@ public class ServiceException extends Exception { * <p> * This method is only used as deserialized, in other cases, use parameterized constructor. * </p> - * + * * @since */ public ServiceException() { @@ -65,7 +65,7 @@ public class ServiceException extends Exception { * Constructor<br/> * <p> * </p> - * + * * @since * @param id: details. * @param cause: reason. @@ -79,7 +79,7 @@ public class ServiceException extends Exception { * Constructor<br/> * <p> * </p> - * + * * @since * @param message: details. */ @@ -91,7 +91,7 @@ public class ServiceException extends Exception { * Constructor<br/> * <p> * </p> - * + * * @since * @param id: exception id. * @param message: details. @@ -105,7 +105,7 @@ public class ServiceException extends Exception { * Constructor<br/> * <p> * </p> - * + * * @since * @param id: exception id. * @param httpCode: http status code. @@ -121,7 +121,7 @@ public class ServiceException extends Exception { * <p> * the exception include the httpcode and message. * </p> - * + * * @since * @param httpCode http code. * @param message details. @@ -135,7 +135,7 @@ public class ServiceException extends Exception { * Constructor<br/> * <p> * </p> - * + * * @since * @param id: exception id. * @param httpCode: http code. @@ -153,7 +153,7 @@ public class ServiceException extends Exception { * <p> * Have a placeholder exception, use args formatted message. * </p> - * + * * @since * @param id: exception id. * @param message: details. @@ -170,7 +170,7 @@ public class ServiceException extends Exception { * <p> * Have a placeholder exception, use args formatted message * </p> - * + * * @since * @param id: exception id. * @param message: details. @@ -187,7 +187,7 @@ public class ServiceException extends Exception { * Constructor<br/> * <p> * </p> - * + * * @since * @param id: exception id. * @param message: details. @@ -202,7 +202,7 @@ public class ServiceException extends Exception { * Constructor<br/> * <p> * </p> - * + * * @since * @param cause: reason. */ @@ -212,7 +212,7 @@ public class ServiceException extends Exception { /** * Get exceptoin id.<br/> - * + * * @return * @since */ @@ -237,7 +237,7 @@ public class ServiceException extends Exception { /** * Obtain the ROA exception handling framework parameters<br/> - * + * * @return exception args. * @since */ @@ -251,7 +251,7 @@ public class ServiceException extends Exception { /** * Gets the parameter information<br/> - * + * * @return parameter list. * @since */ diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java index 68bc7f9e..53e51de7 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java @@ -308,12 +308,15 @@ public class AdapterResourceManager implements IResourceManager { LOG.info("changeWorkingDirectory: " + ftpClient.changeWorkingDirectory(vnfpkg.getString(VNFD_FILE_PATH))); String vnfdPath = csarfilepath + "Artifacts/Deployment/OTHER/"; LOG.info("vnfd_file_name: " + vnfdPath + vnfpkg.getString("vnfd_file_name")); - InputStream inputStream = new FileInputStream(new File(vnfdPath + vnfpkg.getString("vnfd_file_name"))); - flag = ftpClient.storeFile(vnfpkg.getString("vnfd_file_name"), inputStream); - if(flag) { - resJson.put("message", "upload Csar success!"); + try(InputStream inputStream = new FileInputStream(new File(vnfdPath + vnfpkg.getString("vnfd_file_name")))){ + flag = ftpClient.storeFile(vnfpkg.getString("vnfd_file_name"), inputStream); + if(flag) { + resJson.put("message", "upload Csar success!"); + } + } catch(Exception e) { + LOG.error("Exception: " + e); } - inputStream.close(); + ftpClient.logout(); } catch(Exception e) { LOG.error("Exception: " + e); @@ -607,33 +610,23 @@ public class AdapterResourceManager implements IResourceManager { * @since VFC 1.0 */ public static String readVfnPkgInfoFromJson() throws IOException { - InputStream ins = null; - BufferedInputStream bins = null; String fileContent = ""; String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR) + "vnfpkginfo" + System.getProperty(Constant.FILE_SEPARATOR) + Constant.VNFPKGINFO; - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); + try (InputStream ins = new FileInputStream(fileName)) { + try(BufferedInputStream bins = new BufferedInputStream(ins)){ + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); - byte[] contentByte = new byte[ins.available()]; - int num = bins.read(contentByte); - - if(num > 0) { - fileContent = new String(contentByte); + if(num > 0) { + fileContent = new String(contentByte); + } } } catch(FileNotFoundException e) { LOG.error(fileName + "is not found!", e); - } finally { - if(ins != null) { - ins.close(); - } - if(bins != null) { - bins.close(); - } } return fileContent; @@ -641,35 +634,28 @@ public class AdapterResourceManager implements IResourceManager { private static JSONObject readVnfdIdInfoFromJson() { JSONObject jsonObject = new JSONObject(); - InputStream ins = null; - BufferedInputStream bins = null; + String fileContent = ""; String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR) + "vnfpkginfo" + System.getProperty(Constant.FILE_SEPARATOR) + "vnfd_ids.json"; - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); - - byte[] contentByte = new byte[ins.available()]; - int num = bins.read(contentByte); + try (InputStream ins = new FileInputStream(fileName)) { + try (BufferedInputStream bins = new BufferedInputStream(ins)){ + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); - if(num > 0) { - fileContent = new String(contentByte); - } - if(fileContent != null) { - jsonObject = JSONObject.fromObject(fileContent).getJSONObject("vnfdIds"); + if(num > 0) { + fileContent = new String(contentByte); + } + if(fileContent != null) { + jsonObject = JSONObject.fromObject(fileContent).getJSONObject("vnfdIds"); + } } - ins.close(); - bins.close(); } catch(Exception e) { LOG.error(fileName + " read error!", e); - } finally { - } - return jsonObject; } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java index fb5e5b81..b3ba1760 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java @@ -40,7 +40,7 @@ import net.sf.json.JSONObject; * <br> * <p> * </p> - * + * * @author * @version VFC 1.0 Jan 23, 2017 */ @@ -77,38 +77,33 @@ public class VnfmAdapter2DriverMgrService implements IVnfmAdapter2DriverMgrServi /** * Retrieve VIM driver information. - * + * * @return * @throws IOException */ public static String readVnfmAdapterInfoFromJson() throws IOException { - InputStream ins = null; - BufferedInputStream bins = null; - String fileContent = ""; - String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR) + "adapterInfo" + System.getProperty(Constant.FILE_SEPARATOR) + VNFMADAPTER2DRIVERMGR; - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); + return readJson(fileName); + } + + public static String readJson(String fileName) throws IOException { + String fileContent = ""; + + try (InputStream ins = new FileInputStream(fileName)){ + try(BufferedInputStream bins = new BufferedInputStream(ins)){ - byte[] contentByte = new byte[ins.available()]; - int num = bins.read(contentByte); + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); - if(num > 0) { - fileContent = new String(contentByte); + if(num > 0) { + fileContent = new String(contentByte); + } } } catch(FileNotFoundException e) { LOG.error(fileName + "is not found!", e); - } finally { - if(ins != null) { - ins.close(); - } - if(bins != null) { - bins.close(); - } } return fileContent; @@ -116,9 +111,6 @@ public class VnfmAdapter2DriverMgrService implements IVnfmAdapter2DriverMgrServi private static class RegisterVnfm2DriverMgrThread implements Runnable { - // Thread lock Object - private final Object lockObject = new Object(); - private IVnfmAdapter2DriverManager adapter2DriverMgr = new VnfmAdapter2DriverManager(); // url and mothedtype @@ -162,11 +154,11 @@ public class VnfmAdapter2DriverMgrService implements IVnfmAdapter2DriverMgrServi // if registration fails,wait one minute and try again try { - synchronized(lockObject) { - lockObject.wait(Constant.REPEAT_REG_TIME); - } + Thread.sleep(Constant.REPEAT_REG_TIME); } catch(InterruptedException e) { LOG.error(e.getMessage(), e); + // Restore interrupted state... + Thread.currentThread().interrupt(); } sendRequest(this.paramsMap, this.adapterInfo); diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java index 3afdafeb..8df2c796 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java @@ -76,47 +76,41 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService { /** * Retrieve VIM driver information. - * + * * @return * @throws IOException */ public String readVnfmAdapterInfoFromJson() throws IOException { - InputStream ins = null; - BufferedInputStream bins = null; - String fileContent = ""; - String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR) + "adapterInfo" + System.getProperty(Constant.FILE_SEPARATOR) + VNFMADAPTERINFO; - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); - byte[] contentByte = new byte[ins.available()]; - int num = bins.read(contentByte); + return readJson(fileName); + } + + public static String readJson(String fileName) throws IOException { + String fileContent = ""; + + try (InputStream ins = new FileInputStream(fileName)){ + try(BufferedInputStream bins = new BufferedInputStream(ins)){ - if(num > 0) { - fileContent = new String(contentByte); + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); + + if(num > 0) { + fileContent = new String(contentByte); + } } } catch(FileNotFoundException e) { LOG.error(fileName + "is not found!", e); - } finally { - if(ins != null) { - ins.close(); - } - if(bins != null) { - bins.close(); - } } return fileContent; } - private static class RegisterVnfmAdapterThread implements Runnable { - // Thread lock Object - private final Object lockObject = new Object(); + private static class RegisterVnfmAdapterThread implements Runnable { private IDriver2MSBManager adapter2MSBMgr = new Driver2MSBManager(); @@ -161,11 +155,11 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService { // if registration fails,wait one minute and try again try { - synchronized(lockObject) { - lockObject.wait(Constant.REPEAT_REG_TIME); - } + Thread.sleep(Constant.REPEAT_REG_TIME); } catch(InterruptedException e) { LOG.error(e.getMessage(), e); + // Restore interrupted state... + Thread.currentThread().interrupt(); } sendRequest(this.paramsMap, this.adapterInfo); diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java index 3b1036e2..d26f849d 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java @@ -152,11 +152,11 @@ public class Constant { public static final String FILE_SEPARATOR = "file.separator"; - public static final String PASSWORD = "password"; + public static final String PASSWORD = "password"; // NOSONAR public static final String USERNAME = "userName"; - public static final String LOCAL_HOST = "127.0.0.1"; + public static final String LOCAL_HOST = "127.0.0.1"; // NOSONAR private Constant() { // private constructor diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java index 61c1f8fa..bccf4815 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/AbstractSslContext.java @@ -82,7 +82,7 @@ public class AbstractSslContext { KeyManager[] kms = null; try { String CERT_STORE = "etc/conf/server.p12"; - String CERT_STORE_PASSWORD = "Changeme_123"; + String CERT_STORE_PASSWORD = "Changeme_123"; // NOSONAR String KEY_STORE_TYPE = "PKCS12"; if(sslConf != null) { CERT_STORE = sslConf.getString("keyStore"); @@ -90,17 +90,17 @@ public class AbstractSslContext { KEY_STORE_TYPE = sslConf.getString("keyStoreType"); } // load jks file - FileInputStream f_certStore = new FileInputStream(CERT_STORE); - KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE); - ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray()); - f_certStore.close(); + try(FileInputStream f_certStore = new FileInputStream(CERT_STORE)) { + KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE); + ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray()); - // init and create - String alg = KeyManagerFactory.getDefaultAlgorithm(); - KeyManagerFactory kmFact = KeyManagerFactory.getInstance(alg); - kmFact.init(ks, CERT_STORE_PASSWORD.toCharArray()); + // init and create + String alg = KeyManagerFactory.getDefaultAlgorithm(); + KeyManagerFactory kmFact = KeyManagerFactory.getInstance(alg); + kmFact.init(ks, CERT_STORE_PASSWORD.toCharArray()); - kms = kmFact.getKeyManagers(); + kms = kmFact.getKeyManagers(); + } } catch(Exception e) { LOG.error("create KeyManager fail!", e); } @@ -112,23 +112,22 @@ public class AbstractSslContext { try { String TRUST_STORE = "etc/conf/trust.jks"; - String TRUST_STORE_PASSWORD = "Changeme_123"; + String TRUST_STORE_PASSWORD = "Changeme_123"; // NOSONAR String TRUST_STORE_TYPE = "jks"; if(sslConf != null) { TRUST_STORE = sslConf.getString("trustStore"); TRUST_STORE_PASSWORD = sslConf.getString("trustStorePass"); TRUST_STORE_TYPE = sslConf.getString("trustStoreType"); } - FileInputStream f_trustStore = new FileInputStream(TRUST_STORE); - KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE); - ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray()); - f_trustStore.close(); - - String alg = TrustManagerFactory.getDefaultAlgorithm(); - TrustManagerFactory tmFact = TrustManagerFactory.getInstance(alg); - tmFact.init(ks); - tms = tmFact.getTrustManagers(); - + try(FileInputStream f_trustStore = new FileInputStream(TRUST_STORE)) { + KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE); + ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray()); + + String alg = TrustManagerFactory.getDefaultAlgorithm(); + TrustManagerFactory tmFact = TrustManagerFactory.getInstance(alg); + tmFact.init(ks); + tms = tmFact.getTrustManagers(); + } } catch(Exception e) { LOG.error("create TrustManager fail!", e); } @@ -137,43 +136,35 @@ public class AbstractSslContext { /** * readSSLConfToJson - * + * * @return * @throws IOException * @since VFC 1.0 */ public static JSONObject readSSLConfToJson() throws IOException { JSONObject sslJson = null; - InputStream ins = null; - BufferedInputStream bins = null; + String fileContent = ""; String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR) + "conf" + System.getProperty(Constant.FILE_SEPARATOR) + "sslconf.json"; - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); + try (InputStream ins = new FileInputStream(fileName)) { + try(BufferedInputStream bins = new BufferedInputStream(ins)) { - byte[] contentByte = new byte[ins.available()]; - int num = bins.read(contentByte); + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); - if(num > 0) { - fileContent = new String(contentByte); + if(num > 0) { + fileContent = new String(contentByte); + } + sslJson = JSONObject.fromObject(fileContent); } - sslJson = JSONObject.fromObject(fileContent); } catch(FileNotFoundException e) { LOG.error(fileName + "is not found!", e); } catch(Exception e) { - LOG.error("read sslconf file fail.please check if the 'sslconf.json' is exist."); - } finally { - if(ins != null) { - ins.close(); - } - if(bins != null) { - bins.close(); - } + LOG.error("read sslconf file fail.please check if the 'sslconf.json' is exist.", e); } return sslJson; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java index f31d5a5d..858df17d 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/VnfResourceMgr.java @@ -110,7 +110,7 @@ public class VnfResourceMgr { RestfulResponse rsp = VnfmRestfulUtil.getRemoteResponse(ParamConstants.GRANT_RES_URL, VnfmRestfulUtil.TYPE_PUT, grantParam.toString()); if(rsp == null || rsp.getStatus() != Constant.HTTP_OK) { - return null; + return new JSONObject(); } LOG.error("funtion=sendGrantToResmgr, status={}", rsp.getStatus()); return JSONObject.fromObject(rsp.getResponseContent()); diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtilTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtilTest.java index 0dc6751b..3e93f2c2 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtilTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtilTest.java @@ -16,10 +16,9 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; import org.junit.Test; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.ResultRequestUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.ConnectMgrVnfm; import mockit.Mock; @@ -29,14 +28,15 @@ import net.sf.json.JSONObject; public class ResultRequestUtilTest { @Test - public void callTestInternalError(){ - new MockUp<ConnectMgrVnfm>(){ + public void callTestInternalError() { + new MockUp<ConnectMgrVnfm>() { + @Mock public int connect(JSONObject vnfmObj) { return 500; } }; - JSONObject vnfmObject = new JSONObject();; + JSONObject vnfmObject = new JSONObject(); String path = "http://localhost:8080"; String methodName = "get"; String paramsJson = ""; @@ -45,8 +45,9 @@ public class ResultRequestUtilTest { } @Test - public void callTestConnectionErrot(){ - new MockUp<ConnectMgrVnfm>(){ + public void callTestConnectionErrot() { + new MockUp<ConnectMgrVnfm>() { + @Mock public int connect(JSONObject vnfmObj) { return 200; @@ -61,4 +62,34 @@ public class ResultRequestUtilTest { assertTrue(resp.get("data").equals("get connection error")); } + @Test + public void callTest() { + new MockUp<ConnectMgrVnfm>() { + + @Mock + public int connect(JSONObject vnfmObj) { + return 200; + } + + @Mock + public String getRoaRand() { + return "1234"; + } + + @Mock + public String getAccessSession() { + return "1234"; + } + + }; + + JSONObject vnfmObject = new JSONObject(); + vnfmObject.put("url", "/test/123"); + String path = "https://localhost:8080/%s"; + String methodName = "get"; + String paramsJson = ""; + JSONObject resp = ResultRequestUtil.call(vnfmObject, path, methodName, paramsJson); + assertTrue(resp.get("data").equals("get connection error")); + } + } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java index 12910c8e..d61c3b1c 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java @@ -16,12 +16,15 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.ai.internalsvc.impl; -import mockit.Mock; -import mockit.MockUp; +import java.io.File; +import java.io.IOException; + import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.api.internalsvc.impl.VnfmAdapter2DriverMgrService; -import java.io.IOException; +import junit.framework.Assert; +import mockit.Mock; +import mockit.MockUp; /** * Created by QuanZhong on 2017/3/20. @@ -48,4 +51,17 @@ public class VnfmAdapter2DriverMgrServiceTest { mgr.register(); mgr.unregister(); } + + @Test + public void testReadJson() { + File file = new File("./demo.json"); + try { + file.createNewFile(); + String content = VnfmAdapter2DriverMgrService.readJson("./demo.json"); + Assert.assertEquals(content, ""); + file.delete(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java index 84a7c914..56e1eea3 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java @@ -16,14 +16,15 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.ai.internalsvc.impl; -import mockit.Mock; -import mockit.MockUp; -import net.sf.json.JSONObject; +import java.io.File; +import java.io.IOException; + import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.api.internalsvc.impl.VnfmAdapterMgrService; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfMgr; -import java.io.IOException; +import junit.framework.Assert; +import mockit.Mock; +import mockit.MockUp; /** * Created by QuanZhong on 2017/3/20. @@ -42,4 +43,18 @@ public class VnfmAdapterMgrServiceTest { mgr.register(); } + + + @Test + public void testReadJson() { + File file = new File("./demo.json"); + try { + file.createNewFile(); + String content = VnfmAdapterMgrService.readJson("./demo.json"); + Assert.assertEquals(content, ""); + file.delete(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java index b82c26af..8012b5cb 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/VnfRoaTest.java @@ -26,6 +26,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmJsonUtil; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfMgr; @@ -577,4 +578,58 @@ public class VnfRoaTest { } + @Test + public void testGetVnfmById() throws ServiceException { + new MockUp<VnfmUtil>() { + + @Mock + public JSONObject getVnfmById(String vnfmId) { + JSONObject json = new JSONObject(); + json.put("vnfm", "1234"); + return json; + } + }; + String result = vnfRoa.getVnfmById("1234", null); + assertNotNull(result); + } + + @Test + public void testGetJobFromVnfm() throws ServiceException { + new MockUp<VnfMgr>() { + + @Mock + public JSONObject getJobFromVnfm(String jobId, String vnfmId) { + JSONObject json = new JSONObject(); + json.put("retCode", "1"); + return json; + } + + @Mock + public String transferToLcm(JSONObject restJson) { + return "success"; + } + }; + String result = vnfRoa.getJobFromVnfm("jobId", "vnfmId", null, "responseId"); + assertNotNull(result); + } + + @Test + public void testGetJobFromVnfmFail() throws ServiceException { + + new MockUp<VnfMgr>() { + + @Mock + public JSONObject getJobFromVnfm(String jobId, String vnfmId) { + JSONObject json = new JSONObject(); + json.put("retCode", "-1"); + return json; + } + + }; + MockUp<HttpServletResponse> proxyResStub = new MockUp<HttpServletResponse>() {}; + HttpServletResponse mockResInstance = proxyResStub.getMockInstance(); + String result = vnfRoa.getJobFromVnfm("jobId", "vnfmId", mockResInstance, "responseId"); + assertNotNull(result); + } + } diff --git a/zte/vmanager/driver/interfaces/serializers.py b/zte/vmanager/driver/interfaces/serializers.py index a19613ca..c9206579 100644 --- a/zte/vmanager/driver/interfaces/serializers.py +++ b/zte/vmanager/driver/interfaces/serializers.py @@ -97,6 +97,20 @@ class TerminateVnfRequestSerializer(serializers.Serializer): required=False) +class VnfInfoSerializer(serializers.Serializer): + vnfStatus = serializers.CharField( + help_text="vnfStatus", + required=True, + max_length=255, + allow_null=True) + + +class QueryVnfResponseSerializer(serializers.Serializer): + vnfInfo = VnfInfoSerializer( + help_text="vnfInfo", + required=True) + + class JobHistorySerializer(serializers.Serializer): status = serializers.CharField( help_text="Status of job", diff --git a/zte/vmanager/driver/interfaces/urls.py b/zte/vmanager/driver/interfaces/urls.py index 182b7478..e32e53ea 100644 --- a/zte/vmanager/driver/interfaces/urls.py +++ b/zte/vmanager/driver/interfaces/urls.py @@ -21,7 +21,7 @@ urlpatterns = [ url(r'^api/ztevnfmdriver/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/terminate$', views.TerminateVnf.as_view(), name='terminate_vnf'), url(r'^api/ztevnfmdriver/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)$', - views.query_vnf, name='query_vnf'), + views.QueryVnf.as_view(), name='query_vnf'), url(r'^api/ztevnfmdriver/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/jobs/(?P<jobid>[0-9a-zA-Z\-\_]+)$', views.JobView.as_view(), name='operation_status'), url(r'^api/ztevnfmdriver/v1/resource/grant$', views.GrantVnf.as_view(), name='grantvnf'), @@ -30,5 +30,5 @@ urlpatterns = [ views.Scale.as_view(), name='scale'), url(r'^api/ztevnfmdriver/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/heal$', views.Heal.as_view(), name='heal'), - url(r'^samples/$', views.samples, name='samples') + url(r'^samples/$', views.SampleList.as_view(), name='samples') ] diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index 1a1976ed..5a978c63 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -21,13 +21,12 @@ import traceback from drf_yasg import openapi from drf_yasg.utils import swagger_auto_schema from rest_framework import status -from rest_framework.decorators import api_view from rest_framework.response import Response from rest_framework.views import APIView from driver.interfaces.serializers import HealReqSerializer, InstScaleHealRespSerializer, ScaleReqSerializer, \ NotifyReqSerializer, GrantRespSerializer, GrantReqSerializer, JobQueryRespSerializer, TerminateVnfRequestSerializer, \ - InstantiateVnfRequestSerializer + InstantiateVnfRequestSerializer, QueryVnfResponseSerializer from driver.pub.config.config import VNF_FTP from driver.pub.utils import restcall from driver.pub.utils.restcall import req_by_msb @@ -60,14 +59,6 @@ def ignorcase_get(args, key): return "" -def mapping_conv(keyword_map, rest_return): - resp_data = {} - for param in keyword_map: - if keyword_map[param]: - resp_data[keyword_map[param]] = ignorcase_get(rest_return, param) - return resp_data - - # Query vnfm_info from nslcm def get_vnfminfo_from_nslcm(vnfmid): ret = req_by_msb("api/nslcm/v1/vnfms/%s" % vnfmid, "GET") @@ -143,11 +134,11 @@ class InstamtiateVnf(APIView): data["VNFURL"] = data["VNFD"] - for name, value in ignorcase_get(ignorcase_get(instantiateVnfRequestSerializer.data, "additionalParam"), "inputs").items(): + additionalParam = ignorcase_get(instantiateVnfRequestSerializer.data, "additionalParam") + for name, value in ignorcase_get(additionalParam, "inputs").items(): inputs.append({"name": name, "value": value}) data["extension"]["inputs"] = json.dumps(inputs) - additionalParam = ignorcase_get(instantiateVnfRequestSerializer.data, "additionalParam") data["extension"]["extVirtualLinks"] = ignorcase_get(additionalParam, "extVirtualLinks") data["extension"]["vnfinstancename"] = ignorcase_get(instantiateVnfRequestSerializer.data, "vnfInstanceName") data["extension"]["vnfid"] = data["VNFD"] @@ -177,6 +168,7 @@ class InstamtiateVnf(APIView): if not instRespSerializer.is_valid(): raise Exception(instRespSerializer.errors) + logger.debug("[%s] instRespSerializer.data=%s", fun_name(), instRespSerializer.data) return Response(data=instRespSerializer.data, status=status.HTTP_200_OK) except Exception as e: logger.error("Error occurred when instantiating VNF,error:%s", e.message) @@ -232,34 +224,45 @@ class TerminateVnf(APIView): return Response(data={'error': 'TerminateVnf expection'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) -@api_view(http_method_names=['GET']) -def query_vnf(request, *args, **kwargs): - try: - logger.debug("[%s] request.data=%s", fun_name(), request.data) - vnfm_id = ignorcase_get(kwargs, "vnfmid") - ret = get_vnfminfo_from_nslcm(vnfm_id) - if ret[0] != 0: - return Response(data={'error': ret[1]}, status=ret[2]) - vnfm_info = json.JSONDecoder().decode(ret[1]) - logger.debug("[%s] vnfm_info=%s", fun_name(), vnfm_info) - ret = restcall.call_req( - base_url=ignorcase_get(vnfm_info, "url"), - user=ignorcase_get(vnfm_info, "userName"), - passwd=ignorcase_get(vnfm_info, "password"), - auth_type=restcall.rest_no_auth, - resource="v1/vnfs/%s" % (ignorcase_get(kwargs, "vnfInstanceID")), - method='get', - content=json.JSONEncoder().encode({})) - if ret[0] != 0: - return Response(data={'error': ret[1]}, status=ret[2]) - resp = json.JSONDecoder().decode(ret[1]) - vnf_status = ignorcase_get(resp, "vnfinstancestatus") - resp_data = {"vnfInfo": {"vnfStatus": vnf_status}} - logger.debug("[%s]resp_data=%s", fun_name(), resp_data) - except Exception as e: - logger.error("Error occurred when querying VNF information.") - raise e - return Response(data=resp_data, status=ret[2]) +class QueryVnf(APIView): + @swagger_auto_schema( + responses={ + status.HTTP_200_OK: QueryVnfResponseSerializer(), + status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + } + ) + def get(self, request, vnfmid, vnfInstanceId): + try: + logger.debug("[%s] request.data=%s", fun_name(), request.data) + ret = get_vnfminfo_from_nslcm(vnfmid) + if ret[0] != 0: + raise Exception(ret[1]) + + vnfm_info = json.JSONDecoder().decode(ret[1]) + logger.debug("[%s] vnfm_info=%s", fun_name(), vnfm_info) + ret = restcall.call_req( + base_url=ignorcase_get(vnfm_info, "url"), + user=ignorcase_get(vnfm_info, "userName"), + passwd=ignorcase_get(vnfm_info, "password"), + auth_type=restcall.rest_no_auth, + resource="v1/vnfs/%s" % vnfInstanceId, + method='get', + content=json.JSONEncoder().encode({})) + if ret[0] != 0: + raise Exception(ret[1]) + + resp = json.JSONDecoder().decode(ret[1]) + vnf_status = ignorcase_get(resp, "vnfinstancestatus") + resp_data = {"vnfInfo": {"vnfStatus": vnf_status}} + logger.debug("[%s]resp_data=%s", fun_name(), resp_data) + queryVnfResponseSerializer = QueryVnfResponseSerializer(data=resp_data) + if not queryVnfResponseSerializer.is_valid(): + raise Exception(queryVnfResponseSerializer.errors) + return Response(data=queryVnfResponseSerializer.data, status=status.HTTP_200_OK) + except Exception as e: + logger.error("Error occurred when querying VNF information,error:%s", e.message) + logger.error(traceback.format_exc()) + return Response(data={'error': 'QueryVnf expection'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) class JobView(APIView): @@ -608,6 +611,10 @@ def get_vdus(nf_model, aspect_id): return members -@api_view(http_method_names=['GET']) -def samples(request, *args, **kwargs): - return Response(data={"status": "ok"}) +class SampleList(APIView): + @swagger_auto_schema( + responses={ + status.HTTP_200_OK: 'Successfully'}) + def get(self, request): + logger.debug("get") + return Response({"status": "active"}) diff --git a/zte/vmanager/pom.xml b/zte/vmanager/pom.xml index fd8ed693..e0f4d635 100644 --- a/zte/vmanager/pom.xml +++ b/zte/vmanager/pom.xml @@ -25,7 +25,7 @@ <artifactId>vfc-nfvo-driver-vnfm-svnfm-zte-vmanager</artifactId> <version>1.1.0-SNAPSHOT</version> <packaging>pom</packaging> - <name>vfc/nfvo/driver/vnfm/svnfm/zte/vmanager</name> + <name>vfc-nfvo-driver-vnfm-svnfm-zte</name> <description>vfc nfvo driver-vnfm-svnfm-zte-vmanager</description> <build> <plugins> diff --git a/zte/vmanager/tox.ini b/zte/vmanager/tox.ini index 2d18a624..3bbe6c8a 100644 --- a/zte/vmanager/tox.ini +++ b/zte/vmanager/tox.ini @@ -19,4 +19,4 @@ commands = {[testenv]commands} [testenv:cov] -commands = coverage html --omit="*test_*,*__init__.py,*site-packages*" -d htmlcov
\ No newline at end of file +commands = coverage html --omit="*test*,*__init__.py,*site-packages*" -d htmlcov
\ No newline at end of file |