how to execute python API's for load balancer?
I want to execute python API'S for balancer. please guide and share link or document if anybody have it.
First time here? Check out the FAQ!
I want to execute python API'S for balancer. please guide and share link or document if anybody have it.
link for all the neutron API: http://developer.openstack.org/api-re...
below are some ways to call API:
1.Get the keystone token
curl -i 'http://127.0.0.1:5000/v2.0/tokens' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "admin_pass"}}}'
{"access": {"token": {"issued_at": "2014-12-30T06:56:08.718473", "expires": "2014-12-30T07:56:08Z", "id": "afc877f644b94eed95b71100eab17bb9", "tenant": {"description": "Admin Tenant", "enabled": true, "id": "fd987a8fb1b845fbb04b28e8f680d040", "name": "admin"},
2.Use that token in curl request
curl -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token:afc877f644b94eed95b71100eab17bb9" http://openstackJuno:9696/v2.0/networks
{"networks": [{"status": "ACTIVE", "subnets": ["a285caf5-f032-46e6-b359-34029269671a"], "name": "flatNetwork", "provider:physical_network": "ph-enp4s0f1", "admin_state_up": true, "tenant_id": "fd987a8fb1b845fbb04b28e8f680d040", "provider:network_type": "flat", "router:external": false, "shared": false, "id": "18cb4b31-d131-42d7-bcd2-b2ec92a40e7d", "provider:segmentation_id": null}]}
neutron API will be used by importing neutronclient module.
Interface for all the API (including load-balancer API's) are in the file: (neutronclient Installation dir)/v2_0/client.py
sample code for calling API which will list all the subnets. Before calling this script you need to set the keystone credentials.
#!/usr/bin/env python
import os
from oslo.config import cfg
from neutronclient.v2_0 import client
def get_keystone_creds():
d = {}
d['username'] = os.environ['OS_USERNAME']
d['password'] = os.environ['OS_PASSWORD']
d['auth_url'] = os.environ['OS_AUTH_URL']
d['tenant_name'] = os.environ['OS_TENANT_NAME']
return d
def listNetwork():
creds = get_keystone_creds()
myNeutronClient = client.Client(**creds)
print myNeutronClient.list_subnets()
if __name__ == "__main__":
listNetwork()
[root@openstackJuno ~]# python networkTest.py
{'subnets': [{u'name': u'flatSubNet', u'enable_dhcp': True, u'network_id': u'18cb4b31-d131-42d7-bcd2-b2ec92a40e7d', u'tenant_id': u'fd987a8fb1b845fbb04b28e8f680d040', u'dns_nameservers': [], u'ipv6_ra_mode': None, u'allocation_pools': [{u'start': u'192.168.1.10', u'end': u'192.168.1.20'}], u'gateway_ip': u'192.168.1.1', u'ipv6_address_mode': None, u'ip_version': 4, u'host_routes': [], u'cidr': u'192.168.1.0/24', u'id': u'a285caf5-f032-46e6-b359-34029269671a'}]}
Asked: 2014-12-29 03:12:50 -0600
Seen: 1,182 times
Last updated: Dec 30 '14
How to restrict incoming http requests to VM using load balancer?
Could not connect to instance. Retrying.: SSLError: [SSL: BAD_SIGNATURE] bad signature (_ssl.c:579)
load balancer my openstack service to AWS
octavia distribution Algorithm
how to deploy a new load balancing algorithm on open stack..
Octavia - instance is not reachable via the lb-mgmt-net
ip_conntrack: table full, dropping packet
Could not connect to instance. Retrying.: SSLError: [SSL] PEM lib (_ssl.c:2554)