code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def _handle_path_signal_test_cache(self, set_data): """Use the sever to cache results from application runs""" global TEST_DATA_CACHE if set_data: TEST_DATA_CACHE = self.rfile.read(int(self.headers['Content-Length'])).decode() self._send_reply(TEST_DATA_CACHE)
Use the sever to cache results from application runs
_handle_path_signal_test_cache
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def parse_POST_headers(self): # noqa: ignore=N802 """Parse request's POST headers in utf8 aware way Returns: A dictionary with POST arguments mapped to it's keys/values """ length = int(self.headers['Content-Length']) field_data = self.rfile.read(length).decode('utf...
Parse request's POST headers in utf8 aware way Returns: A dictionary with POST arguments mapped to it's keys/values
parse_POST_headers
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def _verify_path_your_ip_args(self, fields): """Verify /your_ip request's arguments Make sure that the POST arguments send by the client while requesting for /your_ip path are valid. Args: fields: decoded POST arguments sent by the client in the form of ...
Verify /your_ip request's arguments Make sure that the POST arguments send by the client while requesting for /your_ip path are valid. Args: fields: decoded POST arguments sent by the client in the form of dictionary Raises: RequestProcessin...
_verify_path_your_ip_args
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def _query_reflector_for_ip(self, reflector_ip, reflector_port): """Ask the reflector to report server's IP address This method queries external reflector for server's IP address. It's done by sending a 'GET /reflect' request to a test_server running on some other mesos slave. Please se...
Ask the reflector to report server's IP address This method queries external reflector for server's IP address. It's done by sending a 'GET /reflect' request to a test_server running on some other mesos slave. Please see the description of the '_handle_path_reflect' method for more deta...
_query_reflector_for_ip
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def _handle_path_your_ip(self): """Responds to requests for server's IP address as seen by other cluster members Determine the server's address by querying external reflector (basically the same test_server, but different service endpoint), and respond to client with JSON hash containin...
Responds to requests for server's IP address as seen by other cluster members Determine the server's address by querying external reflector (basically the same test_server, but different service endpoint), and respond to client with JSON hash containing test UUID's of the server, reflector, ...
_handle_path_your_ip
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def _handle_path_run_cmd(self): """Runs an arbitrary command, and returns the output along with the return code Sometimes there isn't enough time to write code """ length = int(self.headers['Content-Length']) cmd = self.rfile.read(length).decode('utf-8') (status, output)...
Runs an arbitrary command, and returns the output along with the return code Sometimes there isn't enough time to write code
_handle_path_run_cmd
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def _handle_operating_environment(self): """Gets basic operating environment info (such as running user)""" self._send_reply({ 'uid': os.getuid() })
Gets basic operating environment info (such as running user)
_handle_operating_environment
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def do_GET(self): # noqa: ignore=N802 """Mini service router handling GET requests""" if self.path == '/dns_search': self._handle_path_dns_search() elif self.path == '/operating_environment': self._handle_operating_environment() elif self.path == '/ping': ...
Mini service router handling GET requests
do_GET
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def do_POST(self): # noqa: ignore=N802 """Mini service router handling POST requests""" if self.path == '/your_ip': try: self._handle_path_your_ip() except RequestProcessingException as e: logging.error("Request processing exception occured: " ...
Mini service router handling POST requests
do_POST
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def _verify_environment(): """Verify that the environment is sane and can be used by the test_server""" if TEST_UUID_VARNAME not in os.environ: logging.error("Unique test ID is missing in env vars, aborting.") sys.exit(1)
Verify that the environment is sane and can be used by the test_server
_verify_environment
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def start_http_server(listen_port): """Start the test server This function makes sure that the environment is sane and signals are properly handled, and then launches a test server """ _verify_environment() logging.info("HTTP server is starting, port: " "{}, test-UUID: '{}'".f...
Start the test server This function makes sure that the environment is sane and signals are properly handled, and then launches a test server
start_http_server
python
dcos/dcos
packages/dcos-integration-test/extra/util/python_test_server.py
https://github.com/dcos/dcos/blob/master/packages/dcos-integration-test/extra/util/python_test_server.py
Apache-2.0
def run_command(cmd: str, verbose: bool = False, env: dict={}) -> subprocess.CompletedProcess: """ Run a command in a subprocess. Args: verbose: Show the output. Raises: subprocess.CalledProcessError: The given cmd exits with a non-0 exit ...
Run a command in a subprocess. Args: verbose: Show the output. Raises: subprocess.CalledProcessError: The given cmd exits with a non-0 exit code.
run_command
python
dcos/dcos
packages/etcd/extra/etcdctl/dcos_etcdctl.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcdctl/dcos_etcdctl.py
Apache-2.0
def non_existing_file_path_existing_parent_dir(value: str) -> Path: """Validate a path does not exist but its parent directory tree exists.""" path = Path(value) if path.exists(): raise ArgumentTypeError('{} already exists'.format(path)) if not Path(path.parent).exists(): raise ArgumentT...
Validate a path does not exist but its parent directory tree exists.
non_existing_file_path_existing_parent_dir
python
dcos/dcos
packages/etcd/extra/etcdctl/dcos_etcdctl.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcdctl/dcos_etcdctl.py
Apache-2.0
def existing_file_path(value: str) -> Path: """Validate that the value is a file existing on the file system.""" path = Path(value) if not path.exists(): raise argparse.ArgumentTypeError('{} does not exist'.format(path)) if not path.is_file(): raise argparse.ArgumentTypeError('{} is not ...
Validate that the value is a file existing on the file system.
existing_file_path
python
dcos/dcos
packages/etcd/extra/etcdctl/dcos_etcdctl.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcdctl/dcos_etcdctl.py
Apache-2.0
def restore(self) -> None: """ restore etcd cluster from backup file all etcd cluster members are required to be restored through the backup snapshot, that means etcd restore command should be executed on all masters. a command example of restoring a etcd node: ETCDCTL_...
restore etcd cluster from backup file all etcd cluster members are required to be restored through the backup snapshot, that means etcd restore command should be executed on all masters. a command example of restoring a etcd node: ETCDCTL_API=3 etcdctl snapshot restore snapsho...
restore
python
dcos/dcos
packages/etcd/extra/etcdctl/dcos_etcdctl.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcdctl/dcos_etcdctl.py
Apache-2.0
def _get_master_ips(): """ returns IP addresses of master nodes """ master_ip_url = "http://127.0.0.1:8123/v1/hosts/master.mesos" resp = requests.get(master_ip_url, timeout=10) if resp.status_code != 200: resp.raise_for_status() host_ip_list =...
returns IP addresses of master nodes
_get_master_ips
python
dcos/dcos
packages/etcd/extra/etcdctl/dcos_etcdctl.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcdctl/dcos_etcdctl.py
Apache-2.0
def zk_connect(zk_addr: str, zk_user: Optional[str] = None, zk_secret: Optional[str] = None) -> KazooClient: """Connect to ZooKeeper. On connection failure, the function attempts to reconnect indefinitely with exponential backoff up to 3 seconds. If a command fails, that comma...
Connect to ZooKeeper. On connection failure, the function attempts to reconnect indefinitely with exponential backoff up to 3 seconds. If a command fails, that command is retried every 300ms for 3 attempts before failing. These values are chosen to suit a human-interactive time. Args: zk_...
zk_connect
python
dcos/dcos
packages/etcd/extra/etcd_discovery/etcd_discovery.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcd_discovery/etcd_discovery.py
Apache-2.0
def zk_lock(zk: KazooClient, lock_path: str, contender_id: str, timeout: int) -> Generator: """ This contextmanager takes a ZooKeeper lock, yields, then releases the lock. This lock behaves like an interprocess mutex lock. ZooKeeper allows one to read values without holding a lock, but ther...
This contextmanager takes a ZooKeeper lock, yields, then releases the lock. This lock behaves like an interprocess mutex lock. ZooKeeper allows one to read values without holding a lock, but there is no guarantee that you will read the latest value. To read the latest value, you must call `sync()`...
zk_lock
python
dcos/dcos
packages/etcd/extra/etcd_discovery/etcd_discovery.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcd_discovery/etcd_discovery.py
Apache-2.0
def get_registered_nodes(zk: KazooClient, zk_path: str) -> List[str]: """ Return the IPs of nodes that have registered in ZooKeeper. The ZNode `zk_path` is expected to exist, having been created during cluster bootstrap. Args: zk: The client to use to communicate with ZooKeeper...
Return the IPs of nodes that have registered in ZooKeeper. The ZNode `zk_path` is expected to exist, having been created during cluster bootstrap. Args: zk: The client to use to communicate with ZooKeeper. zk_path: The path of the ZNode to use for node registra...
get_registered_nodes
python
dcos/dcos
packages/etcd/extra/etcd_discovery/etcd_discovery.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcd_discovery/etcd_discovery.py
Apache-2.0
def remove_cluster_membership(zk: KazooClient, zk_path: str, ip: str) -> List[str]: """ Remove `ip` from the list of cluster members registered in ZooKeeper. The ZK lock must be held around the call to this function. Args: zk: The client to use to comm...
Remove `ip` from the list of cluster members registered in ZooKeeper. The ZK lock must be held around the call to this function. Args: zk: The client to use to communicate with ZooKeeper. zk_path: The path of the ZNode to use for node registration. ip: ...
remove_cluster_membership
python
dcos/dcos
packages/etcd/extra/etcd_discovery/etcd_discovery.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcd_discovery/etcd_discovery.py
Apache-2.0
def get_designated_node(self) -> str: """ Lazily finds out the designated node to use """ if self._designated_node is None: # Choose one node from the list healthy_nodes = list(filter(self._is_node_healthy, self._nodes)) # In order to not to always hit...
Lazily finds out the designated node to use
get_designated_node
python
dcos/dcos
packages/etcd/extra/etcd_discovery/etcd_discovery.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcd_discovery/etcd_discovery.py
Apache-2.0
def get_members(self) -> JsonTypeMembers: """ gets etcd cluster members an example of results of `member list -w json` [ { 'ID': 2080818695399562020, 'name': 'etcd-10.0.4.116', 'peerURLs': [ 'https://10.0.4.116:2380' ], ...
gets etcd cluster members an example of results of `member list -w json` [ { 'ID': 2080818695399562020, 'name': 'etcd-10.0.4.116', 'peerURLs': [ 'https://10.0.4.116:2380' ], 'clientURLs': [ 'https://10.0....
get_members
python
dcos/dcos
packages/etcd/extra/etcd_discovery/etcd_discovery.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcd_discovery/etcd_discovery.py
Apache-2.0
def get_node_id(self, node_ip: str) -> str: """ Returns etcd member ID in Hex """ members_info = self.get_members() for member in members_info: # Uninitialized members do not have "name" entry if "name" in member and member["name"] == "etcd-{}".format( ...
Returns etcd member ID in Hex
get_node_id
python
dcos/dcos
packages/etcd/extra/etcd_discovery/etcd_discovery.py
https://github.com/dcos/dcos/blob/master/packages/etcd/extra/etcd_discovery/etcd_discovery.py
Apache-2.0
def gen_tls_artifacts(ca_url, artifacts_path): """ Contact the CA service to sign the generated CSR. Write the signed Exhibitor TLS artifacts to the file system. """ # Fail early if IP detect script does not properly resolve yet. ip = invoke_detect_ip() psk_path = Path(PRESHAREDKEY_LOCATION...
Contact the CA service to sign the generated CSR. Write the signed Exhibitor TLS artifacts to the file system.
gen_tls_artifacts
python
dcos/dcos
packages/exhibitor/extra/bootstrap_exhibitor_tls.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/bootstrap_exhibitor_tls.py
Apache-2.0
def run_command(cmd: str, verbose: bool) -> None: """ Run a command in a subprocess. Args: verbose: Show the output. Raises: subprocess.CalledProcessError: The given cmd exits with a non-0 exit code. """ stdout = None if verbose else subprocess.PIPE stderr = None if verbose...
Run a command in a subprocess. Args: verbose: Show the output. Raises: subprocess.CalledProcessError: The given cmd exits with a non-0 exit code.
run_command
python
dcos/dcos
packages/exhibitor/extra/dcos_zk_backup.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/dcos_zk_backup.py
Apache-2.0
def _is_zookeeper_running(verbose: bool) -> bool: """ Returns whether the ZooKeeper process that Exhibitor controls is running. """ zk_pid_file = Path('/var/lib/dcos/exhibitor/zk.pid') zk_pid = int(zk_pid_file.read_text()) try: # Check whether the ZooKeeper that Exhibitor controls is run...
Returns whether the ZooKeeper process that Exhibitor controls is running.
_is_zookeeper_running
python
dcos/dcos
packages/exhibitor/extra/dcos_zk_backup.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/dcos_zk_backup.py
Apache-2.0
def backup_zookeeper( backup: Path, tmp_dir: Path, verbose: bool, ) -> None: """ DC/OS ZooKeeper instance backup procedure. ZooKeeper changes files while it is running. In order to have a consistent backup stop ZooKeeper, run the backup procedure, then start ZooKeeper. See https://jir...
DC/OS ZooKeeper instance backup procedure. ZooKeeper changes files while it is running. In order to have a consistent backup stop ZooKeeper, run the backup procedure, then start ZooKeeper. See https://jira.mesosphere.com/browse/DCOS_OSS-5185 for changing this procedure to allow a backup without ...
backup_zookeeper
python
dcos/dcos
packages/exhibitor/extra/dcos_zk_backup.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/dcos_zk_backup.py
Apache-2.0
def restore_zookeeper(backup: Path, tmp_dir: Path, verbose: bool) -> None: """ DC/OS ZooKeeper restore from backup procedure. ZooKeeper changes files while it is running. In order to have a consistent restore, one must stop ZooKeeper on all master nodes, execute this procedure on all master nodes, ...
DC/OS ZooKeeper restore from backup procedure. ZooKeeper changes files while it is running. In order to have a consistent restore, one must stop ZooKeeper on all master nodes, execute this procedure on all master nodes, and then start ZooKeeper again on all master nodes. Stopping ZooKeeper on...
restore_zookeeper
python
dcos/dcos
packages/exhibitor/extra/dcos_zk_backup.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/dcos_zk_backup.py
Apache-2.0
def _non_existing_file_path_existing_parent_dir(value: str) -> Path: """ Validate that the value is a path to a file which does not exist but the parent directory tree exists. """ path = Path(value) if path.exists(): raise ArgumentTypeError('{} already exists'.format(path)) if not Pa...
Validate that the value is a path to a file which does not exist but the parent directory tree exists.
_non_existing_file_path_existing_parent_dir
python
dcos/dcos
packages/exhibitor/extra/dcos_zk_backup.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/dcos_zk_backup.py
Apache-2.0
def _existing_file_path(value: str) -> Path: """ Validate that the value is a file which does exist on the file system. """ path = Path(value) if not path.exists(): raise ArgumentTypeError('{} does not exist'.format(path)) if not path.is_file(): raise ArgumentTypeError('{} is not...
Validate that the value is a file which does exist on the file system.
_existing_file_path
python
dcos/dcos
packages/exhibitor/extra/dcos_zk_backup.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/dcos_zk_backup.py
Apache-2.0
def _existing_dir_path(value: str) -> Path: """ Validate that the value is a directory which does exist on the file system. """ path = Path(value) if not path.exists(): raise ArgumentTypeError('{} does not exist'.format(path)) if not path.is_dir(): raise ArgumentTypeError('{} is ...
Validate that the value is a directory which does exist on the file system.
_existing_dir_path
python
dcos/dcos
packages/exhibitor/extra/dcos_zk_backup.py
https://github.com/dcos/dcos/blob/master/packages/exhibitor/extra/dcos_zk_backup.py
Apache-2.0
def main(directory, max_files, managed_file): ''' Finds all files under the given `directory` and checks if the number of files exceeds the `max_files`. If so, deletes files starting from the oldest (except for the `managed_file`) until the `max_files` is no longer exceeded. @type directory: s...
Finds all files under the given `directory` and checks if the number of files exceeds the `max_files`. If so, deletes files starting from the oldest (except for the `managed_file`) until the `max_files` is no longer exceeded. @type directory: str, absolute path of the directory to clean up @t...
main
python
dcos/dcos
packages/logrotate/extra/delete-oldest-unmanaged-files.py
https://github.com/dcos/dcos/blob/master/packages/logrotate/extra/delete-oldest-unmanaged-files.py
Apache-2.0
def find_mounts_matching(pattern): ''' Find all matching mounts from the output of the mount command ''' print('Looking for mounts matching pattern "{}"'.format(pattern.pattern)) mounts = subprocess.check_output(['mount'], universal_newlines=True) return pattern.findall(mounts)
Find all matching mounts from the output of the mount command
find_mounts_matching
python
dcos/dcos
packages/mesos/extra/make_disk_resources.py
https://github.com/dcos/dcos/blob/master/packages/mesos/extra/make_disk_resources.py
Apache-2.0
def get_mounts_and_freespace(matching_mounts, cache_mounts): ''' We have previously seen, when only using the free disks available, issues when restarting an agent after adding a new volume. This is because Mesos does not tolerate changes in the amount of disk space available for mounted volumes. If...
We have previously seen, when only using the free disks available, issues when restarting an agent after adding a new volume. This is because Mesos does not tolerate changes in the amount of disk space available for mounted volumes. If the volume was used by a framework before the restart, the Meso...
get_mounts_and_freespace
python
dcos/dcos
packages/mesos/extra/make_disk_resources.py
https://github.com/dcos/dcos/blob/master/packages/mesos/extra/make_disk_resources.py
Apache-2.0
def main(output_env_file, cache_env_file): ''' Find mounts and freespace matching MOUNT_PATTERN, create RESOURCES for the disks, and merge the list of disk resources with optionally existing MESOS_RESOURCES environment variable. @type output_env_file: str, filename to write resources ''' if...
Find mounts and freespace matching MOUNT_PATTERN, create RESOURCES for the disks, and merge the list of disk resources with optionally existing MESOS_RESOURCES environment variable. @type output_env_file: str, filename to write resources
main
python
dcos/dcos
packages/mesos/extra/make_disk_resources.py
https://github.com/dcos/dcos/blob/master/packages/mesos/extra/make_disk_resources.py
Apache-2.0
def main(old_dir, new_dir, networks): ''' Moves all the directories in networks from old_dir to new_dir @type old_dir: str, old CNI directory @type new_dir: str, new CNI directory @type networks: list, names of the directories to move ''' print('Upgrading CNI directory from {} to {}'.format...
Moves all the directories in networks from old_dir to new_dir @type old_dir: str, old CNI directory @type new_dir: str, new CNI directory @type networks: list, names of the directories to move
main
python
dcos/dcos
packages/mesos/extra/upgrade_cni.py
https://github.com/dcos/dcos/blob/master/packages/mesos/extra/upgrade_cni.py
Apache-2.0
def activate_packages(install, repository, package_ids, systemd, block_systemd): """Replace the active package set with package_ids. install: pkgpanda.Install repository: pkgpanda.Repository package_ids: sequence of package IDs to activate systemd: start/stop systemd services block_systemd: if ...
Replace the active package set with package_ids. install: pkgpanda.Install repository: pkgpanda.Repository package_ids: sequence of package IDs to activate systemd: start/stop systemd services block_systemd: if systemd, block waiting for systemd services to come up
activate_packages
python
dcos/dcos
pkgpanda/actions.py
https://github.com/dcos/dcos/blob/master/pkgpanda/actions.py
Apache-2.0
def swap_active_package(install, repository, package_id, systemd, block_systemd): """Replace an active package with a package_id with the same name. swap(install, repository, 'foo--version') will replace the active 'foo' package with 'foo--version'. install: pkgpanda.Install repository: pkgpanda.R...
Replace an active package with a package_id with the same name. swap(install, repository, 'foo--version') will replace the active 'foo' package with 'foo--version'. install: pkgpanda.Install repository: pkgpanda.Repository package_id: package ID to activate systemd: start/stop systemd services...
swap_active_package
python
dcos/dcos
pkgpanda/actions.py
https://github.com/dcos/dcos/blob/master/pkgpanda/actions.py
Apache-2.0
def fetch_package(repository, repository_url, package_id, work_dir): """Fetch package_id from repository_url into repository. repository: pkgpanda.Repository repository_url: URL for remote package repository package_id: package ID to fetch work_dir: location for temporary files, used only if reposi...
Fetch package_id from repository_url into repository. repository: pkgpanda.Repository repository_url: URL for remote package repository package_id: package ID to fetch work_dir: location for temporary files, used only if repository_url is a file URL with a relative path
fetch_package
python
dcos/dcos
pkgpanda/actions.py
https://github.com/dcos/dcos/blob/master/pkgpanda/actions.py
Apache-2.0
def add_package_file(repository, package_filename): """Add a package to the repository from a file. repository: pkgpanda.Repository package_filename: location of the package file """ filename_suffix = '.tar.xz' # Extract Package Id (Filename must be path/{pkg-id}.tar.xz). name = os.path.ba...
Add a package to the repository from a file. repository: pkgpanda.Repository package_filename: location of the package file
add_package_file
python
dcos/dcos
pkgpanda/actions.py
https://github.com/dcos/dcos/blob/master/pkgpanda/actions.py
Apache-2.0
def remove_package(install, repository, package_id): """Remove a package from the local repository. Errors if any packages in package_ids are activated in install. install: pkgpanda.Install repository: pkgpanda.Repository package_id: package ID to remove from repository """ if package_id ...
Remove a package from the local repository. Errors if any packages in package_ids are activated in install. install: pkgpanda.Install repository: pkgpanda.Repository package_id: package ID to remove from repository
remove_package
python
dcos/dcos
pkgpanda/actions.py
https://github.com/dcos/dcos/blob/master/pkgpanda/actions.py
Apache-2.0
def setup(install, repository): """Set up a fresh install of DC/OS. install: pkgpanda.Install repository: pkgpanda.Repository """ # Check for /opt/mesosphere/bootstrap. If not exists, download everything # and install /etc/systemd/system/mutli-user.target/dcos.target bootstrap_path = os.pa...
Set up a fresh install of DC/OS. install: pkgpanda.Install repository: pkgpanda.Repository
setup
python
dcos/dcos
pkgpanda/actions.py
https://github.com/dcos/dcos/blob/master/pkgpanda/actions.py
Apache-2.0
def assert_response(response, status_code, body, headers=None, body_cmp=operator.eq): """Assert response has the expected status_code, body, and headers. body_cmp is a callable that takes the response body and expected body and returns a boolean stating whether the comparison succeeds. body_cmp(re...
Assert response has the expected status_code, body, and headers. body_cmp is a callable that takes the response body and expected body and returns a boolean stating whether the comparison succeeds. body_cmp(response.data, body)
assert_response
python
dcos/dcos
pkgpanda/test_http.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_http.py
Apache-2.0
def assert_json_response(response, status_code, body, headers=None, body_cmp=operator.eq): """Assert JSON response has the expected status_code, body, and headers. Asserts that the response's content-type is application/json. body_cmp is a callable that takes the JSON-decoded response body and expecte...
Assert JSON response has the expected status_code, body, and headers. Asserts that the response's content-type is application/json. body_cmp is a callable that takes the JSON-decoded response body and expected body and returns a boolean stating whether the comparison succeeds. body_cmp(json.l...
assert_json_response
python
dcos/dcos
pkgpanda/test_http.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_http.py
Apache-2.0
def assert_error(response, status_code, headers=None, **kwargs): """Assert error response has the expected status_code and kwargs. Asserts that the response body is a JSON object containing an error message and all provided kwargs. If error is not passed as a kwarg, only the presence of an error messa...
Assert error response has the expected status_code and kwargs. Asserts that the response body is a JSON object containing an error message and all provided kwargs. If error is not passed as a kwarg, only the presence of an error message will be asserted, not its content.
assert_error
python
dcos/dcos
pkgpanda/test_http.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_http.py
Apache-2.0
def test_remove_file_pass(): """ Remove a known directory. Should succeed silently. """ test_dir = tempfile.gettempdir() + PathSeparator + 'test' # Here we really don't care if there is a left over dir since we will be removing it # but we need to make sure there is one pkgpanda.util.make_...
Remove a known directory. Should succeed silently.
test_remove_file_pass
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_remove_file_fail(): """ Remove a non existant directory item. Should fail silently without exceptions. """ test_dir = tempfile.gettempdir() + PathSeparator + 'remove_directory_fail' test_path = test_dir + PathSeparator + "A" # Make sure there is no left over directory pkgpanda.uti...
Remove a non existant directory item. Should fail silently without exceptions.
test_remove_file_fail
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_make_directory_pass(): """ Create a known directory and verify. Postcondition: the directory should exist """ test_dir = tempfile.gettempdir() + PathSeparator + 'make_directory_pass' # Make sure there is no left over directory pkgpanda.util.remove_directory(test_dir) assert not ...
Create a known directory and verify. Postcondition: the directory should exist
test_make_directory_pass
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_make_directory_fail(): """ Attempt to create a directory with a null name. Postcondition: Should throw an OSError """ test_dir = "" # Lets make nothing... # Try to make the directory and check for its error try: pkgpanda.util.make_directory(test_dir) except OSError as e...
Attempt to create a directory with a null name. Postcondition: Should throw an OSError
test_make_directory_fail
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_copy_file_pass(): """ Copy a file from a known directory to another known file path. Postcondition: The file should have been copied. The copy should contain the same contents as the original. """ # Make sure we don't have the temp dirs and files left over test_src_dir = te...
Copy a file from a known directory to another known file path. Postcondition: The file should have been copied. The copy should contain the same contents as the original.
test_copy_file_pass
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_file_fail(): """ Copy a file from a known directory to another known file path whose directory does not exist. Postcondition: Should throw a CalledProcessError or an OSError """ # Make sure we don't have the temp dirs and files left over test_src_dir = tempfile.gettempdir() + Path...
Copy a file from a known directory to another known file path whose directory does not exist. Postcondition: Should throw a CalledProcessError or an OSError
test_file_fail
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_copy_directory_pass(): """ Copy a directory of files from a known directory to another known file path whose directory does not exist. Postcondition: Should have recursively created the directories and files for the entire tree """ # Make sure we don't have the temp dirs and files lef...
Copy a directory of files from a known directory to another known file path whose directory does not exist. Postcondition: Should have recursively created the directories and files for the entire tree
test_copy_directory_pass
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_copy_directory_fail(): """ Attempt to copy a directory of files from a none existant directory to another known file path whose directory does not exist. Postcondition: We should get either a """ # Make sure we don't have the temp dirs and files left over test_src_dir = tem...
Attempt to copy a directory of files from a none existant directory to another known file path whose directory does not exist. Postcondition: We should get either a
test_copy_directory_fail
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def test_write_string(tmpdir): """ `pkgpanda.util.write_string` writes or overwrites a file with permissions for User to read and write, Group to read and Other to read. Permissions of the given filename are preserved, or a new file is created with 0o644 permissions. This test was written to m...
`pkgpanda.util.write_string` writes or overwrites a file with permissions for User to read and write, Group to read and Other to read. Permissions of the given filename are preserved, or a new file is created with 0o644 permissions. This test was written to make current functionality regression-s...
test_write_string
python
dcos/dcos
pkgpanda/test_util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/test_util.py
Apache-2.0
def remove_file(path): """removes a file. fails silently if the file does not exist""" if is_windows: # python library on Windows does not like symbolic links in directories # so calling out to the cmd prompt to do this fixes that. path = path.replace('/', '\\') if os.path.exists...
removes a file. fails silently if the file does not exist
remove_file
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def remove_directory(path): """recursively removes a directory tree. fails silently if the tree does not exist""" if is_windows: # python library on Windows does not like symbolic links in directories # so calling out to the cmd prompt to do this fixes that. path = path.replace('/', '\\'...
recursively removes a directory tree. fails silently if the tree does not exist
remove_directory
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def make_directory(path): """Create a directory, creating intermediate directories if necessary""" if is_windows: path = path.replace('/', '\\') if not os.path.exists(path): os.makedirs(path)
Create a directory, creating intermediate directories if necessary
make_directory
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def copy_file(src_path, dst_path): """copy a single directory item from one location to another""" if is_windows: # To make sure the copy works we are using cmd version as python # libraries may not handle symbolic links and other things that are # thrown at it. src = src_path.re...
copy a single directory item from one location to another
copy_file
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def copy_directory(src_path, dst_path): """copy recursively a directory tree from one location to another""" if is_windows: # To make sure the copy works we are using cmd version as python # libraries may not handle symbolic links and other things that are # thrown at it. src = s...
copy recursively a directory tree from one location to another
copy_directory
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def variant_object(variant_str): """Return a variant object from its string representation.""" if variant_str == '': return None return variant_str
Return a variant object from its string representation.
variant_object
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def extract_tarball(path, target): """Extract the tarball into target. If there are any errors, delete the folder being extracted to. """ # TODO(cmaloney): Validate extraction will pass before unpacking as much as possible. # TODO(cmaloney): Unpack into a temporary directory then move into place to...
Extract the tarball into target. If there are any errors, delete the folder being extracted to.
extract_tarball
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def write_string(filename, data): """ Write a string to a file. Overwrite any data in that file. We use an atomic write practice of creating a temporary file and then moving that temporary file to the given ``filename``. This prevents race conditions such as the file being read by another proce...
Write a string to a file. Overwrite any data in that file. We use an atomic write practice of creating a temporary file and then moving that temporary file to the given ``filename``. This prevents race conditions such as the file being read by another process after it is opened here but not ye...
write_string
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def check_forbidden_services(path, services): """Check if package contains systemd services that may break DC/OS This functions checks the contents of systemd's unit file dirs and throws the exception if there are reserved services inside. Args: path: path where the package contents are ...
Check if package contains systemd services that may break DC/OS This functions checks the contents of systemd's unit file dirs and throws the exception if there are reserved services inside. Args: path: path where the package contents are services: list of reserved services to look for ...
check_forbidden_services
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def scope(self, name, flow_id=None): """ Creates a new scope for TeamCity messages. This method is intended to be called in a ``with`` statement :param name: The name of the scope :param flow_id: Optional flow id that can be used if ``name`` can be non-unique """ with Ex...
Creates a new scope for TeamCity messages. This method is intended to be called in a ``with`` statement :param name: The name of the scope :param flow_id: Optional flow id that can be used if ``name`` can be non-unique
scope
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def split_by_token(token_prefix, token_suffix, string_, strip_token_decoration=False): """Yield a sequence of (substring, is_token) pairs comprising the string. The string is split by token boundary, where a token is a substring that begins with the token prefix and ends with the token suffix. is_token is ...
Yield a sequence of (substring, is_token) pairs comprising the string. The string is split by token boundary, where a token is a substring that begins with the token prefix and ends with the token suffix. is_token is True if the substring is a token. If strip_token_decoration is True, tokens are yielde...
split_by_token
python
dcos/dcos
pkgpanda/util.py
https://github.com/dcos/dcos/blob/master/pkgpanda/util.py
Apache-2.0
def remove_staged_unit_files(self): """Remove staged unit files created by Systemd.stage_new_units().""" for filename in os.listdir(self.__base_systemd): if filename.endswith(self.new_unit_suffix): os.remove(os.path.join(self.__base_systemd, filename))
Remove staged unit files created by Systemd.stage_new_units().
remove_staged_unit_files
python
dcos/dcos
pkgpanda/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/__init__.py
Apache-2.0
def stage_new_units(self, new_wants_dir): """Prepare new systemd units for activation. Unit files targeted by the symlinks in new_wants_dir are copied to a temporary location in the base systemd directory, and the symlinks are rewritten to target the intended final destination of the copied uni...
Prepare new systemd units for activation. Unit files targeted by the symlinks in new_wants_dir are copied to a temporary location in the base systemd directory, and the symlinks are rewritten to target the intended final destination of the copied unit files.
stage_new_units
python
dcos/dcos
pkgpanda/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/__init__.py
Apache-2.0
def list(self): """List the available packages in the repository. A package is a folder which contains a pkginfo.json""" if self.__packages is not None: return self.__packages packages = set() if not os.path.exists(self.__path): return packages ...
List the available packages in the repository. A package is a folder which contains a pkginfo.json
list
python
dcos/dcos
pkgpanda/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/__init__.py
Apache-2.0
def get_active(self): """the active folder has symlinks to all the active packages. Return the full package ids (The targets of the symlinks).""" active_dir = self.get_active_dir() if not os.path.exists(active_dir): if os.path.exists(active_dir + ".old") or os.path.exists(a...
the active folder has symlinks to all the active packages. Return the full package ids (The targets of the symlinks).
get_active
python
dcos/dcos
pkgpanda/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/__init__.py
Apache-2.0
def _identify_archive_type(filename): """Identify archive type basing on extension Args: filename: the path to the archive Returns: Currently only zip and tar.*/tgz archives are supported. The return values for them are 'tar' and 'zip' respectively """ parts = filename.spli...
Identify archive type basing on extension Args: filename: the path to the archive Returns: Currently only zip and tar.*/tgz archives are supported. The return values for them are 'tar' and 'zip' respectively
_identify_archive_type
python
dcos/dcos
pkgpanda/build/src_fetchers.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/src_fetchers.py
Apache-2.0
def _check_components_sanity(path): """Check if archive is sane Check if there is only one top level component (directory) in the extracted archive's directory. Args: path: path to the extracted archive's directory Raises: Raise an exception if there is anything else than a single...
Check if archive is sane Check if there is only one top level component (directory) in the extracted archive's directory. Args: path: path to the extracted archive's directory Raises: Raise an exception if there is anything else than a single directory
_check_components_sanity
python
dcos/dcos
pkgpanda/build/src_fetchers.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/src_fetchers.py
Apache-2.0
def _strip_first_path_component(path): """Simulate tar's --strip-components=1 behaviour using file operations Unarchivers like unzip do not support stripping component paths while inflating the archive. This function simulates this behaviour by moving files around and then removing the TLD directory. ...
Simulate tar's --strip-components=1 behaviour using file operations Unarchivers like unzip do not support stripping component paths while inflating the archive. This function simulates this behaviour by moving files around and then removing the TLD directory. Args: path: path where extracted a...
_strip_first_path_component
python
dcos/dcos
pkgpanda/build/src_fetchers.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/src_fetchers.py
Apache-2.0
def _get_package_list(treeinfo_dict, key, excludes=None): """Return a list of package name strings from treeinfo_dict by key. If key isn't present in treeinfo_dict, an empty list is returned. """ excludes = excludes or list() package_list = treeinfo_dict.get(key, list()) ...
Return a list of package name strings from treeinfo_dict by key. If key isn't present in treeinfo_dict, an empty list is returned.
_get_package_list
python
dcos/dcos
pkgpanda/build/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/__init__.py
Apache-2.0
def hash_files_in_folder(directory): """Given a relative path, hashes all files inside that folder and subfolders Returns a dictionary from filename to the hash of that file. If that whole dictionary is hashed, you get a hash of all the contents of the folder. This is split out from calculating the wh...
Given a relative path, hashes all files inside that folder and subfolders Returns a dictionary from filename to the hash of that file. If that whole dictionary is hashed, you get a hash of all the contents of the folder. This is split out from calculating the whole folder hash so that the behavior in ...
hash_files_in_folder
python
dcos/dcos
pkgpanda/build/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/__init__.py
Apache-2.0
def build_tree_variants(package_store, mkbootstrap): """ Builds all possible tree variants in a given package store """ result = dict() tree_variants = get_variants_from_filesystem(package_store.packages_dir, 'treeinfo.json') if len(tree_variants) == 0: raise Exception('No treeinfo.json can ...
Builds all possible tree variants in a given package store
build_tree_variants
python
dcos/dcos
pkgpanda/build/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/__init__.py
Apache-2.0
def build_tree(package_store, mkbootstrap, tree_variants): """Build packages and bootstrap tarballs for one or all tree variants. Returns a dict mapping tree variants to bootstrap IDs. If tree_variant is None, builds all available tree variants. """ # TODO(cmaloney): Add support for circular depe...
Build packages and bootstrap tarballs for one or all tree variants. Returns a dict mapping tree variants to bootstrap IDs. If tree_variant is None, builds all available tree variants.
build_tree
python
dcos/dcos
pkgpanda/build/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/__init__.py
Apache-2.0
def visit(pkg_tuple: tuple): """Add a package and its requires to the build order. Raises AssertionError if pkg_tuple is in the set of visited packages. If the package has any requires, they're recursively visited and added to the build order depth-first. Then the package itself is add...
Add a package and its requires to the build order. Raises AssertionError if pkg_tuple is in the set of visited packages. If the package has any requires, they're recursively visited and added to the build order depth-first. Then the package itself is added.
visit
python
dcos/dcos
pkgpanda/build/__init__.py
https://github.com/dcos/dcos/blob/master/pkgpanda/build/__init__.py
Apache-2.0
def strip_locals(data): """Returns a dictionary with all keys that begin with local_ removed. If data is a dictionary, recurses through cleaning the keys of that as well. If data is a list, any dictionaries it contains are cleaned. Any lists it contains are recursively handled in the same way. """...
Returns a dictionary with all keys that begin with local_ removed. If data is a dictionary, recurses through cleaning the keys of that as well. If data is a list, any dictionaries it contains are cleaned. Any lists it contains are recursively handled in the same way.
strip_locals
python
dcos/dcos
release/__init__.py
https://github.com/dcos/dcos/blob/master/release/__init__.py
Apache-2.0
def to_json(data): """Return a JSON string representation of data. If data is a dictionary, None is replaced with 'null' in its keys and, recursively, in the keys of any dictionary it contains. This is done to allow the dictionary to be sorted by key before being written to JSON. """ def none_...
Return a JSON string representation of data. If data is a dictionary, None is replaced with 'null' in its keys and, recursively, in the keys of any dictionary it contains. This is done to allow the dictionary to be sorted by key before being written to JSON.
to_json
python
dcos/dcos
release/__init__.py
https://github.com/dcos/dcos/blob/master/release/__init__.py
Apache-2.0
def _build_builders(package_store): """Build all builder containers required to build packages """ global_builders = _get_global_builders() pkg_builders = package_store.builders overlap = set(global_builders) & set(pkg_builders) if overlap: msg_fmt = "Package-defined builders overlap wi...
Build all builder containers required to build packages
_build_builders
python
dcos/dcos
release/__init__.py
https://github.com/dcos/dcos/blob/master/release/__init__.py
Apache-2.0
def get_aws_session(access_key_id, secret_access_key, region_name=None): """ This method will replace access_key_id and secret_access_key with None if one is set to '' This allows falling back to the AWS internal logic so that one of the following options can be used: http://boto3.readthedocs.io/en/late...
This method will replace access_key_id and secret_access_key with None if one is set to '' This allows falling back to the AWS internal logic so that one of the following options can be used: http://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials This is needed by dcos_...
get_aws_session
python
dcos/dcos
release/storage/aws.py
https://github.com/dcos/dcos/blob/master/release/storage/aws.py
Apache-2.0
def __init__(self, bucket, object_prefix, download_url, access_key_id=None, secret_access_key=None, region_name=None): """ If access_key_id and secret_acccess_key are unset, boto3 will try to authenticate by other methods. See here for other credential options: http://boto3.read...
If access_key_id and secret_acccess_key are unset, boto3 will try to authenticate by other methods. See here for other credential options: http://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials
__init__
python
dcos/dcos
release/storage/aws.py
https://github.com/dcos/dcos/blob/master/release/storage/aws.py
Apache-2.0
def copy(self, source_path, destination_path): """Copy the file and all metadata from destination_path to source_path.""" pass
Copy the file and all metadata from destination_path to source_path.
copy
python
dcos/dcos
release/storage/__init__.py
https://github.com/dcos/dcos/blob/master/release/storage/__init__.py
Apache-2.0
def upload(self, destination_path, blob=None, local_path=None, no_cache=None, content_type=None): """Upload to destinoation_path the given blob or local_path, attaching metadata for additional properties.""" pass
Upload to destinoation_path the given blob or local_path, attaching metadata for additional properties.
upload
python
dcos/dcos
release/storage/__init__.py
https://github.com/dcos/dcos/blob/master/release/storage/__init__.py
Apache-2.0
def wait_for_dcos_oss( cluster: Cluster, request: SubRequest, log_dir: Path, ) -> None: """ Helper for ``wait_for_dcos_oss`` that automatically dumps the journal of every cluster node if a ``DCOSTimeoutError`` is hit. """ try: cluster.wait_for_dcos_oss() except DCOSTimeoutErr...
Helper for ``wait_for_dcos_oss`` that automatically dumps the journal of every cluster node if a ``DCOSTimeoutError`` is hit.
wait_for_dcos_oss
python
dcos/dcos
test-e2e/cluster_helpers.py
https://github.com/dcos/dcos/blob/master/test-e2e/cluster_helpers.py
Apache-2.0
def dump_cluster_journals(cluster: Cluster, target_dir: Path) -> None: """ Dump logs for each cluster node to the ``target_dir``. Logs are separated into directories per node. """ target_dir.mkdir(parents=True) for role, nodes in ( ('master', cluster.masters), ('agent', cluster.agent...
Dump logs for each cluster node to the ``target_dir``. Logs are separated into directories per node.
dump_cluster_journals
python
dcos/dcos
test-e2e/cluster_helpers.py
https://github.com/dcos/dcos/blob/master/test-e2e/cluster_helpers.py
Apache-2.0
def _dump_node_journals(node: Node, node_dir: Path) -> None: """ Dump logs from the given cluster node to the ``node_dir``. Dumping the diagnostics bundle is unreliable in case that DC/OS components are broken. This is likely if ``wait_for_dcos_ee`` times out. Instead this dumps the journal for eac...
Dump logs from the given cluster node to the ``node_dir``. Dumping the diagnostics bundle is unreliable in case that DC/OS components are broken. This is likely if ``wait_for_dcos_ee`` times out. Instead this dumps the journal for each systemd unit started by DC/OS.
_dump_node_journals
python
dcos/dcos
test-e2e/cluster_helpers.py
https://github.com/dcos/dcos/blob/master/test-e2e/cluster_helpers.py
Apache-2.0
def _dump_stdout_to_file(node: Node, cmd: List[str], file_path: Path) -> None: """ Dump ``stdout`` of the given command to ``file_path``. Raises: CalledProcessError: If an error occurs when running the given command. """ chunk_size = 2048 proc = node.popen(args=cmd) with open(str(fi...
Dump ``stdout`` of the given command to ``file_path``. Raises: CalledProcessError: If an error occurs when running the given command.
_dump_stdout_to_file
python
dcos/dcos
test-e2e/cluster_helpers.py
https://github.com/dcos/dcos/blob/master/test-e2e/cluster_helpers.py
Apache-2.0
def _dcos_systemd_units(node: Node) -> List[str]: """ Return all systemd services that are started up by DC/OS. """ result = node.run( args=[ 'sudo', 'systemctl', 'show', '-p', 'Wants', 'dcos.target', '|', 'cut', '-d=', '-f2' ], shell=True, ) syste...
Return all systemd services that are started up by DC/OS.
_dcos_systemd_units
python
dcos/dcos
test-e2e/cluster_helpers.py
https://github.com/dcos/dcos/blob/master/test-e2e/cluster_helpers.py
Apache-2.0
def only_changed(safelist: List[str], flags: int = glob.BRACE | glob.DOTGLOB | glob.GLOBSTAR | glob.NEGATE) -> bool: """ Return True if we're in a Pull Request and the only files changed by this PR are in the `safelist`. This function can be used to skip tests if only files named in the `safelist` have ...
Return True if we're in a Pull Request and the only files changed by this PR are in the `safelist`. This function can be used to skip tests if only files named in the `safelist` have been modified.
only_changed
python
dcos/dcos
test-e2e/conditional.py
https://github.com/dcos/dcos/blob/master/test-e2e/conditional.py
Apache-2.0
def docker_backend() -> Docker: """ Creates a common Docker backend configuration that works within the pytest environment directory. """ tmp_dir_path = Path(os.environ['DCOS_E2E_TMP_DIR_PATH']) assert tmp_dir_path.exists() and tmp_dir_path.is_dir() return Docker(workspace_dir=tmp_dir_path)
Creates a common Docker backend configuration that works within the pytest environment directory.
docker_backend
python
dcos/dcos
test-e2e/e2e_module.py
https://github.com/dcos/dcos/blob/master/test-e2e/e2e_module.py
Apache-2.0
def rsa_keypair() -> Tuple[str, str]: """ Generate an RSA keypair with a key size of 2048 bits and an exponent of 65537. Serialize the public key in the the X.509 SubjectPublicKeyInfo/OpenSSL PEM public key format (RFC 5280). Serialize the private key in the PKCS#8 (RFC 3447) format. Return...
Generate an RSA keypair with a key size of 2048 bits and an exponent of 65537. Serialize the public key in the the X.509 SubjectPublicKeyInfo/OpenSSL PEM public key format (RFC 5280). Serialize the private key in the PKCS#8 (RFC 3447) format. Returns: (private key, public key) 2-tuple,...
rsa_keypair
python
dcos/dcos
test-e2e/e2e_module.py
https://github.com/dcos/dcos/blob/master/test-e2e/e2e_module.py
Apache-2.0
def static_three_master_cluster( artifact_path: Path, docker_backend: Docker, request: SubRequest, log_dir: Path, ) -> Generator[Cluster, None, None]: """Spin up a highly-available DC/OS cluster with three master nodes.""" with Cluster( cluster_backend=docker_backend, masters=3, ...
Spin up a highly-available DC/OS cluster with three master nodes.
static_three_master_cluster
python
dcos/dcos
test-e2e/e2e_module.py
https://github.com/dcos/dcos/blob/master/test-e2e/e2e_module.py
Apache-2.0
def zookeeper_backend() -> Generator[Container, None, None]: """ Create a ZooKeeper backend container to support a dynamic DC/OS cluster setup. """ ts = datetime.utcnow().strftime('%Y%m%d%H%M%S') client = docker.from_env(version='auto') zookeeper = client.containers.run( image='digit...
Create a ZooKeeper backend container to support a dynamic DC/OS cluster setup.
zookeeper_backend
python
dcos/dcos
test-e2e/e2e_module.py
https://github.com/dcos/dcos/blob/master/test-e2e/e2e_module.py
Apache-2.0
def dynamic_three_master_cluster( artifact_path: Path, docker_backend: Docker, zookeeper_backend: Container, request: SubRequest, log_dir: Path, ) -> Generator[Cluster, None, None]: """Spin up a dynamic DC/OS cluster with three master nodes.""" exhibitor_zk_port = 2181 exhibitor_zk_ip_ad...
Spin up a dynamic DC/OS cluster with three master nodes.
dynamic_three_master_cluster
python
dcos/dcos
test-e2e/e2e_module.py
https://github.com/dcos/dcos/blob/master/test-e2e/e2e_module.py
Apache-2.0
def get_etcdctl_with_base_args( cert_type: str = "root", endpoint_ip: str = LOCAL_ETCD_ENDPOINT_IP, ) -> List[str]: """Returns args including etcd endpoint and certificates if necessary. As dcos-etcdctl and etcdctl share the same arguments, such as endpoints, ever considering the certificates invol...
Returns args including etcd endpoint and certificates if necessary. As dcos-etcdctl and etcdctl share the same arguments, such as endpoints, ever considering the certificates involved, we group these arguments to generate the basic items to execute either etcdctl or dcos-etcdctl
get_etcdctl_with_base_args
python
dcos/dcos
test-e2e/test_etcd_backup.py
https://github.com/dcos/dcos/blob/master/test-e2e/test_etcd_backup.py
Apache-2.0
def put(self, key: str, value: str) -> None: """assigns the value to the key. etcd is not exposed outside of the DC/OS cluster,so we have to execute etcdctl inside the DC/OS cluster, on a master in our case. `master.dcos.thisdcos.directory:2379` is the endpoint that etcd cluster...
assigns the value to the key. etcd is not exposed outside of the DC/OS cluster,so we have to execute etcdctl inside the DC/OS cluster, on a master in our case. `master.dcos.thisdcos.directory:2379` is the endpoint that etcd cluster is exposed, hence we use this endpoint to set a value t...
put
python
dcos/dcos
test-e2e/test_etcd_backup.py
https://github.com/dcos/dcos/blob/master/test-e2e/test_etcd_backup.py
Apache-2.0
def get_key_from_node( self, key: str, master_node: Node, ) -> str: """gets the value of the key on given master node""" etcdctl_with_args = get_etcdctl_with_base_args( endpoint_ip=str(master_node.private_ip_address)) etcdctl_with_args += ["get...
gets the value of the key on given master node
get_key_from_node
python
dcos/dcos
test-e2e/test_etcd_backup.py
https://github.com/dcos/dcos/blob/master/test-e2e/test_etcd_backup.py
Apache-2.0
def docker_network_three_available_addresses() -> Iterator[Network]: """ Return a custom Docker network with 3 assignable IP addresses. """ # We want to return a Docker network with only three assignable IP # addresses. # To do this, we create a network with 8 IP addresses, where 5 are # res...
Return a custom Docker network with 3 assignable IP addresses.
docker_network_three_available_addresses
python
dcos/dcos
test-e2e/test_master_node_replacement.py
https://github.com/dcos/dcos/blob/master/test-e2e/test_master_node_replacement.py
Apache-2.0
def test_replace_all_static( artifact_path: Path, docker_network_three_available_addresses: Network, tmp_path: Path, request: SubRequest, log_dir: Path, ) -> None: """ In a cluster with an Exhibitor backend consisting of a static ZooKeeper ensemble, after removing one master, and then ad...
In a cluster with an Exhibitor backend consisting of a static ZooKeeper ensemble, after removing one master, and then adding another master with the same IP address, the cluster will get to a healthy state. This is repeated until all masters in the original cluster have been replaced. The purpose o...
test_replace_all_static
python
dcos/dcos
test-e2e/test_master_node_replacement.py
https://github.com/dcos/dcos/blob/master/test-e2e/test_master_node_replacement.py
Apache-2.0