示例#1
0
 def test_make_it(self):
     sot = port.Port(EXAMPLE)
     self.assertTrue(sot.is_admin_state_up)
     self.assertEqual(EXAMPLE['allowed_address_pairs'],
                      sot.allowed_address_pairs)
     self.assertEqual(EXAMPLE['binding:host_id'], sot.binding_host_id)
     self.assertEqual(EXAMPLE['binding:profile'], sot.binding_profile)
     self.assertEqual(EXAMPLE['binding:vif_details'],
                      sot.binding_vif_details)
     self.assertEqual(EXAMPLE['binding:vif_type'], sot.binding_vif_type)
     self.assertEqual(EXAMPLE['binding:vnic_type'], sot.binding_vnic_type)
     self.assertEqual(EXAMPLE['device_id'], sot.device_id)
     self.assertEqual(EXAMPLE['device_owner'], sot.device_owner)
     self.assertEqual(EXAMPLE['extra_dhcp_opts'], sot.extra_dhcp_opts)
     self.assertEqual(EXAMPLE['fixed_ips'], sot.fixed_ips)
     self.assertEqual(EXAMPLE['id'], sot.id)
     self.assertEqual(EXAMPLE['mac_address'], sot.mac_address)
     self.assertEqual(EXAMPLE['name'], sot.name)
     self.assertEqual(EXAMPLE['network_id'], sot.network_id)
     self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
     self.assertEqual(EXAMPLE['security_groups'], sot.security_group_ids)
     self.assertEqual(EXAMPLE['status'], sot.status)
     self.assertTrue(sot.is_port_security_enabled)
     self.assertEqual(EXAMPLE['dns_assignment'], sot.dns_assignment)
     self.assertEqual(EXAMPLE['dns_name'], sot.dns_name)
     self.assertEqual(EXAMPLE['description'], sot.description)
     self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id)
     self.assertEqual(EXAMPLE['created_at'], sot.created_at)
     self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
     self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
 def test_make_it(self):
     sot = port.Port(EXAMPLE)
     self.assertTrue(sot.is_admin_state_up)
     self.assertEqual(EXAMPLE['allowed_address_pairs'],
                      sot.allowed_address_pairs)
     self.assertEqual(EXAMPLE['binding:host_id'], sot.binding_host_id)
     self.assertEqual(EXAMPLE['binding:profile'], sot.binding_profile)
     self.assertEqual(EXAMPLE['binding:vif_details'],
                      sot.binding_vif_details)
     self.assertEqual(EXAMPLE['binding:vif_type'], sot.binding_vif_type)
     self.assertEqual(EXAMPLE['binding:vnic_type'], sot.binding_vnic_type)
     self.assertEqual(EXAMPLE['device_id'], sot.device_id)
     self.assertEqual(EXAMPLE['device_owner'], sot.device_owner)
     self.assertEqual(EXAMPLE['extra_dhcp_opts'], sot.extra_dhcp_opts)
     self.assertEqual(EXAMPLE['fixed_ips'], sot.fixed_ips)
     self.assertEqual(EXAMPLE['id'], sot.id)
     self.assertEqual(EXAMPLE['mac_address'], sot.mac_address)
     self.assertEqual(EXAMPLE['name'], sot.name)
     self.assertEqual(EXAMPLE['network_id'], sot.network_id)
     self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
     self.assertEqual(EXAMPLE['security_groups'], sot.security_group_ids)
     self.assertEqual(EXAMPLE['status'], sot.status)
     self.assertTrue(sot.is_port_security_enabled)
     self.assertEqual(EXAMPLE['dns_assignment'], sot.dns_assignment)
     self.assertEqual(EXAMPLE['dns_name'], sot.dns_name)
     self.assertEqual(EXAMPLE['description'], sot.description)
     dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace(
         tzinfo=None)
     self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
     dt = datetime.datetime(2016, 7, 9, 12, 14, 57, 233772).replace(
         tzinfo=None)
     self.assertEqual(dt, sot.updated_at.replace(tzinfo=None))
示例#3
0
    def test_basic(self):
        sot = port.Port()
        self.assertEqual('port', sot.resource_key)
        self.assertEqual('ports', sot.resources_key)
        self.assertEqual('/ports', sot.base_path)
        self.assertEqual('network', sot.service.service_type)
        self.assertTrue(sot.allow_create)
        self.assertTrue(sot.allow_get)
        self.assertTrue(sot.allow_update)
        self.assertTrue(sot.allow_delete)
        self.assertTrue(sot.allow_list)

        self.assertDictEqual(
            {
                "description": "description",
                "device_id": "device_id",
                "device_owner": "device_owner",
                "fixed_ips": "fixed_ips",
                "ip_address": "ip_address",
                "mac_address": "mac_address",
                "name": "name",
                "network_id": "network_id",
                "status": "status",
                "subnet_id": "subnet_id",
                "is_admin_state_up": "admin_state_up",
                "is_port_security_enabled": "port_security_enabled",
                "project_id": "tenant_id",
                "limit": "limit",
                "marker": "marker",
                "any_tags": "tags-any",
                "not_any_tags": "not-tags-any",
                "not_tags": "not-tags",
                "tags": "tags"
            }, sot._query_mapping._mapping)
示例#4
0
def get_port_obj(port_id='07cfe856-11cc-43d9-9200-ff4dc02d3620',
                 device_owner='compute:kuryr',
                 ip_address=None,
                 vif_details=None,
                 **kwargs):

    fixed_ips = [{
        'subnet_id': 'e1942bb1-5f51-4646-9885-365b66215592',
        'ip_address': '10.10.0.5'
    }, {
        'subnet_id': '4894baaf-df06-4a54-9885-9cd99d1cc245',
        'ip_address': 'fd35:7db5:e3fc:0:f816:3eff:fe80:d421'
    }]
    if ip_address:
        fixed_ips[0]['ip_address'] = ip_address
    security_group_ids = ['cfb3dfc4-7a43-4ba1-b92d-b8b2650d7f88']

    if not vif_details:
        vif_details = {'port_filter': True, 'ovs_hybrid_plug': False}

    port_data = {
        'allowed_address_pairs': [],
        'binding_host_id': 'kuryr-devstack',
        'binding_profile': {},
        'binding_vif_details': vif_details,
        'binding_vif_type': 'ovs',
        'binding_vnic_type': 'normal',
        'created_at': '2017-06-09T13:23:24Z',
        'data_plane_status': None,
        'description': '',
        'device_id': '',
        'device_owner': device_owner,
        'dns_assignment': None,
        'dns_domain': None,
        'dns_name': None,
        'extra_dhcp_opts': [],
        'fixed_ips': fixed_ips,
        'id': port_id,
        'ip_address': None,
        'is_admin_state_up': True,
        'is_port_security_enabled': True,
        'location': None,
        'mac_address': 'fa:16:3e:80:d4:21',
        'name': constants.KURYR_PORT_NAME,
        'network_id': 'ba44f957-c467-412b-b985-ae720514bc46',
        'option_name': None,
        'option_value': None,
        'project_id': 'b6e8fb2bde594673923afc19cf168f3a',
        'qos_policy_id': None,
        'revision_number': 9,
        'security_group_ids': security_group_ids,
        'status': u'DOWN',
        'subnet_id': None,
        'tags': [],
        'trunk_details': None,
        'updated_at': u'2019-12-04T15:06:09Z'
    }
    port_data.update(kwargs)
    return os_port.Port(**port_data)
示例#5
0
def _create_ports(self, payload):
    """bulk create ports using openstacksdk module"""
    # TODO(gryf): this should be implemented on openstacksdk instead.
    response = self.post(os_port.Port.base_path, json=payload)

    if not response.ok:
        raise os_exc.SDKException('Error when bulk creating ports: %s',
                                  response.text)
    return (os_port.Port(**item) for item in response.json()['ports'])
示例#6
0
 def test_basic(self):
     sot = port.Port()
     self.assertEqual('port', sot.resource_key)
     self.assertEqual('ports', sot.resources_key)
     self.assertEqual('/ports', sot.base_path)
     self.assertEqual('network', sot.service.service_type)
     self.assertTrue(sot.allow_create)
     self.assertTrue(sot.allow_retrieve)
     self.assertTrue(sot.allow_update)
     self.assertTrue(sot.allow_delete)
     self.assertTrue(sot.allow_list)
示例#7
0
 def test_make_it(self):
     sot = port.Port(EXAMPLE)
     self.assertEqual(EXAMPLE['admin_state_up'], sot.admin_state_up)
     self.assertEqual(EXAMPLE['allowed_address_pairs'],
                      sot.allowed_address_pairs)
     self.assertEqual(EXAMPLE['binding:host_id'], sot.binding_host_id)
     self.assertEqual(EXAMPLE['binding:profile'], sot.binding_profile)
     self.assertEqual(EXAMPLE['binding:vif_details'],
                      sot.binding_vif_details)
     self.assertEqual(EXAMPLE['binding:vif_type'], sot.binding_vif_type)
     self.assertEqual(EXAMPLE['binding:vnic_type'], sot.binding_vnic_type)
     self.assertEqual(EXAMPLE['device_id'], sot.device_id)
     self.assertEqual(EXAMPLE['device_owner'], sot.device_owner)
     self.assertEqual(EXAMPLE['extra_dhcp_opts'], sot.extra_dhcp_opts)
     self.assertEqual(EXAMPLE['fixed_ips'], sot.fixed_ips)
     self.assertEqual(EXAMPLE['id'], sot.id)
     self.assertEqual(EXAMPLE['mac_address'], sot.mac_address)
     self.assertEqual(EXAMPLE['name'], sot.name)
     self.assertEqual(EXAMPLE['network_id'], sot.network_id)
     self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
     self.assertEqual(EXAMPLE['security_groups'], sot.security_groups)
     self.assertEqual(EXAMPLE['status'], sot.status)
示例#8
0
def _create_ports(self, payload):
    """bulk create ports using openstacksdk module"""
    # TODO(gryf): this function should be removed while we update openstacksdk
    # version to 0.42.
    key_map = {
        'binding_host_id': 'binding:host_id',
        'binding_profile': 'binding:profile',
        'binding_vif_details': 'binding:vif_details',
        'binding_vif_type': 'binding:vif_type',
        'binding_vnic_type': 'binding:vnic_type'
    }

    for port in payload['ports']:
        for key, mapping in key_map.items():
            if key in port:
                port[mapping] = port.pop(key)

    response = self.post(os_port.Port.base_path, json=payload)

    if not response.ok:
        raise os_exc.SDKException('Error when bulk creating ports: %s',
                                  response.text)
    return (os_port.Port(**item) for item in response.json()['ports'])
示例#9
0
 def get_port(self, **data):
     return port.Port(data).get(self.session)
示例#10
0
 def create_port(self, **data):
     return port.Port(data).create(self.session)
示例#11
0
 def update_port(self, **data):
     return port.Port(data).update(self.session)
示例#12
0
 def delete_port(self, **data):
     return port.Port(data).delete(self.session)