def __init__(self, api_url, advertise_address, listen_address,
              ip_lookup_attempts, ip_lookup_sleep, network_interface,
              lookup_timeout, lookup_interval, driver_name):
     super(IronicPythonAgent, self).__init__()
     self.ext_mgr = extension.ExtensionManager(
         namespace='ironic_python_agent.extensions',
         invoke_on_load=True,
         propagate_map_exceptions=True,
     )
     self.api_url = api_url
     self.driver_name = driver_name
     self.api_client = ironic_api_client.APIClient(self.api_url,
                                                   self.driver_name)
     self.listen_address = listen_address
     self.advertise_address = advertise_address
     self.version = pkg_resources.get_distribution('ironic-python-agent')\
         .version
     self.api = app.VersionSelectorApplication(self)
     self.heartbeater = IronicPythonAgentHeartbeater(self)
     self.heartbeat_timeout = None
     self.hardware = hardware.get_manager()
     self.log = log.getLogger(__name__)
     self.started_at = None
     self.node = None
     # lookup timeout in seconds
     self.lookup_timeout = lookup_timeout
     self.lookup_interval = lookup_interval
     self.ip_lookup_attempts = ip_lookup_attempts
     self.ip_lookup_sleep = ip_lookup_sleep
     self.network_interface = network_interface
Exemple #2
0
 def __init__(self, api_url, advertise_address, listen_address,
              ip_lookup_attempts, ip_lookup_sleep, network_interface,
              lookup_timeout, lookup_interval, standalone,
              hardware_initialization_delay=0):
     super(IronicPythonAgent, self).__init__()
     if bool(cfg.CONF.keyfile) != bool(cfg.CONF.certfile):
         LOG.warning("Only one of 'keyfile' and 'certfile' options is "
                     "defined in config file. Its value will be ignored.")
     self.ext_mgr = extension.ExtensionManager(
         namespace='ironic_python_agent.extensions',
         invoke_on_load=True,
         propagate_map_exceptions=True,
         invoke_kwds={'agent': self},
     )
     self.api_url = api_url
     if self.api_url:
         self.api_client = ironic_api_client.APIClient(self.api_url)
         self.heartbeater = IronicPythonAgentHeartbeater(self)
     self.listen_address = listen_address
     self.advertise_address = advertise_address
     self.version = pkg_resources.get_distribution('ironic-python-agent')\
         .version
     self.api = app.VersionSelectorApplication(self)
     self.heartbeat_timeout = None
     self.started_at = None
     self.node = None
     # lookup timeout in seconds
     self.lookup_timeout = lookup_timeout
     self.lookup_interval = lookup_interval
     self.ip_lookup_attempts = ip_lookup_attempts
     self.ip_lookup_sleep = ip_lookup_sleep
     self.network_interface = network_interface
     self.standalone = standalone
     self.hardware_initialization_delay = hardware_initialization_delay
Exemple #3
0
 def setUp(self):
     super(TestBaseIronicPythonAgent, self).setUp()
     self.api_client = ironic_api_client.APIClient(API_URL)
     self.hardware_info = {
         'interfaces': [
             hardware.NetworkInterface('eth0',
                                       '00:0c:29:8c:11:b1',
                                       vendor='0x15b3',
                                       product='0x1014'),
             hardware.NetworkInterface('eth1',
                                       '00:0c:29:8c:11:b2',
                                       lldp=[
                                           (1, '04885a92ec5459'),
                                           (2, '0545746865726e6574312f3138')
                                       ],
                                       vendor='0x15b3',
                                       product='0x1014'),
         ],
         'cpu':
         hardware.CPU('Awesome Jay CPU x10 9001', '9001', '10', 'ARMv9'),
         'disks': [
             hardware.BlockDevice('/dev/sdj', 'small', '9001', False),
             hardware.BlockDevice('/dev/hdj', 'big', '9002', False),
         ],
         'memory':
         hardware.Memory(total='8675309', physical_mb='8675'),
     }
    def __init__(self,
                 api_url,
                 advertise_address,
                 listen_address,
                 ip_lookup_attempts,
                 ip_lookup_sleep,
                 network_interface,
                 lookup_timeout,
                 lookup_interval,
                 standalone,
                 hardware_initialization_delay=0):
        super(IronicPythonAgent, self).__init__()
        if bool(cfg.CONF.keyfile) != bool(cfg.CONF.certfile):
            LOG.warning("Only one of 'keyfile' and 'certfile' options is "
                        "defined in config file. Its value will be ignored.")
        self.ext_mgr = extension.ExtensionManager(
            namespace='ironic_python_agent.extensions',
            invoke_on_load=True,
            propagate_map_exceptions=True,
            invoke_kwds={'agent': self},
        )
        self.api_url = api_url
        if not self.api_url or self.api_url == 'mdns':
            try:
                self.api_url, params = mdns.get_endpoint('baremetal')
            except lib_exc.ServiceLookupFailure:
                if self.api_url:
                    # mDNS explicitly requested, report failure.
                    raise
                else:
                    # implicit fallback to mDNS, do not fail (maybe we're only
                    # running inspection).
                    LOG.warning('Could not get baremetal endpoint from mDNS, '
                                'will not heartbeat')
            else:
                config.override(params)

        if self.api_url:
            self.api_client = ironic_api_client.APIClient(self.api_url)
            self.heartbeater = IronicPythonAgentHeartbeater(self)
        self.listen_address = listen_address
        self.advertise_address = advertise_address
        self.version = pkg_resources.get_distribution('ironic-python-agent')\
            .version
        self.api = app.VersionSelectorApplication(self)
        self.heartbeat_timeout = None
        self.started_at = None
        self.node = None
        # lookup timeout in seconds
        self.lookup_timeout = lookup_timeout
        self.lookup_interval = lookup_interval
        self.ip_lookup_attempts = ip_lookup_attempts
        self.ip_lookup_sleep = ip_lookup_sleep
        self.network_interface = network_interface
        self.standalone = standalone
        self.hardware_initialization_delay = hardware_initialization_delay
        # IPA will stop serving requests and exit after this is set to False
        self.serve_api = True
        self.iscsi_started = False
 def __init__(self, agent):
     super(IronicPythonAgentHeartbeater, self).__init__()
     self.agent = agent
     self.hardware = hardware.get_manager()
     self.api = ironic_api_client.APIClient(agent.api_url,
                                            agent.driver_name)
     self.log = log.getLogger(__name__)
     self.stop_event = threading.Event()
     self.error_delay = self.initial_delay
    def __init__(self, agent):
        """Initialize the heartbeat thread.

        :param agent: an :class:`ironic_python_agent.agent.IronicPythonAgent`
                      instance.
        """
        super(IronicPythonAgentHeartbeater, self).__init__()
        self.agent = agent
        self.api = ironic_api_client.APIClient(agent.api_url,
                                               agent.driver_name)
        self.error_delay = self.initial_delay
        self.reader = None
        self.writer = None
    def __init__(self, agent):
        """Initialize the heartbeat thread.

        :param agent: an :class:`ironic_python_agent.agent.IronicPythonAgent`
                      instance.
        """
        super(IronicPythonAgentHeartbeater, self).__init__()
        self.agent = agent
        self.hardware = hardware.get_manager()
        self.api = ironic_api_client.APIClient(agent.api_url,
                                               agent.driver_name)
        self.log = log.getLogger(__name__)
        self.stop_event = threading.Event()
        self.error_delay = self.initial_delay
Exemple #8
0
 def setUp(self):
     super(TestBaseIronicPythonAgent, self).setUp()
     self.api_client = ironic_api_client.APIClient(API_URL, DRIVER)
     self.hardware_info = {
         'interfaces': [
             hardware.NetworkInterface('eth0', '00:0c:29:8c:11:b1'),
             hardware.NetworkInterface('eth1', '00:0c:29:8c:11:b2'),
         ],
         'cpu': hardware.CPU('Awesome Jay CPU x10 9001', '9001', '10',
                             'ARMv9'),
         'disks': [
             hardware.BlockDevice('/dev/sdj', 'small', '9001', False),
             hardware.BlockDevice('/dev/hdj', 'big', '9002', False),
         ],
         'memory': hardware.Memory(total='8675309',
                                   physical_mb='8675'),
     }
Exemple #9
0
    def __init__(self,
                 api_url,
                 advertise_address,
                 listen_address,
                 ip_lookup_attempts,
                 ip_lookup_sleep,
                 network_interface,
                 lookup_timeout,
                 lookup_interval,
                 standalone,
                 agent_token,
                 hardware_initialization_delay=0,
                 advertise_protocol='http'):
        super(IronicPythonAgent, self).__init__()
        if bool(cfg.CONF.keyfile) != bool(cfg.CONF.certfile):
            LOG.warning("Only one of 'keyfile' and 'certfile' options is "
                        "defined in config file. Its value will be ignored.")
        self.ext_mgr = base.init_ext_manager(self)
        self.api_url = api_url
        if (not self.api_url or self.api_url == 'mdns') and not standalone:
            try:
                self.api_url, params = mdns.get_endpoint('baremetal')
            except lib_exc.ServiceLookupFailure:
                if self.api_url:
                    # mDNS explicitly requested, report failure.
                    raise
                else:
                    # implicit fallback to mDNS, do not fail (maybe we're only
                    # running inspection).
                    LOG.warning('Could not get baremetal endpoint from mDNS, '
                                'will not heartbeat')
            else:
                config.override(params)

        if self.api_url:
            self.api_client = ironic_api_client.APIClient(self.api_url)
            self.heartbeater = IronicPythonAgentHeartbeater(self)
        self.listen_address = listen_address
        self.advertise_address = advertise_address
        self.advertise_protocol = advertise_protocol
        self.version = pkg_resources.get_distribution('ironic-python-agent')\
            .version
        self.api = app.Application(self, cfg.CONF)
        self.heartbeat_timeout = None
        self.started_at = None
        self.node = None
        # lookup timeout in seconds
        self.lookup_timeout = lookup_timeout
        self.lookup_interval = lookup_interval
        self.ip_lookup_attempts = ip_lookup_attempts
        self.ip_lookup_sleep = ip_lookup_sleep
        self.network_interface = network_interface
        self.standalone = standalone
        self.hardware_initialization_delay = hardware_initialization_delay
        # IPA will stop serving requests and exit after this is set to False
        self.serve_api = True
        self.agent_token = agent_token
        # Allows this to be turned on by the conductor while running,
        # in the event of long running ramdisks where the conductor
        # got upgraded somewhere along the way.
        self.agent_token_required = cfg.CONF.agent_token_required
        self.iscsi_started = False