Modify nodes to hosts
Change-Id: Idccfdefc5f54e5292a071d51a80eb398d215df7b
This commit is contained in:
parent
20a6274d58
commit
e4211c9e6b
@ -14,7 +14,7 @@ from keystoneauth1 import loading
|
||||
from keystoneauth1 import session as ksa_session
|
||||
|
||||
from gyanclient.common import httpclient
|
||||
from gyanclient.v1 import nodes
|
||||
from gyanclient.v1 import hosts
|
||||
from gyanclient.v1 import models
|
||||
from gyanclient.v1 import versions
|
||||
|
||||
@ -116,7 +116,7 @@ class Client(object):
|
||||
session=session,
|
||||
api_version=api_version,
|
||||
**client_kwargs)
|
||||
self.nodes = nodes.NodeManager(self.http_client)
|
||||
self.hosts = hosts.HostManager(self.http_client)
|
||||
self.models = models.ModelManager(self.http_client)
|
||||
self.versions = versions.VersionManager(self.http_client)
|
||||
|
||||
|
@ -18,34 +18,34 @@ from gyanclient.common import utils
|
||||
from gyanclient import exceptions
|
||||
|
||||
|
||||
class Node(base.Resource):
|
||||
class Host(base.Resource):
|
||||
def __repr__(self):
|
||||
return "<Node %s>" % self._info
|
||||
return "<Host %s>" % self._info
|
||||
|
||||
|
||||
class NodeManager(base.Manager):
|
||||
resource_class = Node
|
||||
class HostManager(base.Manager):
|
||||
resource_class = Host
|
||||
|
||||
@staticmethod
|
||||
def _path(id=None):
|
||||
|
||||
if id:
|
||||
return '/v1/ml-nodes/%s' % id
|
||||
return '/v1/hosts/%s' % id
|
||||
else:
|
||||
return '/v1/ml-nodes'
|
||||
return '/v1/hosts'
|
||||
|
||||
def list_nodes(self, **kwargs):
|
||||
"""Retrieve a list of Nodes.
|
||||
def list_hosts(self, **kwargs):
|
||||
"""Retrieve a list of Hosts.
|
||||
|
||||
:returns: A list of nodes.
|
||||
:returns: A list of hosts.
|
||||
|
||||
"""
|
||||
|
||||
return self._list_pagination(self._path(''),
|
||||
"nodes")
|
||||
"hosts")
|
||||
|
||||
def get(self, id):
|
||||
try:
|
||||
return self._list(self._path(id))[0]
|
||||
except IndexError:
|
||||
return None
|
||||
return None
|
@ -24,23 +24,23 @@ from gyanclient.common import utils as gyan_utils
|
||||
from gyanclient import exceptions as exc
|
||||
|
||||
|
||||
def _show_node(node):
|
||||
utils.print_dict(node._info)
|
||||
def _show_host(host):
|
||||
utils.print_dict(host._info)
|
||||
|
||||
|
||||
@utils.arg('node-id',
|
||||
metavar='<node-id>',
|
||||
help='ID or name of the node to show.')
|
||||
def do_node_show(cs, args):
|
||||
"""Show details of a Node."""
|
||||
@utils.arg('host-id',
|
||||
metavar='<host-id>',
|
||||
help='ID or name of the host to show.')
|
||||
def do_host_show(cs, args):
|
||||
"""Show details of a Host."""
|
||||
opts = {}
|
||||
opts['node_id'] = args.node_id
|
||||
opts['host_id'] = args.host_id
|
||||
opts = gyan_utils.remove_null_parms(**opts)
|
||||
node = cs.nodes.get(**opts)
|
||||
_show_node(node)
|
||||
host = cs.hosts.get(**opts)
|
||||
_show_host(host)
|
||||
|
||||
|
||||
def do_node_list(cs, args):
|
||||
"""List Nodes"""
|
||||
nodes = cs.nodes.list_nodes()
|
||||
gyan_utils.list_nodes(nodes)
|
||||
def do_host_list(cs, args):
|
||||
"""List Hosts"""
|
||||
hosts = cs.hosts.list_hosts()
|
||||
gyan_utils.list_hosts(hosts)
|
@ -10,12 +10,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from gyanclient.v1 import nodes_shell
|
||||
from gyanclient.v1 import hosts_shell
|
||||
from gyanclient.v1 import models_shell
|
||||
from gyanclient.v1 import versions_shell
|
||||
|
||||
COMMAND_MODULES = [
|
||||
nodes_shell,
|
||||
hosts_shell,
|
||||
models_shell,
|
||||
versions_shell
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user