class Configuration(ResourceBase): identity_attributes = t.identity( ('key', t.string(52)), ('host', t.string(52)), ('group', t.string(52))) other_attributes = t.other(('value', t.string(512))) db_attributes = t.db(('version', t.string(36))) def __init__(self, **kwargs): super(Configuration, self).__init__({}, **kwargs)
class FilterEntry(AciResourceBase): """Resource representing a classifier entry of a filter in ACI. Identity attributes: name of ACI tenant, name of filter and name of entry. Values for classification fields may be integers as per standards (e.g. ip_protocol = 6 for TCP, 17 for UDP), or special strings listed below. UNSPECIFIED may be used to indicate that a particular field should be ignored. Field | Special string values -------------------------------------------------------------------------- arp_opcode | req, reply ether_type | trill, arp, mpls_ucast, mac_security, fcoe, ip ip_protocol | icmp, igmp, tcp, egp, igp, udp, icmpv6, eigrp, ospfigp icmpv4_type | echo-rep, dst-unreach, src-quench, echo, time-exceeded icmpv6_type | dst-unreach, time-exceeded, echo-req, echo-rep, | nbr-solicit, nbr-advert, redirect source_from_port, | ftpData, smtp, dns, http, pop3, https, rtsp source_to_port, | dest_from_port, | dest_to_port | tcp_flags | est, syn, ack, fin, rst """ identity_attributes = t.identity(('tenant_name', t.name), ('filter_name', t.name), ('name', t.name)) other_attributes = t.other( ('display_name', t.name), ('arp_opcode', t.string()), ('ether_type', t.string()), ('ip_protocol', t.string()), ('icmpv4_type', t.string()), ('icmpv6_type', t.string()), ('source_from_port', t.port), ('source_to_port', t.port), ('dest_from_port', t.port), ('dest_to_port', t.port), ('tcp_flags', t.string()), ('stateful', t.bool), ('fragment_only', t.bool), ('monitored', t.bool)) _aci_mo_name = 'vzEntry' _tree_parent = Filter def __init__(self, **kwargs): super(FilterEntry, self).__init__( { 'arp_opcode': self.UNSPECIFIED, 'ether_type': self.UNSPECIFIED, 'ip_protocol': self.UNSPECIFIED, 'icmpv4_type': self.UNSPECIFIED, 'icmpv6_type': self.UNSPECIFIED, 'source_from_port': self.UNSPECIFIED, 'source_to_port': self.UNSPECIFIED, 'dest_from_port': self.UNSPECIFIED, 'dest_to_port': self.UNSPECIFIED, 'tcp_flags': self.UNSPECIFIED, 'stateful': False, 'fragment_only': False, 'monitored': False }, **kwargs)
class Topology(AciRoot): identity_attributes = t.identity() other_attributes = t.other( ('name', t.name)) _aci_mo_name = 'fabricTopology' _tree_parent = None def __init__(self, **kwargs): super(Topology, self).__init__({}, name='topology', monitored=True)
class HostLinkNetworkLabel(resource.ResourceBase): """A network label to host link""" identity_attributes = t.identity(('host_name', t.string(128)), ('network_label', t.string(64)), ('interface_name', t.string(32))) other_attributes = t.other() def __init__(self, **kwargs): super(HostLinkNetworkLabel, self).__init__({}, **kwargs)
class VMMPolicy(AciRoot): identity_attributes = t.identity( ('type', t.enum("VMWare", "OpenStack", "Kubernetes"))) other_attributes = t.other(('monitored', t.bool), ('display_name', t.name)) _aci_mo_name = 'vmmProvP' _tree_parent = None def __init__(self, **kwargs): super(VMMPolicy, self).__init__({'monitored': False}, **kwargs)
class Agent(ResourceBase): """Resource representing an AIM Agent""" identity_attributes = t.identity(('id', t.id)) other_attributes = t.other( ('agent_type', t.string(255)), ('host', t.string(255)), ('binary_file', t.string(255)), ('admin_state_up', t.bool), ('description', t.string(255)), ('hash_trees', t.list_of_ids), ('version', t.string())) # Attrbutes completely managed by the DB (eg. timestamps) db_attributes = t.db(('heartbeat_timestamp', t.string())) def __init__(self, **kwargs): super(Agent, self).__init__({'admin_state_up': True, 'id': utils.generate_uuid()}, **kwargs) def __eq__(self, other): return self.id == other.id # An object is hashable if it has a hash value which never changes during # its lifetime (it needs a __hash__() method), and can be compared to # other objects (it needs an __eq__() or __cmp__() method). # Hashable objects which compare equal must have the same hash value. # # If you define __eq__() , the default __hash__() (namely, hashing the # address of the object in memory) goes away. # So for each class defining __eq__() we must also # define __hash__() even though parent class has __hash__(). def __hash__(self): return super(Agent, self).__hash__() def is_down(self, context): current = context.store.current_timestamp # When the store doesn't support timestamps the agent can never # be considered down. if current is None: return False result = current - self.heartbeat_timestamp >= datetime.timedelta( seconds=cfg.CONF.aim.agent_down_time) if result: LOG.warn("Agent %s is down. Last heartbeat was %s" % (self.id, self.heartbeat_timestamp)) else: LOG.debug("Agent %s is alive, its last heartbeat was %s" % (self.id, self.heartbeat_timestamp)) return result def down_time(self, context): if self.is_down(context): current = context.store.current_timestamp return (current - self.heartbeat_timestamp).seconds
class EndpointGroup(AciResourceBase): """Resource representing an endpoint-group in ACI. Identity attributes: name of ACI tenant, name of application-profile and name of endpoint-group. Attribute 'static_paths' is a list of dicts with the following keys: * path: (Required) path-name of the switch-port which is bound to EndpointGroup * encap: (Required) encapsulation mode and identifier for this EndpointGroup on the specified switch-port. Must be specified in the format 'vlan-<vlan-id>' for VLAN encapsulation """ identity_attributes = t.identity( ('tenant_name', t.name), ('app_profile_name', t.name), ('name', t.name)) other_attributes = t.other( ('display_name', t.name), ('bd_name', t.name), ('policy_enforcement_pref', t.enum("", "enfFAorced", "unenforced")), ('provided_contract_names', t.list_of_names), ('consumed_contract_names', t.list_of_names), ('openstack_vmm_domain_names', t.list_of_names), ('physical_domain_names', t.list_of_names), ('vmm_domains', t.list_of_dicts(('type', t.name), ('name', t.name))), ('physical_domains', t.list_of_dicts(('name', t.name))), ('static_paths', t.list_of_static_paths), ('epg_contract_masters', t.list_of_dicts(('app_profile_name', t.name), ('name', t.name))), ('monitored', t.bool), ('sync', t.bool)) _aci_mo_name = 'fvAEPg' _tree_parent = ApplicationProfile POLICY_UNENFORCED = 'unenforced' POLICY_ENFORCED = 'enforced' def __init__(self, **kwargs): super(EndpointGroup, self).__init__({'bd_name': '', 'provided_contract_names': [], 'consumed_contract_names': [], 'openstack_vmm_domain_names': [], 'physical_domain_names': [], 'vmm_domains': [], 'physical_domains': [], 'policy_enforcement_pref': self.POLICY_UNENFORCED, 'static_paths': [], 'epg_contract_masters': [], 'monitored': False, 'sync': True}, **kwargs)
class HostDomainMappingV2(resource.ResourceBase): """host to VMM and phys-dom mapping, version 2""" identity_attributes = t.identity( ('host_name', t.string(128)), ('domain_name', t.string(64)), ('domain_type', t.enum('PhysDom', 'OpenStack', 'Kubernetes', 'VMware'))) other_attributes = t.other() def __init__(self, **kwargs): super(HostDomainMappingV2, self).__init__({}, **kwargs)
class Pod(AciResourceBase): root = 'topology' identity_attributes = t.identity(('name', t.name)) other_attributes = t.other(('monitored', t.bool)) _aci_mo_name = 'fabricPod' _tree_parent = Topology def __init__(self, **kwargs): super(Pod, self).__init__({'monitored': False}, **kwargs)
class HostDomainMapping(resource.ResourceBase): """host to VMM and phys-dom mapping""" identity_attributes = t.identity( ('host_name', t.string(128))) other_attributes = t.other( ('vmm_domain_name', t.string(64)), ('physical_domain_name', t.string(64))) def __init__(self, **kwargs): super(HostDomainMapping, self).__init__({'vmm_domain_name': '', 'physical_domain_name': ''}, **kwargs)
class SecurityGroup(AciResourceBase): """Resource representing a Security Group in ACI. Identity attributes: name of ACI tenant and name of security group """ identity_attributes = t.identity(('tenant_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('monitored', t.bool)) _aci_mo_name = 'hostprotPol' _tree_parent = Tenant def __init__(self, **kwargs): super(SecurityGroup, self).__init__({'monitored': False}, **kwargs)
class PhysicalDomain(AciRoot): """Resource representing a Physical domain. Identity attributes: name """ identity_attributes = t.identity(('name', t.name)) other_attributes = t.other(('monitored', t.bool), ('display_name', t.name)) _aci_mo_name = 'physDomP' _tree_parent = None def __init__(self, **kwargs): super(PhysicalDomain, self).__init__({'monitored': False}, **kwargs)
class Filter(AciResourceBase): """Resource representing a contract filter in ACI. Identity attributes: name of ACI tenant and name of filter. """ identity_attributes = t.identity(('tenant_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('monitored', t.bool)) _aci_mo_name = 'vzFilter' _tree_parent = Tenant def __init__(self, **kwargs): super(Filter, self).__init__({'monitored': False}, **kwargs)
class ApplicationProfile(AciResourceBase): """Resource representing an application-profile in ACI. Identity attributes: name of ACI tenant, name of app-profile. """ identity_attributes = t.identity(('tenant_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('monitored', t.bool)) _aci_mo_name = 'fvAp' _tree_parent = Tenant def __init__(self, **kwargs): super(ApplicationProfile, self).__init__({'monitored': False}, **kwargs)
class VmmInjectedNamespace(AciResourceBase): """Resource representing a VMM injected namespace in ACI. Identity attributes: VMM domain type, VMM domain name, controller name, and namespace name. """ identity_attributes = t.identity( ('domain_type', t.name), ('domain_name', t.name), ('controller_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name)) _aci_mo_name = 'vmmInjectedNs' _tree_parent = VMMController def __init__(self, **kwargs): super(VmmInjectedNamespace, self).__init__({}, **kwargs)
class L3OutNodeProfile(AciResourceBase): """Resource representing a logical node profile. Identity attributes: name of ACI tenant, name of L3Out, name of node profile. """ identity_attributes = t.identity(('tenant_name', t.name), ('l3out_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('monitored', t.bool)) _aci_mo_name = 'l3extLNodeP' _tree_parent = L3Outside def __init__(self, **kwargs): super(L3OutNodeProfile, self).__init__({'monitored': False}, **kwargs)
class ActionLog(api_res.ResourceBase): CREATE = 'create' DELETE = 'delete' RESET = 'reset' identity_attributes = t.identity(('uuid', t.string(64))) other_attributes = t.other( ('action', t.enum(CREATE, DELETE, RESET)), ('object_type', t.string(50)), ('object_dict', t.string()), ('root_rn', t.string(64)), ) db_attributes = t.db(('timestamp', t.string()), ('id', t.integer)) def __init__(self, **kwargs): super(ActionLog, self).__init__({'uuid': utils.generate_uuid()}, **kwargs)
class VMMDomain(AciResourceBase): """Resource representing a VMM domain. Identity attributes: VMM type (eg. Openstack) and name """ identity_attributes = t.identity( ('type', t.enum("VMWare", "OpenStack", "Kubernetes")), ('name', t.name)) other_attributes = t.other( ('monitored', t.bool), ('display_name', t.name), ('enforcement_pref', t.enum('sw', 'hw', 'unknown')), ('mode', t.enum('default', 'n1kv', 'unknown', 'ovs', 'k8s')), ('mcast_address', t.string()), ('encap_mode', t.enum('unknown', 'vlan', 'vxlan')), ('pref_encap_mode', t.enum('unspecified', 'vlan', 'vxlan')), ('vlan_pool_name', t.name), ('vlan_pool_type', t.enum('static', 'dynamic')), ('mcast_addr_pool_name', t.name)) _aci_mo_name = 'vmmDomP' _tree_parent = VMMPolicy def __init__(self, **kwargs): defaults = { 'monitored': False, 'enforcement_pref': 'hw', 'mode': 'default', 'mcast_address': '0.0.0.0', 'encap_mode': 'unknown', 'pref_encap_mode': 'unspecified', 'vlan_pool_name': '', 'vlan_pool_type': 'dynamic', 'mcast_addr_pool_name': '' } vmm_type = kwargs.get('type') if vmm_type == 'Kubernetes': defaults['enforcement_pref'] = 'sw' defaults['mode'] = 'k8s' elif vmm_type == 'OpenStack': defaults['enforcement_pref'] = 'sw' defaults['mode'] = 'ovs' if kwargs.get('encap_mode') and kwargs['encap_mode'] != 'unknown': defaults['pref_encap_mode'] = kwargs['encap_mode'] super(VMMDomain, self).__init__(defaults, **kwargs)
class Tenant(AciRoot): """Resource representing a Tenant in ACI. Identity attribute is RN for ACI tenant. """ identity_attributes = t.identity(('name', t.name)) other_attributes = t.other(('display_name', t.name), ('monitored', t.bool), ('descr', t.string())) _aci_mo_name = 'fvTenant' _tree_parent = None def __init__(self, **kwargs): super(Tenant, self).__init__({ 'monitored': False, 'descr': '' }, **kwargs)
class Endpoint(ResourceBase): """Resource representing an endpoint. Identity attribute: UUID of the endpoint. """ identity_attributes = t.identity(('uuid', t.id)) other_attributes = t.other( ('display_name', t.name), ('epg_tenant_name', t.name), ('epg_app_profile_name', t.name), ('epg_name', t.name)) def __init__(self, **kwargs): super(Endpoint, self).__init__( { 'epg_name': None, 'epg_tenant_name': None, 'epg_app_profile_name': None }, **kwargs)
class SecurityGroupSubject(AciResourceBase): """Resource representing a subject within a security group in ACI. Identity attributes: name of ACI tenant, name of security group and name of subject. """ identity_attributes = t.identity(('tenant_name', t.name), ('security_group_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('monitored', t.bool)) _aci_mo_name = 'hostprotSubj' _tree_parent = SecurityGroup def __init__(self, **kwargs): super(SecurityGroupSubject, self).__init__({'monitored': False}, **kwargs)
class ConcreteDevice(resource.AciResourceBase): """Resource representing concrete device in a L4-L7 device cluster. """ identity_attributes = t.identity(('tenant_name', t.name), ('device_cluster_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('monitored', t.bool)) _aci_mo_name = 'vnsCDev' _tree_parent = DeviceCluster def __init__(self, **kwargs): super(ConcreteDevice, self).__init__({ 'display_name': '', 'monitored': False }, **kwargs)
class Agent(ResourceBase): """Resource representing an AIM Agent""" identity_attributes = t.identity(('id', t.id)) other_attributes = t.other( ('agent_type', t.string(255)), ('host', t.string(255)), ('binary_file', t.string(255)), ('admin_state_up', t.bool), ('description', t.string(255)), ('hash_trees', t.list_of_ids), ('version', t.string())) # Attrbutes completely managed by the DB (eg. timestamps) db_attributes = t.db(('heartbeat_timestamp', t.string())) def __init__(self, **kwargs): super(Agent, self).__init__( { 'admin_state_up': True, 'id': utils.generate_uuid() }, **kwargs) def __eq__(self, other): return self.id == other.id def is_down(self, context): current = context.store.current_timestamp # When the store doesn't support timestamps the agent can never # be considered down. if current is None: return False result = current - self.heartbeat_timestamp >= datetime.timedelta( seconds=cfg.CONF.aim.agent_down_time) if result: LOG.warn("Agent %s is down. Last heartbeat was %s" % (self.id, self.heartbeat_timestamp)) else: LOG.debug("Agent %s is alive, its last heartbeat was %s" % (self.id, self.heartbeat_timestamp)) return result def down_time(self, context): if self.is_down(context): current = context.store.current_timestamp return (current - self.heartbeat_timestamp).seconds
class SecurityGroupRule(AciResourceBase): """Resource representing a SG subject's rule in ACI. Identity attributes: name of ACI tenant, name of security group, name of subject and name of rule """ identity_attributes = t.identity( ('tenant_name', t.name), ('security_group_name', t.name), ('security_group_subject_name', t.name), ('name', t.name)) other_attributes = t.other( ('display_name', t.name), ('direction', t.enum("", "ingress", "egress")), ('ethertype', t.enum("", "undefined", "ipv4", "ipv6")), ('remote_ips', t.list_of_strings), ('ip_protocol', t.string()), ('from_port', t.port), ('to_port', t.port), ('conn_track', t.enum('normal', 'reflexive')), ('icmp_type', t.string()), ('icmp_code', t.string()), ('remote_group_id', t.name), ('monitored', t.bool)) _aci_mo_name = 'hostprotRule' _tree_parent = SecurityGroupSubject def __init__(self, **kwargs): super(SecurityGroupRule, self).__init__( {'direction': 'ingress', 'ethertype': "undefined", 'remote_ips': [], 'ip_protocol': self.UNSPECIFIED, 'from_port': self.UNSPECIFIED, 'to_port': self.UNSPECIFIED, 'icmp_type': self.UNSPECIFIED, 'icmp_code': self.UNSPECIFIED, 'conn_track': 'reflexive', 'remote_group_id': '', 'monitored': False}, **kwargs)
class ConcreteDeviceInterface(resource.AciResourceBase): """Resource representing interface of concrete device in device cluster. """ identity_attributes = t.identity(('tenant_name', t.name), ('device_cluster_name', t.name), ('device_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('path', t.string()), ('monitored', t.bool)) _aci_mo_name = 'vnsCIf' _tree_parent = ConcreteDevice def __init__(self, **kwargs): super(ConcreteDeviceInterface, self).__init__( { 'display_name': '', 'path': '', 'monitored': False }, **kwargs)
class HostLink(resource.ResourceBase): """Switch-port connection information for a host node.""" identity_attributes = t.identity(('host_name', t.string(36)), ('interface_name', t.string(36))) other_attributes = t.other( ('interface_mac', t.mac_address), ('switch_id', t.string()), ('module', t.string()), ('port', t.string()), ('path', t.string()), ('pod_id', t.string()), ('from_config', t.bool)) def __init__(self, **kwargs): super(HostLink, self).__init__( { 'interface_mac': '', 'switch_id': '', 'module': '', 'port': '', 'path': '', 'pod_id': '1', 'from_config': False }, **kwargs)
class L3Outside(AciResourceBase): """Resource representing an L3 Outside. Identity attributes: name of ACI tenant, name of L3Out. """ identity_attributes = t.identity(('tenant_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('vrf_name', t.name), ('l3_domain_dn', t.string()), ('bgp_enable', t.bool), ('monitored', t.bool)) _aci_mo_name = 'l3extOut' _tree_parent = Tenant def __init__(self, **kwargs): super(L3Outside, self).__init__( { 'vrf_name': '', 'l3_domain_dn': '', 'bgp_enable': False, 'monitored': False }, **kwargs)
class ServiceRedirectPolicy(resource.AciResourceBase): """Resource representing a service-redirect policy. """ identity_attributes = t.identity(('tenant_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('destinations', t.list_of_dicts(('ip', t.string()), ('mac', t.mac_address))), ('monitored', t.bool)) _aci_mo_name = 'vnsSvcRedirectPol' _tree_parent = resource.Tenant def __init__(self, **kwargs): super(ServiceRedirectPolicy, self).__init__( { 'display_name': '', 'destinations': [], 'monitored': False }, **kwargs)
class VmmInjectedDeployment(AciResourceBase): """Resource representing a VMM injected deployment in ACI. Identity attributes: VMM domain type, VMM domain name, controller name, namespace name and deployment name. """ identity_attributes = t.identity( ('domain_type', t.name), ('domain_name', t.name), ('controller_name', t.name), ('namespace_name', t.name), ('name', t.name)) other_attributes = t.other(('display_name', t.name), ('replicas', t.integer)) db_attributes = t.db(('guid', t.string())) _aci_mo_name = 'vmmInjectedDepl' _tree_parent = VmmInjectedNamespace def __init__(self, **kwargs): super(VmmInjectedDeployment, self).__init__({ 'replicas': 0, 'guid': '' }, **kwargs)
class VMMController(AciResourceBase): """Resource representing a VMM controller profile in ACI. Identity attributes: VMM domain type, VMM domain name, controller name. """ identity_attributes = t.identity( ('domain_type', t.name), ('domain_name', t.name), ('name', t.name)) other_attributes = t.other( ('display_name', t.name), ('scope', t.enum('unmanaged', 'vm', 'iaas', 'network', 'MicrosoftSCVMM', 'openstack', 'kubernetes')), ('root_cont_name', t.name), ('host_or_ip', t.name), ('mode', t.enum('default', 'n1kv', 'unknown', 'ovs', 'k8s')), ('monitored', t.bool)) _aci_mo_name = 'vmmCtrlrP' _tree_parent = VMMDomain def __init__(self, **kwargs): defaults = {'monitored': False, 'scope': 'vm', 'root_cont_name': '', 'host_or_ip': '', 'mode': 'default'} vmm_type = kwargs.get('domain_type') if vmm_type == 'Kubernetes': defaults['scope'] = 'kubernetes' defaults['mode'] = 'k8s' elif vmm_type == 'OpenStack': defaults['scope'] = 'openstack' defaults['mode'] = 'ovs' name = kwargs.get('name') if name: defaults['root_cont_name'] = name defaults['host_or_ip'] = name super(VMMController, self).__init__(defaults, **kwargs)