Radoslav Gerganov 1dc80c7f85 Refactor the PBM support
Having a Pbm class that inherits from Vim is a design mistake that we
need to fix before start using Pbm features in other projects like Nova.

This patch introduces a new base class 'Service' which provides common
functionality for invoking vSphere APIs and both Vim and Pbm inherit
from it. That will allow to further evolve our APIs and add features
which are specific to only Vim or Pbm.

Existing clients which use the Vim object through VMwareAPISession are
not impacted by this change. The interface of VMwareAPISession is
unchanged.

Change-Id: Icf54e3d0305b30c73d0ff7d9c85da1893392c3aa
2014-07-11 10:23:40 +03:00

47 lines
1.7 KiB
Python

# Copyright (c) 2014 VMware, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.vmware import service
class Vim(service.Service):
"""Service class that provides access to the VIM API."""
def __init__(self, protocol='https', host='localhost', port=None,
wsdl_url=None):
"""Constructs a VIM service client object.
:param protocol: http or https
:param host: server IP address or host name
:param port: port for connection
:param wsdl_url: VIM WSDL url
:raises: VimException, VimFaultException, VimAttributeException,
VimSessionOverLoadException, VimConnectionException
"""
base_url = service.Service.build_base_url(protocol, host, port)
soap_url = base_url + '/sdk'
if wsdl_url is None:
wsdl_url = soap_url + '/vimService.wsdl'
super(Vim, self).__init__(wsdl_url, soap_url)
def retrieve_service_content(self):
return self.RetrieveServiceContent(service.SERVICE_INSTANCE)
def __repr__(self):
return "VIM Object"
def __str__(self):
return "VIM Object"