def setUp(self): super(UtilsFakeTest, self).setUp() config.parse_power_config(['/etc/powervc/powervc.conf'], 'cinder') self.utils = FakeUtils() # get nova_client nova_fakeclient = PVCFakeNovaClient('r', 'p', 's', 'http://localhost:5000/') # delegate to nova extension class nova_client = delegate.new_composite_deletgate( [ext_nova.Client(nova_fakeclient), nova_fakeclient]) # get cinder client cinder_fakeclient = PVCFakeCinderClient('r', 'p') # delegate to nova extension class cinder_client = delegate.new_composite_deletgate( [ext_cinder.Client(cinder_fakeclient), cinder_fakeclient]) self.utils._novaclient = nova_client self.utils._cinderclient = cinder_client self.utils.scg_cache = SCGCache(nova_client) self.scg_id_list = ['sdfb541cb-f418-4b4b-3129-a814865023fs', 'f4b541cb-f418-4b4b-83b9-a8148650d4e9'] self.scg_name_list = ['Auto-SCG for Registered SAN', 'SCG Sample']
def main(): try: config.parse_power_config(sys.argv, 'powervc-neutron') logging_config.setup_logging(cfg.CONF) agent = RpcListener() agent.daemon_loop() sys.exit(0) except Exception: traceback.print_exc() raise
def test_parse_config_1(self): p1 = mock.patch('oslo.config.cfg.find_config_files', new=mock.MagicMock(return_value=["%s%s%s" % (os.path.dirname(__file__), os.sep, "powervc_test_1.conf")])) try: p1.start() config.parse_power_config([], "powervc-baseproject", None) # default value self.assertEqual(config.CONF.powervc.auth_url, "http://localhost:5000/v2.0/") # value in file self.assertEqual(config.CONF.powervc.qpid_port, 5679) finally: p1.stop()
def main(): try: config.parse_power_config(sys.argv, 'powervc-neutron') logging_config.setup_logging(cfg.CONF) LOG.info(_('Create RPC interface')) ctx = context.get_admin_context_without_session() rpc = RpcClient(ctx) LOG.info(_('Calling RPC method')) result = rpc.get_pvc_network_uuid('abc') LOG.info(_('Result from RPC call: %s'), result) sys.exit(0) except Exception: traceback.print_exc() raise
def test_parse_config_2(self): p2 = mock.patch('oslo.config.cfg.find_config_files', new=mock.MagicMock(side_effect=[["%s%s%s" % (os.path.dirname(__file__), os.sep, "powervc_test_1.conf")], ["%s%s%s" % (os.path.dirname(__file__), os.sep, "powervc_test_2.conf")]])) try: p2.start() config.parse_power_config([], "baseproject", None) # extend value in second file self.assertEqual(config.CONF.powervc.qpid_username, "powervc_qpid_2") finally: p2.stop()
def test_parse_config_1(self): p1 = mock.patch( 'oslo.config.cfg.find_config_files', new=mock.MagicMock(return_value=[ "%s%s%s" % (os.path.dirname(__file__), os.sep, "powervc_test_1.conf") ])) try: p1.start() config.parse_power_config([], "powervc-baseproject", None) # default value self.assertEqual(config.CONF.powervc.auth_url, "http://localhost:5000/v2.0/") # value in file self.assertEqual(config.CONF.powervc.staging_project_name, "Public") finally: p1.stop()
def _load_power_config(argv): """ Loads the powervc config. """ # Cinder is typically started with the --config-file option. # This prevents the default config files from loading since # the olso config code will only load those # config files as specified on the command line. # If the cinder is started with the # --config-file option then append our powervc.conf file to # the command line so it gets loaded as well. for arg in argv: if arg == '--config-file' or arg.startswith('--config-file='): argv[len(argv):] = ["--config-file"] + \ [cfg.find_config_files(project='powervc', prog='powervc')[0]] break config.parse_power_config(argv, 'cinder')
def test_parse_config_2(self): p2 = mock.patch( 'oslo.config.cfg.find_config_files', new=mock.MagicMock(side_effect=[[ "%s%s%s" % (os.path.dirname(__file__), os.sep, "powervc_test_1.conf") ], [ "%s%s%s" % (os.path.dirname(__file__), os.sep, "powervc_test_2.conf") ]])) try: p2.start() config.parse_power_config([], "baseproject", None) # extend value in second file self.assertEqual(config.CONF.powervc.staging_user, "admin") finally: p2.stop()
def parse_config(*args, **kwargs): rpc.set_defaults(control_exchange='nova') common_config.parse_power_config(*args, **kwargs) rpc.init(CONF)
# Copyright 2013 IBM Corp. """ Simple cinder client tests TODO: Convert to pyunit and use config file """ import powervc.common.constants as constants from powervc.common import config config.parse_power_config((), 'powervc') import powervc.common.client.factory as clients cinder_client = clients.POWERVC.new_client(str(constants.SERVICE_TYPES.volume)) print '=' * 10, 'Listing volumes', '=' * 10 vol_list = cinder_client.volumes.list() for vol in vol_list: print str(vol.display_name), str(vol.display_description), \ vol.id
def parse_config(*args, **kwargs): common_config.parse_power_config(*args, **kwargs)
# Copyright 2014 IBM Corp. from webob import exc from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova import compute from nova.i18n import _ from powervc.common import constants as common_constants from powervc.common import config config.parse_power_config([], 'nova') authorize = extensions.extension_authorizer('compute', 'host-maintenance-mode') class Controller(wsgi.Controller): """Controller class to show host maintenance mode and set host maintenance mode with evacuation operation """ def __init__(self, *args, **kwargs): super(Controller, self).__init__(*args, **kwargs) self.compute_api = compute.API() self.host_api = compute.HostAPI() from powervc.common.client import factory self.pvcclient = factory.POWERVC.new_client( str(common_constants.SERVICE_TYPES.compute)) @wsgi.extends def show(self, req, id): """Describe host-maintenance-mode by hostname.""" context = req.environ["nova.context"]