def update_loadbalancer_resource(self, lb): try: new_lb = self.clients("neutron").show_loadbalancer(lb["id"]) except Exception as e: if getattr(e, "status_code", 400) == 404: raise exceptions.GetResourceNotFound(resource=lb) raise exceptions.GetResourceFailure(resource=lb, err=e) return new_lb["loadbalancer"]
def update_loadbalancer_resource(self, lb): try: new_lb = self._clients.octavia().load_balancer_show(lb["id"]) except Exception as e: if getattr(e, "status_code", 400) == 404: raise exceptions.GetResourceNotFound(resource=lb) raise exceptions.GetResourceFailure(resource=lb, err=e) return new_lb
def update_pool_resource(self, pool): try: new_pool = self._clients.octavia().pool_show(pool["id"]) except Exception as e: if getattr(e, "status_code", 400) == 404: raise exceptions.GetResourceNotFound(resource=pool) raise exceptions.GetResourceFailure(resource=pool, err=e) return new_pool
def _get_cluster(self, cluster): """Get cluster details. :param cluster: cluster to get :returns: object of cluster """ try: return self.admin_clients("senlin").get_cluster(cluster.id) except Exception as e: if getattr(e, "code", getattr(e, "http_status", 400)) == 404: raise exceptions.GetResourceNotFound(resource=cluster.id) raise exceptions.GetResourceFailure(resource=cluster.id, err=e)
def get_secret(self, secret_ref): """Get the secret. :param secret_name: The name of the secret. """ secret = self._clients.barbican().secrets.get(secret_ref) # secret is lazy, its properties would be filled with real # values while getting some property. try: secret.status except Exception as e: from rally import exceptions raise exceptions.GetResourceFailure(resource=secret, err=e) return secret
def load_balancer_show(self, lb_id): """Show a load balancer :param string lb: dict of the load balancer to show :return: A dict of the specified load balancer's settings """ try: new_lb = self._clients.octavia().load_balancer_show(lb_id) except Exception as e: if getattr(e, "code", 400) == 404: raise exceptions.GetResourceNotFound(resource=lb_id) raise exceptions.GetResourceFailure(resource=lb_id, err=e) return new_lb
def _update_resource(self, resource): try: manager = getattr(resource, "manager", None) if manager: res = manager.get(resource.id) else: if isinstance(resource, block.Volume): attr = "volumes" elif isinstance(resource, block.VolumeSnapshot): attr = "volume_snapshots" elif isinstance(resource, block.VolumeBackup): attr = "backups" res = getattr(self._get_client(), attr).get(resource.id) except Exception as e: if getattr(e, "code", getattr(e, "http_status", 400)) == 404: raise exceptions.GetResourceNotFound(resource=resource) raise exceptions.GetResourceFailure(resource=resource, err=e) return res
def _get_from_manager(resource): # catch client side errors try: res = resource.manager.get(resource.id) except Exception as e: if getattr(e, "code", 400) == 404: raise exceptions.GetResourceNotFound(resource=resource) raise exceptions.GetResourceFailure(resource=resource, err=e) # catch abnormal status, such as "no valid host" for servers status = get_status(res) if status in ("DELETED", "DELETE_COMPLETE"): raise exceptions.GetResourceNotFound(resource=res) if status in error_statuses: raise exceptions.GetResourceErrorStatus(resource=res, status=status, fault="") return res
def _get_from_manager(resource): # catch client side errors try: res = resource.manager.get(resource.id) except Exception as e: if getattr(e, 'code', 400) == 404: raise exceptions.GetResourceNotFound(resource=resource) raise exceptions.GetResourceFailure(resource=resource, err=e) # catch abnormal status, such as "no valid host" for servers status = res.status.upper() if status == "DELETED": raise exceptions.GetResourceNotFound(resource=res) if status in error_statuses: if isinstance(res.manager, servers.ServerManager): msg = res.fault['message'] else: msg = '' raise exceptions.GetResourceErrorStatus(resource=res, status=status, fault=msg) return res