Пример #1
0
    def update(self, req, id, body):
        LOG.debug(_('Updating app node by id %s' % id))
        context = req.environ['vsm.context']

        if not self.is_valid_body(body, 'appnode'):
            raise exc.HTTPBadRequest()

        body = body.get('appnode')
        LOG.debug('PUT body: %s' % body)

        if id is None:
            expl = _('Request body and URI mismatch: No appnode_id')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        # convert from unicode to str
        id = str(id)
        os_tenant_name = body.get('os_tenant_name', None)
        os_username = body.get('os_username', None)
        os_password = body.get('os_password', None)
        os_auth_url = body.get('os_auth_url', None)

        if not os_tenant_name or not os_username or not os_password or not os_auth_url:
            expl = _(
                'Request body and URI mismatch: os_tenant_name or os_username or os_password or os_auth_url required.'
            )
            raise webob.exc.HTTPBadRequest(explanation=expl)

        appnodes.update(context, id, body)
        return webob.Response(status_int=201)
Пример #2
0
    def _write_openstack_ip(self):
        """ Write Openstack nova controller ips
            and cinder volume ips into DB.

         Openstack Ips:
            10.239.82.xx
            10.239.82.yy
         Just write Ip addr here.
        """
        ip_list = self._cluster_info['openstack_ip']
        if ip_list:
            try:
                # fake one user id and project id
                self._context.user_id = 32 * '1'
                self._context.project_id = 32 * '1'
                node_list = appnodes.create(self._context,
                                            ip_list,
                                            allow_duplicate=True)
                #LOG.debug('app nodes added %s' % node_list)
                for node in node_list:
                    status = 'reachable'
                    appnodes.update(self._context, node.id, status)
            except Exception as e:
                LOG.error('Failed to add app nodes with error %s' % e)
                return False
        return True
Пример #3
0
    def update(self, req, id, body):
        LOG.debug(_('Updating app node by id %s' % id))
        context = req.environ['vsm.context']

        if not self.is_valid_body(body, 'appnode'):
            raise exc.HTTPBadRequest()

        body = body.get('appnode')
        LOG.debug('PUT body: %s' % body)

        if id is None:
            expl = _('Request body and URI mismatch: No appnode_id')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        # convert from unicode to str
        id = str(id)
        os_tenant_name = body.get('os_tenant_name', None)
        os_username = body.get('os_username', None)
        os_password = body.get('os_password', None)
        os_auth_url = body.get('os_auth_url', None)

        if not os_tenant_name or not os_username or not os_password or not os_auth_url:
            expl = _('Request body and URI mismatch: os_tenant_name or os_username or os_password or os_auth_url required.')
            raise webob.exc.HTTPBadRequest(explanation=expl)

        appnodes.update(context, id, body)
        return webob.Response(status_int=201)
Пример #4
0
    def create(self, req, body):
        """create app nodes."""
        LOG.debug(_('Creating new app nodes %s'), body)

        if not self.is_valid_body(body, 'appnodes'):
            raise exc.HTTPBadRequest()

        context = req.environ['vsm.context']
        ip_list = body['appnodes']
        if not isinstance(ip_list, list):
            expl = _('Invalid Request body: should be a list of IP address.')
            raise webob.exc.HTTPBadRequest(explanation=expl)

        node_list = appnodes.create(context, ip_list)
        node_view = self._view_builder.index(node_list)
        for node in node_list:
            #LOG.info('Node %s, Node id: %s, Node ip: %s' % (node, node.id, node.ip))
            #ssh = utils.SSHClient(ip='10.239.131.170', user='******', key_file=r'~/.ssh/id_rsa')
            #ssh = utils.SSHClient(node.ip, 'root', '~/.ssh/id_rsa')
            #ret = ssh.check_ssh(retries=1)
            #status = 'reachable' if ret else 'unreachable'
            status = 'reachable'
            appnodes.update(context, node.id, status)

        return node_view
Пример #5
0
    def update(self, req, id, body):
        LOG.debug(_('Updating app node by id %s' % id))
        context = req.environ['vsm.context']

        if not self.is_valid_body(body, 'appnode'):
            raise exc.HTTPBadRequest()

        body = body.get('appnode')
        LOG.debug('PUT body: %s' % body)

        if id is None:
            expl = _('Request body and URI mismatch: No appnode_id')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        # convert from unicode to str
        id = str(id)
        status = body.get('ssh_status', None)
        log = body.get('log_info', None)
        ip = body.get('ip', None)

        if not status and not log and not ip:
            expl = _('Request body and URI mismatch: ssh_status or log_info required.')
            raise webob.exc.HTTPBadRequest(explanation=expl)

        appnodes.update(context, id, status, log, ip)
        return webob.Response(status_int=201)
Пример #6
0
    def create(self, req, body):
        """create app nodes."""
        LOG.debug(_('Creating new app nodes %s'), body)

        if not self.is_valid_body(body, 'appnodes'):
            raise exc.HTTPBadRequest()

        context = req.environ['vsm.context']
        ip_list = body['appnodes']
        if not isinstance(ip_list, list):
            expl = _('Invalid Request body: should be a list of IP address.')
            raise webob.exc.HTTPBadRequest(explanation=expl)

        node_list = appnodes.create(context, ip_list)
        node_view = self._view_builder.index(node_list)
        for node in node_list:
            #LOG.info('Node %s, Node id: %s, Node ip: %s' % (node, node.id, node.ip))
            #ssh = utils.SSHClient(ip='10.239.131.170', user='******', key_file=r'~/.ssh/id_rsa')
            #ssh = utils.SSHClient(node.ip, 'root', '~/.ssh/id_rsa')
            #ret = ssh.check_ssh(retries=1)
            #status = 'reachable' if ret else 'unreachable'
            status = 'reachable'
            appnodes.update(context, node.id, status)

        return node_view
Пример #7
0
    def update(self, req, id, body):
        LOG.debug(_('Updating app node by id %s' % id))
        context = req.environ['vsm.context']

        if not self.is_valid_body(body, 'appnode'):
            raise exc.HTTPBadRequest()

        body = body.get('appnode')
        LOG.debug('PUT body: %s' % body)

        if id is None:
            expl = _('Request body and URI mismatch: No appnode_id')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        # convert from unicode to str
        id = str(id)
        status = body.get('ssh_status', None)
        log = body.get('log_info', None)
        ip = body.get('ip', None)

        if not status and not log and not ip:
            expl = _(
                'Request body and URI mismatch: ssh_status or log_info required.'
            )
            raise webob.exc.HTTPBadRequest(explanation=expl)

        appnodes.update(context, id, status, log, ip)
        return webob.Response(status_int=201)
Пример #8
0
    def _write_openstack_ip(self):
        """ Write Openstack nova controller ips
            and cinder volume ips into DB.

         Openstack Ips:
            10.239.82.xx
            10.239.82.yy
         Just write Ip addr here.
        """
        ip_list = self._cluster_info['openstack_ip']
        if ip_list:
            try:
                # fake one user id and project id
                self._context.user_id = 32 * '1'
                self._context.project_id = 32 * '1'
                node_list = appnodes.create(self._context, ip_list, allow_duplicate=True)
                #LOG.debug('app nodes added %s' % node_list)
                for node in node_list:
                    status = 'reachable'
                    appnodes.update(self._context, node.id, status)
            except Exception as e:
                LOG.error('Failed to add app nodes with error %s' % e)
                return False
        return True