Example #1
0
 def __init__(self, name="", keys="", inbox=None, datapath=None, args=None):
     super(CeilometerDriver, self).__init__(name, keys, inbox, datapath, args)
     datasource_driver.ExecutionDriver.__init__(self)
     session = ds_utils.get_keystone_session(args)
     self.ceilometer_client = cc.get_client(version="2", session=session)
     self.add_executable_client_methods(self.ceilometer_client, "ceilometerclient.v2.")
     self._init_end_start_poll()
Example #2
0
    def __init__(self, configs):
        super(ExecApiManager, self).__init__()
        self._exec_api_sessions = {}
        self._exec_api_endpoints = {}
        # state tracking the most recent state consisting of the union
        # of all the rows from all the _exec_api tables
        # used to determine which rows are new
        self._last_exec_api_state = set([])

        for config in configs:
            # FIXME(json_ingester): validate config
            if config.get('allow_exec_api', False) is True:
                auth_config = config.get('authentication')
                if auth_config is None:
                    session = requests.Session()
                    session.headers.update(
                        config.get('api_default_headers', {}))
                else:
                    if auth_config['type'] == 'keystone':
                        session = datasource_utils.get_keystone_session(
                            config['authentication']['config'],
                            headers=config.get('api_default_headers', {}))
                    else:
                        LOG.error('authentication type %s not supported.',
                                  auth_config.get['type'])
                        raise exception.BadConfig(
                            'authentication type {} not '
                            'supported.'.auth_config['type'])

                name = config['name']
                self._exec_api_endpoints[name] = config['api_endpoint']
                self._exec_api_sessions[name] = session
 def __init__(self, name='', args=None):
     super(NeutronV2QosDriver, self).__init__(name, args=args)
     self.creds = args
     session = ds_utils.get_keystone_session(self.creds)
     self.neutron = neutronclient.v2_0.client.Client(session=session)
     self.initialize_update_methods()
     self._init_end_start_poll()
Example #4
0
 def __init__(self, name='', keys='', inbox=None, datapath=None, args=None):
     super(GlanceV2Driver, self).__init__(name, keys, inbox, datapath, args)
     datasource_driver.ExecutionDriver.__init__(self)
     self.creds = args
     session = ds_utils.get_keystone_session(self.creds)
     self.glance = glclient.Client(session=session)
     self.add_executable_client_methods(self.glance, 'glanceclient.v2.')
     self._init_end_start_poll()
Example #5
0
 def __init__(self, name='', keys='', inbox=None, datapath=None, args=None):
     super(HeatV1Driver, self).__init__(name, keys, inbox, datapath, args)
     datasource_driver.ExecutionDriver.__init__(self)
     self.creds = args
     session = ds_utils.get_keystone_session(self.creds)
     endpoint = session.get_endpoint(service_type='orchestration',
                                     interface='publicURL')
     self.heat = heatclient.Client(session=session, endpoint=endpoint)
     self._init_end_start_poll()
 def __init__(self, name='', args=None):
     super(CeilometerDriver, self).__init__(name, args=args)
     datasource_driver.ExecutionDriver.__init__(self)
     session = ds_utils.get_keystone_session(args)
     self.ceilometer_client = cc.get_client(version='2', session=session)
     self.add_executable_client_methods(self.ceilometer_client,
                                        'ceilometerclient.v2.')
     self.initialize_update_method()
     self._init_end_start_poll()
Example #7
0
 def __init__(self, name='', keys='', inbox=None, datapath=None, args=None):
     super(IronicDriver, self).__init__(name, keys, inbox, datapath, args)
     datasource_driver.ExecutionDriver.__init__(self)
     self.creds = self.get_ironic_credentials(args)
     session = ds_utils.get_keystone_session(self.creds)
     self.ironic_client = client.get_client(session=session)
     self.add_executable_client_methods(self.ironic_client,
                                        'ironicclient.v1.')
     self._init_end_start_poll()
Example #8
0
 def __init__(self, name='', keys='', inbox=None, datapath=None, args=None):
     super(CinderDriver, self).__init__(name, keys, inbox, datapath, args)
     datasource_driver.ExecutionDriver.__init__(self)
     session = ds_utils.get_keystone_session(args)
     self.cinder_client = cinderclient.client.Client(version='2',
                                                     session=session)
     self.add_executable_client_methods(self.cinder_client,
                                        'cinderclient.v2.')
     self._init_end_start_poll()
Example #9
0
 def __init__(self, name='', args=None):
     super(TackerDriver, self).__init__(name, args=args)
     datasource_driver.ExecutionDriver.__init__(self)
     self.creds = args
     session = ds_utils.get_keystone_session(self.creds)
     self.tacker_client = tacker_client.Client(session=session)
     self.add_executable_client_methods(self.tacker_client,
                                        'tackerclient.v1_0.client')
     self.initialize_update_methods()
     self._init_end_start_poll()
Example #10
0
    def __init__(self, name='', args=None):
        super(MistralDriver, self).__init__(name, args=args)
        datasource_driver.ExecutionDriver.__init__(self)
        session = ds_utils.get_keystone_session(args)
        self.mistral_client = mistral_client.Client(session=session)

        self.add_executable_client_methods(
            self.mistral_client, 'mistralclient.api.v2.')
        self.initialize_update_method()
        self._init_end_start_poll()
Example #11
0
 def __init__(self, name='', args=None):
     super(AodhDriver, self).__init__(name, args=args)
     datasource_driver.ExecutionDriver.__init__(self)
     session = ds_utils.get_keystone_session(args)
     endpoint = session.get_endpoint(service_type='alarming',
                                     interface='publicURL')
     self.aodh_client = aodh_client.Client(version='2', session=session,
                                           endpoint_override=endpoint)
     self.add_executable_client_methods(self.aodh_client, 'aodhclient.v2.')
     self.initialize_update_method()
     self._init_end_start_poll()
Example #12
0
 def __init__(self, name='', args=None):
     super(IronicDriver, self).__init__(name, args)
     datasource_driver.ExecutionDriver.__init__(self)
     self.creds = self.get_ironic_credentials(args)
     session = ds_utils.get_keystone_session(self.creds)
     self.ironic_client = client.get_client(
         api_version=self.creds.get('api_version', '1'), session=session)
     self.add_executable_client_methods(self.ironic_client,
                                        'ironicclient.v1.')
     self.initialize_update_methods()
     self._init_end_start_poll()
Example #13
0
    def __init__(self, name='', args=None):
        super(MuranoDriver, self).__init__(name, args=args)
        datasource_driver.ExecutionDriver.__init__(self)
        self.creds = args
        session = datasource_utils.get_keystone_session(self.creds)
        client_version = "1"
        self.murano_client = muranoclient.client.Client(
            client_version, session=session, endpoint_type='publicURL',
            service_type='application-catalog')
        self.add_executable_client_methods(
            self.murano_client,
            'muranoclient.v1.')
        logger.debug("Successfully created murano_client")

        self.action_call_returns = []
        self._init_end_start_poll()
Example #14
0
 def _initialize_session(self):
     auth_config = self._config.get('authentication')
     if auth_config is None:
         self._session = requests.Session()
         self._session.headers.update(
             self._config.get('api_default_headers', {}))
     else:
         if auth_config['type'] == 'keystone':
             self._session = datasource_utils.get_keystone_session(
                 self._config['authentication']['config'],
                 headers=self._config.get('api_default_headers', {}))
         else:
             LOG.error('authentication type %s not supported.',
                       auth_config.get['type'])
             raise exception.BadConfig(
                 'authentication type {} not supported.'.format(
                     auth_config['type']))
Example #15
0
    def __init__(self,  name='', args=None):
        super(MonascaDriver, self).__init__(name, args=args)
        datasource_driver.ExecutionDriver.__init__(self)
        if not args.get('project_name'):
            args['project_name'] = args['tenant_name']

        # set default polling time to 1hr
        self.poll_time = int(args.get('poll_time', 3600))

        session = ds_utils.get_keystone_session(args)

        # if the endpoint not defined retrieved it from keystone catalog
        if 'endpoint' not in args:
            args['endpoint'] = session.get_endpoint(service_type='monitoring',
                                                    interface='publicURL')

        self.monasca = monasca_client.Client('2_0', session=session,
                                             endpoint=args['endpoint'])
        self.add_executable_client_methods(self.monasca, 'monascaclient.')
        self.initialize_update_methods()
        self._init_end_start_poll()
Example #16
0
 def __init__(self, name='', args=None):
     super(NovaDriver, self).__init__(name, args)
     datasource_driver.ExecutionDriver.__init__(self)
     self.creds = args
     session = ds_utils.get_keystone_session(self.creds)
     self.nova_client = novaclient.client.Client(
         version=self.creds.get('api_version', '2.26'), session=session)
     self.add_executable_method('servers_set_meta',
                                [{'name': 'server',
                                 'description': 'server id'},
                                 {'name': 'meta-key1',
                                  'description': 'meta key 1'},
                                 {'name': 'meta-value1',
                                  'description': 'value for meta key1'},
                                 {'name': 'meta-keyN',
                                  'description': 'meta key N'},
                                 {'name': 'meta-valueN',
                                  'description': 'value for meta keyN'}],
                                "A wrapper for servers.set_meta()")
     self.add_executable_client_methods(self.nova_client, 'novaclient.v2.')
     self.initialize_update_methods()
     self._init_end_start_poll()
Example #17
0
    def __init__(self, name='', args=None):
        super(NeutronV2Driver, self).__init__(name, args=args)
        datasource_driver.ExecutionDriver.__init__(self)
        self.creds = args
        session = ds_utils.get_keystone_session(self.creds)
        self.neutron = neutronclient.v2_0.client.Client(session=session)

        # specify the arg name for all method structured args
        self.method_structured_args = {
            'add_bgp_speaker_to_dragent': {'named': frozenset(['body'])},
            'add_gateway_router': {'named': frozenset(['body'])},
            'add_interface_router': {'named': frozenset(['body'])},
            'add_network_to_bgp_speaker': {'named': frozenset(['body'])},
            'add_network_to_dhcp_agent': {'named': frozenset(['body'])},
            'add_peer_to_bgp_speaker': {'named': frozenset(['body'])},
            'add_router_to_l3_agent': {'named': frozenset(['body'])},
            'associate_flavor': {'named': frozenset(['body'])},
            'associate_health_monitor': {'named': frozenset(['body'])},
            'connect_network_gateway': {'named': frozenset(['body'])},
            'create_address_scope': {'named': frozenset(['body'])},
            'create_bandwidth_limit_rule': {'named': frozenset(['body'])},
            'create_bgp_peer': {'named': frozenset(['body'])},
            'create_bgp_speaker': {'named': frozenset(['body'])},
            'create_bgpvpn': {'named': frozenset(['body'])},
            'create_bgpvpn_network_assoc': {'named': frozenset(['body'])},
            'create_bgpvpn_port_assoc': {'named': frozenset(['body'])},
            'create_bgpvpn_router_assoc': {'named': frozenset(['body'])},
            'create_dscp_marking_rule': {'named': frozenset(['body'])},
            'create_endpoint_group': {'named': frozenset(['body'])},
            'create_ext': {'named': frozenset(['body'])},
            'create_firewall': {'named': frozenset(['body'])},
            'create_firewall_policy': {'named': frozenset(['body'])},
            'create_firewall_rule': {'named': frozenset(['body'])},
            'create_flavor': {'named': frozenset(['body'])},
            'create_floatingip': {'named': frozenset(['body'])},
            'create_fwaas_firewall_group': {'named': frozenset(['body'])},
            'create_fwaas_firewall_policy': {'named': frozenset(['body'])},
            'create_fwaas_firewall_rule': {'named': frozenset(['body'])},
            'create_gateway_device': {'named': frozenset(['body'])},
            'create_health_monitor': {'named': frozenset(['body'])},
            'create_ikepolicy': {'named': frozenset(['body'])},
            'create_ipsec_site_connection': {'named': frozenset(['body'])},
            'create_ipsecpolicy': {'named': frozenset(['body'])},
            'create_lbaas_healthmonitor': {'named': frozenset(['body'])},
            'create_lbaas_l7policy': {'named': frozenset(['body'])},
            'create_lbaas_l7rule': {'named': frozenset(['body'])},
            'create_lbaas_member': {'named': frozenset(['body'])},
            'create_lbaas_pool': {'named': frozenset(['body'])},
            'create_listener': {'named': frozenset(['body'])},
            'create_loadbalancer': {'named': frozenset(['body'])},
            'create_member': {'named': frozenset(['body'])},
            'create_metering_label': {'named': frozenset(['body'])},
            'create_metering_label_rule': {'named': frozenset(['body'])},
            'create_minimum_bandwidth_rule': {'named': frozenset(['body'])},
            'create_network': {'named': frozenset(['body'])},
            'create_network_gateway': {'named': frozenset(['body'])},
            'create_network_log': {'named': frozenset(['body'])},
            'create_pool': {'named': frozenset(['body'])},
            'create_port': {'named': frozenset(['body'])},
            'create_qos_policy': {'named': frozenset(['body'])},
            'create_qos_queue': {'named': frozenset(['body'])},
            'create_rbac_policy': {'named': frozenset(['body'])},
            'create_router': {'named': frozenset(['body'])},
            'create_security_group': {'named': frozenset(['body'])},
            'create_security_group_rule': {'named': frozenset(['body'])},
            'create_service_profile': {'named': frozenset(['body'])},
            'create_sfc_flow_classifier': {'named': frozenset(['body'])},
            'create_sfc_port_chain': {'named': frozenset(['body'])},
            'create_sfc_port_pair': {'named': frozenset(['body'])},
            'create_sfc_port_pair_group': {'named': frozenset(['body'])},
            'create_sfc_service_graph': {'named': frozenset(['body'])},
            'create_subnet': {'named': frozenset(['body'])},
            'create_subnetpool': {'named': frozenset(['body'])},
            'create_trunk': {'named': frozenset(['body'])},
            'create_vip': {'named': frozenset(['body'])},
            'create_vpnservice': {'named': frozenset(['body'])},
            'disconnect_network_gateway': {'named': frozenset(['body'])},
            'firewall_policy_insert_rule': {'named': frozenset(['body'])},
            'firewall_policy_remove_rule': {'named': frozenset(['body'])},
            'insert_rule_fwaas_firewall_policy': {
                'named': frozenset(['body'])},
            'remove_interface_router': {'named': frozenset(['body'])},
            'remove_network_from_bgp_speaker': {'named': frozenset(['body'])},
            'remove_peer_from_bgp_speaker': {'named': frozenset(['body'])},
            'remove_rule_fwaas_firewall_policy': {
                'named': frozenset(['body'])},
            'replace_tag': {'named': frozenset(['body'])},
            'retry_request': {'named': frozenset(['body'])},
            'show_minimum_bandwidth_rule': {'named': frozenset(['body'])},
            'trunk_add_subports': {'named': frozenset(['body'])},
            'trunk_remove_subports': {'named': frozenset(['body'])},
        }

        self.add_executable_method('update_resource_attrs',
                                   [{'name': 'resource_type',
                                     'description': 'resource type (e.g. ' +
                                                    'port, network, subnet)'},
                                    {'name': 'id',
                                     'description': 'ID of the resource'},
                                    {'name': 'attr1',
                                     'description': 'attribute name to ' +
                                     'update (e.g. admin_state_up)'},
                                    {'name': 'attr1-value',
                                     'description': 'updated attr1 value'},
                                    {'name': 'attrN',
                                     'description': 'attribute name to ' +
                                     'update'},
                                    {'name': 'attrN-value',
                                     'description': 'updated attrN value'}],
                                   "A wrapper for update_<resource_type>()")
        self.add_executable_method('attach_port_security_group',
                                   [{'name': 'port_id',
                                     'description': 'ID of target port'},
                                    {'name': 'security_group_id',
                                     'description': 'ID security group to be '
                                                    'attached'}],
                                   "Attach a security group to port (WARNING: "
                                   "may overwrite concurrent changes to "
                                   "port's security groups list.")
        self.add_executable_method('detach_port_security_group',
                                   [{'name': 'port_id',
                                     'description': 'ID of target port'},
                                    {'name': 'security_group_id',
                                     'description': 'ID security group to be '
                                                    'detached'}],
                                   "Detach a security group to port (WARNING: "
                                   "may overwrite concurrent changes to "
                                   "port's security groups list.")

        # add action methods from client, but exclude 'update_*' because those
        # are covered by the update_resource_attr method.
        exclude_methods = ['update_address_scope', 'update_agent',
                           'update_bandwidth_limit_rule', 'update_bgp_peer',
                           'update_bgp_speaker', 'update_bgpvpn',
                           'update_bgpvpn_network_assoc',
                           'update_bgpvpn_port_assoc',
                           'update_bgpvpn_router_assoc',
                           'update_dscp_marking_rule', 'update_endpoint_group',
                           'update_ext', 'update_firewall',
                           'update_firewall_policy', 'update_firewall_rule',
                           'update_flavor', 'update_floatingip',
                           'update_fwaas_firewall_group',
                           'update_fwaas_firewall_policy',
                           'update_fwaas_firewall_rule',
                           'update_gateway_device', 'update_health_monitor',
                           'update_ikepolicy', 'update_ipsec_site_connection',
                           'update_ipsecpolicy', 'update_lbaas_healthmonitor',
                           'update_lbaas_l7policy', 'update_lbaas_l7rule',
                           'update_lbaas_member', 'update_lbaas_pool',
                           'update_listener', 'update_loadbalancer',
                           'update_member', 'update_minimum_bandwidth_rule',
                           'update_network', 'update_network_gateway',
                           'update_network_log', 'update_pool', 'update_port',
                           'update_qos_policy', 'update_quota',
                           'update_rbac_policy', 'update_router',
                           'update_security_group', 'update_service_profile',
                           'update_sfc_flow_classifier',
                           'update_sfc_port_chain', 'update_sfc_port_pair',
                           'update_sfc_port_pair_group',
                           'update_sfc_service_graph', 'update_subnet',
                           'update_subnetpool', 'update_trunk', 'update_vip',
                           'update_vpnservice']
        self.add_executable_client_methods(self.neutron,
                                           'neutronclient.v2_0.client',
                                           exclude_methods)
        self.initialize_update_methods()
        self._init_end_start_poll()