2 # Copyright 2019 Tech Mahindra Limited
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
20 from osmclient
import client
21 from robot
.api
import logger
26 def __init__(self
, host
="127.0.0.1", user
=None, password
=None, project
=None):
31 if password
is not None:
32 kwargs
['password'] = password
33 if project
is not None:
34 kwargs
['project'] = project
35 self
.client
= client
.Client(host
=host
, sol005
=True, **kwargs
)
37 def get_vim_list(self
):
38 resp
= self
.client
.vim
.list()
39 logger
.info('VIM List: {}'.format(resp
))
40 return json
.dumps(resp
)
42 def create_vim_account(self
, name
, vim_type
, user
, password
, auth_url
, tenant
, desc
='', config
=None):
44 if config
is not None:
45 vim_access
['config'] = config
46 vim_access
['vim-type'] = vim_type
47 vim_access
['vim-username'] = user
48 vim_access
['vim-password'] = password
49 vim_access
['vim-url'] = auth_url
50 vim_access
['vim-tenant-name'] = tenant
51 vim_access
['description'] = desc
53 resp
= self
.client
.vim
.create(name
, vim_access
)
54 logger
.info('Create VIM Account: {}'.format(resp
))
55 return json
.dumps(resp
)
57 def delete_vim_account(self
, name
):
58 resp
= self
.client
.vim
.delete(name
)
59 return json
.dumps(resp
)
61 def get_vnfd_list(self
):
62 resp
= self
.client
.vnfd
.list()
63 logger
.info('VNF Descriptor List: {}'.format(resp
))
64 return json
.dumps(resp
)
66 def get_nsd_list(self
):
67 resp
= self
.client
.nsd
.list()
68 logger
.info('NS Descriptor List: {}'.format(resp
))
69 return json
.dumps(resp
)