Merge "Rebase cluster service to resource2/proxy2"
This commit is contained in:
commit
0485f682f0
|
@ -21,18 +21,18 @@ from openstack.cluster.v1 import policy_type as _policy_type
|
|||
from openstack.cluster.v1 import profile as _profile
|
||||
from openstack.cluster.v1 import profile_type as _profile_type
|
||||
from openstack.cluster.v1 import receiver as _receiver
|
||||
from openstack import proxy
|
||||
from openstack import resource
|
||||
from openstack import proxy2
|
||||
from openstack import resource2
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
class Proxy(proxy2.BaseProxy):
|
||||
|
||||
def get_build_info(self):
|
||||
"""Get build info for service engine and API
|
||||
|
||||
:returns: A dictionary containing the API and engine revision string.
|
||||
"""
|
||||
return self._get(build_info.BuildInfo)
|
||||
return self._get(build_info.BuildInfo, requires_id=False)
|
||||
|
||||
def profile_types(self, **query):
|
||||
"""Get a generator of profile types.
|
||||
|
@ -465,19 +465,25 @@ class Proxy(proxy.BaseProxy):
|
|||
return self._find(_node.Node, name_or_id,
|
||||
ignore_missing=ignore_missing)
|
||||
|
||||
def get_node(self, node, args=None):
|
||||
def get_node(self, node, details=False):
|
||||
"""Get a single node.
|
||||
|
||||
:param node: The value can be the name or ID of a node or a
|
||||
:class:`~openstack.cluster.v1.node.Node` instance.
|
||||
:param args: An optional argument that will be translated into query
|
||||
strings when retrieving the node.
|
||||
:param details: An optional argument that indicates whether the
|
||||
server should return more details when retrieving the node data.
|
||||
|
||||
:returns: One :class:`~openstack.cluster.v1.node.Node`
|
||||
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
||||
node matching the name or ID could be found.
|
||||
"""
|
||||
return self._get(_node.Node, node, args=args)
|
||||
# NOTE: When retrieving node with details (using NodeDetail resource),
|
||||
# the `node_id` is treated as part of the base_path thus a URI
|
||||
# property rather than a resource ID as assumed by the _get() method
|
||||
# in base proxy.
|
||||
if details:
|
||||
return self._get(_node.NodeDetail, requires_id=False, node_id=node)
|
||||
return self._get(_node.Node, node)
|
||||
|
||||
def nodes(self, **query):
|
||||
"""Retrieve a generator of nodes.
|
||||
|
@ -617,14 +623,13 @@ class Proxy(proxy.BaseProxy):
|
|||
:class:`~openstack.cluster.v1.cluster.Cluster` instance.
|
||||
:param kwargs \*\*query: Optional query parameters to be sent to
|
||||
restrict the policies to be returned. Available parameters include:
|
||||
|
||||
* enabled: A boolean value indicating whether the policy is
|
||||
enabled on the cluster.
|
||||
:returns: A generator of cluster-policy binding instances.
|
||||
"""
|
||||
cluster_id = resource.Resource.get_id(cluster)
|
||||
cluster_id = resource2.Resource._get_id(cluster)
|
||||
return self._list(_cluster_policy.ClusterPolicy, paginated=False,
|
||||
path_args={'cluster_id': cluster_id}, **query)
|
||||
cluster_id=cluster_id, **query)
|
||||
|
||||
def get_cluster_policy(self, cluster_policy, cluster):
|
||||
"""Get a cluster-policy binding.
|
||||
|
@ -640,10 +645,8 @@ class Proxy(proxy.BaseProxy):
|
|||
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
||||
cluster-policy binding matching the criteria could be found.
|
||||
"""
|
||||
cluster_id = resource.Resource.get_id(cluster)
|
||||
policy_id = resource.Resource.get_id(cluster_policy)
|
||||
return self._get(_cluster_policy.ClusterPolicy, policy_id,
|
||||
path_args={'cluster_id': cluster_id})
|
||||
return self._get(_cluster_policy.ClusterPolicy, cluster_policy,
|
||||
cluster_id=cluster)
|
||||
|
||||
def create_receiver(self, **attrs):
|
||||
"""Create a new receiver from attributes.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Action(resource.Resource):
|
||||
|
@ -23,41 +23,44 @@ class Action(resource.Resource):
|
|||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'name', 'target', 'action', 'status', 'sort', 'global_project')
|
||||
|
||||
# Properties
|
||||
#: Name of the action.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: ID of the target object, which can be a cluster or a node.
|
||||
target_id = resource.prop('target')
|
||||
target_id = resource.Body('target')
|
||||
#: Built-in type name of action.
|
||||
action = resource.prop('action')
|
||||
action = resource.Body('action')
|
||||
#: A string representation of the reason why the action was created.
|
||||
cause = resource.prop('cause')
|
||||
cause = resource.Body('cause')
|
||||
#: The owning engine that is currently running the action.
|
||||
owner_id = resource.prop('owner')
|
||||
owner_id = resource.Body('owner')
|
||||
#: Interval in seconds between two consecutive executions.
|
||||
interval = resource.prop('interval')
|
||||
interval = resource.Body('interval')
|
||||
#: The time the action was started.
|
||||
start_at = resource.prop('start_time')
|
||||
start_at = resource.Body('start_time')
|
||||
#: The time the action completed execution.
|
||||
end_at = resource.prop('end_time')
|
||||
end_at = resource.Body('end_time')
|
||||
#: The timeout in seconds.
|
||||
timeout = resource.prop('timeout')
|
||||
timeout = resource.Body('timeout')
|
||||
#: Current status of the action.
|
||||
status = resource.prop('status')
|
||||
status = resource.Body('status')
|
||||
#: A string describing the reason that brought the action to its current
|
||||
# status.
|
||||
status_reason = resource.prop('status_reason')
|
||||
status_reason = resource.Body('status_reason')
|
||||
#: A dictionary containing the inputs to the action.
|
||||
inputs = resource.prop('inputs', type=dict)
|
||||
inputs = resource.Body('inputs', type=dict)
|
||||
#: A dictionary containing the outputs to the action.
|
||||
outputs = resource.prop('outputs', type=dict)
|
||||
outputs = resource.Body('outputs', type=dict)
|
||||
#: A list of actions that must finish before this action starts execution.
|
||||
depends_on = resource.prop('depends_on', type=list)
|
||||
depends_on = resource.Body('depends_on', type=list)
|
||||
#: A list of actions that can start only after this action has finished.
|
||||
depended_by = resource.prop('depended_by', type=list)
|
||||
depended_by = resource.Body('depended_by', type=list)
|
||||
#: Timestamp when the action is created.
|
||||
created_at = resource.prop('created_at')
|
||||
created_at = resource.Body('created_at')
|
||||
#: Timestamp when the action was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
updated_at = resource.Body('updated_at')
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class BuildInfo(resource.Resource):
|
||||
|
@ -20,8 +20,10 @@ class BuildInfo(resource.Resource):
|
|||
service = cluster_service.ClusterService()
|
||||
|
||||
# Capabilities
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
|
||||
# Properties
|
||||
api = resource.prop('api')
|
||||
engine = resource.prop('engine')
|
||||
#: String representation of the API build version
|
||||
api = resource.Body('api')
|
||||
#: String representation of the engine build version
|
||||
engine = resource.Body('engine')
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
from openstack import utils
|
||||
|
||||
|
||||
|
@ -23,59 +23,62 @@ class Cluster(resource.Resource):
|
|||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
patch_update = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'name', 'status', 'sort', 'global_project')
|
||||
|
||||
# Properties
|
||||
#: The name of the cluster.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The ID of the profile used by this cluster.
|
||||
profile_id = resource.prop('profile_id')
|
||||
profile_id = resource.Body('profile_id')
|
||||
#: The ID of the user who created this cluster, thus the owner of it.
|
||||
user_id = resource.prop('user')
|
||||
user_id = resource.Body('user')
|
||||
#: The ID of the project this cluster belongs to.
|
||||
project_id = resource.prop('project')
|
||||
project_id = resource.Body('project')
|
||||
#: The domain ID of the cluster owner.
|
||||
domain_id = resource.prop('domain')
|
||||
domain_id = resource.Body('domain')
|
||||
#: The ID of the parent cluster (if any).
|
||||
parent_id = resource.prop('parent')
|
||||
parent_id = resource.Body('parent')
|
||||
#: Timestamp of when the cluster was initialized.
|
||||
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||
init_at = resource.prop('init_at')
|
||||
init_at = resource.Body('init_at')
|
||||
#: Timestamp of when the cluster was created.
|
||||
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||
created_at = resource.prop('created_at')
|
||||
created_at = resource.Body('created_at')
|
||||
#: Timestamp of when the cluster was last updated.
|
||||
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||
updated_at = resource.prop('updated_at')
|
||||
updated_at = resource.Body('updated_at')
|
||||
#: Lower bound (inclusive) for the size of the cluster.
|
||||
min_size = resource.prop('min_size', type=int)
|
||||
min_size = resource.Body('min_size', type=int)
|
||||
#: Upper bound (inclusive) for the size of the cluster. A value of
|
||||
#: -1 indicates that there is no upper limit of cluster size.
|
||||
max_size = resource.prop('max_size', type=int)
|
||||
max_size = resource.Body('max_size', type=int)
|
||||
#: Desired capacity for the cluster. A cluster would be created at the
|
||||
#: scale specified by this value.
|
||||
desired_capacity = resource.prop('desired_capacity', type=int)
|
||||
desired_capacity = resource.Body('desired_capacity', type=int)
|
||||
#: Default timeout (in seconds) for cluster operations.
|
||||
timeout = resource.prop('timeout')
|
||||
timeout = resource.Body('timeout')
|
||||
#: A string representation of the cluster status.
|
||||
status = resource.prop('status')
|
||||
status = resource.Body('status')
|
||||
#: A string describing the reason why the cluster in current status.
|
||||
status_reason = resource.prop('status_reason')
|
||||
status_reason = resource.Body('status_reason')
|
||||
#: A collection of key-value pairs that are attached to the cluster.
|
||||
metadata = resource.prop('metadata', type=dict)
|
||||
metadata = resource.Body('metadata', type=dict)
|
||||
#: A dictionary with some runtime data associated with the cluster.
|
||||
data = resource.prop('data', type=dict)
|
||||
data = resource.Body('data', type=dict)
|
||||
#: A list IDs of nodes that are members of the cluster.
|
||||
node_ids = resource.prop('nodes')
|
||||
node_ids = resource.Body('nodes')
|
||||
#: Name of the profile used by the cluster.
|
||||
profile_name = resource.prop('profile_name')
|
||||
profile_name = resource.Body('profile_name')
|
||||
|
||||
def action(self, session, body):
|
||||
url = utils.urljoin(self.base_path, self.id, 'actions')
|
||||
url = utils.urljoin(self.base_path, self._get_id(self), 'actions')
|
||||
resp = session.post(url, endpoint_filter=self.service, json=body)
|
||||
return resp.json()
|
||||
|
||||
|
@ -152,17 +155,3 @@ class Cluster(resource.Resource):
|
|||
'recover': params
|
||||
}
|
||||
return self.action(session, body)
|
||||
|
||||
def delete(self, session):
|
||||
"""Delete the remote resource associated with this instance.
|
||||
|
||||
:param session: The session to use for making this request.
|
||||
:type session: :class:`~openstack.session.Session`
|
||||
|
||||
:returns: The instance of the Cluster which was deleted.
|
||||
:rtype: :class:`~openstack.cluster.v1.cluster.Cluster`.
|
||||
"""
|
||||
url = self._get_url(self, self.id)
|
||||
resp = session.delete(url, endpoint_filter=self.service)
|
||||
self.location = resp.headers['location']
|
||||
return self
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class ClusterPolicy(resource.Resource):
|
||||
id_attribute = 'policy_id'
|
||||
resource_key = 'cluster_policy'
|
||||
resources_key = 'cluster_policies'
|
||||
base_path = '/clusters/%(cluster_id)s/policies'
|
||||
|
@ -23,20 +22,20 @@ class ClusterPolicy(resource.Resource):
|
|||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
|
||||
# Properties
|
||||
#: ID of the policy object.
|
||||
policy_id = resource.prop('policy_id')
|
||||
policy_id = resource.Body('policy_id', alternate_id=True)
|
||||
#: Name of the policy object.
|
||||
policy_name = resource.prop('policy_name')
|
||||
policy_name = resource.Body('policy_name')
|
||||
#: ID of the cluster object.
|
||||
cluster_id = resource.prop('cluster_id')
|
||||
cluster_id = resource.URI('cluster_id')
|
||||
#: Name of the cluster object.
|
||||
cluster_name = resource.prop('cluster_name')
|
||||
cluster_name = resource.Body('cluster_name')
|
||||
#: Type string of the policy.
|
||||
policy_type = resource.prop('policy_type')
|
||||
policy_type = resource.Body('policy_type')
|
||||
#: Whether the policy is enabled on the cluster. *Type: bool*
|
||||
is_enabled = resource.prop('enabled', type=bool)
|
||||
is_enabled = resource.Body('enabled', type=bool)
|
||||
#: Data associated with the cluster-policy binding.
|
||||
data = resource.prop('data', type=dict)
|
||||
data = resource.Body('data', type=dict)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Event(resource.Resource):
|
||||
|
@ -23,29 +23,33 @@ class Event(resource.Resource):
|
|||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'oname', 'otype', 'oid', 'cluster_id', 'action', 'level',
|
||||
'sort', 'global_project')
|
||||
|
||||
# Properties
|
||||
#: Timestamp string (in ISO8601 format) when the event was generated.
|
||||
generated_at = resource.prop('timestamp')
|
||||
generated_at = resource.Body('timestamp')
|
||||
#: The UUID of the object related to this event.
|
||||
obj_id = resource.prop('oid')
|
||||
obj_id = resource.Body('oid')
|
||||
#: The name of the object related to this event.
|
||||
obj_name = resource.prop('oname')
|
||||
obj_name = resource.Body('oname')
|
||||
#: The type name of the object related to this event.
|
||||
obj_type = resource.prop('otype')
|
||||
obj_type = resource.Body('otype')
|
||||
#: The UUID of the cluster related to this event, if any.
|
||||
cluster_id = resource.prop('cluster_id')
|
||||
cluster_id = resource.Body('cluster_id')
|
||||
#: The event level (priority).
|
||||
level = resource.prop('level')
|
||||
level = resource.Body('level')
|
||||
#: The ID of the user.
|
||||
user_id = resource.prop('user')
|
||||
user_id = resource.Body('user')
|
||||
#: The ID of the project (tenant).
|
||||
project_id = resource.prop('project')
|
||||
project_id = resource.Body('project')
|
||||
#: The string representation of the action associated with the event.
|
||||
action = resource.prop('action')
|
||||
action = resource.Body('action')
|
||||
#: The status of the associated object.
|
||||
status = resource.prop('status')
|
||||
status = resource.Body('status')
|
||||
#: A string description of the reason that brought the object into its
|
||||
#: current status.
|
||||
status_reason = resource.prop('status_reason')
|
||||
status_reason = resource.Body('status_reason')
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
from openstack import utils
|
||||
|
||||
|
||||
|
@ -23,53 +23,56 @@ class Node(resource.Resource):
|
|||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
patch_update = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'show_details', 'name', 'sort', 'global_project', 'cluster_id')
|
||||
|
||||
# Properties
|
||||
#: The name of the node.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The ID of the physical object that backs the node.
|
||||
physical_id = resource.prop('physical_id')
|
||||
physical_id = resource.Body('physical_id')
|
||||
#: The ID of the cluster in which this node is a member.
|
||||
#: A node is an orphan node if this field is empty.
|
||||
cluster_id = resource.prop('cluster_id')
|
||||
cluster_id = resource.Body('cluster_id')
|
||||
#: The ID of the profile used by this node.
|
||||
profile_id = resource.prop('profile_id')
|
||||
profile_id = resource.Body('profile_id')
|
||||
#: The ID of the project this node belongs to.
|
||||
project_id = resource.prop('project')
|
||||
project_id = resource.Body('project')
|
||||
#: The name of the profile used by this node.
|
||||
profile_name = resource.prop('profile_name')
|
||||
profile_name = resource.Body('profile_name')
|
||||
#: An integer that is unique inside the owning cluster.
|
||||
#: A value of -1 means this node is an orphan node.
|
||||
index = resource.prop('index', type=int)
|
||||
index = resource.Body('index', type=int)
|
||||
#: A string indicating the role the node plays in a cluster.
|
||||
role = resource.prop('role')
|
||||
role = resource.Body('role')
|
||||
#: The timestamp of the node object's initialization.
|
||||
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||
init_at = resource.prop('init_at')
|
||||
init_at = resource.Body('init_at')
|
||||
#: The timestamp of the node's creation, i.e. the physical object
|
||||
#: represented by this node is also created.
|
||||
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||
created_at = resource.prop('created_at')
|
||||
created_at = resource.Body('created_at')
|
||||
#: The timestamp the node was last updated.
|
||||
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||
updated_at = resource.prop('updated_at')
|
||||
updated_at = resource.Body('updated_at')
|
||||
#: A string indicating the node's status.
|
||||
status = resource.prop('status')
|
||||
status = resource.Body('status')
|
||||
#: A string describing why the node entered its current status.
|
||||
status_reason = resource.prop('status_reason')
|
||||
status_reason = resource.Body('status_reason')
|
||||
#: A map containing key-value pairs attached to the node.
|
||||
metadata = resource.prop('tags', type=dict)
|
||||
metadata = resource.Body('tags', type=dict)
|
||||
#: A map containing some runtime data for this node.
|
||||
data = resource.prop('data', type=dict)
|
||||
data = resource.Body('data', type=dict)
|
||||
#: A map containing the details of the physical object this node
|
||||
#: represents
|
||||
details = resource.prop('details', type=dict)
|
||||
details = resource.Body('details', type=dict)
|
||||
|
||||
def _action(self, session, body):
|
||||
"""Procedure the invoke an action API.
|
||||
|
@ -103,16 +106,14 @@ class Node(resource.Resource):
|
|||
}
|
||||
return self._action(session, body)
|
||||
|
||||
def delete(self, session):
|
||||
"""Delete the remote resource associated with this instance.
|
||||
|
||||
:param session: The session to use for making this request.
|
||||
:type session: :class:`~openstack.session.Session`
|
||||
class NodeDetail(Node):
|
||||
base_path = '/nodes/%(node_id)s?show_details=True'
|
||||
|
||||
:returns: The instance of the Node which was deleted.
|
||||
:rtype: :class:`~openstack.cluster.v1.node.Node`.
|
||||
"""
|
||||
url = self._get_url(self, self.id)
|
||||
resp = session.delete(url, endpoint_filter=self.service)
|
||||
self.location = resp.headers['location']
|
||||
return self
|
||||
allow_create = False
|
||||
allow_get = True
|
||||
allow_update = False
|
||||
allow_delete = False
|
||||
allow_list = False
|
||||
|
||||
node_id = resource.URI('node_id')
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Policy(resource.Resource):
|
||||
|
@ -22,23 +22,26 @@ class Policy(resource.Resource):
|
|||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_create = True
|
||||
allow_delete = True
|
||||
allow_update = True
|
||||
|
||||
patch_update = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'name', 'type', 'sort', 'global_project')
|
||||
|
||||
# Properties
|
||||
#: The name of the policy.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The type name of the policy.
|
||||
type = resource.prop('type')
|
||||
type = resource.Body('type')
|
||||
#: The timestamp when the policy is created.
|
||||
created_at = resource.prop('created_at')
|
||||
created_at = resource.Body('created_at')
|
||||
#: The timestamp when the policy was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
updated_at = resource.Body('updated_at')
|
||||
#: The specification of the policy.
|
||||
spec = resource.prop('spec', type=dict)
|
||||
spec = resource.Body('spec', type=dict)
|
||||
#: A dictionary containing runtime data of the policy.
|
||||
data = resource.prop('data', type=dict)
|
||||
data = resource.Body('data', type=dict)
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class PolicyType(resource.Resource):
|
||||
id_attribute = 'name'
|
||||
resource_key = 'policy_type'
|
||||
resources_key = 'policy_types'
|
||||
base_path = '/policy-types'
|
||||
|
@ -23,10 +22,10 @@ class PolicyType(resource.Resource):
|
|||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
|
||||
# Properties
|
||||
#: Name of policy type.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name', alternate_id=True)
|
||||
#: The schema of the policy type.
|
||||
schema = resource.prop('schema')
|
||||
schema = resource.Body('schema')
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Profile(resource.Resource):
|
||||
|
@ -22,23 +22,26 @@ class Profile(resource.Resource):
|
|||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
patch_update = True
|
||||
|
||||
# properties
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'name', 'type', 'metadata')
|
||||
|
||||
# Bodyerties
|
||||
#: The name of the profile
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The type of the profile.
|
||||
type_name = resource.prop('type')
|
||||
type_name = resource.Body('type')
|
||||
#: The spec of the profile.
|
||||
spec = resource.prop('spec', type=dict)
|
||||
spec = resource.Body('spec', type=dict)
|
||||
#: A collection of key-value pairs that are attached to the profile.
|
||||
metadata = resource.prop('metadata', type=dict)
|
||||
metadata = resource.Body('metadata', type=dict)
|
||||
#: Timestamp of when the profile was created.
|
||||
created_at = resource.prop('created_at')
|
||||
created_at = resource.Body('created_at')
|
||||
#: Timestamp of when the profile was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
updated_at = resource.Body('updated_at')
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class ProfileType(resource.Resource):
|
||||
id_attribute = 'name'
|
||||
resource_key = 'profile_type'
|
||||
resources_key = 'profile_types'
|
||||
base_path = '/profile-types'
|
||||
|
@ -23,10 +22,10 @@ class ProfileType(resource.Resource):
|
|||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
|
||||
# Properties
|
||||
#: Name of the profile type.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name', alternate_id=True)
|
||||
#: The schema of the profile type.
|
||||
schema = resource.prop('schema')
|
||||
schema = resource.Body('schema')
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
from openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Receiver(resource.Resource):
|
||||
|
@ -22,34 +22,37 @@ class Receiver(resource.Resource):
|
|||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_create = True
|
||||
allow_delete = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'name', 'type', 'cluster_id', 'action', 'sort', 'global_project')
|
||||
|
||||
# Properties
|
||||
#: The name of the receiver.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The type of the receiver.
|
||||
type = resource.prop('type')
|
||||
type = resource.Body('type')
|
||||
#: The ID of the user who created the receiver, thus the owner of it.
|
||||
user_id = resource.prop('user')
|
||||
user_id = resource.Body('user')
|
||||
#: The ID of the project this receiver belongs to.
|
||||
project_id = resource.prop('project')
|
||||
project_id = resource.Body('project')
|
||||
#: The domain ID of the receiver.
|
||||
domain_id = resource.prop('domain')
|
||||
domain_id = resource.Body('domain')
|
||||
#: The ID of the targeted cluster.
|
||||
cluster_id = resource.prop('cluster_id')
|
||||
cluster_id = resource.Body('cluster_id')
|
||||
#: The name of the targeted action.
|
||||
action = resource.prop('action')
|
||||
action = resource.Body('action')
|
||||
#: Timestamp of when the receiver was created.
|
||||
created_at = resource.prop('created_at')
|
||||
created_at = resource.Body('created_at')
|
||||
#: Timestamp of when the receiver was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
updated_at = resource.Body('updated_at')
|
||||
#: The credential of the impersonated user.
|
||||
actor = resource.prop('actor', type=dict)
|
||||
actor = resource.Body('actor', type=dict)
|
||||
#: A dictionary containing key-value pairs that are provided to the
|
||||
#: targeted action.
|
||||
params = resource.prop('params', type=dict)
|
||||
params = resource.Body('params', type=dict)
|
||||
#: The information about the channel through which you can trigger the
|
||||
#: receiver hence the associated action.
|
||||
channel = resource.prop('channel', type=dict)
|
||||
channel = resource.Body('channel', type=dict)
|
||||
|
|
|
@ -19,6 +19,7 @@ FAKE_ID = '633bd3c6-520b-420f-8e6a-dc2a47022b53'
|
|||
FAKE_NAME = 'node_create_c3783474'
|
||||
|
||||
FAKE = {
|
||||
'id': FAKE_ID,
|
||||
'name': FAKE_NAME,
|
||||
'target': 'c378e474-d091-43a3-b083-e19719291358',
|
||||
'action': 'NODE_CREATE',
|
||||
|
@ -50,12 +51,12 @@ class TestAction(testtools.TestCase):
|
|||
self.assertEqual('actions', sot.resources_key)
|
||||
self.assertEqual('/actions', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = action.Action(FAKE)
|
||||
self.assertIsNone(sot.id)
|
||||
sot = action.Action(**FAKE)
|
||||
self.assertEqual(FAKE['id'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['target'], sot.target_id)
|
||||
self.assertEqual(FAKE['action'], sot.action)
|
||||
|
|
|
@ -35,10 +35,9 @@ class TestBuildInfo(testtools.TestCase):
|
|||
self.assertEqual('/build-info', sot.base_path)
|
||||
self.assertEqual('build_info', sot.resource_key)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = build_info.BuildInfo(FAKE)
|
||||
self.assertIsNone(sot.id)
|
||||
sot = build_info.BuildInfo(**FAKE)
|
||||
self.assertEqual(FAKE['api'], sot.api)
|
||||
self.assertEqual(FAKE['engine'], sot.engine)
|
||||
|
|
|
@ -20,6 +20,7 @@ FAKE_ID = '092d0955-2645-461a-b8fa-6a44655cdb2c'
|
|||
FAKE_NAME = 'test_cluster'
|
||||
|
||||
FAKE = {
|
||||
'id': 'IDENTIFIER',
|
||||
'desired_capacity': 1,
|
||||
'max_size': 3,
|
||||
'min_size': 0,
|
||||
|
@ -74,14 +75,15 @@ class TestCluster(testtools.TestCase):
|
|||
self.assertEqual('/clusters', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
self.assertIsNone(sot.id)
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
self.assertEqual(FAKE['id'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
|
||||
self.assertEqual(FAKE['profile_id'], sot.profile_id)
|
||||
|
@ -98,8 +100,7 @@ class TestCluster(testtools.TestCase):
|
|||
self.assertEqual(FAKE['updated_at'], sot.updated_at)
|
||||
|
||||
def test_scale_in(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -112,8 +113,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_scale_out(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -126,8 +126,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_resize(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -140,8 +139,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_add_nodes(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -154,8 +152,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_del_nodes(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -168,8 +165,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_policy_attach(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -191,8 +187,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_policy_detach(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -206,8 +201,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_policy_update(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -229,8 +223,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_check(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -243,8 +236,7 @@ class TestCluster(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_recover(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = cluster.Cluster(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = mock.Mock(return_value='')
|
||||
|
@ -255,14 +247,3 @@ class TestCluster(testtools.TestCase):
|
|||
body = {'recover': {}}
|
||||
sess.post.assert_called_once_with(url, endpoint_filter=sot.service,
|
||||
json=body)
|
||||
|
||||
def test_cluster_delete(self):
|
||||
sot = cluster.Cluster(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
url = 'clusters/%s' % sot.id
|
||||
resp = mock.Mock(headers={'location': 'actions/fake_action'})
|
||||
sess = mock.Mock()
|
||||
sess.delete = mock.Mock(return_value=resp)
|
||||
clus = sot.delete(sess)
|
||||
self.assertEqual('actions/fake_action', clus.location)
|
||||
sess.delete.assert_called_once_with(url, endpoint_filter=sot.service)
|
||||
|
|
|
@ -35,15 +35,14 @@ class TestClusterPolicy(testtools.TestCase):
|
|||
sot = cluster_policy.ClusterPolicy()
|
||||
self.assertEqual('cluster_policy', sot.resource_key)
|
||||
self.assertEqual('cluster_policies', sot.resources_key)
|
||||
self.assertEqual('policy_id', sot.id_attribute)
|
||||
self.assertEqual('/clusters/%(cluster_id)s/policies',
|
||||
sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = cluster_policy.ClusterPolicy(FAKE)
|
||||
sot = cluster_policy.ClusterPolicy(**FAKE)
|
||||
self.assertEqual(FAKE['policy_id'], sot.id)
|
||||
self.assertEqual(FAKE['cluster_id'], sot.cluster_id)
|
||||
self.assertEqual(FAKE['cluster_name'], sot.cluster_name)
|
||||
|
|
|
@ -18,10 +18,8 @@ from openstack.cluster.v1 import event
|
|||
FAKE = {
|
||||
'action': 'NODE_CREATE',
|
||||
'cluster_id': None,
|
||||
'deleted_time': None,
|
||||
'id': 'ffaed25e-46f5-4089-8e20-b3b4722fd597',
|
||||
'level': '20',
|
||||
'metadata': {},
|
||||
'oid': 'efff1c11-2ada-47da-bedd-2c9af4fd099a',
|
||||
'oname': 'node_create_b4a49016',
|
||||
'otype': 'NODEACTION',
|
||||
|
@ -44,17 +42,15 @@ class TestEvent(testtools.TestCase):
|
|||
self.assertEqual('events', sot.resources_key)
|
||||
self.assertEqual('/events', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = event.Event(FAKE)
|
||||
sot = event.Event(**FAKE)
|
||||
self.assertEqual(FAKE['id'], sot.id)
|
||||
self.assertEqual(FAKE['action'], sot.action)
|
||||
self.assertEqual(FAKE['cluster_id'], sot.cluster_id)
|
||||
self.assertEqual(FAKE['deleted_time'], sot.deleted_time)
|
||||
self.assertEqual(FAKE['level'], sot.level)
|
||||
self.assertEqual(FAKE['metadata'], sot.metadata)
|
||||
self.assertEqual(FAKE['oid'], sot.obj_id)
|
||||
self.assertEqual(FAKE['oname'], sot.obj_name)
|
||||
self.assertEqual(FAKE['otype'], sot.obj_type)
|
||||
|
|
|
@ -56,9 +56,6 @@ FAKE_CREATE_RESP = {
|
|||
|
||||
class TestNode(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNode, self).setUp()
|
||||
|
||||
def test_basic(self):
|
||||
sot = node.Node()
|
||||
self.assertEqual('node', sot.resource_key)
|
||||
|
@ -66,13 +63,13 @@ class TestNode(testtools.TestCase):
|
|||
self.assertEqual('/nodes', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = node.Node(FAKE)
|
||||
sot = node.Node(**FAKE)
|
||||
self.assertEqual(FAKE['id'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['profile_id'], sot.profile_id)
|
||||
|
@ -86,8 +83,7 @@ class TestNode(testtools.TestCase):
|
|||
self.assertEqual(FAKE['updated_at'], sot.updated_at)
|
||||
|
||||
def test_check(self):
|
||||
sot = node.Node(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = node.Node(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = {'action': '1234-5678-abcd'}
|
||||
|
@ -100,8 +96,7 @@ class TestNode(testtools.TestCase):
|
|||
json=body)
|
||||
|
||||
def test_recover(self):
|
||||
sot = node.Node(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
sot = node.Node(**FAKE)
|
||||
|
||||
resp = mock.Mock()
|
||||
resp.json = {'action': '2345-6789-bbbb'}
|
||||
|
@ -113,13 +108,14 @@ class TestNode(testtools.TestCase):
|
|||
sess.post.assert_called_once_with(url, endpoint_filter=sot.service,
|
||||
json=body)
|
||||
|
||||
def test_node_delete(self):
|
||||
sot = node.Node(FAKE)
|
||||
sot['id'] = 'IDENTIFIER'
|
||||
url = 'nodes/%s' % sot.id
|
||||
resp = mock.Mock(headers={'location': 'actions/fake_action'})
|
||||
sess = mock.Mock()
|
||||
sess.delete = mock.Mock(return_value=resp)
|
||||
nod = sot.delete(sess)
|
||||
self.assertEqual('actions/fake_action', nod.location)
|
||||
sess.delete.assert_called_once_with(url, endpoint_filter=sot.service)
|
||||
|
||||
class TestNodeDetail(testtools.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
sot = node.NodeDetail()
|
||||
self.assertEqual('/nodes/%(node_id)s?show_details=True', sot.base_path)
|
||||
self.assertFalse(sot.allow_create)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertFalse(sot.allow_delete)
|
||||
self.assertFalse(sot.allow_list)
|
||||
|
|
|
@ -19,6 +19,7 @@ FAKE_ID = 'ac5415bd-f522-4160-8be0-f8853e4bc332'
|
|||
FAKE_NAME = 'test_policy'
|
||||
|
||||
FAKE = {
|
||||
'id': FAKE_ID,
|
||||
'name': FAKE_NAME,
|
||||
'spec': {
|
||||
'type': 'senlin.policy.deletion',
|
||||
|
@ -49,14 +50,14 @@ class TestPolicy(testtools.TestCase):
|
|||
self.assertEqual('/policies', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = policy.Policy(FAKE)
|
||||
self.assertIsNone(sot.id)
|
||||
sot = policy.Policy(**FAKE)
|
||||
self.assertEqual(FAKE['id'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['spec'], sot.spec)
|
||||
self.assertEqual(FAKE['data'], sot.data)
|
||||
|
|
|
@ -27,16 +27,15 @@ class TestPolicyType(testtools.TestCase):
|
|||
|
||||
def test_basic(self):
|
||||
sot = policy_type.PolicyType()
|
||||
self.assertEqual('name', sot.id_attribute)
|
||||
self.assertEqual('policy_type', sot.resource_key)
|
||||
self.assertEqual('policy_types', sot.resources_key)
|
||||
self.assertEqual('/policy-types', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = policy_type.PolicyType(FAKE)
|
||||
self.assertEqual(FAKE['name'], sot.id)
|
||||
sot = policy_type.PolicyType(**FAKE)
|
||||
self.assertEqual(FAKE['name'], sot._get_id(sot))
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['schema'], sot.schema)
|
||||
|
|
|
@ -50,14 +50,14 @@ class TestProfile(testtools.TestCase):
|
|||
self.assertEqual('/profiles', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
self.assertTrue(sot.patch_update)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = profile.Profile(FAKE)
|
||||
sot = profile.Profile(**FAKE)
|
||||
self.assertEqual(FAKE['id'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['metadata'], sot.metadata)
|
||||
|
|
|
@ -27,16 +27,15 @@ class TestProfileType(testtools.TestCase):
|
|||
|
||||
def test_basic(self):
|
||||
sot = profile_type.ProfileType()
|
||||
self.assertEqual('name', sot.id_attribute)
|
||||
self.assertEqual('profile_type', sot.resource_key)
|
||||
self.assertEqual('profile_types', sot.resources_key)
|
||||
self.assertEqual('/profile-types', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = profile_type.ProfileType(FAKE)
|
||||
self.assertEqual(FAKE['name'], sot.id)
|
||||
sot = profile_type.ProfileType(**FAKE)
|
||||
self.assertEqual(FAKE['name'], sot._get_id(sot))
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['schema'], sot.schema)
|
||||
|
|
|
@ -24,18 +24,19 @@ from openstack.cluster.v1 import policy_type
|
|||
from openstack.cluster.v1 import profile
|
||||
from openstack.cluster.v1 import profile_type
|
||||
from openstack.cluster.v1 import receiver
|
||||
from openstack import proxy as proxy_base
|
||||
from openstack.tests.unit import test_proxy_base
|
||||
from openstack import proxy2 as proxy_base
|
||||
from openstack.tests.unit import test_proxy_base2
|
||||
|
||||
|
||||
class TestClusterProxy(test_proxy_base.TestProxyBase):
|
||||
class TestClusterProxy(test_proxy_base2.TestProxyBase):
|
||||
def setUp(self):
|
||||
super(TestClusterProxy, self).setUp()
|
||||
self.proxy = _proxy.Proxy(self.session)
|
||||
|
||||
def test_build_info_get(self):
|
||||
self.verify_get(self.proxy.get_build_info, build_info.BuildInfo,
|
||||
ignore_value=True)
|
||||
ignore_value=True,
|
||||
expected_kwargs={'requires_id': False})
|
||||
|
||||
def test_profile_types(self):
|
||||
self.verify_list(self.proxy.profile_types,
|
||||
|
@ -103,7 +104,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_add_nodes(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.add_nodes",
|
||||
self.proxy.cluster_add_nodes,
|
||||
|
@ -113,7 +114,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_add_nodes_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.add_nodes",
|
||||
self.proxy.cluster_add_nodes,
|
||||
method_args=[mock_cluster, ["node1"]],
|
||||
|
@ -121,7 +122,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_del_nodes(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.del_nodes",
|
||||
self.proxy.cluster_del_nodes,
|
||||
|
@ -131,7 +132,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_del_nodes_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.del_nodes",
|
||||
self.proxy.cluster_del_nodes,
|
||||
method_args=[mock_cluster, ["node1"]],
|
||||
|
@ -139,7 +140,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_scale_out(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.scale_out",
|
||||
self.proxy.cluster_scale_out,
|
||||
|
@ -149,7 +150,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_scale_out_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.scale_out",
|
||||
self.proxy.cluster_scale_out,
|
||||
method_args=[mock_cluster, 5],
|
||||
|
@ -157,7 +158,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_scale_in(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.scale_in",
|
||||
self.proxy.cluster_scale_in,
|
||||
|
@ -167,7 +168,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_scale_in_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.scale_in",
|
||||
self.proxy.cluster_scale_in,
|
||||
method_args=[mock_cluster, 5],
|
||||
|
@ -175,7 +176,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_resize(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.resize",
|
||||
self.proxy.cluster_resize,
|
||||
|
@ -186,7 +187,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_resize_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.resize",
|
||||
self.proxy.cluster_resize,
|
||||
method_args=[mock_cluster],
|
||||
|
@ -195,7 +196,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_attach_policy(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.policy_attach",
|
||||
self.proxy.cluster_attach_policy,
|
||||
|
@ -207,7 +208,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_attach_policy_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.policy_attach",
|
||||
self.proxy.cluster_attach_policy,
|
||||
method_args=[mock_cluster, "FAKE_POLICY"],
|
||||
|
@ -217,7 +218,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_detach_policy(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.policy_detach",
|
||||
self.proxy.cluster_detach_policy,
|
||||
|
@ -227,7 +228,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_detach_policy_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.policy_detach",
|
||||
self.proxy.cluster_detach_policy,
|
||||
method_args=[mock_cluster, "FAKE_POLICY"],
|
||||
|
@ -235,7 +236,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_find')
|
||||
def test_cluster_update_policy(self, mock_find):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_find.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.policy_update",
|
||||
self.proxy.cluster_update_policy,
|
||||
|
@ -247,7 +248,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
ignore_missing=False)
|
||||
|
||||
def test_cluster_update_policy_with_obj(self):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.policy_update",
|
||||
self.proxy.cluster_update_policy,
|
||||
method_args=[mock_cluster, "FAKE_POLICY"],
|
||||
|
@ -257,7 +258,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
def test_cluster_check(self, mock_get):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_get.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.check",
|
||||
self.proxy.check_cluster,
|
||||
|
@ -266,7 +267,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
def test_cluster_recover(self, mock_get):
|
||||
mock_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
mock_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
mock_get.return_value = mock_cluster
|
||||
self._verify("openstack.cluster.v1.cluster.Cluster.recover",
|
||||
self.proxy.recover_cluster,
|
||||
|
@ -286,13 +287,16 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
self.verify_find(self.proxy.find_node, node.Node)
|
||||
|
||||
def test_node_get(self):
|
||||
self.verify_get(self.proxy.get_node, node.Node, args=None,
|
||||
expected_kwargs={'args': None})
|
||||
self.verify_get(self.proxy.get_node, node.Node)
|
||||
|
||||
def test_node_get_with_args(self):
|
||||
self.verify_get(self.proxy.get_node, node.Node, args={'details': True},
|
||||
method_kwargs={'args': {'details': True}},
|
||||
expected_kwargs={'args': {'details': True}})
|
||||
def test_node_get_with_details(self):
|
||||
self._verify2('openstack.proxy2.BaseProxy._get',
|
||||
self.proxy.get_node,
|
||||
method_args=['NODE_ID'],
|
||||
method_kwargs={'details': True},
|
||||
expected_args=[node.NodeDetail],
|
||||
expected_kwargs={'node_id': 'NODE_ID',
|
||||
'requires_id': False})
|
||||
|
||||
def test_nodes(self):
|
||||
self.verify_list(self.proxy.nodes, node.Node,
|
||||
|
@ -305,7 +309,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
def test_node_check(self, mock_get):
|
||||
mock_node = node.Node.from_id('FAKE_NODE')
|
||||
mock_node = node.Node.new(id='FAKE_NODE')
|
||||
mock_get.return_value = mock_node
|
||||
self._verify("openstack.cluster.v1.node.Node.check",
|
||||
self.proxy.check_node,
|
||||
|
@ -314,7 +318,7 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
|
||||
@mock.patch.object(proxy_base.BaseProxy, '_get_resource')
|
||||
def test_node_recover(self, mock_get):
|
||||
mock_node = node.Node.from_id('FAKE_NODE')
|
||||
mock_node = node.Node.new(id='FAKE_NODE')
|
||||
mock_get.return_value = mock_node
|
||||
self._verify("openstack.cluster.v1.node.Node.recover",
|
||||
self.proxy.recover_node,
|
||||
|
@ -349,39 +353,36 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
self.verify_list(self.proxy.cluster_policies,
|
||||
cluster_policy.ClusterPolicy,
|
||||
paginated=False, method_args=["FAKE_CLUSTER"],
|
||||
expected_kwargs={"path_args": {
|
||||
"cluster_id": "FAKE_CLUSTER"}})
|
||||
expected_kwargs={"cluster_id": "FAKE_CLUSTER"})
|
||||
|
||||
def test_get_cluster_policies(self):
|
||||
fake_policy = policy.Policy.from_id("FAKE_POLICY")
|
||||
fake_cluster = cluster.Cluster.from_id('FAKE_CLUSTER')
|
||||
def test_get_cluster_policy(self):
|
||||
fake_policy = cluster_policy.ClusterPolicy.new(id="FAKE_POLICY")
|
||||
fake_cluster = cluster.Cluster.new(id='FAKE_CLUSTER')
|
||||
|
||||
# Policy object as input
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
# ClusterPolicy object as input
|
||||
self._verify2('openstack.proxy2.BaseProxy._get',
|
||||
self.proxy.get_cluster_policy,
|
||||
method_args=[fake_policy, "FAKE_CLUSTER"],
|
||||
expected_args=[cluster_policy.ClusterPolicy,
|
||||
'FAKE_POLICY'],
|
||||
expected_kwargs={"path_args": {
|
||||
"cluster_id": "FAKE_CLUSTER"}})
|
||||
fake_policy],
|
||||
expected_kwargs={'cluster_id': 'FAKE_CLUSTER'},
|
||||
expected_result=fake_policy)
|
||||
|
||||
# Policy ID as input
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy2.BaseProxy._get',
|
||||
self.proxy.get_cluster_policy,
|
||||
method_args=["FAKE_POLICY", "FAKE_CLUSTER"],
|
||||
expected_args=[cluster_policy.ClusterPolicy,
|
||||
"FAKE_POLICY"],
|
||||
expected_kwargs={"path_args": {
|
||||
"cluster_id": "FAKE_CLUSTER"}})
|
||||
expected_kwargs={"cluster_id": "FAKE_CLUSTER"})
|
||||
|
||||
# Cluster object as input
|
||||
self._verify2('openstack.proxy.BaseProxy._get',
|
||||
self._verify2('openstack.proxy2.BaseProxy._get',
|
||||
self.proxy.get_cluster_policy,
|
||||
method_args=["FAKE_POLICY", fake_cluster],
|
||||
expected_args=[cluster_policy.ClusterPolicy,
|
||||
"FAKE_POLICY"],
|
||||
expected_kwargs={"path_args": {
|
||||
"cluster_id": "FAKE_CLUSTER"}})
|
||||
expected_kwargs={"cluster_id": fake_cluster})
|
||||
|
||||
def test_receiver_create(self):
|
||||
self.verify_create(self.proxy.create_receiver, receiver.Receiver)
|
||||
|
|
|
@ -19,6 +19,7 @@ FAKE_ID = 'ae63a10b-4a90-452c-aef1-113a0b255ee3'
|
|||
FAKE_NAME = 'test_receiver'
|
||||
|
||||
FAKE = {
|
||||
'id': FAKE_ID,
|
||||
'name': FAKE_NAME,
|
||||
'type': 'webhook',
|
||||
'cluster_id': 'FAKE_CLUSTER',
|
||||
|
@ -51,14 +52,14 @@ class TestReceiver(testtools.TestCase):
|
|||
self.assertEqual('/receivers', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = receiver.Receiver(FAKE)
|
||||
self.assertIsNone(sot.id)
|
||||
sot = receiver.Receiver(**FAKE)
|
||||
self.assertEqual(FAKE['id'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['type'], sot.type)
|
||||
self.assertEqual(FAKE['cluster_id'], sot.cluster_id)
|
||||
|
|
Loading…
Reference in New Issue