Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Created September 29, 2016 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuuichi-fujioka/4ae7aa2718602c00fa54111234f25458 to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/4ae7aa2718602c00fa54111234f25458 to your computer and use it in GitHub Desktop.
call rpc
import json
import sys
from oslo_config import cfg
import oslo_i18n
from neutron.agent import rpc
from neutron.common import config
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron import context
def main(ports):
oslo_i18n.install('neutron')
config.init(['--config-file', '/etc/neutron/neutron.conf', '--config-file', '/etc/neutron/plugins/ml2/ml2_conf.ini'])
n_rpc.init(cfg.CONF)
api = rpc.PluginApi(topics.PLUGIN)
ctxt = context.get_admin_context_without_session()
data = api.get_devices_details_list(ctxt,ports,None)
print json.dumps(data, indent=2)
if __name__ == '__main__':
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment