Created
September 28, 2017 08:00
-
-
Save celebdor/dba48c702d799bda5e9fe1b35e641ba4 to your computer and use it in GitHub Desktop.
Creates N ports for each of the hypervisors in the deployment for later usage of Kuryr-Kubernetes baremetal vif pool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import os_client_config | |
from pprint import pprint | |
neutron = os_client_config.make_client('network', cloud='envvars') | |
nova = os_client_config.make_client('compute', cloud='envvars') | |
hypervisors = nova.hypervisors.list() | |
bulk_port_req = {'ports': []} | |
for hyper in hypervisors: | |
if 'compute-0' in hyper.hypervisor_hostname: | |
continue | |
bulk_port_req['ports'].extend([{ | |
'binding:host_id': hyper.hypervisor_hostname, | |
'project_id': sys.argv[2], | |
'network_id': sys.argv[3], | |
'device_owner': 'compute:kuryr', | |
'admin_state_up': True, | |
'name': 'kaboom', | |
'security_groups': sys.argv[4].split(',')} for _ in range(int(sys.argv[1]))]) | |
ports = neutron.create_port(bulk_port_req).get('ports') | |
pprint(ports) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of a port created with it. It got the proper vif_type
(ipython)(overcloud) [stack@myhost trunk_updates]$ openstack port show ff5853fc-d7a7-4278-a6c3-8f787f6206cf
+-----------------------+-----------------------------------------------------------------------------------------+
| Field | Value |
+-----------------------+-----------------------------------------------------------------------------------------+
| admin_state_up | UP |
| allowed_address_pairs | |
| binding_host_id | overcloud-novacompute-3.localdomain |
| binding_profile | |
| binding_vif_details | port_filter='True' |
| binding_vif_type | ovs |
| binding_vnic_type | normal |
| created_at | 2017-09-28T06:53:29Z |
| data_plane_status | None |
| description | |
| device_id | |
| device_owner | compute:kuryr |
| dns_assignment | fqdn='host-10-10-0-69.kuryrscale.', hostname='host-10-10-0-69', ip_address='10.10.0.69' |
| dns_name | |
| extra_dhcp_opts | |
| fixed_ips | ip_address='10.10.0.69', subnet_id='79ab7740-0804-4e88-90ea-7889cb0cb994' |
| id | ff5853fc-d7a7-4278-a6c3-8f787f6206cf |
| ip_address | None |
| mac_address | fa:16:3e:3c:0d:fe |
| name | kaboom |
| network_id | 6da5c11c-ee21-4a9c-b62f-8902826cc22b |
| option_name | None |
| option_value | None |
| port_security_enabled | True |
| project_id | 72023a29c79045dc890fea7fca854eff |
| qos_policy_id | None |
| revision_number | 5 |
| security_group_ids | 3350f421-079e-434c-a95e-23845fe968cc, f59d8ee3-93fd-45c9-a1fe-211f7f2fcd2a |
| status | DOWN |
| subnet_id | None |
| tags | |
| trunk_details | None |
| updated_at | 2017-09-28T07:26:25Z |
+-----------------------+-----------------------------------------------------------------------------------------+