def __init__(self, topic): super(AgentNotifierApi, self).__init__( topic=topic, default_version=self.BASE_RPC_API_VERSION) self.topic_network_delete = topics.get_topic_name( topic, topics.NETWORK, topics.DELETE) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE)
def __init__(self, topic): self.topic = topic self.topic_network_delete = topics.get_topic_name(topic, topics.NETWORK, topics.DELETE) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) self.topic_port_delete = topics.get_topic_name(topic, topics.PORT, topics.DELETE) target = oslo_messaging.Target(topic=topic, version="1.0") self.client = n_rpc.get_client(target)
def __init__(self, topic): target = oslo_messaging.Target( topic=topic, version=self.BASE_RPC_API_VERSION) self.client = n_rpc.get_client(target) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) self.topic_subnet_update = topics.get_topic_name(topic, topics.SUBNET, topics.UPDATE)
def __init__(self, topic=topics.SERVICEVM_AGENT): super(ServiceVMAgentNotifyApi, self).__init__( topic=topic, default_version=self.BASE_RPC_API_VERSION) self.topic_subnet_delete = topics.get_topic_name(topic, topics.SUBNET, topics.DELETE) self.topic_subnet_create = topics.get_topic_name(topic, topics.SUBNET, topics.CREATE) self.topic_subnet_update = topics.get_topic_name(topic, topics.SUBNET, topics.UPDATE)
def __init__(self, agent_type, connection, int_br=None, tun_br=None): """Create a new BaGPipe-BGP REST service client. :param agent_type: bagpipe-bgp agent type (Linux bridge or OVS) :param connection: RPC Connection :param int_br: OVS integration bridge :param tun_br: OVS tunnel bridge """ super(BaGPipeBGPAgent, self).__init__( cfg.CONF.BAGPIPE.bagpipe_bgp_ip, cfg.CONF.BAGPIPE.bagpipe_bgp_port, agent_type ) self.agent_type = agent_type self.ping_interval = cfg.CONF.BAGPIPE.ping_interval self.reg_attachments = defaultdict(list) self.gateway_info_for_net = defaultdict(default_gw_info) self.bagpipe_bgp_status = self.BAGPIPEBGP_DOWN self.seq_num = 0 # OVS-specific variables: if self.agent_type == n_const.AGENT_TYPE_OVS: self.int_br = int_br self.tun_br = tun_br self.setup_mpls_br(cfg.CONF.BAGPIPE.mpls_bridge) # RPC setpup if self.agent_type == n_const.AGENT_TYPE_LINUXBRIDGE: connection.create_consumer( topics.get_topic_name(topics.AGENT, topics_BAGPIPE, topics.UPDATE, cfg.CONF.host), [self], fanout=False ) else: LOG.info("bagpipe-l2 RPCs disabled for OVS bridge") connection.create_consumer( topics.get_topic_name(topics.AGENT, topics_BAGPIPE_BGPVPN, topics.UPDATE), [self], fanout=True ) connection.create_consumer( topics.get_topic_name(topics.AGENT, topics_BAGPIPE_BGPVPN, topics.UPDATE, cfg.CONF.host), [self], fanout=False, ) # Starts a greenthread for bagpipe-bgp status polling self._start_bagpipe_bgp_status_polling(self.ping_interval)
def __init__(self, topic): self.topic = topic self.topic_network_delete = topics.get_topic_name(topic, topics.NETWORK, topics.DELETE) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) self.topic_port_delete = topics.get_topic_name(topic, topics.PORT, topics.DELETE) self.topic_tunnel_update = topics.get_topic_name(topic, constants.TUNNEL, topics.UPDATE) target = messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target)
def set_port_type(self, context, ports_info): LOG.debug(_('set_port_type:%(ports_info)s'),{'ports_info':ports_info}) if not ports_info.get('host_id', None): return self.topic_sc_create = constants.SERVICECHAIN_AGENT_TOPIC hosts_flows = {} if not hosts_flows.has_key(ports_info['host_id']): hosts_flows[ports_info['host_id']] = [] hosts_flows[ports_info['host_id']].append(ports_info) for host in hosts_flows: LOG.debug(_('add flows to host %(host)s, flows:%(flows)s'), {'host':host, 'flows':hosts_flows[host]}) topic = topics.get_topic_name(self.topic, 'port_type', 'set', ports_info['host_id']) self.cast(context, self.make_msg('set_port_type', ports_info=hosts_flows[host]), topic=topic)
def create_consumers(endpoints, prefix, topic_details): """Create agent RPC consumers. :param endpoints: The list of endpoints to process the incoming messages. :param prefix: Common prefix for the plugin/agent message queues. :param topic_details: A list of topics. Each topic has a name, an operation, and an optional host param keying the subscription to topic.host for plugin calls. :returns: A common Connection. """ connection = n_rpc.create_connection(new=True) for details in topic_details: topic, operation, node_name = itertools.islice( itertools.chain(details, [None]), 3) topic_name = topics.get_topic_name(prefix, topic, operation) connection.create_consumer(topic_name, endpoints, fanout=True) if node_name: node_topic_name = '%s.%s' % (topic_name, node_name) connection.create_consumer(node_topic_name, endpoints, fanout=False) connection.consume_in_threads() return connection
def __init__(self, topic): super(AgentNotifierApi, self).__init__( topic=topic, default_version=self.BASE_RPC_API_VERSION) self.topic_info_update = topics.get_topic_name(topic, constants.INFO, topics.UPDATE)
def __init__(self, topic=topics.AGENT): self.topic = topic self.topic_l2pop_update = topics.get_topic_name(topic, topics.L2POPULATION, topics.UPDATE) target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target)
def __init__(self, topic=topics.AGENT): super(L2populationAgentNotifyAPI, self).__init__( topic=topic, default_version=self.BASE_RPC_API_VERSION) self.topic_l2pop_update = topics.get_topic_name(topic, topics.L2POPULATION, topics.UPDATE)
def test_delete_network(self): rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT) self._test_rpc_api(rpcapi, topics.get_topic_name(topics.AGENT, topics.NETWORK, topics.DELETE), 'network_delete', rpc_method='fanout_cast', network_id='fake_request_spec')
def test_tunnel_update(self): rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT) self._test_rpc_api(rpcapi, topics.get_topic_name(topics.AGENT, type_tunnel.TUNNEL, topics.UPDATE), 'tunnel_update', rpc_method='fanout_cast', tunnel_ip='fake_ip', tunnel_type='gre')
def test_tunnel_update(self): rpcapi = povs.AgentNotifierApi(topics.AGENT) self._test_ovs_api(rpcapi, topics.get_topic_name(topics.AGENT, constants.TUNNEL, topics.UPDATE), 'tunnel_update', rpc_method='fanout_cast', tunnel_ip='fake_ip', tunnel_id='fake_id')
def test_port_delete(self): rpcapi = ana.AgentNotifierApi(topics.AGENT) self._test_hyperv_neutron_api( rpcapi, topics.get_topic_name(topics.AGENT, topics.PORT, topics.DELETE), "port_delete", rpc_method="fanout_cast", port_id="port_id", )
def test_delete_network(self): rpcapi = ana.AgentNotifierApi(topics.AGENT) self._test_hyperv_neutron_api( rpcapi, topics.get_topic_name(topics.AGENT, topics.NETWORK, topics.DELETE), "network_delete", rpc_method="fanout_cast", network_id="fake_request_spec", )
def test_device_delete(self): rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT) self._test_rpc_api(rpcapi, topics.get_topic_name(topics.AGENT, ovsvapp_const.DEVICE, topics.DELETE), 'device_delete', rpc_method='call', network_info='fake_network_info', host=FAKE_HOST)
def __init__(self, topic=topics.AGENT): self.topic = topic self.topic_bgpvpn_update = topics.get_topic_name(self.topic, topics_BAGPIPE_BGPVPN, topics.UPDATE) target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target)
def ask_agent_to_delete_flow_rules(self, context, flows): LOG.debug('Ask agent on the specific host to delete flows ') LOG.debug('flows: %s', flows) host = flows.get('host') cctxt = self.client.prepare( topic=topics.get_topic_name( self.topic, sfc_topics.PORTFLOW, topics.DELETE), server=host) cctxt.cast(context, 'delete_flow_rules', flowrule_entries=flows)
def test_device_update(self): rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT) self._test_rpc_api( rpcapi, topics.get_topic_name(topics.AGENT, ovsvapp_rpc.DEVICE, topics.UPDATE), "device_update", rpc_method="fanout_cast", device_data="fake_device_data", )
def test_port_delete(self): rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT) self._test_rpc_api( rpcapi, topics.get_topic_name(topics.AGENT, topics.PORT, topics.DELETE), 'port_delete', rpc_method='cast', fanout=True, port_id='fake_port')
def enhanced_sg_provider_updated(self, context, network_id): sg_topic = ovsvapp_const.OVSVAPP + '_' + topics.SECURITY_GROUP cctxt = self.client.prepare( topic=topics.get_topic_name(self.topic, sg_topic, topics.UPDATE), fanout=True) cctxt.cast(context, 'enhanced_sg_provider_updated', network_id=network_id)
def test_enhanced_sg_provider_updated(self): rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT) self._test_rpc_api(rpcapi, topics.get_topic_name(topics.AGENT, self.sg_topic, topics.UPDATE), 'enhanced_sg_provider_updated', rpc_method='cast', fanout=True, network_id=FAKE_NETWORK_ID)
def test_delete_network(self): rpcapi = agent_notify_api.AgentNotifierApi(topics.AGENT) self._test_mlnx_api( rpcapi, topics.get_topic_name(topics.AGENT, topics.NETWORK, topics.DELETE), 'network_delete', rpc_method='cast', fanout=True, network_id='fake_request_spec')
def test_tunnel_update(self): rpcapi = ana.AgentNotifierApi(topics.AGENT) self._test_hyperv_neutron_api( rpcapi, topics.get_topic_name( topics.AGENT, constants.TUNNEL, topics.UPDATE), 'tunnel_update', rpc_method='cast', fanout=True, tunnel_ip='fake_ip', tunnel_id='fake_id')
def test_port_delete(self): rpcapi = ana.AgentNotifierApi(topics.AGENT) self._test_hyperv_neutron_api( rpcapi, topics.get_topic_name( topics.AGENT, topics.PORT, topics.DELETE), 'port_delete', rpc_method='cast', fanout=True, port_id='port_id')
def test_device_update(self): rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT) self._test_rpc_api(rpcapi, topics.get_topic_name(topics.AGENT, self.cluster_device_topic, topics.UPDATE), 'device_update', rpc_method='cast', fanout=True, device_data='fake_device_data', cluster_id=FAKE_CLUSTER_ID)
def test_tunnel_update(self): rpcapi = ana.AgentNotifierApi(topics.AGENT) self._test_hyperv_neutron_api( rpcapi, topics.get_topic_name(topics.AGENT, constants.TUNNEL, topics.UPDATE), "tunnel_update", rpc_method="fanout_cast", tunnel_ip="fake_ip", tunnel_id="fake_id", )
def test_tunnel_update(self): rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT) self._test_rpc_api( rpcapi, topics.get_topic_name(topics.AGENT, type_tunnel.TUNNEL, topics.UPDATE), "tunnel_update", rpc_method="fanout_cast", tunnel_ip="fake_ip", tunnel_type="gre", )
def test_device_delete(self): rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT) self._test_rpc_api(rpcapi, topics.get_topic_name(topics.AGENT, self.cluster_device_topic, topics.DELETE), 'device_delete', rpc_method='call', network_info='fake_network_info', host=FAKE_HOST, cluster_id=FAKE_CLUSTER_ID)
def test_port_update_old_agent(self): cfg.CONF.set_override('rpc_support_old_agents', True, 'AGENT') rpcapi = agent_notify_api.AgentNotifierApi(topics.AGENT) expected_msg = rpcapi.make_msg('port_update', port='fake_port', network_type='vlan', physical_network='fake_net', segmentation_id='fake_vlan_id', vlan_id='fake_vlan_id') self._test_mlnx_api(rpcapi, topics.get_topic_name(topics.AGENT, topics.PORT, topics.UPDATE), 'port_update', rpc_method='fanout_cast', expected_msg=expected_msg, port='fake_port', network_type='vlan', physical_network='fake_net', vlan_id='fake_vlan_id')
def teardown_connectivity_audit(self, context, audit_uuid, hostname): """ Call teardown_connectivity_audit for given host, or cast for all if none is specified. """ if hostname: topic_pnet_connectivity_call = topics.get_topic_name( self.topic, topics.PNET_CONNECTIVITY, topics.UPDATE, hostname) cctxt = self.client.prepare(topic=topic_pnet_connectivity_call, fanout=False) return cctxt.call(context, 'teardown_connectivity_audit', audit_uuid=audit_uuid) else: cctxt = self.client.prepare( topic=self.topic_pnet_connectivity_cast, fanout=True) cctxt.cast(context, 'teardown_connectivity_audit', audit_uuid=audit_uuid) return True
def delete_port_flows(self, context, flows): LOG.debug(_('delete_port_flows:%(flows)s'),{'flows':flows}) self.topic_sc_delete = constants.SERVICECHAIN_AGENT_TOPIC hosts_flows = {} if not hosts_flows.has_key(flows['host_id']): hosts_flows[flows['host_id']] = [] hosts_flows[flows['host_id']].append(flows) for host in hosts_flows: LOG.debug(_('add flows to host %(host)s, flows:%(flows)s'), {'host':host, 'flows':hosts_flows[host]}) topic = topics.get_topic_name(self.topic, 'port_flows', 'delete', flows['host_id']) self.cast(context, self.make_msg('delete_port_flows', port_flows=hosts_flows[host]), topic=topic)
def __init__(self, topic): target = oslo_messaging.Target(topic=topic, version=self.BASE_RPC_API_VERSION) self.client = n_rpc.get_client(target) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) self.topic_port_delete = topics.get_topic_name(topic, topics.PORT, topics.DELETE) self.topic_subnet_update = topics.get_topic_name( topic, topics.SUBNET, topics.UPDATE) self.topic_opflex_notify_vrf = topics.get_topic_name( topic, TOPIC_OPFLEX, NOTIFY_VRF, topics.UPDATE) self.topic_opflex_endpoint_update = topics.get_topic_name( topic, TOPIC_OPFLEX, ENDPOINT, topics.UPDATE) self.topic_opflex_vrf_update = topics.get_topic_name( topic, TOPIC_OPFLEX, VRF, topics.UPDATE)
def __init__(self, topic): self.topic = topic self.topic_network_delete = topics.get_topic_name( topic, topics.NETWORK, topics.DELETE) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) self.topic_port_delete = topics.get_topic_name(topic, topics.PORT, topics.DELETE) self.topic_network_update = topics.get_topic_name( topic, topics.NETWORK, topics.UPDATE) self.topic_subnet_create = topics.get_topic_name( topic, topics.SUBNET, topics.CREATE) self.topic_subnet_delete = topics.get_topic_name( topic, topics.SUBNET, topics.DELETE) target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target)
def _get_vm_link_update_topic(self, host=None): return topics.get_topic_name(self.topic, VM_LINK, topics.UPDATE, host)
def _topic(self, action=topics.CREATE, host=None): return topics.get_topic_name(topics.AGENT, aci_constants.ACI_TOPIC, action, host)
def _get_dvr_update_topic(self): return topics.get_topic_name(self.topic, topics.DVR, topics.UPDATE)
def __init__(self, topic): super(NECPluginV2AgentNotifierApi, self).__init__(topic=topic, default_version=self.BASE_RPC_API_VERSION) self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE)
def __init__(self, topic): self.topic = topic self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) target = messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target)
def _get_device_topic(self, action, cluster_id): cluster_device_topic = ovsvapp_utils.get_cluster_based_topic( cluster_id, ovsvapp_const.DEVICE) return topics.get_topic_name(self.topic, cluster_device_topic, action)
def _get_tunnel_delete_topic(self): return topics.get_topic_name(self.topic, TUNNEL, topics.DELETE)
def __init__(self, topic=topics.AGENT): target = oslo_messaging.Target(topic=topic, version='1.0') self.topic = topic self.client = n_rpc.get_client(target) self.topic_pnet_connectivity_cast = topics.get_topic_name( topic, topics.PNET_CONNECTIVITY, topics.UPDATE)
def test_fdb_add_called_two_networks(self): self._register_ml2_agents() with self.subnet(network=self._network) as subnet: host_arg = {portbindings.HOST_ID: HOST + '_2'} with self.port(subnet=subnet, device_owner=DEVICE_OWNER_COMPUTE, arg_list=(portbindings.HOST_ID,), **host_arg) as port1: with self.subnet(cidr='10.1.0.0/24') as subnet2: with self.port(subnet=subnet2, device_owner=DEVICE_OWNER_COMPUTE, arg_list=(portbindings.HOST_ID,), **host_arg): host_arg = {portbindings.HOST_ID: HOST} with self.port(subnet=subnet, device_owner=DEVICE_OWNER_COMPUTE, arg_list=(portbindings.HOST_ID,), **host_arg) as port3: p1 = port1['port'] p3 = port3['port'] device = 'tap' + p3['id'] self.mock_cast.reset_mock() self.mock_fanout.reset_mock() self.callbacks.update_device_up( self.adminContext, agent_id=HOST, device=device) p1_ips = [p['ip_address'] for p in p1['fixed_ips']] expected1 = {'args': {'fdb_entries': {p1['network_id']: {'ports': {'20.0.0.2': [constants.FLOODING_ENTRY, [p1['mac_address'], p1_ips[0]]]}, 'network_type': 'vxlan', 'segment_id': 1}}}, 'namespace': None, 'method': 'add_fdb_entries'} topic = topics.get_topic_name(topics.AGENT, topics.L2POPULATION, topics.UPDATE, HOST) self.mock_cast.assert_called_with(mock.ANY, expected1, topic=topic) p3_ips = [p['ip_address'] for p in p3['fixed_ips']] expected2 = {'args': {'fdb_entries': {p1['network_id']: {'ports': {'20.0.0.1': [constants.FLOODING_ENTRY, [p3['mac_address'], p3_ips[0]]]}, 'network_type': 'vxlan', 'segment_id': 1}}}, 'namespace': None, 'method': 'add_fdb_entries'} self.mock_fanout.assert_called_with( mock.ANY, expected2, topic=self.fanout_topic)
def __init__(self, topic=topics.PLUGIN): topic = topics.get_topic_name(topic, topics.L2POPULATION, l2pop_rpc.L2POP_QUERY) target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target)
def __init__(self, topic): target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target) self.topic_info_update = topics.get_topic_name(topic, constants.INFO, topics.UPDATE)
def __init__(self): self.topic_bagpipe_update = topics.get_topic_name( topics.AGENT, topics_BAGPIPE, topics.UPDATE) target = oslo_messaging.Target(topic=topics.AGENT, version='1.0') self.client = n_rpc.get_client(target)
def _get_vm_link_delete_topic(self, host=None): return topics.get_topic_name(self.topic, VM_LINK, topics.DELETE, host)
def _get_security_group_topic(self): return topics.get_topic_name(self.topic, topics.SECURITY_GROUP, topics.UPDATE)
def __init__(self, topic=topics.AGENT): target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target) self.topic_qos_update = topics.get_topic_name(topic, topics.QOS, topics.UPDATE)
def port_update(self, context, port): topic_port_update = topics.get_topic_name(self.client.target.topic, topics.PORT, topics.UPDATE) cctxt = self.client.prepare(fanout=True, topic=topic_port_update) cctxt.cast(context, 'port_update', port=port)
def __init__(self, topic=topics.AGENT): self.topic = topic self.topic_l2pop_update = topics.get_topic_name( topic, topics.L2POPULATION, topics.UPDATE) target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target)
def __init__(self, topic, agt_topic_tbl): super(MechDriversAgentNotifierApi, self).__init__( topic=topic, default_version=self.BASE_RPC_API_VERSION) self.topic_dfa_update = topics.get_topic_name(topic, agt_topic_tbl, topics.UPDATE)
def _get_ovs_network_update_topic(self, host=None): return topics.get_topic_name(self.topic, OVS_NETWORK, topics.UPDATE, host)
def _get_device_topic(self, host=None): return topics.get_topic_name(topics.AGENT, c_const.CUMULUS, topics.UPDATE, host)
def _get_ovs_network_delete_topic(self, host=None): return topics.get_topic_name(self.topic, OVS_NETWORK, topics.DELETE, host)
def _get_security_group_topic(self, host=None): return topics.get_topic_name(topics.AGENT, dvs_const.DVS, topics.UPDATE, host)
def _get_vm_link_create_topic(self, host=None): return topics.get_topic_name(self.topic, VM_LINK, topics.CREATE, host)
def _get_tunnel_update_topic(self): return topics.get_topic_name(self.topic, TUNNEL, topics.UPDATE)
def setUp(self): super(TestL2PopulationRpcTestCase, self).setUp() self.adminContext = context.get_admin_context() self.type_manager = managers.TypeManager() self.notifier = rpc.AgentNotifierApi(topics.AGENT) self.callbacks = rpc.RpcCallbacks(self.notifier, self.type_manager) net_arg = {pnet.NETWORK_TYPE: 'vxlan', pnet.SEGMENTATION_ID: '1'} self._network = self._make_network(self.fmt, 'net1', True, arg_list=( pnet.NETWORK_TYPE, pnet.SEGMENTATION_ID, ), **net_arg) net_arg = { pnet.NETWORK_TYPE: 'vlan', pnet.PHYSICAL_NETWORK: 'physnet1', pnet.SEGMENTATION_ID: '2' } self._network2 = self._make_network(self.fmt, 'net2', True, arg_list=( pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK, pnet.SEGMENTATION_ID, ), **net_arg) net_arg = {pnet.NETWORK_TYPE: 'flat', pnet.PHYSICAL_NETWORK: 'noagent'} self._network3 = self._make_network(self.fmt, 'net3', True, arg_list=( pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK, ), **net_arg) notifier_patch = mock.patch(NOTIFIER) notifier_patch.start() self.fanout_topic = topics.get_topic_name(topics.AGENT, topics.L2POPULATION, topics.UPDATE) fanout = ('neutron.plugins.ml2.drivers.l2pop.rpc.' 'L2populationAgentNotifyAPI._notification_fanout') fanout_patch = mock.patch(fanout) self.mock_fanout = fanout_patch.start() cast = ('neutron.plugins.ml2.drivers.l2pop.rpc.' 'L2populationAgentNotifyAPI._notification_host') cast_patch = mock.patch(cast) self.mock_cast = cast_patch.start() uptime = ('neutron.plugins.ml2.drivers.l2pop.db.get_agent_uptime') uptime_patch = mock.patch(uptime, return_value=190) uptime_patch.start()