def test_reduce_cluster2(self): self.mock_response_json_values({"result": "succeeded"}) self.proxy.reduce_cluster("any-cluster-id", 3) self.proxy.reduce_cluster(_cluster.Cluster(id="any-cluster-id"), 3) self.proxy.reduce_cluster(_cluster.ClusterInfo(id="any-cluster-id"), 3) body = { "service_id": "", "plan_id": "", "parameters": { "order_id": "", "scale_type": "scale_in", "node_id": "node_orderadd", "instances": 3, "include_instances": [], "exclude_instances": [] }, "previous_values": { "plan_id": "" } } self.session.put.assert_has_calls([ mock.call("cluster_infos/any-cluster-id", endpoint_filter=self.service, endpoint_override=self.service.get_endpoint_override(), json=body), mock.call("cluster_infos/any-cluster-id", endpoint_filter=self.service, endpoint_override=self.service.get_endpoint_override(), json=body), mock.call("cluster_infos/any-cluster-id", endpoint_filter=self.service, endpoint_override=self.service.get_endpoint_override(), json=body) ])
def expand_cluster(self, cluster, amount): """Reduce node amount of the cluster :param cluster: value can be the ID of a cluster or an instance of :class:`~openstack.map_reduce.v1.cluster.ClusterInfo` :param amount: the node amount to expand :returns: Cluster been expand :rtype: :class:`~openstack.map_reduce.v1.cluster.ClusterInfo` """ # in case of user pass ClusterInfo as cluster if isinstance(cluster, _cluster.Cluster): cluster = _cluster.ClusterInfo(id=cluster.id) cluster_info = self._get_resource(_cluster.ClusterInfo, cluster) return cluster_info.expand(self._session, amount)
def reduce_cluster(self, cluster, amount, includes=[], excludes=[]): """Reduce node amount of the cluster :param cluster: value can be the ID of a cluster or an instance of :class:`~openstack.map_reduce.v1.cluster.ClusterInfo` :param amount: the node amount to reduce :param includes: instance id list which should be reduced :param excludes: instance id list which should be excluded :returns: Cluster been reduced :rtype: :class:`~openstack.map_reduce.v1.cluster.ClusterInfo` """ # in case of user pass ClusterInfo as cluster if isinstance(cluster, _cluster.Cluster): cluster = _cluster.ClusterInfo(id=cluster.id) cluster_info = self._get_resource(_cluster.ClusterInfo, cluster) return cluster_info.reduce(self._session, amount, includes, excludes)
def test_delete_cluster_with_instance2(self): self.proxy.delete_cluster(_cluster.ClusterInfo(id="any-cluster-id")) self.assert_session_delete("clusters/any-cluster-id")