Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upgrade33
Browse files Browse the repository at this point in the history
  • Loading branch information
dgoodwin committed Jul 14, 2016
2 parents 3073846 + faf5618 commit 03f31fd
Show file tree
Hide file tree
Showing 77 changed files with 1,078 additions and 558 deletions.
86 changes: 3 additions & 83 deletions filter_plugins/oo_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,85 +339,6 @@ def oo_filter_list(data, filter_attr=None):
# Gather up the values for the list of keys passed in
return [x for x in data if filter_attr in x and x[filter_attr]]

@staticmethod
def oo_oc_nodes_matching_selector(nodes, selector):
""" Filters a list of nodes by selector.
Examples:
nodes = [{"kind": "Node", "metadata": {"name": "node1.example.com",
"labels": {"kubernetes.io/hostname": "node1.example.com",
"color": "green"}}},
{"kind": "Node", "metadata": {"name": "node2.example.com",
"labels": {"kubernetes.io/hostname": "node2.example.com",
"color": "red"}}}]
selector = 'color=green'
returns = ['node1.example.com']
nodes = [{"kind": "Node", "metadata": {"name": "node1.example.com",
"labels": {"kubernetes.io/hostname": "node1.example.com",
"color": "green"}}},
{"kind": "Node", "metadata": {"name": "node2.example.com",
"labels": {"kubernetes.io/hostname": "node2.example.com",
"color": "red"}}}]
selector = 'color=green,color=red'
returns = ['node1.example.com','node2.example.com']
Args:
nodes (list[dict]): list of node definitions
selector (str): "label=value" node selector to filter `nodes` by
Returns:
list[str]: nodes filtered by selector
"""
if not isinstance(nodes, list):
raise errors.AnsibleFilterError("failed expects nodes to be a list, got {0}".format(type(nodes)))
if not isinstance(selector, basestring):
raise errors.AnsibleFilterError("failed expects selector to be a string")
if not re.match('.*=.*', selector):
raise errors.AnsibleFilterError("failed selector does not match \"label=value\" format")
node_lists = []
for node_selector in ''.join(selector.split()).split(','):
label = node_selector.split('=')[0]
value = node_selector.split('=')[1]
node_lists.append(FilterModule.oo_oc_nodes_with_label(nodes, label, value))
nodes = set(node_lists[0])
for node_list in node_lists[1:]:
nodes.intersection_update(node_list)
return list(nodes)

@staticmethod
def oo_oc_nodes_with_label(nodes, label, value):
""" Filters a list of nodes by label, value.
Examples:
nodes = [{"kind": "Node", "metadata": {"name": "node1.example.com",
"labels": {"kubernetes.io/hostname": "node1.example.com",
"color": "green"}}},
{"kind": "Node", "metadata": {"name": "node2.example.com",
"labels": {"kubernetes.io/hostname": "node2.example.com",
"color": "red"}}}]
label = 'color'
value = 'green'
returns = ['node1.example.com']
Args:
nodes (list[dict]): list of node definitions
label (str): label to filter `nodes` by
value (str): value of `label` to filter `nodes` by
Returns:
list[str]: nodes filtered by selector
"""
if not isinstance(nodes, list):
raise errors.AnsibleFilterError("failed expects nodes to be a list")
if not isinstance(label, basestring):
raise errors.AnsibleFilterError("failed expects label to be a string")
if not isinstance(value, basestring):
raise errors.AnsibleFilterError("failed expects value to be a string")
matching_nodes = []
for node in nodes:
if label in node['metadata']['labels']:
if node['metadata']['labels'][label] == value:
matching_nodes.append(node['metadata']['name'])
return matching_nodes

@staticmethod
def oo_nodes_with_label(nodes, label, value=None):
""" Filters a list of nodes by label and value (if provided)
Expand Down Expand Up @@ -707,7 +628,8 @@ def oo_openshift_env(hostvars):
if regex.match(key):
facts[key] = hostvars[key]

migrations = {'openshift_router_selector': 'openshift_hosted_router_selector'}
migrations = {'openshift_router_selector': 'openshift_hosted_router_selector',
'openshift_registry_selector': 'openshift_hosted_registry_selector'}
for old_fact, new_fact in migrations.iteritems():
if old_fact in facts and new_fact not in facts:
facts[new_fact] = facts[old_fact]
Expand Down Expand Up @@ -771,7 +693,7 @@ def oo_persistent_volumes(hostvars, groups, persistent_volumes=None):
fsType=filesystem,
volumeID=volume_id)))
persistent_volumes.append(persistent_volume)
else:
elif kind != 'object':
msg = "|failed invalid storage kind '{0}' for component '{1}'".format(
kind,
component)
Expand Down Expand Up @@ -921,7 +843,5 @@ def filters(self):
"oo_get_hosts_from_hostvars": self.oo_get_hosts_from_hostvars,
"oo_image_tag_to_rpm_version": self.oo_image_tag_to_rpm_version,
"oo_merge_dicts": self.oo_merge_dicts,
"oo_oc_nodes_matching_selector": self.oo_oc_nodes_matching_selector,
"oo_oc_nodes_with_label": self.oo_oc_nodes_with_label,
"oo_merge_hostvars": self.oo_merge_hostvars,
}
110 changes: 57 additions & 53 deletions inventory/byo/hosts.aep.example
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
#osm_mcs_labels_per_project=5
#osm_uid_allocator_range='1000000000-1999999999/10000'

# Configure additional projects
#openshift_additional_projects={'my-project': {'default_node_selector': 'label=value'}}

# Enable cockpit
#osm_use_cockpit=true
#
Expand Down Expand Up @@ -244,10 +247,15 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
# based on the number of nodes matching the openshift router selector.
#openshift_hosted_router_replicas=2
#
# Router force subdomain (optional)
# A router path format to force on all routes used by this router
# (will ignore the route host value)
#openshift_hosted_router_force_subdomain='${name}-${namespace}.apps.example.com'
#
# Router certificate (optional)
# Provide local certificate paths which will be configured as the
# router's default certificate.
#openshift_hosted_router_certificate={"certfile": "/path/to/router.crt", "keyfile": "/path/to/router.key"}
#openshift_hosted_router_certificate={"certfile": "/path/to/router.crt", "keyfile": "/path/to/router.key", "cafile": "/path/to/router-ca.crt"}

# Openshift Registry Options
#
Expand All @@ -263,7 +271,54 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
# Registry selector (optional)
# Registry will only be created if nodes matching this label are present.
# Default value: 'region=infra'
#openshift_registry_selector='region=infra'
#openshift_hosted_registry_selector='region=infra'
#
# Registry replicas (optional)
# Unless specified, openshift-ansible will calculate the replica count
# based on the number of nodes matching the openshift registry selector.
#openshift_hosted_registry_replicas=2

# Registry Storage Options
#
# NFS Host Group
# An NFS volume will be created with path "nfs_directory/volume_name"
# on the host within the [nfs] host group. For example, the volume
# path using these options would be "/exports/registry"
#openshift_hosted_registry_storage_kind=nfs
#openshift_hosted_registry_storage_access_modes=['ReadWriteMany']
#openshift_hosted_registry_storage_nfs_directory=/exports
#openshift_hosted_registry_storage_nfs_options='*(rw,root_squash)'
#openshift_hosted_registry_storage_volume_name=registry
#openshift_hosted_registry_storage_volume_size=10Gi
#
# External NFS Host
# NFS volume must already exist with path "nfs_directory/_volume_name" on
# the storage_host. For example, the remote volume path using these
# options would be "nfs.example.com:/exports/registry"
#openshift_hosted_registry_storage_kind=nfs
#openshift_hosted_registry_storage_access_modes=['ReadWriteMany']
#openshift_hosted_registry_storage_host=nfs.example.com
#openshift_hosted_registry_storage_nfs_directory=/exports
#openshift_hosted_registry_storage_volume_name=registry
#openshift_hosted_registry_storage_volume_size=10Gi
#
# Openstack
# Volume must already exist.
#openshift_hosted_registry_storage_kind=openstack
#openshift_hosted_registry_storage_access_modes=['ReadWriteOnce']
#openshift_hosted_registry_storage_openstack_filesystem=ext4
#openshift_hosted_registry_storage_openstack_volumeID=3a650b4f-c8c5-4e0a-8ca5-eaee11f16c57
#openshift_hosted_registry_storage_volume_size=10Gi
#
# AWS S3
# S3 bucket must already exist.
#openshift_hosted_registry_storage_kind=object
#openshift_hosted_registry_storage_provider=s3
#openshift_hosted_registry_storage_s3_accesskey=aws_access_key_id
#openshift_hosted_registry_storage_s3_secretkey=aws_secret_access_key
#openshift_hosted_registry_storage_s3_bucket=bucket_name
#openshift_hosted_registry_storage_s3_region=bucket_region
#openshift_hosted_registry_storage_s3_chunksize=26214400

# Configure the multi-tenant SDN plugin (default is 'redhat/openshift-ovs-subnet')
# os_sdn_network_plugin_name='redhat/openshift-ovs-multitenant'
Expand Down Expand Up @@ -334,57 +389,6 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
# Configure dnsIP in the node config
#openshift_dns_ip=172.30.0.1

# Persistent Storage Options
#
## Registry Storage Options
##
## Storage Kind
## Specifies which storage kind will be used for the registry.
## "nfs" and "openstack" are supported kinds at this time.
##openshift_hosted_registry_storage_kind=nfs
##
## Persistent Volume Access Mode
## When using the 'openstack' storage kind, this has to be 'ReadWriteOnce'
##openshift_hosted_registry_storage_access_modes=['ReadWriteMany']
##
## Registry Volume Name
## Specify the storage volume name. This directory will be created
## within openshift_hosted_registry_storage_nfs_directory if
## specifying an [nfs] group. Ex. /exports/registry
## This variable must be supplied if using a pre-existing nfs server.
##openshift_hosted_registry_storage_volume_name=registry
##
## NFS Specific Options
##
## Storage Host
## This variable can be used to identify a pre-existing storage host
## if a storage host group corresponding to the storage kind (such as
## [nfs]) is not specified,
##openshift_hosted_registry_storage_host=nfs.example.com
##
## NFS Export Options
##openshift_hosted_registry_storage_nfs_options='*(rw,root_squash)'
##
## NFS Export Directory
## Specify the root exports directory. This directory will be created
## if specifying an [nfs] host group.
## This variable must be supplied if using a pre-existing nfs server.
##openshift_hosted_registry_storage_nfs_directory=/exports
##
## Openstack Specific Options
##
## Openstack Volume ID
## Specify the identifier of the volume to use for the registry.
## At this time, the volume has to be created manually by the administrator.
##openshift_hosted_registry_storage_openstack_volumeID=3a650b4f-c8c5-4e0a-8ca5-eaee11f16c57
##
## Openstack Volume Size
##openshift_hosted_registry_storage_volume_size=10Gi
##
## Openstack Volume Filesystem
## Specify the filesystem that will be used when formatting the volume
##openshift_hosted_registry_storage_openstack_filesystem=ext4

# Configure node kubelet arguments
#openshift_node_kubelet_args={'max-pods': ['110'], 'image-gc-high-threshold': ['90'], 'image-gc-low-threshold': ['80']}

Expand Down
111 changes: 58 additions & 53 deletions inventory/byo/hosts.origin.example
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
#osm_mcs_labels_per_project=5
#osm_uid_allocator_range='1000000000-1999999999/10000'

# Configure additional projects
#openshift_additional_projects={'my-project': {'default_node_selector': 'label=value'}}

# Enable cockpit
#osm_use_cockpit=true
#
Expand Down Expand Up @@ -250,10 +253,15 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
# based on the number of nodes matching the openshift router selector.
#openshift_hosted_router_replicas=2
#
# Router force subdomain (optional)
# A router path format to force on all routes used by this router
# (will ignore the route host value)
#openshift_hosted_router_force_subdomain='${name}-${namespace}.apps.example.com'
#
# Router certificate (optional)
# Provide local certificate paths which will be configured as the
# router's default certificate.
#openshift_hosted_router_certificate={"certfile": "/path/to/router.crt", "keyfile": "/path/to/router.key"}
#openshift_hosted_router_certificate={"certfile": "/path/to/router.crt", "keyfile": "/path/to/router.key", "cafile": "/path/to/router-ca.crt"}

# Openshift Registry Options
#
Expand All @@ -269,7 +277,55 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
# Registry selector (optional)
# Registry will only be created if nodes matching this label are present.
# Default value: 'region=infra'
#openshift_registry_selector='region=infra'
#openshift_hosted_registry_selector='region=infra'
#
# Registry replicas (optional)
# Unless specified, openshift-ansible will calculate the replica count
# based on the number of nodes matching the openshift registry selector.
#openshift_hosted_registry_replicas=2

# Registry Storage Options
#
# NFS Host Group
# An NFS volume will be created with path "nfs_directory/volume_name"
# on the host within the [nfs] host group. For example, the volume
# path using these options would be "/exports/registry"
#openshift_hosted_registry_storage_kind=nfs
#openshift_hosted_registry_storage_access_modes=['ReadWriteMany']
#openshift_hosted_registry_storage_nfs_directory=/exports
#openshift_hosted_registry_storage_nfs_options='*(rw,root_squash)'
#openshift_hosted_registry_storage_volume_name=registry
#openshift_hosted_registry_storage_volume_size=10Gi
#
# External NFS Host
# NFS volume must already exist with path "nfs_directory/_volume_name" on
# the storage_host. For example, the remote volume path using these
# options would be "nfs.example.com:/exports/registry"
#openshift_hosted_registry_storage_kind=nfs
#openshift_hosted_registry_storage_access_modes=['ReadWriteMany']
#openshift_hosted_registry_storage_host=nfs.example.com
#openshift_hosted_registry_storage_nfs_directory=/exports
#openshift_hosted_registry_storage_volume_name=registry
#openshift_hosted_registry_storage_volume_size=10Gi
#
# Openstack
# Volume must already exist.
#openshift_hosted_registry_storage_kind=openstack
#openshift_hosted_registry_storage_access_modes=['ReadWriteOnce']
#openshift_hosted_registry_storage_openstack_filesystem=ext4
#openshift_hosted_registry_storage_openstack_volumeID=3a650b4f-c8c5-4e0a-8ca5-eaee11f16c57
#openshift_hosted_registry_storage_volume_size=10Gi
#
# AWS S3
# S3 bucket must already exist.
#openshift_hosted_registry_storage_kind=object
#openshift_hosted_registry_storage_provider=s3
#openshift_hosted_registry_storage_s3_accesskey=aws_access_key_id
#openshift_hosted_registry_storage_s3_secretkey=aws_secret_access_key
#openshift_hosted_registry_storage_s3_bucket=bucket_name
#openshift_hosted_registry_storage_s3_region=bucket_region
#openshift_hosted_registry_storage_s3_chunksize=26214400
#openshift_hosted_registry_pullthrough=true

# Configure the multi-tenant SDN plugin (default is 'redhat/openshift-ovs-subnet')
# os_sdn_network_plugin_name='redhat/openshift-ovs-multitenant'
Expand Down Expand Up @@ -340,57 +396,6 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
# Configure dnsIP in the node config
#openshift_dns_ip=172.30.0.1

# Persistent Storage Options
#
## Registry Storage Options
##
## Storage Kind
## Specifies which storage kind will be used for the registry.
## "nfs" and "openstack" are supported kinds at this time.
##openshift_hosted_registry_storage_kind=nfs
##
## Persistent Volume Access Mode
## When using the 'openstack' storage kind, this has to be 'ReadWriteOnce'
##openshift_hosted_registry_storage_access_modes=['ReadWriteMany']
##
## Registry Volume Name
## Specify the storage volume name. This directory will be created
## within openshift_hosted_registry_storage_nfs_directory if
## specifying an [nfs] group. Ex. /exports/registry
## This variable must be supplied if using a pre-existing nfs server.
##openshift_hosted_registry_storage_volume_name=registry
##
## NFS Specific Options
##
## Storage Host
## This variable can be used to identify a pre-existing storage host
## if a storage host group corresponding to the storage kind (such as
## [nfs]) is not specified,
##openshift_hosted_registry_storage_host=nfs.example.com
##
## NFS Export Options
##openshift_hosted_registry_storage_nfs_options='*(rw,root_squash)'
##
## NFS Export Directory
## Specify the root exports directory. This directory will be created
## if specifying an [nfs] host group.
## This variable must be supplied if using a pre-existing nfs server.
##openshift_hosted_registry_storage_nfs_directory=/exports
##
## Openstack Specific Options
##
## Openstack Volume ID
## Specify the identifier of the volume to use for the registry.
## At this time, the volume has to be created manually by the administrator.
##openshift_hosted_registry_storage_openstack_volumeID=3a650b4f-c8c5-4e0a-8ca5-eaee11f16c57
##
## Openstack Volume Size
##openshift_hosted_registry_storage_volume_size=10Gi
##
## Openstack Volume Filesystem
## Specify the filesystem that will be used when formatting the volume
##openshift_hosted_registry_storage_openstack_filesystem=ext4

# Configure node kubelet arguments
#openshift_node_kubelet_args={'max-pods': ['110'], 'image-gc-high-threshold': ['90'], 'image-gc-low-threshold': ['80']}

Expand Down
Loading

0 comments on commit 03f31fd

Please sign in to comment.