Custom Search

Monday, July 7, 2014

OpenStack HeatCLI and heatclient flow of stack-create action

#heat --os-username admin --os-password nova --os-tenant-name admin --os-auth-url http://192.168.56.102:35357/v2.0 --heat-url http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83 --os-no-client-auth --debug stack-create stk1 -f https://raw.githubusercontent.com/openstack/heat-templates/master/hot/hello_world.yaml -P "db_password=P23456" -P "KeyName=k2" -P "ImageId=13ad8950-1f00-4587-8d3c-dd726265de08"

* "8004" is the port where "heat-api" is running

######### Heat CLI #########

1)
/usr/lib/python2.7/dist-packages/heatclient/shell.py

class HeatShell(object):
    def main(self, argv):
        client = heat_client.Client(api_version, endpoint, **kwargs)
        args.func(client, args)

2)
/usr/lib/python2.7/dist-packages/heatclient/v1/shell.py

def do_stack_create(hc, args):
    hc.stacks.create(**fields)
   
* Here "hc" is heat_client.Client()
* Check /usr/lib/python2.7/dist-packages/heatclient/v1/client.py
   
3)
/usr/lib/python2.7/dist-packages/heatclient/v1/stacks.py

class Stack(base.Resource):
    def create(self, **fields):
        return self.manager.create(self.identifier, **fields)

class StackManager(base.BaseManager):
    resource_class = Stack
   
    def create(self, **kwargs):
        """Create a stack."""
        headers = self.client.credentials_headers()
       
        import pdb
        pdb.set_trace()

       
        resp, body = self.client.json_request('POST', '/stacks',
                                              data=kwargs, headers=headers)

        return body

IMP (DEBUG)
===========


Add a break point and check the value following variables of "self.client".

###Keystone EndPoint
(Pdb) self.client.auth_url
'http://192.168.56.102:35357/v2.0'

###Endpoint where to send this request after keystone authentication
(Pdb) self.client.endpoint_url
'http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83'

(Pdb) self.client.endpoint
'http://127.0.0.1:8004/v1/5864a59a240e4a43bc3c17fcbd6cfd83'

* "8004" is the port where "heat-api" is running

4)
/usr/lib/python2.7/dist-packages/heatclient/v1/client.py

class Client(object):
    self.http_client = http.HTTPClient(*args, **kwargs)
    self.stacks = stacks.StackManager(self.http_client)

5)
/usr/lib/python2.7/dist-packages/heatclient/common/http.py

class HTTPClient(object):
    def json_request(self, method, url, **kwargs):
        resp = self._http_request(url, method, **kwargs)

    def _http_request(self, url, method, **kwargs):
        resp = requests.request(-----) <=== Make Restful Call
6)
Next : OpenStack heat-api flow of stack-create action

http://fosshelp.blogspot.com/2014/07/openstack-heat-api-flow-of-stack-create.html


No comments:

Post a Comment