Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@atomic.action_timer("some")
def some_func(self, a, b):
return a + b
:param size: volume size (integer, in GB) or
dictionary, must contain two values:
min - minimum size volumes will be created as;
max - maximum size volumes will be created as.
:param image: image to be used to create initial volume
:param nested_level: amount of nested levels
:param kwargs: optional args to create volumes
"""
if image:
kwargs["imageRef"] = image
source_vol = self.cinder.create_volume(size, **kwargs)
kwargs.pop("imageRef", None)
for i in range(nested_level):
with atomic.ActionTimer(self, "cinder.clone_volume"):
source_vol = self.cinder.create_volume(
source_vol.size, source_volid=source_vol.id,
**kwargs)
@atomic.action_timer("glance.list_images")
def _list_images(self):
"""Returns user images list."""
return list(self.clients("glance").images.list())
@atomic.action_timer("barbican.orders_get")
def orders_get(self, order_ref):
"""Get the order
:param order_ref: The order reference
"""
return self._clients.barbican().orders.get(order_ref)
@atomic.action_timer("neutron.show_security_group_rule")
def _show_security_group_rule(self, security_group_rule, **kwargs):
"""Show information of a given security group rule.
:param security_group_rule: id of security group rule
:param kwargs: Optional additional arguments for roles list
:return: details of security group rule
"""
return self.clients("neutron").show_security_group_rule(
security_group_rule, **kwargs)
@atomic.action_timer("ec2.boot_servers")
def _boot_servers(self, image_id, flavor_name,
instance_num=1, **kwargs):
"""Boot multiple servers.
Returns when all the servers are actually booted and are in the
"Running" state.
:param image_id: ID of the image to be used for server creation
:param flavor_name: Name of the flavor to be used for server creation
:param instance_num: Number of instances to boot
:param kwargs: Other optional parameters to boot servers
:returns: List of created server objects
"""
reservation = self.clients("ec2").run_instances(
image_id=image_id,
@atomic.action_timer("nova.list_servers")
def _list_servers(self, detailed=True):
"""Returns user servers list."""
return self.clients("nova").servers.list(detailed)
def run(self):
client = self.get_ec2_client()
with atomic.ActionTimer(self, 'describe_regions_ec2api'):
data = client.describe_regions()
@atomic.action_timer("designate.list_zones")
def _list_zones(self, criterion=None, marker=None, limit=None):
"""Return user zone list.
:param criterion: API Criterion to filter by
:param marker: UUID marker of the item to start the page from
:param limit: How many items to return in the page.
:returns: list of designate zones
"""
return self.clients("designate", version="2").zones.list()
@atomic.action_timer("senlin.create_cluster")
def _create_cluster(self, profile_id, desired_capacity=0, min_size=0,
max_size=-1, timeout=60, metadata=None):
"""Create a new cluster from attributes.
:param profile_id: ID of profile used to create cluster
:param desired_capacity: The capacity or initial number of nodes
owned by the cluster
:param min_size: The minimum number of nodes owned by the cluster
:param max_size: The maximum number of nodes owned by the cluster.
-1 means no limit
:param timeout: The timeout value in minutes for cluster creation
:param metadata: A set of key value pairs to associate with the cluster
:returns: object of cluster created.
"""
attrs = {