1 # Copyright ETSI Contributors and Others.
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
17 from osmclient
.cli_commands
import utils
18 from prettytable
import PrettyTable
22 logger
= logging
.getLogger("osmclient")
25 @click.command(name
="wim-create", short_help
="creates a new WIM account")
26 @click.option("--name", prompt
=True, help="Name for the WIM account")
27 @click.option("--user", help="WIM username")
28 @click.option("--password", help="WIM password")
29 @click.option("--url", prompt
=True, help="WIM url")
30 @click.option("--config", default
=None, help="WIM specific config parameters")
31 @click.option("--wim_type", help="WIM type")
32 @click.option("--description", default
=None, help="human readable description")
36 help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge "
37 "(WAN service endpoint id and info)",
44 help="do not return the control immediately, but keep it "
45 "until the operation is completed, or timeout",
60 """creates a new WIM account"""
62 utils
.check_client_version(ctx
.obj
, ctx
.command
.name
)
67 wim
["password"] = password
70 wim
["wim_type"] = wim_type
72 wim
["description"] = description
74 wim
["config"] = config
75 ctx
.obj
.wim
.create(name
, wim
, wim_port_mapping
, wait
=wait
)
78 @click.command(name
="wim-update", short_help
="updates a WIM account")
79 @click.argument("name")
80 @click.option("--newname", help="New name for the WIM account")
81 @click.option("--user", help="WIM username")
82 @click.option("--password", help="WIM password")
83 @click.option("--url", help="WIM url")
84 @click.option("--config", help="WIM specific config parameters")
85 @click.option("--wim_type", help="WIM type")
86 @click.option("--description", help="human readable description")
90 help="File describing the port mapping between DC edge (datacenters, switches, ports) and WAN edge "
91 "(WAN service endpoint id and info)",
98 help="do not return the control immediately, but keep it until the operation is completed, or timeout",
114 """updates a WIM account
116 NAME: name or ID of the WIM account
119 utils
.check_client_version(ctx
.obj
, ctx
.command
.name
)
122 wim
["name"] = newname
126 wim
["password"] = password
130 wim
["wim_type"] = wim_type
132 wim
["description"] = description
134 wim
["config"] = config
135 ctx
.obj
.wim
.update(name
, wim
, wim_port_mapping
, wait
=wait
)
138 @click.command(name
="wim-delete", short_help
="deletes a WIM account")
139 @click.argument("name")
141 "--force", is_flag
=True, help="forces the deletion bypassing pre-conditions"
148 help="do not return the control immediately, but keep it until the operation is completed, or timeout",
151 def wim_delete(ctx
, name
, force
, wait
):
152 """deletes a WIM account
154 NAME: name or ID of the WIM account to be deleted
157 utils
.check_client_version(ctx
.obj
, ctx
.command
.name
)
158 ctx
.obj
.wim
.delete(name
, force
, wait
=wait
)
161 @click.command(name
="wim-list", short_help
="list all WIM accounts")
166 help="restricts the list to the WIM accounts matching the filter",
169 def wim_list(ctx
, filter):
170 """list all WIM accounts"""
172 utils
.check_client_version(ctx
.obj
, ctx
.command
.name
)
174 filter = "&".join(filter)
175 resp
= ctx
.obj
.wim
.list(filter)
176 table
= PrettyTable(["wim name", "uuid"])
178 table
.add_row([wim
["name"], wim
["uuid"]])
183 @click.command(name
="wim-show", short_help
="shows the details of a WIM account")
184 @click.argument("name")
186 def wim_show(ctx
, name
):
187 """shows the details of a WIM account
189 NAME: name or ID of the WIM account
192 utils
.check_client_version(ctx
.obj
, ctx
.command
.name
)
193 resp
= ctx
.obj
.wim
.get(name
)
194 if "password" in resp
:
195 resp
["password"] = "********"
197 table
= PrettyTable(["key", "attribute"])
198 for k
, v
in list(resp
.items()):
199 table
.add_row([k
, json
.dumps(v
, indent
=2)])