desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Testing a create service'
| @mock.patch('oc_service.Utils.create_tmpfile_copy')
@mock.patch('oc_service.OCService._run')
def test_create_with_labels(self, mock_cmd, mock_tmpfile_copy):
| params = {'name': 'router', 'namespace': 'default', 'ports': {'name': '9000-tcp', 'port': 9000, 'protocol': 'TCP', 'targetPOrt': 9000}, 'state': 'present', 'labels': {'component': 'some_component', 'infra': 'true'}, 'clusterip': None, 'portalip': None, 'selector': {'router': 'router'}, 'session_affinity': 'ClientIP... |
'Testing a create service'
| @mock.patch('oc_service.Utils.create_tmpfile_copy')
@mock.patch('oc_service.OCService._run')
def test_create_with_external_ips(self, mock_cmd, mock_tmpfile_copy):
| params = {'name': 'router', 'namespace': 'default', 'ports': {'name': '9000-tcp', 'port': 9000, 'protocol': 'TCP', 'targetPOrt': 9000}, 'state': 'present', 'labels': {'component': 'some_component', 'infra': 'true'}, 'clusterip': None, 'portalip': None, 'selector': {'router': 'router'}, 'session_affinity': 'ClientIP... |
'Testing adding a secret'
| @mock.patch('oc_secret.locate_oc_binary')
@mock.patch('oc_secret.Utils.create_tmpfile_copy')
@mock.patch('oc_secret.Utils._write')
@mock.patch('oc_secret.OCSecret._run')
def test_adding_a_secret(self, mock_cmd, mock_write, mock_tmpfile_copy, mock_oc_binary):
| params = {'state': 'present', 'namespace': 'default', 'name': 'testsecretname', 'type': 'Opaque', 'contents': [{'path': '/tmp/somesecret.json', 'data': "{'one': 1, 'two': 2, 'three': 3}"}], 'decode': False, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False, 'files': None, 'delete_af... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing a get'
| @mock.patch('oc_process.Utils.create_tmpfile_copy')
@mock.patch('oc_process.OCProcess._run')
def test_state_list(self, mock_cmd, mock_tmpfile_copy):
| params = {'template_name': 'mysql-ephermeral', 'namespace': 'test', 'content': None, 'state': 'list', 'reconcile': False, 'create': False, 'params': {'NAMESPACE': 'test', 'DATABASE_SERVICE_NAME': 'testdb'}, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
mock_cmd.side_effect = [(0, OCProces... |
'Testing a process with no create'
| @mock.patch('oc_process.Utils.create_tmpfile_copy')
@mock.patch('oc_process.OCProcess._run')
def test_process_no_create(self, mock_cmd, mock_tmpfile_copy):
| params = {'template_name': 'mysql-ephermeral', 'namespace': 'test', 'content': None, 'state': 'present', 'reconcile': False, 'create': False, 'params': {'NAMESPACE': 'test', 'DATABASE_SERVICE_NAME': 'testdb'}, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
mysqlproc = '{\n "... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Constructor for OCObjectValidator'
| def __init__(self, kubeconfig):
| super(OCObjectValidator, self).__init__('default', kubeconfig)
|
'return invalid object information'
| def get_invalid(self, kind, invalid_filter):
| rval = self._get(kind)
if (rval['returncode'] != 0):
return (False, rval, [])
return (True, rval, list(filter(invalid_filter, rval['results'][0]['items'])))
|
'run the idempotent ansible code
params comes from the ansible portion of this module'
| @staticmethod
def run_ansible(params):
| objectvalidator = OCObjectValidator(params['kubeconfig'])
all_invalid = {}
failed = False
def _is_invalid_namespace(namespace):
name = namespace['metadata']['name']
if (not any(((name == 'kube'), (name == 'kubernetes'), (name == 'openshift'), name.startswith('kube-'), name.startswith('ku... |
'Constructor for OCVolume'
| def __init__(self, config, verbose=False):
| super(OCServiceAccount, self).__init__(config.namespace, kubeconfig=config.kubeconfig, verbose=verbose)
self.config = config
self.service_account = None
|
'return whether a volume exists'
| def exists(self):
| if self.service_account:
return True
return False
|
'return volume information'
| def get(self):
| result = self._get(self.kind, self.config.name)
if (result['returncode'] == 0):
self.service_account = ServiceAccount(content=result['results'][0])
elif (('"%s" not found' % self.config.name) in result['stderr']):
result['returncode'] = 0
result['results'] = [{}]
return res... |
'delete the object'
| def delete(self):
| return self._delete(self.kind, self.config.name)
|
'create the object'
| def create(self):
| return self._create_from_content(self.config.name, self.config.data)
|
'update the object'
| def update(self):
| for secret in self.config.secrets:
result = self.service_account.find_secret(secret)
if (not result):
self.service_account.add_secret(secret)
for secret in self.config.image_pull_secrets:
result = self.service_account.find_image_pull_secret(secret)
if (not result):
... |
'verify an update is needed'
| def needs_update(self):
| for secret in self.config.secrets:
result = self.service_account.find_secret(secret)
if (not result):
return True
for secret in self.config.image_pull_secrets:
result = self.service_account.find_image_pull_secret(secret)
if (not result):
return True
re... |
'run the ansible idempotent code'
| @staticmethod
def run_ansible(params, check_mode):
| rconfig = ServiceAccountConfig(params['name'], params['namespace'], params['kubeconfig'], params['secrets'], params['image_pull_secrets'])
oc_sa = OCServiceAccount(rconfig, verbose=params['debug'])
state = params['state']
api_rval = oc_sa.get()
if (state == 'list'):
return {'changed': False,... |
'Constructor for Registry
a registry consists of 3 or more parts
- dc/docker-registry
- svc/docker-registry
Parameters:
:registry_config:
:verbose:'
| def __init__(self, registry_config, verbose=False):
| super(Registry, self).__init__(registry_config.namespace, registry_config.kubeconfig, verbose)
self.version = OCVersion(registry_config.kubeconfig, verbose)
self.svc_ip = None
self.portal_ip = None
self.config = registry_config
self.verbose = verbose
self.registry_parts = [{'kind': 'dc', 'na... |
'deploymentconfig property'
| @property
def deploymentconfig(self):
| return self.dconfig
|
'setter for deploymentconfig property'
| @deploymentconfig.setter
def deploymentconfig(self, config):
| self.dconfig = config
|
'service property'
| @property
def service(self):
| return self.svc
|
'setter for service property'
| @service.setter
def service(self, config):
| self.svc = config
|
'prepared_registry property'
| @property
def prepared_registry(self):
| if (not self.__prepared_registry):
results = self.prepare_registry()
if ((not results) or (('returncode' in results) and (results['returncode'] != 0))):
raise RegistryException('Could not perform registry preparation. {}'.format(results))
self.__prepared_registry =... |
'setter method for prepared_registry attribute'
| @prepared_registry.setter
def prepared_registry(self, data):
| self.__prepared_registry = data
|
'return the self.registry_parts'
| def get(self):
| self.deploymentconfig = None
self.service = None
rval = 0
for part in self.registry_parts:
result = self._get(part['kind'], name=part['name'])
if ((result['returncode'] == 0) and (part['kind'] == 'dc')):
self.deploymentconfig = DeploymentConfig(result['results'][0])
e... |
'does the object exist?'
| def exists(self):
| if (self.deploymentconfig and self.service):
return True
return False
|
'return all pods'
| def delete(self, complete=True):
| parts = []
for part in self.registry_parts:
if ((not complete) and (part['kind'] == 'svc')):
continue
parts.append(self._delete(part['kind'], part['name']))
rval = 0
for part in parts:
if (('returncode' in part) and (part['returncode'] != 0)):
rval = part[... |
'prepare a registry for instantiation'
| def prepare_registry(self):
| options = self.config.to_option_list(ascommalist='labels')
cmd = ['registry']
cmd.extend(options)
cmd.extend(['--dry-run=True', '-o', 'json'])
results = self.openshift_cmd(cmd, oadm=True, output=True, output_type='json')
if ((results['returncode'] != 0) and ('items' not in results['results'])):
... |
'Create a registry'
| def create(self):
| results = []
self.needs_update()
if (self.deploymentconfig is None):
results.append(self._create(self.prepared_registry['deployment_file']))
elif self.prepared_registry['deployment_update']:
results.append(self._replace(self.prepared_registry['deployment_file']))
if (self.service is ... |
'run update for the registry. This performs a replace if required'
| def update(self):
| if self.service:
svcip = self.service.get('spec.clusterIP')
if svcip:
self.svc_ip = svcip
portip = self.service.get('spec.portalIP')
if portip:
self.portal_ip = portip
results = []
if self.prepared_registry['deployment_update']:
results.append(... |
'update a deployment config with changes'
| def add_modifications(self, deploymentconfig):
| if self.deploymentconfig:
result = self.deploymentconfig.get_env_var('REGISTRY_HTTP_SECRET')
if result:
deploymentconfig.update_env_var('REGISTRY_HTTP_SECRET', result['value'])
for (key, value) in self.config.config_options['env_vars'].get('value', {}).items():
if (not deploy... |
'check to see if we need to update'
| def needs_update(self):
| exclude_list = ['clusterIP', 'portalIP', 'type', 'protocol']
if ((self.service is None) or (not Utils.check_def_equal(self.prepared_registry['service'].yaml_dict, self.service.yaml_dict, exclude_list, debug=self.verbose))):
self.prepared_registry['service_update'] = True
exclude_list = ['dnsPolicy',... |
'run idempotent ansible code'
| @staticmethod
def run_ansible(params, check_mode):
| registry_options = {'images': {'value': params['images'], 'include': True}, 'latest_images': {'value': params['latest_images'], 'include': True}, 'labels': {'value': params['labels'], 'include': True}, 'ports': {'value': ','.join(params['ports']), 'include': True}, 'replicas': {'value': params['replicas'], 'include... |
'Constructor for OCGroup'
| def __init__(self, config, verbose=False):
| super(OCGroup, self).__init__(config.namespace, config.kubeconfig)
self.config = config
self.namespace = config.namespace
self._group = None
|
'property function service'
| @property
def group(self):
| if (not self._group):
self.get()
return self._group
|
'setter function for yedit var'
| @group.setter
def group(self, data):
| self._group = data
|
'return whether a group exists'
| def exists(self):
| if self.group:
return True
return False
|
'return group information'
| def get(self):
| result = self._get(self.kind, self.config.name)
if (result['returncode'] == 0):
self.group = Group(content=result['results'][0])
elif ('groups "{}" not found'.format(self.config.name) in result['stderr']):
result['returncode'] = 0
result['results'] = [{}]
return result
|
'delete the object'
| def delete(self):
| return self._delete(self.kind, self.config.name)
|
'create the object'
| def create(self):
| return self._create_from_content(self.config.name, self.config.data)
|
'update the object'
| def update(self):
| return self._replace_content(self.kind, self.config.name, self.config.data)
|
'verify an update is needed'
| def needs_update(self):
| return (not Utils.check_def_equal(self.config.data, self.group.yaml_dict, skip_keys=[], debug=True))
|
'run the idempotent ansible code'
| @staticmethod
def run_ansible(params, check_mode=False):
| gconfig = GroupConfig(params['name'], params['namespace'], params['kubeconfig'])
oc_group = OCGroup(gconfig, verbose=params['debug'])
state = params['state']
api_rval = oc_group.get()
if (api_rval['returncode'] != 0):
return {'failed': True, 'msg': api_rval}
if (state == 'list'):
... |
'Constructor for OCStorageClass'
| def __init__(self, config, verbose=False):
| super(OCStorageClass, self).__init__(None, kubeconfig=config.kubeconfig, verbose=verbose)
self.config = config
self.storage_class = None
|
'return whether a storageclass exists'
| def exists(self):
| if self.storage_class:
return True
return False
|
'return storageclass'
| def get(self):
| result = self._get(self.kind, self.config.name)
if (result['returncode'] == 0):
self.storage_class = StorageClass(content=result['results'][0])
elif (('"%s" not found' % self.config.name) in result['stderr']):
result['returncode'] = 0
result['results'] = [{}]
return result
|
'delete the object'
| def delete(self):
| return self._delete(self.kind, self.config.name)
|
'create the object'
| def create(self):
| return self._create_from_content(self.config.name, self.config.data)
|
'update the object'
| def update(self):
| self.delete()
import time
time.sleep(5)
return self.create()
|
'verify an update is needed'
| def needs_update(self):
| if (self.storage_class.get_parameters() != self.config.parameters):
return True
for (anno_key, anno_value) in self.storage_class.get_annotations().items():
if (('is-default-class' in anno_key) and (anno_value != self.config.default_storage_class)):
return True
return False
|
'run the ansible idempotent code'
| @staticmethod
def run_ansible(params, check_mode):
| rconfig = StorageClassConfig(params['name'], provisioner='kubernetes.io/{}'.format(params['provisioner']), parameters=params['parameters'], annotations=params['annotations'], api_version='storage.k8s.io/{}'.format(params['api_version']), default_storage_class=params.get('default_storage_class', 'false'), kubeconfig... |
'Constructor for OCScale'
| def __init__(self, resource_name, namespace, replicas, kind, kubeconfig='/etc/origin/master/admin.kubeconfig', verbose=False):
| super(OCScale, self).__init__(namespace, kubeconfig=kubeconfig, verbose=verbose)
self.kind = kind
self.replicas = replicas
self.name = resource_name
self._resource = None
|
'property function for resource var'
| @property
def resource(self):
| if (not self._resource):
self.get()
return self._resource
|
'setter function for resource var'
| @resource.setter
def resource(self, data):
| self._resource = data
|
'return replicas information'
| def get(self):
| vol = self._get(self.kind, self.name)
if (vol['returncode'] == 0):
if (self.kind == 'dc'):
self.resource = DeploymentConfig(content=vol['results'][0])
vol['results'] = [self.resource.get_replicas()]
if (self.kind == 'rc'):
self.resource = ReplicationController... |
'update replicas into dc'
| def put(self):
| self.resource.update_replicas(self.replicas)
return self._replace_content(self.kind, self.name, self.resource.yaml_dict)
|
'verify whether an update is needed'
| def needs_update(self):
| return self.resource.needs_update_replicas(self.replicas)
|
'perform the idempotent ansible logic'
| @staticmethod
def run_ansible(params, check_mode):
| oc_scale = OCScale(params['name'], params['namespace'], params['replicas'], params['kind'], params['kubeconfig'], verbose=params['debug'])
state = params['state']
api_rval = oc_scale.get()
if (api_rval['returncode'] != 0):
return {'failed': True, 'msg': api_rval}
if (state == 'list'):
... |
'Constructor for OpenshiftOC'
| def __init__(self, kind, namespace, name=None, selector=None, kubeconfig='/etc/origin/master/admin.kubeconfig', verbose=False, all_namespaces=False):
| super(OCObject, self).__init__(namespace, kubeconfig=kubeconfig, verbose=verbose, all_namespaces=all_namespaces)
self.kind = kind
self.name = name
self.selector = selector
|
'return a kind by name'
| def get(self):
| results = self._get(self.kind, name=self.name, selector=self.selector)
if ((results['returncode'] != 0) and ('stderr' in results) and ('"{}" not found'.format(self.name) in results['stderr'])):
results['returncode'] = 0
return results
|
'delete the object'
| def delete(self):
| results = self._delete(self.kind, name=self.name, selector=self.selector)
if ((results['returncode'] != 0) and ('stderr' in results) and ('"{}" not found'.format(self.name) in results['stderr'])):
results['returncode'] = 0
return results
|
'Create a config
NOTE: This creates the first file OR the first conent.
TODO: Handle all files and content passed in'
| def create(self, files=None, content=None):
| if files:
return self._create(files[0])
content['data'] = yaml.dump(content['data'])
content_file = Utils.create_tmp_files_from_contents(content)[0]
return self._create(content_file['path'])
|
'update a current openshift object
This receives a list of file names or content
and takes the first and calls replace.
TODO: take an entire list'
| def update(self, files=None, content=None, force=False):
| if files:
return self._replace(files[0], force)
if (content and ('data' in content)):
content = content['data']
return self.update_content(content, force)
|
'update an object through using the content param'
| def update_content(self, content, force=False):
| return self._replace_content(self.kind, self.name, content, force=force)
|
'check to see if we need to update'
| def needs_update(self, files=None, content=None, content_type='yaml'):
| objects = self.get()
if (objects['returncode'] != 0):
return objects
data = None
if files:
data = Utils.get_resource_file(files[0], content_type)
elif (content and ('data' in content)):
data = content['data']
else:
data = content
return (not Utils.check_def_eq... |
'perform the ansible idempotent code'
| @staticmethod
def run_ansible(params, check_mode=False):
| ocobj = OCObject(params['kind'], params['namespace'], params['name'], params['selector'], kubeconfig=params['kubeconfig'], verbose=params['debug'], all_namespaces=params['all_namespaces'])
state = params['state']
api_rval = ocobj.get()
if (state == 'list'):
return {'changed': False, 'results': a... |
'Constructor for OCVolume'
| def __init__(self, sname, namespace, labels, selector, cluster_ip, portal_ip, ports, session_affinity, service_type, external_ips, kubeconfig='/etc/origin/master/admin.kubeconfig', verbose=False):
| super(OCService, self).__init__(namespace, kubeconfig, verbose)
self.namespace = namespace
self.config = ServiceConfig(sname, namespace, ports, selector, labels, cluster_ip, portal_ip, session_affinity, service_type, external_ips)
self.user_svc = Service(content=self.config.data)
self.svc = None
|
'property function service'
| @property
def service(self):
| if (not self.svc):
self.get()
return self.svc
|
'setter function for service var'
| @service.setter
def service(self, data):
| self.svc = data
|
'return whether a service exists'
| def exists(self):
| if self.service:
return True
return False
|
'return service information'
| def get(self):
| result = self._get(self.kind, self.config.name)
if (result['returncode'] == 0):
self.service = Service(content=result['results'][0])
result['clusterip'] = self.service.get('spec.clusterIP')
elif (('services "%s" not found' % self.config.name) in result['stderr']):
result['cl... |
'delete the service'
| def delete(self):
| return self._delete(self.kind, self.config.name)
|
'create a service'
| def create(self):
| return self._create_from_content(self.config.name, self.user_svc.yaml_dict)
|
'create a service'
| def update(self):
| self.user_svc.add_cluster_ip(self.service.get('spec.clusterIP'))
self.user_svc.add_portal_ip(self.service.get('spec.portalIP'))
return self._replace_content(self.kind, self.config.name, self.user_svc.yaml_dict)
|
'verify an update is needed'
| def needs_update(self):
| skip = ['clusterIP', 'portalIP']
return (not Utils.check_def_equal(self.user_svc.yaml_dict, self.service.yaml_dict, skip_keys=skip, debug=True))
|
'Run the idempotent ansible code'
| @staticmethod
def run_ansible(params, check_mode):
| oc_svc = OCService(params['name'], params['namespace'], params['labels'], params['selector'], params['clusterip'], params['portalip'], params['ports'], params['session_affinity'], params['service_type'], params['external_ips'], params['kubeconfig'], params['debug'])
state = params['state']
api_rval = oc_svc... |
'Constructor for OpenshiftOC
a router consists of 3 or more parts
- dc/router
- svc/router
- sa/router
- secret/router-certs
- clusterrolebinding/router-router-role'
| def __init__(self, router_config, verbose=False):
| super(Router, self).__init__('default', router_config.kubeconfig, verbose)
self.config = router_config
self.verbose = verbose
self.router_parts = [{'kind': 'dc', 'name': self.config.name}, {'kind': 'svc', 'name': self.config.name}, {'kind': 'sa', 'name': self.config.config_options['service_account']['va... |
'property for the prepared router'
| @property
def prepared_router(self):
| if (self.__prepared_router is None):
results = self._prepare_router()
if ((not results) or (('returncode' in results) and (results['returncode'] != 0))):
if ('stderr' in results):
raise RouterException(('Could not perform router preparation: %s' % results['... |
'setter for the prepared_router'
| @prepared_router.setter
def prepared_router(self, obj):
| self.__prepared_router = obj
|
'property deploymentconfig'
| @property
def deploymentconfig(self):
| return self.dconfig
|
'setter for property deploymentconfig'
| @deploymentconfig.setter
def deploymentconfig(self, config):
| self.dconfig = config
|
'property for service'
| @property
def service(self):
| return self.svc
|
'setter for property service'
| @service.setter
def service(self, config):
| self.svc = config
|
'property secret'
| @property
def secret(self):
| return self._secret
|
'setter for property secret'
| @secret.setter
def secret(self, config):
| self._secret = config
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.