-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from oracle/develop
Adding functionality for LB and Object Store
- Loading branch information
Showing
24 changed files
with
2,127 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2020, Oracle and/or its affiliates. | ||
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. | ||
|
||
pipeline { | ||
options { | ||
disableConcurrentBuilds() | ||
} | ||
|
||
agent { | ||
docker { | ||
image "${RUNNER_IMAGE}" | ||
} | ||
} | ||
|
||
stages { | ||
stage('Build') { | ||
steps { | ||
sh """ | ||
# create virtual environment | ||
sudo pip-3.6 install virtualenv | ||
virtualenv ~/.venvs/chaostk | ||
# enter the python virtual environment | ||
source ~/.venvs/chaostk/bin/activate | ||
# install oci sdk | ||
pip-3.6 install oci | ||
# install dependencies | ||
pip-3.6 install -r requirements.txt -r requirements-dev.txt | ||
chaos --version | ||
# setup dev environment | ||
python3.6 setup.py develop | ||
# run the CI script | ||
bash ./ci.bash | ||
""" | ||
} | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from chaoslib.types import Configuration, Secrets | ||
from oci.load_balancer import LoadBalancerClient | ||
|
||
from chaosoci import oci_client | ||
from chaosoci.types import OCIResponse | ||
|
||
__all__ = ["delete_backend_server", "delete_backend_set", | ||
"delete_hostname", "delete_listener", | ||
"delete_load_balancer", "delete_routing_policy", | ||
"delete_path_route_set"] | ||
|
||
|
||
# Compute Client Actions | ||
|
||
def delete_backend_server(load_balancer_id: str, | ||
backend_set_name: str, | ||
backend_name: str, | ||
configuration: Configuration = None, | ||
secrets: Secrets = None) -> OCIResponse: | ||
"""Delete a given backend server""" | ||
|
||
client = oci_client(LoadBalancerClient, configuration, secrets, | ||
skip_deserialization=True) | ||
delete_backend_response = client.delete_backend(load_balancer_id, backend_name, backend_set_name).data | ||
|
||
return delete_backend_response | ||
|
||
|
||
def delete_backend_set(load_balancer_id: str, | ||
backend_set_name: str, | ||
configuration: Configuration = None, | ||
secrets: Secrets = None) -> OCIResponse: | ||
"""Delete a given backend set""" | ||
client = oci_client(LoadBalancerClient, configuration, secrets, | ||
skip_deserialization=False) | ||
|
||
delete_backend_set_response = client.delete_backend_set(load_balancer_id, backend_set_name).data | ||
|
||
return delete_backend_set_response | ||
|
||
|
||
# Compute Client Management Actions | ||
|
||
def delete_hostname(load_balancer_id: str, | ||
load_balancer_name: str, | ||
configuration: Configuration = None, | ||
secrets: Secrets = None) -> OCIResponse: | ||
"""Delete a given hostname""" | ||
|
||
client = oci_client(LoadBalancerClient, configuration, secrets, | ||
skip_deserialization=True) | ||
|
||
delete_hostname_response = client.delete_hostname(load_balancer_id, load_balancer_name).data | ||
|
||
return delete_hostname_response | ||
|
||
|
||
def delete_listener(listener_id: str, | ||
listener_name: str, | ||
configuration: Configuration = None, | ||
secrets: Secrets = None) -> OCIResponse: | ||
"""Delete a given LB Listener""" | ||
|
||
client = oci_client(LoadBalancerClient, configuration, secrets, | ||
skip_deserialization=True) | ||
|
||
delete_listener_response = client.delete_listener(listener_id, listener_name).data | ||
|
||
return delete_listener_response | ||
|
||
|
||
def delete_load_balancer(load_balancer_id: str, | ||
configuration: Configuration = None, | ||
secrets: Secrets = None) -> OCIResponse: | ||
"""Delete a given Load Balancer""" | ||
|
||
client = oci_client(LoadBalancerClient, configuration, secrets, | ||
skip_deserialization=True) | ||
|
||
delete_load_balancer_response = client.delete_load_balancer(load_balancer_id).data | ||
|
||
return delete_load_balancer_response | ||
|
||
|
||
def delete_path_route_set(load_balancer_id: str, | ||
path_route_set_name: str, | ||
configuration: Configuration = None, | ||
secrets: Secrets = None) -> OCIResponse: | ||
"""Delete a given set path route""" | ||
|
||
client = oci_client(LoadBalancerClient, configuration, secrets, | ||
skip_deserialization=True) | ||
|
||
delete_path_route_set_response = client.delete_path_route_set(load_balancer_id, path_route_set_name).data | ||
|
||
return delete_path_route_set_response | ||
|
||
|
||
def delete_routing_policy(load_balancer_id: str, | ||
routing_policy_name: str, | ||
configuration: Configuration = None, | ||
secrets: Secrets = None) -> OCIResponse: | ||
"""Delete a given routing policy""" | ||
|
||
client = oci_client(LoadBalancerClient, configuration, secrets, | ||
skip_deserialization=True) | ||
|
||
delete_routing_policy_response = client.delete_routing_policy(load_balancer_id, routing_policy_name).data | ||
|
||
return delete_routing_policy_response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# -*- coding: utf-8 -*- | ||
__all__ = ["get_load_balancers", "filter_load_balancers", "get_backend_sets"] | ||
|
||
from typing import Any, Dict, List | ||
|
||
from chaoslib.exceptions import ActivityFailed | ||
|
||
from logzero import logger | ||
|
||
from oci.core import ComputeClient, ComputeManagementClient | ||
from oci.core.models import Instance, InstancePool | ||
from oci.load_balancer import LoadBalancerClient | ||
from oci.load_balancer.models import LoadBalancer | ||
|
||
|
||
def get_load_balancers(client: LoadBalancerClient = None, | ||
compartment_id: str = None) -> List[Instance]: | ||
"""Return a complete, unfiltered list of instances in the compartment.""" | ||
load_bals = [] | ||
|
||
load_bals_raw = client.list_load_balancers(compartment_id=compartment_id) | ||
load_bals.extend(load_bals_raw.data) | ||
while load_bals_raw.has_next_page: | ||
load_bals_raw = client.list_load_balancers(compartment_id=compartment_id, | ||
page=load_bals_raw.next_page) | ||
load_bals.extend(load_bals_raw.data) | ||
|
||
return load_bals | ||
|
||
|
||
def filter_load_balancers(load_bals: List[LoadBalancer] = None, | ||
filters: Dict[str, Any] = None) -> List[LoadBalancer]: | ||
"""Return only those load_bals that match the filters provided.""" | ||
load_bals = load_bals or None | ||
|
||
if load_bals is None: | ||
raise ActivityFailed('No load_bals were found.') | ||
|
||
filters_set = {x for x in filters} | ||
available_filters_set = {x for x in load_bals[0].attribute_map} | ||
|
||
# Partial filtering may return load_bals we do not want. We avoid it. | ||
if not filters_set.issubset(available_filters_set): | ||
raise ActivityFailed('Some of the chosen filters were not found,' | ||
' we cannot continue.') | ||
|
||
# Walk the load_bals and find those that match the given filters. | ||
filtered = [] | ||
for load_bal in load_bals: | ||
sentinel = True | ||
for attr, val in filters.items(): | ||
if val != getattr(load_bal, attr, None): | ||
sentinel = False | ||
break | ||
|
||
if sentinel: | ||
filtered.append(load_bal) | ||
|
||
return filtered | ||
|
||
|
||
def get_backend_sets(client: LoadBalancerClient = None, | ||
loadbalancer_id: str = None) -> List[Instance]: | ||
"""Return a complete, unfiltered list of instances in the compartment.""" | ||
backend_set = [] | ||
|
||
backend_set_raw = client.list_backend_sets(load_balancer_id=loadbalancer_id) | ||
backend_set.extend(backend_set_raw.data) | ||
while backend_set_raw.has_next_page: | ||
backend_set_raw = client.list_backend_sets(load_balancer_id=loadbalancer_id, | ||
page=backend_set_raw.next_page) | ||
backend_set.extend(backend_set_raw.data) | ||
|
||
return backend_set |
Oops, something went wrong.