5 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
19 ==============================
21 ==============================
38 Cloud infratructure is openstack based, openstack services already utilize
39 a common framework for openstack own commands. These commands are accessed via
40 the **openstack** command. The syntax used in this command is the following:
44 openstack <openstack domain> <operation> [<options>]
47 Below is an example of some **openstack** commands.
53 openstack server show <server-name>
55 openstack network list
59 The **openstack** command is implemented ontop of the python **cliff** framework.
61 **cliff** framework supports the following:
63 - structure the commands tokens.
65 - map command tokens to command handlers.
67 - parse command arguments.
69 - format commands output.
71 - bash auto-completion of commands.
73 A well integrated platform is expected to provide a common way to access the
74 interfaces provided by the platform. As such cloud infrastructure utilizes
75 the same **cliff** framework to implement the infrastrcture own middleware CLIs.
77 The infrastrcutre CLIs can be accessed via the **hostcli** command.
79 The syntax used in this command is the following:
83 hostcli <middleware domain> <operation> [<options>]
85 Below is an example of some **hostcli** commands.
89 hostcli has show nodes
91 hostcli has show services --node <node-name>
95 hostcli motd set --motd <message of the day text>
99 In addition to providing the common look and feel for the end user, the
100 *hostcli* takes care of authorizing with keystone and provide a token
101 for authentication usage
103 The following diagram describes the highlevel design for **hostcli** CLI
106 .. image:: docs/hostcli.png
109 When using yarf restful framework to implement the backend for middleware
110 the frame provides a RestRequest class to make the authentication transperant
113 Example of using this request:
117 def take_action(self, parsed_args):
118 req = self.app.client_manager.resthandler
119 ret = req.get("has/v1/cluster", decode_json=True)
121 columns = ('admin-state',
125 data = (status['admin-state'],
126 status['running-state'],
129 return (columns, data)
131 The beef is ot get the resthandler from client_manager that is defined in the app.
132 This will return the object RestRequest for you that has the HTTP operations predefined.
133 The only thing needed is the path of the url. The actual address should not be defined,
134 since it's extracted from the keystone session from the endpoints.