def get_server_groups(self):
     """ Get servers data from input model
     """
     url = ("%s%s" % (self.endpoint_url,
                      facade_constants.SERVER_GROUPS_URL))
     LOG.info("Retrieving server groups from input model")
     return http_requests.get(url, headers=self._ks_auth_header())
 def get_interfaces_by_name(self, name):
     """ Get servers data from input model
     """
     url = ("%s%s/%s" % (self.endpoint_url, facade_constants.INTERFACES_URL,
                         name))
     LOG.info("Retrieving interfaces from input model")
     return http_requests.get(url, headers=self._ks_auth_header())
 def get_controlplanes(self):
     """ Get servers data from input model
     """
     url = ("%s%s" % (self.endpoint_url,
                      facade_constants.CONTROLPLANES_URL))
     LOG.info("Retrieving servers.yml from input model")
     return http_requests.get(url, headers=self._ks_auth_header())
 def get_model_expanded(self, id_=None):
     """ Get detailed input model
     """
     if not id_:
         url = ("%s%s" % (self.endpoint_url,
                          facade_constants.EXPANDED_INPUT_MODEL_URL))
     else:
         url = ("%s%s/%s" % (self.endpoint_url,
                             facade_constants.EXPANDED_INPUT_MODEL_SERVERS,
                             id_))
     LOG.info("Retrieving expanded input model")
     return http_requests.get(url, headers=self._ks_auth_header())
 def get_pass_through(self):
     """ Get pass through yml contents """
     LOG.info("Retrieving pass through yml from input model")
     url = ("%s%s" % (self.endpoint_url, facade_constants.PASS_THROUGH_URL))
     try:
         resp = http_requests.get(url, headers=self._ks_auth_header())
         LOG.debug("Pass through contents: %s" % resp)
         return resp
     except facade_exceptions.NotFound:
         raise facade_exceptions.NotFound(
             'Could not find pass_through.yml in the input model, '
             'please create one or get a copy from the example input '
             'models')
 def get_hostnames(self):
     """ Get all the cp generated hostname for all servers
         return {'server-id1': cp-generated-hostname1,
                  'server-id2': cp-generated-hostname2, .... }
     """
     url = ("%s%s" % (self.endpoint_url,
                      facade_constants.CP_OUTPUT_SERVER_INFO))
     LOG.info("Retrieving CP output for servers_info_yml")
     servers = http_requests.get(url, headers=self._ks_auth_header())
     hostnames = dict()
     for key in servers:
         hostnames[key] = servers[key]['hostname']
     return hostnames
 def cobbler_deploy_status(self, id_, **kwargs):
     """ Get the status of os install
     """
     url = self.endpoint_url + facade_constants.OSINSTALL
     resp = http_requests.get(url, headers=self._ks_auth_header())
     res_deployment_status = resp.get('servers').get(id_)
     if res_deployment_status in facade_constants.FAILED_STATES:
         raise facade_exceptions.CobblerException(
             _("[%s]: Failed to install operating system") % id_)
     elif res_deployment_status == facade_constants.COMPLETE:
         LOG.info("[%s]: OS installed successfully" % id_)
         return res_deployment_status
     else:
         raise facade_exceptions.RetryException()
 def _get_status(self, pRef, **kwargs):
     url = ("%s%s/%s" % (self.endpoint_url, facade_constants.PLAYS,
                         pRef))
     resp = http_requests.get(url, headers=self._ks_auth_header())
     resp_code = resp.get('code')
     if resp_code == 0:
         return resp
     elif resp_code and resp_code != 0:
         CommandString = resp.get('commandString')
         message = (_("Playbook: '%s' run failed. Check ansible logs "
                    "[%s, %s] on deployer for more details for "
                    "process[%s].")
                    % (logging.mask_password(CommandString),
                       '~/.ansible/ansible.log',
                       '/var/log/configuration_processor/errors.log',
                       pRef))
         LOG.error("%s" % message)
         raise facade_exceptions.GetException("%s. Status Code: %s"
                                              % (message, resp_code))
     else:
         kill_process = partial(self._kill_play, pRef)
         raise facade_exceptions.RetryException(cleanup=kill_process)
Beispiel #9
0
 def test_get(self, mock_req):
     http_requests.get(self.url)
 def get_networks(self):
     """ Get servers data from input model
     """
     url = ("%s%s" % (self.endpoint_url, facade_constants.NETWORKS_URL))
     LOG.info("Retrieving networks from input model")
     return http_requests.get(url, headers=self._ks_auth_header())
 def get_interfaces_by_id(self, id_):
     url = ("%s%s/%s" % (self.endpoint_url, facade_constants.INTERFACES_URL,
                         id_))
     LOG.info("[%s] Retrieving interfaces from input model" % id_)
     return http_requests.get(url, headers=self._ks_auth_header())
 def get_server_by_id(self, id_):
     url = ("%s%s/%s" % (self.endpoint_url, facade_constants.SERVERS_URL,
                         id_))
     LOG.info("[%s] Retrieving servers.yml from input model" % id_)
     return http_requests.get(url, headers=self._ks_auth_header())
 def get_model(self):
     """ Get complete input model.
     """
     url = ("%s%s" % (self.endpoint_url, facade_constants.INPUT_MODEL_URL))
     LOG.info("Retrieving complete input model")
     return http_requests.get(url, headers=self._ks_auth_header())