def mockPhysicalRouter(self, id): try: device = mock_physical_router_db[id] device_obj = PhysicalRouter( name=device['fq_name'][-1], display_name=device["display_name"], physical_router_role=device["physical_router_role"], routing_bridging_roles=RoutingBridgingRolesType( rb_role=device['routing_bridging_roles']), physical_router_user_credentials=UserCredentials( username='******', password='******'), fq_name=device["fq_name"], physical_router_vendor_name=device[ "physical_router_vendor_name"], physical_router_device_family=device[ "physical_router_device_family"], physical_router_product_name=device[ "physical_router_product_name"], physical_router_serial_number=device[ "physical_router_serial_number"], physical_router_management_ip=device[ "physical_router_management_ip"], physical_router_os_version=device["physical_router_os_version"] ) device_obj.uuid = id mock_prs[id]=device_obj self._vnc_lib.physical_router_create(device_obj) except RefsExistError: logger.info("Physical router {} already exists".format(id)) except Exception as ex: logger.error("ERROR creating physical router {}: {}".format(id, ex))
def mockFabricObj(self): fabric_obj = Fabric(name='fab01') fabric_obj.uuid = FAB_UUID1 fabric_obj.fq_name = [DGSC, 'fab01'] cred = UserCredentials(username='******', password='******') credentials = DeviceCredential(credential=cred) fabric_credentials = DeviceCredentialList( device_credential=[credentials]) fabric_obj.set_fabric_credentials(fabric_credentials) fabric_obj.set_annotations(KeyValuePairs([ KeyValuePair(key='cli_sync_input', value=mock_job_template_input_schema)])) return fabric_obj
def test_fabric_create(self): fabric_credentials = DeviceCredentialList(device_credential=[ DeviceCredential( credential=UserCredentials(username='******', password='******'), vendor='juniper', device_family='juniper')]) prop_map = {'name': 'f-{}'.format(self.id()), 'display_name': 'fabric test', 'parent_obj': self.gsc, 'parent_type': 'global-system-config', 'fabric_ztp': True, 'fabric_os_version': 'junos', 'fabric_credentials': fabric_credentials, 'fabric_enterprise_style': False, 'annotations': {}} obj = self.set_properties(Fabric(), prop_map) self.assertSchemaObjCreateOrUpdate(obj)
def mockFabric(self): try: fabric_obj = Fabric(name='fab01') fabric_obj.uuid = FAB_UUID1 fabric_obj.fq_name = [DGSC, 'fab01'] cred = UserCredentials(username='******', password='******') credentials = DeviceCredential(credential=cred) fabric_credentials = DeviceCredentialList( device_credential=[credentials]) fabric_obj.set_fabric_credentials(fabric_credentials) fabric_obj.set_annotations(KeyValuePairs([ KeyValuePair(key='cli_sync_input', value=mock_job_template_input_schema)])) self._vnc_lib.fabric_create(fabric_obj) except RefsExistError: logger.info("Fabric {} already exists".format('fab01')) except Exception as ex: logger.error("ERROR creating fabric {}: {}".format('fab01', ex))
def test_physical_router_create(self): dnsmasq = DnsmasqLeaseParameters( lease_expiry_time=100, client_id='4d972916-3204-11ea-a6fa-d7a3d77d36a2') auto_system = AutonomousSystemsType(asn=[294967295]) junos_service_ports = JunosServicePorts(service_port=['2010']) snmp_credentials = SNMPCredentials( version=1, local_port=8081, retries=3, timeout=300, v2_community='some_string', v3_security_name='some_string', v3_security_level='some_string', v3_security_engine_id='some_string', v3_context='some_string', v3_context_engine_id='some_string', v3_authentication_protocol='some_string', v3_authentication_password='******', v3_privacy_protocol='some_string', v3_privacy_password='******', v3_engine_id='some_string', v3_engine_boots=3, v3_engine_time=300) user_credentials = UserCredentials(username='******', password='******') routing_bridging_roles = RoutingBridgingRolesType(rb_roles=['CRB']) telemetry_info = TelemetryStateInfo(server_ip='10.100.0.100', server_port='8080', resource=[TelemetryResourceInfo()]) prop_map = { 'name': 'pr-{}'.format(self.id()), 'annotations': {}, 'parent_obj': self.gsc, 'parent_type': 'global-system-config', 'display_name': 'some_string', 'physical_router_autonomous_system': auto_system, 'physical_router_cli_commit_state': 'in_sync', 'physical_router_dataplane_ip': 'some_string', 'physical_router_device_family': 'some_string', 'physical_router_dhcp_parameters': dnsmasq, 'physical_router_encryption_type': 'none', 'physical_router_hostname': 'some_string', 'physical_router_junos_service_ports': junos_service_ports, 'physical_router_lldp': False, 'physical_router_loopback_ip': '127.0.0.1', 'physical_router_managed_state': 'dhcp', 'physical_router_management_ip': '10.100.100.255', 'physical_router_management_mac': 'some_string', 'physical_router_os_version': 'some_string', 'physical_router_product_name': 'some_string', 'physical_router_replicator_loopback_ip': 'some_string', 'physical_router_role': 'spine', 'physical_router_serial_number': 'some_string', 'physical_router_snmp': False, 'physical_router_snmp_credentials': snmp_credentials, 'physical_router_supplemental_config': 'some_string', 'physical_router_underlay_config': 'some_string', 'physical_router_underlay_managed': False, 'physical_router_user_credentials': user_credentials, 'physical_router_vendor_name': 'some_string', 'physical_router_vnc_managed': False, 'routing_bridging_roles': routing_bridging_roles, 'telemetry_info': telemetry_info } obj = self.set_properties(PhysicalRouter(), prop_map) self.assertSchemaObjCreateOrUpdate(obj)