#Environments
ENV OPEN_CLI_HOME /opt/onap/cli
-ENV ONAP_CLI_DEBUG false
-ENV ONAP_CLI_DEBUG_PORT 5005
-ENV CLI_MODE console
-ENV CLI_PRODUCT_VERSION onap-1.1
+ENV OPEN_CLI_DEBUG false
+ENV OPEN_CLI_DEBUG_PORT 5005
+ENV OPEN_CLI_MODE console
+ENV OPEN_CLI_PRODUCT_VERSION open-cli
ENV HOST_URL http://localhost:8080
-ENV ONAP_USERNAME guest
-ENV ONAP_PASSWORD guest
+ENV OPEN_USERNAME guest
+ENV OPEN_PASSWORD guest
#Copy CLI into docker
ADD ./STAGE $OPEN_CLI_HOME
EXPOSE 8080
#Start
-ENTRYPOINT if [ "$CLI_MODE" = "daemon" ]; then service lighttpd start; gotty --permit-write --reconnect onap; else onap -v && /bin/bash; fi
+ENTRYPOINT if [ "$OPEN_CLI_MODE" = "daemon" ]; then service lighttpd start; gotty --permit-write --reconnect onap; else onap -v && /bin/bash; fi
#Cleanup
RUN apt-get purge -y pandoc && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/go /tmp/gotty /tmp/* /var/tmp/*
-RUN echo ONAP CLI docker successfully created !!
\ No newline at end of file
+RUN echo ONAP CLI docker successfully created !!
occ:
image: onap/cli
environment:
- CLI_MODE: 'daemon'
+ OPEN_CLI_MODE: 'daemon'
expose:
- 80
- 8080
tty: true
image: onap/cli
environment:
- CLI_MODE: 'console'
+ OPEN_CLI_MODE: 'console'
debug:
stdin_open: true
tty: true
image: onap/cli
environment:
- CLI_MODE: 'console'
- ONAP_CLI_DEBUG: "true"
+ OPEN_CLI_MODE: 'console'
+ OPEN_CLI_DEBUG: "true"
expose:
- 5005
ports:
<!DOCTYPE html><html><head><link rel="icon" href="./open-cli.png">
<meta charset="utf-8"><title>ONAP CLI</title><style></style></head><body id="preview">
-<h1><a id="ONAP_Commandline_interface_CLI_0"></a>ONAP Command-line interface (CLI)</h1>
+<h1><a id="OPEN_Commandline_interface_CLI_0"></a>ONAP Command-line interface (CLI)</h1>
<p style="color:blue"><strong>One Command to command whole Onap !!</strong></p>
<p>Provides unified commands to operate ONAP from Linux console and Web console.</p>
<h2><a id="To_Run_in_Interactive_mode_16"></a>To Run in Interactive mode</h2>
<p>Type <strong>onap</strong> from linux console</p>
-
+<h2><a id="Set_the_product_version_20"></a>Set the product version</h2>
+<p>CLI framework is enhanced to handle multiple product versions at same<br>
+time. so to choose the product version, set evironment variable<br>
+<strong>CLI_PROUDCT_VERSION</strong>.</p>
+<p>NOTE: In interactive mode, product version can be selected using<br>
+typing <strong>use <product-version></strong></p>
+<p>Run <em>onap [-v|–version]</em> to see the CLI and available product version details</p>
+<h2><a id="Help_31"></a>Help</h2>
+<p><em>onap [-h|–help]</em><br>
+<em>onap <command> [-h|–help]</em></p>
+<h2><a id="Debug_Mode_36"></a>Debug Mode</h2>
+<p>To run in debug mode, set following environment variables:</p>
+<ol>
+<li>OPEN_CLI_DEBUG - By default its false, otherwise Set to true</li>
+<li>OPEN_CLI_DEBUG_PORT - By default it is 5005, otherwise set to new TCP port number</li>
+</ol>
<h2><a id="More_details_42"></a>More details</h2>
<p><a href="https://wiki.onap.org">https://wiki.onap.org</a></p>
fileset(dir:
"${project.build.directory}/../../../plugins/target/lib/")
}
-
ant.copy(todir:
"${deployUnzip}/conf") {
fileset(file:
CLASSPATH=$CLASSPATH:$entry
done
-if [ "$ONAP_CLI_DEBUG" = "true" ]
+if [ "$OPEN_CLI_DEBUG" = "true" ]
then
- java -Xdebug -Xrunjdwp:transport=dt_socket,address=${ONAP_CLI_DEBUG_PORT:-5005},server=y -classpath $CLASSPATH -DONAP_CLI_HOME=$ONAP_CLI_HOME org.onap.cli.main.OnapCli "$@"
+ java -Xdebug -Xrunjdwp:transport=dt_socket,address=${OPEN_CLI_DEBUG_PORT:-5005},server=y -classpath $CLASSPATH -DOPEN_CLI_HOME=$OPEN_CLI_HOME org.onap.cli.main.OnapCli "$@"
else
- java -classpath $CLASSPATH -DONAP_CLI_HOME=$ONAP_CLI_HOME org.onap.cli.main.OnapCli "$@"
+ java -classpath $CLASSPATH -DOPEN_CLI_HOME=$OPEN_CLI_HOME org.onap.cli.main.OnapCli "$@"
fi
private String cmdSchemaName;
- private OnapCommandInfo info;
-
- private String productVersion;
-
- private OnapService onapService = new OnapService();
+ private OnapCommandInfo info = new OnapCommandInfo();
private List<OnapCommandParameter> cmdParameters = new ArrayList<>();
protected boolean isInitialzied = false;
- protected CommandType type = CommandType.CMD;
-
public String getSchemaVersion() {
return Constants.OPEN_CLI_SCHEMA_VERSION_VALUE;
}
this.info = info;
}
- public boolean isCommandInternal() {
- return onapService.getName() != null
- && onapService.getName().equalsIgnoreCase(OnapCommandConfg.getInternalCmd())
- && this.type.equals(CommandType.CMD);
- }
-
- /*
- * Onap service, this command uses to execute it. , defined by derived command
- */
- public OnapService getService() {
- return this.onapService;
- }
-
- public void setService(OnapService service) {
- this.onapService = service;
- }
-
public void setParameters(List<OnapCommandParameter> parameters) {
this.cmdParameters = parameters;
}
this.cmdSchemaName = schemaName;
}
- public CommandType getType() {
- return this.type;
- }
-
- public void setType(CommandType type) {
- this.type = type;
- }
-
/**
* Initialize this command from command schema.
*
*/
protected void validate() throws OnapCommandException {
for (OnapCommandParameter param : this.getParameters()) {
- try {
- param.validate();
- } catch (OnapCommandParameterMissing e) {
- if (OnapCommandConfg.getExcludeParamsForNoAuthEnableExternalCmd().contains(param.getName())) {
- Optional<OnapCommandParameter> noAuthParamOpt = this.getParameters().stream().filter(p -> p.getName()
- .equalsIgnoreCase(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH)).findFirst();
-
- if (noAuthParamOpt.isPresent() && "true".equalsIgnoreCase(noAuthParamOpt.get().getValue().toString())) {
- continue;
- }
- }
- throw e;
- } catch (OnapCommandException e) {
- throw e;
- }
-
- }
+ param.validate();
+ }
}
/**
* @return version
*/
public String printVersion() {
- return this.getService().toString();
+ return this.getInfo().getService();
}
/**
public String printHelp() throws OnapCommandHelpFailed {
return OnapCommandUtils.help(this);
}
- // (mrkanag) Add toString for all command, parameter, result, etc objects in JSON format
-
- public void setVersion(String version) {
- this.productVersion = version;
- }
- public String getVersion() {
- return this.productVersion;
- }
+ // (mrkanag) Add toString for all command, parameter, result, etc objects in JSON format
}
import org.onap.cli.fw.error.OnapCommandNotFound;
import org.onap.cli.fw.error.OnapCommandProductVersionInvalid;
import org.onap.cli.fw.error.OnapCommandRegistrationFailed;
-import org.onap.cli.fw.error.OnapCommandRegistrationVersionMissing;
+import org.onap.cli.fw.error.OnapCommandRegistrationProductInfoMissing;
import org.onap.cli.fw.input.cache.OnapCommandParameterCache;
import org.onap.cli.fw.output.OnapCommandResult;
import org.onap.cli.fw.output.OnapCommandResultAttribute;
public class OnapCommandRegistrar {
private Map<String, Class<? extends OnapCommand>> registry = new HashMap<>();
- private Map<String, String> authCmds = new HashMap<>();
-
private Set<String> availableProductVersions = new HashSet<>();
private String enabledProductVersion = OnapCommandConfg.getEnabledProductVersion();
* Command Class
* @throws OnapCommandInvalidRegistration
* Invalid registration exception
- * @throws OnapCommandRegistrationVersionMissing
+ * @throws OnapCommandRegistrationProductInfoMissing
*/
- public void register(String name, String version, Class<? extends OnapCommand> cmd) throws OnapCommandInvalidRegistration, OnapCommandRegistrationVersionMissing {
+ public void register(String name, String version, Class<? extends OnapCommand> cmd) throws OnapCommandInvalidRegistration, OnapCommandRegistrationProductInfoMissing {
if (version == null || version.isEmpty()) {
- throw new OnapCommandRegistrationVersionMissing(name);
+ throw new OnapCommandRegistrationProductInfoMissing(name);
}
this.registry.put(name + ":" + version, cmd);
return cmd;
}
- private void autoDiscover() throws OnapCommandInvalidRegistration, OnapCommandRegistrationVersionMissing {
+ private void autoDiscover() throws OnapCommandInvalidRegistration, OnapCommandRegistrationProductInfoMissing {
List<Class<OnapCommand>> cmds = OnapCommandUtils.findOnapCommands();
for (Class<OnapCommand> cmd : cmds) {
String errorNote = "";
String usageNote = "\n\nTo enable a product version, use one of following methods:"
- + "\n 1. set env variable CLI_PRODUCT_VERSION"
+ + "\n 1. set env variable OPEN_CLI_PRODUCT_VERSION"
+ "\n 2. set cli.product.version in open-cli.properties"
+ "\n 3. in interactive mode, use the directive 'use <product version>'\n";
OnapCommand login = this.findAuthCommand("login");
OnapCommandUtils.copyParamsFrom(this.cmd, login);
- login.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue(this.getServiceUrl(login));
login.execute();
//It is safely assumed that all outputs are considered as common http headers.
return this.getServiceUrl(this.cmd);
}
- private String getServiceUrl(OnapCommand cmd) throws OnapCommandException {
+ private String getServiceUrl(OnapHttpCommand cmd) throws OnapCommandException {
if (cmd.getService().isModeDirect()){
return cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).getValue().toString();
} else { //Catalog mode
try {
//Find the auth command for the given service and version under current enabled product
auth = OnapCommandRegistrar.getRegistrar().get(
- this.cmd.getService().getName() + "-" +
- this.cmd.getService().getVersion() + "-" +
+ this.cmd.getInfo().getService() + "-" +
this.cmd.getService().getAuthType() + "-" + authAction);
} catch (OnapCommandNotFound e) {
- try {
- //Find the auth command for the given service under current enabled product
- auth = OnapCommandRegistrar.getRegistrar().get(
- this.cmd.getService().getName() + "-" +
+ //Find the auth command for current enabled product
+ auth = OnapCommandRegistrar.getRegistrar().get(
this.cmd.getService().getAuthType() + "-" + authAction);
- } catch (OnapCommandNotFound e1) {
- //Find the auth command for current enabled product
- auth = OnapCommandRegistrar.getRegistrar().get(
- this.cmd.getService().getAuthType() + "-" + authAction);
- }
}
return auth;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.auth.BasicScheme;
-import org.onap.cli.fw.OnapCommand;
import org.onap.cli.fw.OnapCommandSchema;
import org.onap.cli.fw.conf.Constants;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.input.OnapCommandParameter;
-@OnapCommandSchema(name = "basic-login", version = "cli-1.0", type = "auth", schema = "basic-login.yaml")
-public class BasicAuthLoginCommand extends OnapCommand {
+@OnapCommandSchema(name = "basic-login", version = "open-cli", type = "auth", schema = "basic-login.yaml")
+public class BasicAuthLoginCommand extends OnapHttpCommand {
@Override
protected void run() throws OnapCommandException {
Map<String, OnapCommandParameter> paramMap = getParametersMap();
OnapCommandParameter usernameParam = paramMap.get(Constants.DEAFULT_PARAMETER_USERNAME);
String username = usernameParam.getValue().toString();
- OnapCommandParameter usernamePassword = paramMap.get(Constants.DEAFULT_PARAMETER_PASS_WORD);
+ OnapCommandParameter usernamePassword = paramMap.get(Constants.DEAFULT_PARAMETER_PASSWORD);
String password = usernamePassword.getValue().toString();
//Execute the command to get token
package org.onap.cli.fw.cmd;
-import org.onap.cli.fw.OnapCommand;
import org.onap.cli.fw.OnapCommandSchema;
import org.onap.cli.fw.error.OnapCommandException;
-@OnapCommandSchema(name = "basic-logout", version = "cli-1.0", type = "auth", schema = "basic-logout.yaml")
-public class BasicAuthLogoutCommand extends OnapCommand {
+@OnapCommandSchema(name = "basic-logout", version = "open-cli", type = "auth", schema = "basic-logout.yaml")
+public class BasicAuthLogoutCommand extends OnapHttpCommand {
@Override
protected void run() throws OnapCommandException {
package org.onap.cli.fw.cmd;
-import org.onap.cli.fw.OnapCommand;
import org.onap.cli.fw.OnapCommandSchema;
import org.onap.cli.fw.error.OnapCommandException;
-@OnapCommandSchema(name = "catalog", version = "cli-1.0", type = "catalog", schema = "catalog.yaml")
-public class CatalogCommand extends OnapCommand {
+@OnapCommandSchema(name = "catalog", version = "open-cli", type = "catalog", schema = "catalog.yaml")
+public class CatalogCommand extends OnapHttpCommand {
@Override
protected void run() throws OnapCommandException {
import org.onap.cli.fw.OnapCommand;
import org.onap.cli.fw.ad.OnapAuthClient;
+import org.onap.cli.fw.ad.OnapService;
import org.onap.cli.fw.conf.Constants;
import org.onap.cli.fw.conf.OnapCommandConfg;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandFailedMocoGenerate;
import org.onap.cli.fw.http.HttpInput;
import org.onap.cli.fw.http.HttpResult;
+import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cli.fw.output.OnapCommandResultAttribute;
import org.onap.cli.fw.utils.OnapCommandUtils;
import org.onap.cli.http.mock.MockJsonGenerator;
protected OnapAuthClient authClient;
+ private OnapService onapService = new OnapService();
+
public void setInput(HttpInput input) {
this.input = input;
}
return resultMap;
}
+ /*
+ * Onap service, this command uses to execute it.
+ */
+ public OnapService getService() {
+ return this.onapService;
+ }
+
+ public void setService(OnapService service) {
+ this.onapService = service;
+ }
+
@Override
protected void initializeProfileSchema() throws OnapCommandException {
- OnapCommandUtils.loadHTTPSchemaSection(this, this.getSchemaName(), false);
+ OnapCommandUtils.loadHttpSchema(this, this.getSchemaName(), true, false);
+ }
+
+ @Override
+ protected void validate() throws OnapCommandException {
+ if (! this.isAuthRequired()) {
+ if (this.getParametersMap().containsKey(Constants.DEAFULT_PARAMETER_USERNAME)) {
+ this.getParametersMap().get(Constants.DEAFULT_PARAMETER_USERNAME).setOptional(true);
+ }
+ if (this.getParametersMap().containsKey(Constants.DEAFULT_PARAMETER_PASSWORD)) {
+ this.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASSWORD).setOptional(true);
+ }
+ }
+
+ super.validate();
+ }
+
+ private boolean isAuthRequired() {
+ return !this.getService().isNoAuth()
+ && "false".equals(this.getParametersMap().get(Constants.DEFAULT_PARAMETER_NO_AUTH).getValue())
+ && this.getInfo().getCommandType().equals(CommandType.CMD);
}
@Override
protected void run() throws OnapCommandException {
try {
- // For auth type commands, login and logout logic is not required
- boolean isAuthRequired = !this.getService().isNoAuth()
- && "false".equals(this.getParametersMap().get(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH).getValue())
- && this.getType().equals(CommandType.CMD);
-
- if (!isCommandInternal()) {
- this.authClient = new OnapAuthClient(
- this,
- this.getResult().isDebug());
- }
+ // For auth/catalog type commands, login and logout logic is not required
+ boolean isAuthRequired = this.isAuthRequired();
+
+ this.authClient = new OnapAuthClient(
+ this,
+ this.getResult().isDebug());
if (isAuthRequired) {
this.authClient.login();
* Refresh external schema.
*
*/
-@OnapCommandSchema(name = "schema-refresh", version = "cli-1.0", schema = "schema-refresh.yaml")
+@OnapCommandSchema(name = "schema-refresh", version = "open-cli", schema = "schema-refresh.yaml")
public class OnapSchemaRefreshCommand extends OnapCommand {
@Override
attribute.setValues(slNumbers);
} else if ("command".equals(attribute.getName())) {
attribute.setValues(cmdNames);
- } else if ("product-version".equals(attribute.getName())) {
+ } else if ("product".equals(attribute.getName())) {
attribute.setValues(cmdVersions);
} else if ("schema".equals(attribute.getName())) {
attribute.setValues(cmdFiles);
- } else if ("version".equals(attribute.getName())) {
+ } else if ("ocs-version".equals(attribute.getName())) {
attribute.setValues(versions);
}
}
/**
* Validate schema command.
*/
-@OnapCommandSchema(name = "schema-validate", version = "cli-1.0", schema = "schema-validate.yaml")
+@OnapCommandSchema(name = "schema-validate", version = "open-cli", schema = "schema-validate.yaml")
public class OnapSchemaValidateCommand extends OnapCommand {
@Override
}, location, true, true);
- error.addAll(OnapCommandUtils.loadHTTPSchemaSection(new OnapHttpCommand(),
- location, true));
+ error.addAll(OnapCommandUtils.loadHttpSchema(new OnapHttpCommand(),
+ location, true, true));
List<String> slNumber = new ArrayList<>();
for (int i = 1; i <= error.size(); i++) {
public static final String SSLCONTEST_TLS = "TLSV1.2";
public static final String APPLICATION_JSON = "application/json";
- public static final String SERVICE_NAME = "cli.service_name";
+ public static final String OPEN_CLI_PRODUCT_NAME = "cli.product_name";
+
//http
public static final String URI = "uri";
public static final String COMMAND_TYPE = "type";
public static final String SERVICE = "service";
public static final String PARAMETERS = "parameters";
- public static final String DEFAULT_PARAMETERS = "default_parameters";
- public static final String DEFAULT_PARAMETERS_INCLUDE = "include";
- public static final String DEFAULT_PARAMETERS_EXCLUDE = "exclude";
public static final String RESULTS = "results";
public static final String ATTRIBUTES = "attributes";
public static final String DEFAULT_PARAMETER_FILE_NAME = "default_input_parameters.yaml";
+ public static final String DEFAULT_PARAMETER_HTTP_FILE_NAME = "default_input_parameters_http.yaml";
// Common parameters used across all commands.
public static final String DEAFULT_PARAMETER_USERNAME = "host-username";
- public static final String DEAFULT_PARAMETER_PASS_WORD = "host-password";
+ public static final String DEAFULT_PARAMETER_PASSWORD = "host-password";
public static final String DEAFULT_PARAMETER_HOST_URL = "host-url";
public static final String DEFAULT_PARAMETER_HELP = "help";
public static final String DEFAULT_PARAMETER_VERSION = "version";
public static final String DEFAULT_PARAMETER_OUTPUT_FORMAT = "format";
public static final String DEFAULT_PARAMETER_OUTPUT_ATTR_LONG = "long";
public static final String DEFAULT_PARAMETER_OUTPUT_NO_TITLE = "no-title";
- public static final String DEFAULT_PARAMETER_OUTPUT_NO_AUTH = "no-auth";
+ public static final String DEFAULT_PARAMETER_NO_AUTH = "no-auth";
// Configuration properties
public static final String CONF = "open-cli.properties";
public static final String OPEN_IGNORE_AUTH = "cli.ignore_auth";
public static final String OPEN_CLI_VERSION = "cli.version";
- public static final String OPEN_CLI_PRODUCT_VERSION = "cli.product.version";
- public static final String OPEN_CLI_PRODUCT_VERSION_ENV_NAME = "CLI_PRODUCT_VERSION";
+ public static final String OPEN_OPEN_CLI_PRODUCT_VERSION_ENV_NAME = "OPEN_CLI_PRODUCT_VERSION";
public static final String HTTP_API_KEY_USE_COOKIES = "cli.http.api_key_use_cookies";
- public static final String EXCLUDE_PARAMS_INTERNAL_CMD = "cli.exclude_params_internal_cmd";
- public static final String NO_AUTH_DISABLE_INCLUDE_PARAMS_EXTERNAL_CMD = "cli.no_auth_disable_include_params_external_cmd";
- public static final String NO_AUTH_ENABLE_EXCLUDE_PARAMS_EXTERNAL_CMD = "cli.no_auth_enable_exclude_params_external_cmd";
- public static final String NO_AUTH_ENABLE_INCLUDE_PARAMS_EXTERNAL_CMD = "cli.no_auth_enable_include_params_external_cmd";
+
public static final String SERVICE_AUTH = "cli.service.auth";
public static final String SERVICE_AUTH_BASIC_HTTP_HEADERS = "cli.http.basic.common_headers";
}
public static String getEnabledProductVersion() {
- String version = System.getenv(Constants.OPEN_CLI_PRODUCT_VERSION_ENV_NAME);
+ String version = System.getenv(Constants.OPEN_OPEN_CLI_PRODUCT_VERSION_ENV_NAME);
if (version == null) {
- version = prps.getProperty(Constants.OPEN_CLI_PRODUCT_VERSION);
+ version = prps.getProperty(Constants.OPEN_CLI_PRODUCT_NAME);
}
return version;
}
return false;
}
- public static String getInternalCmd() {
- return prps.getProperty(Constants.SERVICE_NAME);
+ public static String getProductName() {
+ return prps.getProperty(Constants.OPEN_CLI_PRODUCT_NAME);
}
public static String getAuthType() {
return getHeaderValues(serviceHeader, paramMap);
}
- public static Set<String> getExcludeParamsForInternalCmd() {
- return Arrays.stream(prps.getProperty(Constants.EXCLUDE_PARAMS_INTERNAL_CMD) // NOSONAR
- .split(",")).map(String::trim).collect(Collectors.toSet());
- }
-
- public static Set<String> getIncludeParamsForNoAuthDisableExternalCmd() {
- return Arrays.stream(prps.getProperty(Constants.NO_AUTH_DISABLE_INCLUDE_PARAMS_EXTERNAL_CMD) // NOSONAR
- .split(",")).map(String::trim).collect(Collectors.toSet());
- }
-
- public static Set<String> getExcludeParamsForNoAuthEnableExternalCmd() {
- return Arrays.stream(prps.getProperty(Constants.NO_AUTH_ENABLE_EXCLUDE_PARAMS_EXTERNAL_CMD) // NOSONAR
- .split(",")).map(String::trim).collect(Collectors.toSet());
- }
-
- public static Set<String> getIncludeParamsForNoAuthEnableExternalCmd() {
- return Arrays.stream(prps.getProperty(Constants.NO_AUTH_ENABLE_INCLUDE_PARAMS_EXTERNAL_CMD) // NOSONAR
- .split(",")).map(String::trim).collect(Collectors.toSet());
- }
-
//mrkanag move this utils class
public static List<String> getSchemaAttrInfo(String key) {
return Arrays.stream(prps.getProperty(key).split(",")).map(String::trim).collect(Collectors.toList()); // NOSONAR
* Command Not registered in Onap Command Registrar as version missing.
*
*/
-public class OnapCommandRegistrationVersionMissing extends OnapCommandException {
+public class OnapCommandRegistrationProductInfoMissing extends OnapCommandException {
private static final long serialVersionUID = 5513297861129088463L;
- public OnapCommandRegistrationVersionMissing(String cmdName) {
- super("0x2003", "Command " + cmdName + " version is missing");
+ public OnapCommandRegistrationProductInfoMissing(String cmdName) {
+ super("0x2003", "Command " + cmdName + "'s product info is missing");
}
}
private String author;
- private CommandType type;
+ private CommandType type = CommandType.CMD;
public String getProduct() {
return product;
* @throws OnapCommandInvalidParameterValue
* exception
*/
+ //mrkanag return value in the type format instead of string format
public Object getValue() {
if (value != null) {
return value;
import static org.onap.cli.fw.conf.Constants.BODY;
import static org.onap.cli.fw.conf.Constants.BOOLEAN_VALUE;
import static org.onap.cli.fw.conf.Constants.CLIENT;
-import static org.onap.cli.fw.conf.Constants.COMMAND_TYPE;
import static org.onap.cli.fw.conf.Constants.COMMAND_TYPE_VALUES;
import static org.onap.cli.fw.conf.Constants.DATA_DIRECTORY;
import static org.onap.cli.fw.conf.Constants.DATA_DIRECTORY_JSON_PATTERN;
-import static org.onap.cli.fw.conf.Constants.DEAFULT_PARAMETER_HOST_URL;
-import static org.onap.cli.fw.conf.Constants.DEAFULT_PARAMETER_PASS_WORD;
+import static org.onap.cli.fw.conf.Constants.DEAFULT_PARAMETER_PASSWORD;
import static org.onap.cli.fw.conf.Constants.DEAFULT_PARAMETER_USERNAME;
-import static org.onap.cli.fw.conf.Constants.DEFAULT_PARAMETERS;
-import static org.onap.cli.fw.conf.Constants.DEFAULT_PARAMETERS_EXCLUDE;
-import static org.onap.cli.fw.conf.Constants.DEFAULT_PARAMETERS_INCLUDE;
import static org.onap.cli.fw.conf.Constants.DEFAULT_PARAMETER_FILE_NAME;
+import static org.onap.cli.fw.conf.Constants.DEFAULT_PARAMETER_HTTP_FILE_NAME;
+import static org.onap.cli.fw.conf.Constants.DEFAULT_PARAMETER_NO_AUTH;
import static org.onap.cli.fw.conf.Constants.DEFAULT_VALUE;
import static org.onap.cli.fw.conf.Constants.DESCRIPTION;
import static org.onap.cli.fw.conf.Constants.DIRECTION;
import static org.onap.cli.fw.conf.Constants.INFO_TYPE;
import static org.onap.cli.fw.conf.Constants.INPUT_PARAMS_LIST;
import static org.onap.cli.fw.conf.Constants.INPUT_PARAMS_MANDATORY_LIST;
+import static org.onap.cli.fw.conf.Constants.IS_INCLUDE;
import static org.onap.cli.fw.conf.Constants.IS_OPTIONAL;
import static org.onap.cli.fw.conf.Constants.IS_SECURED;
-import static org.onap.cli.fw.conf.Constants.IS_INCLUDE;
import static org.onap.cli.fw.conf.Constants.LONG_OPTION;
import static org.onap.cli.fw.conf.Constants.METHOD;
import static org.onap.cli.fw.conf.Constants.METHOD_TYPE;
import static org.onap.cli.fw.conf.Constants.SAMPLE_RESPONSE;
import static org.onap.cli.fw.conf.Constants.SCHEMA_FILE_NOT_EXIST;
import static org.onap.cli.fw.conf.Constants.SCHEMA_FILE_WRONG_EXTN;
-import static org.onap.cli.fw.conf.Constants.SCHEMA_INVALID_DEFAULT_PARAMS_SECTION;
import static org.onap.cli.fw.conf.Constants.SCOPE;
import static org.onap.cli.fw.conf.Constants.SERVICE;
import static org.onap.cli.fw.conf.Constants.SERVICE_PARAMS_LIST;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.onap.cli.fw.OnapCommand;
-import org.onap.cli.fw.OnapCommandRegistrar;
-import org.onap.cli.fw.ad.OnapCredentials;
import org.onap.cli.fw.ad.OnapService;
import org.onap.cli.fw.cmd.CommandType;
import org.onap.cli.fw.cmd.OnapHttpCommand;
import org.onap.cli.fw.error.OnapCommandHttpHeaderNotFound;
import org.onap.cli.fw.error.OnapCommandHttpInvalidResponseBody;
import org.onap.cli.fw.error.OnapCommandHttpInvalidResultMap;
-import org.onap.cli.fw.error.OnapCommandInvalidDefaultParameter;
import org.onap.cli.fw.error.OnapCommandInvalidParameterType;
import org.onap.cli.fw.error.OnapCommandInvalidParameterValue;
import org.onap.cli.fw.error.OnapCommandInvalidPrintDirection;
try {
Map<String, ?> defaultParameterMap = includeDefault ?
validateSchemaVersion(DEFAULT_PARAMETER_FILE_NAME, cmd.getSchemaVersion()) : new HashMap<>();
- Map<String, List<Map<String, String>>> commandYamlMap = (Map<String, List<Map<String, String>>>)validateSchemaVersion(schemaName, cmd.getSchemaVersion());
- List<String> defParams = new ArrayList<>();
+ Map<String, List<Map<String, String>>> commandYamlMap =
+ (Map<String, List<Map<String, String>>>)validateSchemaVersion(schemaName, cmd.getSchemaVersion());
if (includeDefault) {
if (commandYamlMap.get(PARAMETERS) == null) {
} else {
commandYamlMap.get(PARAMETERS).addAll((List<Map<String, String>>) defaultParameterMap.get(PARAMETERS));
}
- defParams = ((List<Map<String, String>>) defaultParameterMap.get(PARAMETERS)).stream()
- .map(p -> p.get(NAME)).collect(Collectors.toList());
}
- return parseSchema(cmd, commandYamlMap, defParams, validateSchema);
+ return parseSchema(cmd, commandYamlMap, validateSchema);
} catch (OnapCommandException e) {
throw e;
} catch (Exception e) {
}
}
- private static void processNoAuth(Set<String> parameterSet, final OnapCommand cmd, final List<String> includeParams,
- final List<String> excludeParams) throws OnapCommandInvalidDefaultParameter {
- // processing for no-auth type
- if (cmd.getService() != null) {
- List<String> includeAuthParams = new ArrayList();
- List<String> excludeAuthParams = new ArrayList<>();
- boolean noAuth = cmd.getService().isNoAuth();
- if (cmd.isCommandInternal()) {
- excludeAuthParams.addAll(OnapCommandConfg.getExcludeParamsForInternalCmd());
- } else {
- if (noAuth) {
- includeAuthParams.addAll(OnapCommandConfg.getIncludeParamsForNoAuthEnableExternalCmd());
- excludeAuthParams.addAll(OnapCommandConfg.getExcludeParamsForNoAuthEnableExternalCmd());
+ public static List<String> loadHttpSchema(OnapHttpCommand cmd, String schemaName, boolean includeDefault,
+ boolean validateSchema) throws OnapCommandException {
+ try {
+ Map<String, ?> defaultParameterMap = includeDefault ?
+ validateSchemaVersion(DEFAULT_PARAMETER_HTTP_FILE_NAME, cmd.getSchemaVersion()) : new HashMap<>();
+ Map<String, List<Map<String, String>>> commandYamlMap = (Map<String, List<Map<String, String>>>)validateSchemaVersion(schemaName, cmd.getSchemaVersion());
+
+ if (includeDefault) {
+ if (commandYamlMap.get(PARAMETERS) == null) {
+ commandYamlMap.put(PARAMETERS, (List<Map<String, String>>) defaultParameterMap.get(PARAMETERS));
} else {
- includeAuthParams.addAll(OnapCommandConfg.getIncludeParamsForNoAuthDisableExternalCmd());
+ commandYamlMap.get(PARAMETERS).addAll((List<Map<String, String>>) defaultParameterMap.get(PARAMETERS));
}
- }
-
- List<String> invalidExclude = excludeAuthParams.stream().filter(includeParams::contains)
- .collect(Collectors.toList());
+ }
+ List<String> errors = parseSchema(cmd, commandYamlMap, validateSchema);
+ errors.addAll(parseHttpSchema(cmd, commandYamlMap, validateSchema));
+ return errors;
- List<String> invalidInclude = includeAuthParams.stream().filter(excludeParams::contains)
- .filter(p->!includeParams.contains(p)).collect(Collectors.toList());
-
- if (!invalidExclude.isEmpty() || !invalidInclude.isEmpty()) {
- throw new OnapCommandInvalidDefaultParameter(Stream.concat(invalidExclude.stream(), invalidInclude.stream())
- .collect(Collectors.toList()));
- }
-
-
- parameterSet.addAll(includeAuthParams);
- parameterSet.removeAll(excludeAuthParams);
+ } catch (OnapCommandException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new OnapCommandInvalidSchema(schemaName, e);
}
}
private static List<String> parseSchema(OnapCommand cmd,
final Map<String, ?> values,
- final List<String> defaultParamNames,
boolean validate) throws OnapCommandException {
List<String> exceptionList = new ArrayList<>();
List<String> shortOptions = new ArrayList<>();
List<String> longOptions = new ArrayList<>();
- Set<String> filteredDefaultParams = new HashSet<>();
if (validate) {
validateTags(exceptionList, (Map<String, Object>) values, OnapCommandConfg.getSchemaAttrInfo(TOP_LEVEL_PARAMS_LIST),
}
- List<String> sections = Arrays.asList(NAME, DESCRIPTION, INFO, VERSION, COMMAND_TYPE, SERVICE,
- DEFAULT_PARAMETERS, PARAMETERS, RESULTS);
+ List<String> sections = Arrays.asList(NAME, DESCRIPTION, INFO, PARAMETERS, RESULTS);
for (String key : sections) {
}
break;
- case VERSION:
- Object version = values.get(key);
- if (version != null) {
- cmd.setVersion(version.toString());
- }
- break;
-
case DESCRIPTION:
Object description = values.get(key);
if (description != null) {
}
break;
-
- case COMMAND_TYPE:
- Object type = values.get(key);
- if (type != null) {
- cmd.setType(CommandType.get(type.toString()));
- }
- break;
-
case INFO:
Map<String, String> infoMap = (Map<String, String>) values.get(key);
}
break;
- case SERVICE:
- Map<String, String> serviceMap = (Map<String, String>) values.get(key);
-
- if (serviceMap != null) {
- if (validate) {
- validateTags(exceptionList, (Map<String, Object>) values.get(key),
- OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_LIST),
- OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_MANDATORY_LIST), SERVICE);
-
- HashMap<String, String> validationMap = new HashMap<>();
- validationMap.put(AUTH, AUTH_VALUES);
- validationMap.put(MODE, MODE_VALUES);
-
- for (String secKey : validationMap.keySet()) {
- if (serviceMap.containsKey(secKey)) {
- Object obj = serviceMap.get(secKey);
- if (obj == null) {
- exceptionList.add("Attribute '" + secKey + "' under '" + SERVICE + "' is empty");
- } else {
- String value = String.valueOf(obj);
- if (!OnapCommandConfg.getSchemaAttrInfo(validationMap.get(secKey)).contains(value)) {
- exceptionList.add("Attribute '" + secKey + "' contains invalid value. Valide values are "
- + OnapCommandConfg.getSchemaAttrInfo(validationMap.get(key))); //
- }
- }
- }
- }
- }
-
- OnapService srv = new OnapService();
-
- for (Map.Entry<String, String> entry1 : serviceMap.entrySet()) {
- String key1 = entry1.getKey();
-
- switch (key1) {
- case NAME:
- srv.setName(serviceMap.get(key1));
- break;
-
- case VERSION:
- srv.setVersion(serviceMap.get(key1).toString());
- break;
-
- case AUTH:
- Object obj = serviceMap.get(key1);
- srv.setAuthType(obj.toString());
- break;
-
- case MODE:
- Object mode = serviceMap.get(key1);
- srv.setMode(mode.toString());
- break;
- }
- }
- cmd.setService(srv);
- }
- break;
-
- case DEFAULT_PARAMETERS:
- Map<String, List<String>> defParameters = (Map) values.get(DEFAULT_PARAMETERS);
- List<String> includeParams = new ArrayList<>();
- List<String> excludeParams = new ArrayList<>();
-
- if (values.containsKey(DEFAULT_PARAMETERS) && defParameters == null) {
- // if default parameter section is available then it must have either include
- // or exclude sub-section.
- throwOrCollect(new OnapCommandInvalidSchema(SCHEMA_INVALID_DEFAULT_PARAMS_SECTION),
- exceptionList, validate);
- }
-
-
- if (defParameters != null) {
- // validate default parameters
- if (defParameters.containsKey(DEFAULT_PARAMETERS_INCLUDE)) {
- includeParams = defParameters.get(DEFAULT_PARAMETERS_INCLUDE);
- }
-
- List<String> invInclude = includeParams.stream()
- .filter(p -> !defaultParamNames.contains(p))
- .collect(Collectors.toList());
-
- if (defParameters.containsKey(DEFAULT_PARAMETERS_EXCLUDE)) {
- excludeParams = defParameters.get(DEFAULT_PARAMETERS_EXCLUDE);
- }
-
- List<String> invExclude = excludeParams.stream().filter(p -> !defaultParamNames.contains(p))
- .collect(Collectors.toList());
-
-
- if (!invExclude.isEmpty() || !invInclude.isEmpty()) {
-
- throwOrCollect(new OnapCommandInvalidDefaultParameter(Stream.concat(invInclude.stream(),
- invExclude.stream()).collect(Collectors.toList())),
- exceptionList, validate);
- }
-
- if (!includeParams.isEmpty()) {
- filteredDefaultParams.addAll(includeParams);
- } else if (!excludeParams.isEmpty()) {
- List<String> finalExcludeParams = excludeParams;
- defaultParamNames.stream().filter(p -> !finalExcludeParams.contains(p))
- .forEach(filteredDefaultParams::add);
- }
- } else {
- filteredDefaultParams.addAll(defaultParamNames);
- }
- try {
- processNoAuth(filteredDefaultParams, cmd, includeParams, excludeParams);
- } catch (OnapCommandException e) {
- throwOrCollect(e, exceptionList, validate);
- }
- break;
-
case PARAMETERS:
List<Map<String, String>> parameters = (List) values.get(key);
if (parameters != null) {
Set<String> names = new HashSet<>();
- Set<String> inputShortOptions = new HashSet<>();
- Set<String> inputLongOptions = new HashSet<>();
for (Map<String, String> parameter : parameters) {
OnapCommandParameter param = new OnapCommandParameter();
+ //Override the parameters from its base such as default parameters list
+ if (cmd.getParametersMap().containsKey(param.getName())) {
+ param = cmd.getParametersMap().get(param.getName());
+ }
+
if (validate) {
validateTags(exceptionList, parameter, OnapCommandConfg.getSchemaAttrInfo(INPUT_PARAMS_LIST),
OnapCommandConfg.getSchemaAttrInfo(INPUT_PARAMS_MANDATORY_LIST), PARAMETERS);
}
}
- // Add the element to command :
- // 1. if parameter is available in filtered parameter list.
- // 2. otherwise, parameter p is available in command yaml file.
- if (filteredDefaultParams.contains(param.getName()) || !defaultParamNames.contains(param.getName())) {
+ if ( !cmd.getParametersMap().containsKey(param.getName()) ) {
cmd.getParameters().add(param);
}
}
* @throws OnapCommandInvalidSchemaVersion
* invalid schema version
*/
- public static ArrayList<String> loadHTTPSchemaSection(OnapHttpCommand cmd, String schemaName,
- boolean validate) throws OnapCommandException {
+ private static ArrayList<String> parseHttpSchema(OnapHttpCommand cmd,
+ final Map<String, ?> values,
+ boolean validate) throws OnapCommandException {
ArrayList<String> errorList = new ArrayList<>();
try {
- Map<String, ?> values = (Map<String, ?>) validateSchemaVersion(schemaName, cmd.getSchemaVersion());
Map<String, ?> valMap = (Map<String, ?>) values.get(HTTP);
if (valMap != null) {
break;
}
}catch (Exception ex) {
- throwOrCollect(new OnapCommandInvalidSchema(schemaName, ex), errorList, validate);
+ throwOrCollect(new OnapCommandInvalidSchema(cmd.getSchemaName(), ex), errorList, validate);
}
}
break;
+ case SERVICE:
+ Map<String, String> serviceMap = (Map<String, String>) valMap.get(key1);
+
+ if (serviceMap != null) {
+ if (validate) {
+ validateTags(errorList, (Map<String, Object>) valMap.get(key1),
+ OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_LIST),
+ OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_MANDATORY_LIST), SERVICE);
+
+ HashMap<String, String> validationMap = new HashMap<>();
+ validationMap.put(AUTH, AUTH_VALUES);
+ validationMap.put(MODE, MODE_VALUES);
+
+ for (String secKey : validationMap.keySet()) {
+ if (serviceMap.containsKey(secKey)) {
+ Object obj = serviceMap.get(secKey);
+ if (obj == null) {
+ errorList.add("Attribute '" + secKey + "' under '" + SERVICE + "' is empty");
+ } else {
+ String value = String.valueOf(obj);
+ if (!OnapCommandConfg.getSchemaAttrInfo(validationMap.get(secKey)).contains(value)) {
+ errorList.add("Attribute '" + secKey + "' contains invalid value. Valide values are "
+ + OnapCommandConfg.getSchemaAttrInfo(validationMap.get(key1))); //
+ }
+ }
+ }
+ }
+ }
+
+ OnapService srv = new OnapService();
+
+ for (Map.Entry<String, String> entry : serviceMap.entrySet()) {
+ String key = entry.getKey();
+
+ switch (key) {
+ case NAME:
+ srv.setName(serviceMap.get(key));
+ break;
+
+ case VERSION:
+ srv.setVersion(serviceMap.get(key).toString());
+ break;
+
+ case AUTH:
+ Object obj = serviceMap.get(key);
+ srv.setAuthType(obj.toString());
+
+ //On None type, username, password and no_auth are invalid
+ if (srv.isNoAuth()) {
+ cmd.getParametersMap().remove(DEAFULT_PARAMETER_USERNAME);
+ cmd.getParametersMap().remove(DEAFULT_PARAMETER_PASSWORD);
+ cmd.getParametersMap().remove(DEFAULT_PARAMETER_NO_AUTH);
+ }
+ break;
+
+ case MODE:
+ Object mode = serviceMap.get(key);
+ srv.setMode(mode.toString());
+ break;
+ }
+ }
+ cmd.setService(srv);
+ }
+ break;
+
case SUCCESS_CODES:
if (validate) {
validateHttpSccessCodes(errorList, (List<Object>) valMap.get(key1));
* help failed exception
*/
public static String help(OnapCommand cmd) throws OnapCommandHelpFailed {
+ //mrkanag refactor onap name into oclip
String help = "usage: onap " + cmd.getName();
// Add description
help += "\n\n" + cmd.getDescription();
// Add service
- help += "\n\nOnap service: " + cmd.getService();
+ help += "\n\nService: " + cmd.getInfo().getService();
// Add whole command
String commandOptions = "";
return help;
}
- /**
- * Helps to create OnapCredentials from default params.
- *
- * @param params
- * list of parameters
- * @return OnapCredentials
- * @throws OnapCommandInvalidParameterValue
- * exception
- */
- public static OnapCredentials fromParameters(List<OnapCommandParameter> params)
- throws OnapCommandInvalidParameterValue {
- Map<String, String> paramMap = new HashMap<>();
-
- for (OnapCommandParameter param : params) {
- paramMap.put(param.getName(), param.getValue().toString());
- }
- return new OnapCredentials(paramMap.get(DEAFULT_PARAMETER_USERNAME),
- paramMap.get(DEAFULT_PARAMETER_PASS_WORD),
- paramMap.get(DEAFULT_PARAMETER_HOST_URL));
- }
-
/**
* Create Dict from list of Parameters.
*
schema.setCmdName((String) resourceMap.get(NAME));
Object obj = resourceMap.get(OPEN_CLI_SCHEMA_VERSION);
schema.setVersion(obj.toString());
- schema.setCmdVersion(resourceMap.get(Constants.VERSION).toString());
- if (resourceMap.get(Constants.COMMAND_TYPE) != null) {
- schema.setType(resourceMap.get(Constants.COMMAND_TYPE).toString());
+ Map<String, ?> infoMap = (Map<String, ?>) resourceMap.get(Constants.INFO);
+ if (infoMap != null && infoMap.get(Constants.COMMAND_TYPE) != null) {
+ schema.setType(infoMap.get(Constants.COMMAND_TYPE).toString());
+ }
+ if (infoMap != null && infoMap.get(Constants.INFO_PRODUCT) != null) {
+ schema.setCmdVersion(infoMap.get(Constants.INFO_PRODUCT).toString());
}
if (resourceMap.get(Constants.HTTP) != null) {
*
* @throws OnapCommandInvalidParameterValue
*/
- public static void copyParamsFrom(OnapCommand from, OnapCommand to) throws OnapCommandInvalidParameterValue {
+ public static void copyParamsFrom(OnapHttpCommand from, OnapCommand to) throws OnapCommandInvalidParameterValue {
for (OnapCommandParameter param: to.getParameters()) {
OnapCommandParameter fromParam = from.getParametersMap().get(param.getName());
open_cli_schema_version: 1.0
parameters:
- - name: host-username
- type: string
- description: Host user name
- short_option: u
- long_option: host-username
- default_value: $s{env:HOST_USERNAME}
- is_optional: false
- - name: host-password
- type: string
- description: Host user password
- short_option: p
- long_option: host-password
- default_value: $s{env:HOST_PASSWORD}
- is_secured: true
- is_optional: false
- - name: host-url
- type: url
- description: host url in http(s)
- short_option: m
- long_option: host-url
- is_optional: false
- default_value: $s{env:HOST_URL}
- name: help
type: string
description: print help message
description: whether to print title or not
short_option: t
long_option: no-title
- default_value: false
- - name: no-auth
- type: bool
- description: whether to authenticate user or not
- short_option: a
- long_option: no-auth
default_value: false
\ No newline at end of file
--- /dev/null
+open_cli_schema_version: 1.0
+parameters:
+ - name: host-username
+ type: string
+ description: Host user name
+ short_option: u
+ long_option: host-username
+ default_value: $s{env:HOST_USERNAME}
+ is_optional: false
+ - name: host-password
+ type: string
+ description: Host user password
+ short_option: p
+ long_option: host-password
+ default_value: $s{env:HOST_PASSWORD}
+ is_secured: true
+ is_optional: false
+ - name: host-url
+ type: url
+ description: host url in http(s)
+ short_option: m
+ long_option: host-url
+ is_optional: false
+ default_value: $s{env:HOST_URL}
+ - name: no-auth
+ type: bool
+ description: whether to authenticate user or not
+ short_option: a
+ long_option: no-auth
+ default_value: false
\ No newline at end of file
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=${ONAP_CLI_HOME}/logs/onap-cli.log
+log4j.appender.file.File=${OPEN_CLI_HOME}/logs/oclip.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
\ No newline at end of file
+log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
description: basic login auth command
-version: cli-1.0
-
-type: auth
-
-service:
- name: open-cli
- version: 1.0.0
- mode: direct
+info:
+ product: open-cli
+ service: basic-auth
+ type: auth
+ author: Kanagaraj Manickam mkr1481@gmail.com
results:
direction: portrait
description: basic logout auth command
-version: cli-1.0
-
-type: auth
-
-service:
- name: open-cli
- version: 1.0.0
- mode: direct
\ No newline at end of file
+info:
+ product: open-cli
+ service: basic-auth
+ type: auth
+ author: Kanagaraj Manickam mkr1481@gmail.com
name: catalog
-description: cli catalog command to find the base path for service.
+description: cli catalog command to find the base path for service.
-version: cli-1.0
+info:
+ product: open-cli
+ service: catalog
+ type: catalog
+ author: Kanagaraj Manickam mkr1481@gmail.com
-type: catalog
-
-service:
- auth: none
- name: open-cli
- version: 1.0.0
- mode: direct
-
parameters:
- name: catalog-service-name
type: string
short_option: i
long_option: catalog-service-version
is_optional: false
+
results:
direction: portrait
attributes:
description: service base path, to append with host-url for connecting the service.
scope: short
type: string
- default_value: /
\ No newline at end of file
+ default_value: /
\ No newline at end of file
open_cli_schema_version: 1.0
name: schema-refresh
-description: Onap command to refresh schemas stored in OPEN_cli_schema folders.
-version: cli-1.0
-service:
- auth: none
- name: open-cli
- version: 1.0.0
+description: Onap command to refresh schemas stored in open_cli_schema folders.
+
+info:
+ product: open-cli
+ service: schema
+ type: auth
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
results:
direction: landscape
attributes:
description: Command name
scope: short
type: string
- - name: product-version
+ - name: product
description: Command product version
scope: short
type: string
description: Schema name
scope: short
type: string
- - name: version
+ - name: ocs-version
description: Schema version
scope: short
type: string
\ No newline at end of file
open_cli_schema_version: 1.0
name: schema-validate
description: Onap command to validate schema
-version: cli-1.0
-service:
- auth: none
- name: open-cli
- version: 1.0.0
-default_parameters:
- exclude:
- - host-username
- - host-password
- - host-url
- - no-auth
+
+info:
+ product: open-cli
+ service: schema
+ type: auth
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: schema-location
type: url
short_option: i
long_option: internal-schema
is_optional: false
+
results:
direction: landscape
attributes:
cli.ignore_auth=false
cli.http.api_key_use_cookies=true
cli.discover_always=false
-
-cli.service_name=open-cli
-cli.product.version=cli-1.0
+cli.product_name=open-cli
cli.version=1.0
-# service section
-cli.exclude_params_internal_cmd=host-username,host-password,host-url,no-auth
-cli.no_auth_disable_include_params_external_cmd=host-username,host-password,host-url,no-auth
-cli.no_auth_enable_exclude_params_external_cmd=host-username,host-password,no-auth
-cli.no_auth_enable_include_params_external_cmd=host-url
-
#schema validation
-cli.schema.top_level_params_list=open_cli_schema_version,name,version,description,service,parameters,results,http,type,info
+cli.schema.top_level_params_list=open_cli_schema_version,name,description,parameters,results,http,info
cli.schema.top_level_mandatory_list=open_cli_schema_version
-cli.schema.service_params_list=name,version,auth,mode
-cli.schema.service_params_mandatory_list=name,version
+cli.schema.info_params_list=product,service,type,author
+cli.schema.info_params_mandatory_list=product,service
-cli.schema.input_params_list=name,description,type,short_option,long_option, is_optional,default_value,is_secured
+cli.schema.input_params_list=name,description,type,short_option,long_option, is_optional,default_value,is_secured,is_include
cli.schema.input_params_mandatory_list=name,description,type
cli.schema.result_params_list=name,description,scope,type,is_secured, default_value
cli.schema.result_params_mandatory_list=name, description, type, scope
-cli.schema.http_sections=request,success_codes,result_map,sample_response
+#http
+cli.schema.http_sections=request,service,success_codes,result_map,sample_response
cli.schema.http_mandatory_sections=request, success_codes
cli.schema.http_request_params=uri,method,body,headers,queries,multipart_entity_name
cli.schema.http_request_mandatory_params=uri,method
-cli.schema.info_params_list=product,service,type,author
-cli.schema.info_params_mandatory_list=product,service
+cli.schema.service_params_list=name,version,auth,mode
+cli.schema.service_params_mandatory_list=auth,mode
cli.schema.http_methods=post,get,delete,put,head
* This command helps to test the Command functionalities.
*
*/
-@OnapCommandSchema(name = "sample-test", version="cli-1.0", schema = "sample-test-schema.yaml")
+@OnapCommandSchema(name = "sample-test", version="open-cli", schema = "sample-test-schema.yaml")
public class OnapCommandSample extends OnapCommand {
public OnapCommandSample() {
public class OnapCommandSampleTest {
@Test
public void sampleTestVersion() {
-
+
try {
-
- OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
+
+ OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
List<OnapCommandParameter> parameters = new ArrayList();
OnapCommandParameter v = new OnapCommandParameter();
@Test
public void sampleTest() {
-
+
try {
- OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
+ OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
List<OnapCommandParameter> parameters = new ArrayList();
OnapCommandParameter v = new OnapCommandParameter();
v.setName(Constants.DEFAULT_PARAMETER_VERSION);
t.setValue("true");
parameters.add(t);
OnapCommandParameter a = new OnapCommandParameter();
- a.setName(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH);
+ a.setName(Constants.DEFAULT_PARAMETER_NO_AUTH);
a.setValue("true");
parameters.add(a);
OnapCommandParameter d = new OnapCommandParameter();
parameters.add(m);
sample.setParameters(parameters);
sample.execute();
-
+
//validate whether output attributes default value got initialized as part of execute()
OnapCommandResultAttribute attr = sample.getResult().getRecordsMap().get("output-1");
String attrValue = attr.getValues().get(0);
attrValue = attr.getValues().get(0);
assertEquals(attrValue, "test");
} catch (IllegalArgumentException e){
- fail("Failed to replace the output default value on output-1");
- } catch (OnapCommandException e) {
+ fail("Failed to replace the output default value on output-1");
+ } catch (OnapCommandException e) {
}
}
t.setValue("true");
parameters.add(t);
OnapCommandParameter a = new OnapCommandParameter();
- a.setName(Constants.DEFAULT_PARAMETER_OUTPUT_NO_AUTH);
+ a.setName(Constants.DEFAULT_PARAMETER_NO_AUTH);
a.setValue("true");
parameters.add(a);
OnapCommandParameter d = new OnapCommandParameter();
public void registerTest() throws OnapCommandException {
OnapCommand test = new OnapCommandTest();
Class<OnapCommand> cmd = (Class<OnapCommand>) test.getClass();
- registerar.register("test", "cli-1.0", cmd);
- OnapCommand cc = registerar.get("test");
+ registerar.register("Test", "open-cli", cmd);
+ OnapCommand cc = registerar.get("Test");
assertTrue(cmd == cc.getClass());
}
public void cmdTestSchema() throws OnapCommandException {
OnapCommand test = new OnapCommandTest();
Class<OnapCommand> cmd = (Class<OnapCommand>) test.getClass();
- registerar.register("test", "cli-1.0", cmd);
- OnapCommand cc = registerar.get("test");
+ registerar.register("Test", "open-cli", cmd);
+ OnapCommand cc = registerar.get("Test");
}
@Test
@Test
public void onapCommandRegistrationFailedTest() throws OnapCommandException {
- @OnapCommandSchema(name = "Test2", version= "cli-1.0", schema = "sample-test-schema.yaml")
+ @OnapCommandSchema(name = "Test2", version= "open-cli", schema = "sample-test-schema.yaml")
class Test extends OnapCommand {
@Override
OnapCommand com = new Test();
Class<OnapCommand> cmd = (Class<OnapCommand>) com.getClass();
try {
- registerar.register("Test2", "cli-1.0", cmd);
+ registerar.register("Test2", "open-cli", cmd);
registerar.get("Test2");
fail("This should have thrown an exception");
} catch (OnapCommandRegistrationFailed e) {
OnapCommand test = new OnapCommandTest1();
Class<OnapCommand> cmd = (Class<OnapCommand>) test.getClass();
registerar = new OnapCommandRegistrar();
- registerar.register("test1", "cli-1.0", cmd);
+ registerar.register("test1", "open-cli", cmd);
String help = registerar.getHelp();
assertNotNull(help);
}
OnapCommandRegistrar.getRegistrar().setInteractiveMode(false);
assertTrue(!OnapCommandRegistrar.getRegistrar().isInteractiveMode());
- OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("cli-1.0");
- assertEquals("cli-1.0", OnapCommandRegistrar.getRegistrar().getEnabledProductVersion());
+ OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("open-cli");
+ assertEquals("open-cli", OnapCommandRegistrar.getRegistrar().getEnabledProductVersion());
OnapCommandRegistrar.getRegistrar().getAvailableProductVersions();
assertTrue(OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion().contains("schema-refresh"));
}
}
-@OnapCommandSchema(name = OnapCommandTest.CMD_NAME, version = "cli-1.0", schema = "sample-test-schema.yaml")
+@OnapCommandSchema(name = OnapCommandTest.CMD_NAME, version = "open-cli", schema = "sample-test-schema.yaml")
class OnapCommandTest extends OnapCommand {
public OnapCommandTest() {
}
-@OnapCommandSchema(name = OnapCommandTest1.CMD_NAME, version = "cli-1.0", schema = "test-schema.yaml")
+@OnapCommandSchema(name = OnapCommandTest1.CMD_NAME, version = "open-cli", schema = "test-schema.yaml")
class OnapCommandTest1 extends OnapCommand {
public OnapCommandTest1() {
public void internalCommandTest() {
try {
OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("sample-test");
- cmd.getService().setName(OnapCommandConfg.getInternalCmd());
+ cmd.getInfo().setService(OnapCommandConfg.getProductName());
cmd.execute();
} catch (OnapCommandException e) {
OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-yes-catalog.yaml");
cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080");
cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_USERNAME).setValue("test");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASS_WORD).setValue("password");
+ cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASSWORD).setValue("password");
cmd.execute();
} catch (OnapCommandException e) {
OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-no-catalog.yaml");
cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080");
cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_USERNAME).setValue("test");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASS_WORD).setValue("password");
+ cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASSWORD).setValue("password");
cmd.execute();
} catch (OnapCommandException e) {
package org.onap.cli.fw.cmd;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.junit.Ignore;
import org.junit.Test;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.http.HttpInput;
import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cli.fw.input.ParameterType;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
public class OnapHttpCommandTest {
+ @Ignore
@Test(expected = OnapCommandException.class)
public void runTest() throws OnapCommandException {
OnapCommandParameter param1 = new OnapCommandParameter();
assertTrue(cmdName.equalsIgnoreCase("sample-test1"));
assertTrue(cmdFile.equalsIgnoreCase("sample-test1-schema-http.yaml"));
assertTrue(version.equalsIgnoreCase("1.0"));
- assertTrue(cmdVer.equalsIgnoreCase("cli-1.0"));
+ assertTrue(cmdVer.equalsIgnoreCase("open-cli"));
}
}
List<String> errorList4 = OnapCommandUtils.loadSchema(cmd2, "schema-validate-invalid.yaml", true, true);
OnapHttpCommand onapHttpCommand = new OnapHttpCommand();
- errorList4.addAll(OnapCommandUtils.loadHTTPSchemaSection(onapHttpCommand,
- "schema-validate-invalid.yaml", true));
+ errorList4.addAll(OnapCommandUtils.loadHttpSchema(onapHttpCommand,
+ "schema-validate-invalid.yaml", true, true));
assertTrue(errorList4.size() > 0);
OnapCommand cmd5 = new OnapCommand() {
com.setValue("value");
}
- OnapCredentials cre = OnapCommandUtils.fromParameters(cmd.getParameters());
- assertTrue(cre != null);
Map<String, OnapCommandParameter> map = OnapCommandUtils.getInputMap(cmd.getParameters());
- assertTrue(map.size() == 16);
+ assertTrue(map.size() == 15);
}
@Test
assertTrue("sample-test".equals(cmd.getName()));
Map<String, OnapCommandParameter> map = OnapCommandUtils.getInputMap(cmd.getParameters());
- assertTrue(map.size() == 11);
+ assertTrue(map.size() == 7);
}
@Test
OnapHttpCommand cmd = new OnapHttpCommandSample();
cmd.setName("sample-test-http");
try {
- OnapCommandUtils.loadHTTPSchemaSection(cmd, "sample-test-schema.yaml", false);
+ OnapCommandUtils.loadHttpSchema(cmd, "sample-test-schema.yaml", true, false);
} catch (OnapCommandParameterNameConflict | OnapCommandParameterOptionConflict
| OnapCommandInvalidParameterType | OnapCommandInvalidPrintDirection
| OnapCommandInvalidResultAttributeScope | OnapCommandSchemaNotFound | OnapCommandInvalidSchema
OnapHttpCommand cmd = new OnapHttpCommandSample();
cmd.setName("sample-create-http");
try {
- OnapCommandUtils.loadHTTPSchemaSection(cmd, "sample-test-schema-http.yaml", true);
+ OnapCommandUtils.loadHttpSchema(cmd, "sample-test-schema-http.yaml", true, true);
assertTrue(cmd.getSuccessStatusCodes().size() == 2);
} catch (OnapCommandParameterNameConflict | OnapCommandParameterOptionConflict
| OnapCommandInvalidParameterType | OnapCommandInvalidPrintDirection
String actualResult = OnapCommandUtils.help(cmd);
String expectedHelp = FileUtil.loadResource("sample-cmd-test-help.txt");
+
+ //mrkanag compare the result
}
@Test
assert info != null;
}
- @OnapCommandSchema(name = "sample-test-info", version = "cli-1.0", schema = "sample-test-info.yaml")
+ @OnapCommandSchema(name = "sample-test-info", version = "open-cli", schema = "sample-test-info.yaml")
class OnapCommandSampleInfo extends OnapCommand {
@Override
protected void run() throws OnapCommandException {
}
}
- @OnapCommandSchema(name = "sample-test", version = "cli-1.0", schema = "sample-test-schema.yaml")
+ @OnapCommandSchema(name = "sample-test", version = "open-cli", schema = "sample-test-schema.yaml")
class OnapCommandSample extends OnapCommand {
@Override
protected void run() throws OnapCommandException {
}
}
- @OnapCommandSchema(name = "sample-swagger-test", version = "cli-1.0", schema = "sample-test-schema-swagger.yaml")
+ @OnapCommandSchema(name = "sample-swagger-test", version = "open-cli", schema = "sample-test-schema-swagger.yaml")
class OnapSwaggerBasedCommandSample extends OnapSwaggerCommand {
@Override
}
}
- @OnapCommandSchema(name = "sample-http-test", version = "cli-1.0", schema = "sample-test-schema-http.yaml")
+ @OnapCommandSchema(name = "sample-http-test", version = "open-cli", schema = "sample-test-schema-http.yaml")
class OnapHttpCommandSample extends OnapHttpCommand {
@Override
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-verion: cli-1.0
-service:
- name: sample
- version: v1
- auth: none
+
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: bool-param
type: bool
open_cli_schema_version: 1.0
name: sample-test1
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
+
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: bool-param
type: bool
Onap service: sample v1
Options:
-[-u | --host-username] [-p | --host-password] [-m | --host-url]
[-h | --help] [-v | --version] [-d | --debug]
[-f | --format] [-s | --long] [-t | --no-title]
[-a | --no-auth] [-b | --bool] [-x | --secure]
[-l | --long-opt] [-r | --url] [-z | --env]
<positional-args>
where,
--u | --host-username Onap user name. It is of type STRING. By
- default, it is read from environment variable
- HOST_USERNAME.
--p | --host-password Onap user password. It is of type STRING. By
- default, it is read from environment variable
- HOST_PASSWORD. Secured.
--m | --host-url Onap MSB url. It is of type URL. By default, it
- is read from environment variable OPEN_MSB_URL.
-h | --help Onap command help message. It is of type STRING.
By default, it is false.
-v | --version Onap command service version. It is of type
false.
-t | --no-title whether to print title or not. It is of type BOOL.
By default, it is false.
--a | --no-auth whether to authenticate user or not. It is of type
- BOOL. By default, it is false.
-b | --bool Onap boolean param, by default its always false.
It is of type BOOL. It is optional. By default, it
is false.
open_cli_schema_version: 1.0
name: sample-test-info
description: Onap sample command to test the command features
-version: cli-1.0
+
info:
- product: cli-1.0
- service: cli
+ product: open-cli
+ service: test
type: cmd
author: Kanagaraj Manickam mkr1481@gmail.com
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
+
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: bool-param
type: bool
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: bool-param
type: bool
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: bool-param
type: bool
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: bool-param
type: bool
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: bool-param
type: bool
open_cli_schema_version: 1.0
name: sample-create-http
description: Register microservice into Onap
-version: cli-1.0
-service:
- name: msb
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: service-name
description: Onap service name
description: sample
-version: sample-test-1.0
-
-service:
- name: sample
- version: v1
- auth: none
- mode: direct
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
http:
+
+ service:
+ name: sample
+ version: v1
+ auth: none
+ mode: direct
request:
uri: /test
method: GET
description: sample
-version: sample-test-1.0
-service:
- name: sample
- version: v1
- auth: none
- mode: catalog
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
http:
+
+ service:
+ name: sample
+ version: v1
+ auth: none
+ mode: catalog
+
request:
uri: /test
method: GET
open_cli_schema_version: 1.0
name: sample-test-swagger
description: Sample swagger command test.
-version: cli-1.0
-service:
- name: sample
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: user
type: string
description: sample
-version: sample-test-1.0
-
-service:
- name: sample
- version: v1
- auth: basic
- mode: direct
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
http:
+
+ service:
+ name: sample
+ version: v1
+ auth: basic
+ mode: direct
request:
uri: /test
method: GET
description: sample
-version: sample-test-1.0
-service:
- name: sample
- version: v1
- auth: basic
- mode: catalog
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
http:
+
+ service:
+ name: sample
+ version: v1
+ auth: basic
+ mode: catalog
+
request:
uri: /test
method: GET
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
- auth: none
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: bool-param
type: bool
open_cli_schema_version: 1.0
description: Register microservice into Onap
name: schema-validate
-service:
- name: msb
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: service-name1
description: Onap service name
open_cli_schema_version: 1.0
description: Register microservice into Onap
name: schema-validate
-service:
- name: msb
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: service-name1
description: Onap service name
scope: long
type: url
http:
+ service:
+ name: msb
+ version: v1
+ type: direct
+ auth: none
request:
uri: /services
method: POST1
open_cli_schema_version: 1.0
name: sdnc-create
description: Register SDNC into Onap
-service:
- name: extsys
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
parameters:
- name: name
description: Onap SDNC name
open_cli_schema_version: 1.0
description: Register microservice into Onap
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
name: schema-validate
parameters:
- name: service-name1
open_cli_schema_version: 1.0
name: sdnc-create
description: Register SDNC into Onap
-service:
- name: extsys
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: name
description: Onap SDNC name
for (OnapCommandParameter param: cmd.getParameters()) {
if (OnapCommandRegistrar.getRegistrar().getParamCache().containsKey(
- cmd.getService().getName() + ":" + param.getLongOption())) {
+ cmd.getInfo().getService() + ":" + param.getLongOption())) {
param.setValue(OnapCommandRegistrar.getRegistrar().getParamCache().get(
- cmd.getService().getName() + ":" + param.getLongOption()));
+ cmd.getInfo().getService() + ":" + param.getLongOption()));
} else if (OnapCommandRegistrar.getRegistrar().getParamCache().containsKey(param.getLongOption())) {
param.setValue(OnapCommandRegistrar.getRegistrar().getParamCache().get(param.getLongOption()));
}
}
cli = new OnapCli(new String[] {});
- mockConsole("use cli-1.0");
+ mockConsole("use open-cli");
try {
cli.handleInteractive();
} catch (Exception e) {
* This command helps to test the Command functionalities.
*
*/
-@OnapCommandSchema(name = "sample-test", version = "cli-1.0", schema = "sample-test-schema.yaml")
+@OnapCommandSchema(name = "sample-test", version = "open-cli", schema = "sample-test-schema.yaml")
public class OnapCommandSampleTest extends OnapCommand {
@Override
open_cli_schema_version: 1.0
name: sample-create
description: Sample create into Onap
-version: cli-1.0
-service:
- name: sample
- version: v1
- auth: none
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: service-name
description: Onap service name
open_cli_schema_version: 1.0
name: sample-test
description: Onap sample command to test the command features
-version: cli-1.0
-service:
- name: sample
- version: v1
+info:
+ product: open-cli
+ service: test
+ type: cmd
+ author: Kanagaraj Manickam mkr1481@gmail.com
+
parameters:
- name: bool-param
type: bool
description: First cmd hello world using http runing under lighttpd in cli at http://<cli-ip>:8080/version.json
-version: sample-1.0
-
-service:
- name: sample-service
- version: 1.0.0
- auth: none
- mode: direct
+info:
+ product: sample
+ service: hello-world
parameters:
- name: name
scope: short
http:
+ service:
+ name: sample-service
+ version: 1.0.0
+ auth: none
+ mode: direct
request:
uri: /version.json
method: GET
description: First cmd hello world
-version: sample-1.0
+info:
+ product: sample
+ service: hello-world
service:
name: sample-service
if (sch.getCmdVersion().equals(version)) {
System.out.println(
"************************* validate '" + sch.getCmdName() + "' *******************************");
- OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("cli-1.0");
+ OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("open-cli");
this.handle(new String[] { "schema-validate", "-l", sch.getSchemaName(), "-i"});
}
}