-@cli.command(name='sdnc-update', short_help='updates an SDN controller')
-@click.argument('name')
-@click.option('--newname', help='New name for the SDN controller')
-@click.option('--type', help='SDN controller type')
-@click.option('--sdn_controller_version', help='SDN controller username')
-@click.option('--ip_address', help='SDN controller IP address')
-@click.option('--port', help='SDN controller port')
-@click.option('--switch_dpid', help='Switch DPID (Openflow Datapath ID)')
-@click.option('--user', help='SDN controller username')
-@click.option('--password', help='SDN controller password')
-#@click.option('--description', default=None, help='human readable description')
-@click.option('--wait',
- required=False,
- default=False,
- is_flag=True,
- help='do not return the control immediately, but keep it \
- until the operation is completed, or timeout')
-@click.pass_context
-def sdnc_update(ctx,
- name,
- newname,
- type,
- sdn_controller_version,
- ip_address,
- port,
- switch_dpid,
- user,
- password,
- wait):
+@cli_osm.command(name="sdnc-create", short_help="creates a new SDN controller")
+@click.option("--name", prompt=True, help="Name to create sdn controller")
+@click.option("--type", prompt=True, help="SDN controller type")
+@click.option(
+ "--sdn_controller_version", # hidden=True,
+ help="Deprecated. Use --config {version: sdn_controller_version}",
+)
+@click.option("--url", help="URL in format http[s]://HOST:IP/")
+@click.option("--ip_address", help="Deprecated. Use --url") # hidden=True,
+@click.option("--port", help="Deprecated. Use --url") # hidden=True,
+@click.option(
+ "--switch_dpid", help="Deprecated. Use --config {switch_id: DPID}" # hidden=True,
+)
+@click.option(
+ "--config",
+ help="Extra information for SDN in yaml format, as {switch_id: identity used for the plugin (e.g. DPID: "
+ "Openflow Datapath ID), version: version}",
+)
+@click.option("--user", help="SDN controller username")
+@click.option(
+ "--password",
+ hide_input=True,
+ confirmation_prompt=True,
+ help="SDN controller password",
+)
+@click.option("--description", default=None, help="human readable description")
+@click.option(
+ "--wait",
+ required=False,
+ default=False,
+ is_flag=True,
+ help="do not return the control immediately, but keep it until the operation is completed, or timeout",
+)
+@click.pass_context
+def sdnc_create(ctx, **kwargs):
+ """creates a new SDN controller"""
+ logger.debug("")
+ sdncontroller = {
+ x: kwargs[x]
+ for x in kwargs
+ if kwargs[x] and x not in ("wait", "ip_address", "port", "switch_dpid")
+ }
+ if kwargs.get("port"):
+ print("option '--port' is deprecated, use '--url' instead")
+ sdncontroller["port"] = int(kwargs["port"])
+ if kwargs.get("ip_address"):
+ print("option '--ip_address' is deprecated, use '--url' instead")
+ sdncontroller["ip"] = kwargs["ip_address"]
+ if kwargs.get("switch_dpid"):
+ print(
+ "option '--switch_dpid' is deprecated, use '--config={switch_id: id|DPID}' instead"
+ )
+ sdncontroller["dpid"] = kwargs["switch_dpid"]
+ if kwargs.get("sdn_controller_version"):
+ print(
+ "option '--sdn_controller_version' is deprecated, use '--config={version: SDN_CONTROLLER_VERSION}'"
+ " instead"
+ )
+ # try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.sdnc.create(kwargs["name"], sdncontroller, wait=kwargs["wait"])
+ # except ClientException as e:
+ # print(str(e))
+ # exit(1)
+
+
+@cli_osm.command(name="sdnc-update", short_help="updates an SDN controller")
+@click.argument("name")
+@click.option("--newname", help="New name for the SDN controller")
+@click.option("--description", default=None, help="human readable description")
+@click.option("--type", help="SDN controller type")
+@click.option("--url", help="URL in format http[s]://HOST:IP/")
+@click.option(
+ "--config",
+ help="Extra information for SDN in yaml format, as "
+ "{switch_id: identity used for the plugin (e.g. DPID: "
+ "Openflow Datapath ID), version: version}",
+)
+@click.option("--user", help="SDN controller username")
+@click.option("--password", help="SDN controller password")
+@click.option("--ip_address", help="Deprecated. Use --url") # hidden=True
+@click.option("--port", help="Deprecated. Use --url") # hidden=True
+@click.option(
+ "--switch_dpid", help="Deprecated. Use --config {switch_dpid: DPID}"
+) # hidden=True
+@click.option(
+ "--sdn_controller_version", help="Deprecated. Use --config {version: VERSION}"
+) # hidden=True
+@click.option(
+ "--wait",
+ required=False,
+ default=False,
+ is_flag=True,
+ help="do not return the control immediately, but keep it until the operation is completed, or timeout",
+)
+@click.pass_context
+def sdnc_update(ctx, **kwargs):