Exemple #1
0
    def create_one_quota(attrs=None):
        """Create a fake quota

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with project_id, resource and so on
        """

        attrs = attrs or {}

        quota_info = {
            'resource': 'Cluster',
            'created_at': '2017-09-15T05:40:34+00:00',
            'updated_at': '2017-09-15T05:40:34+00:00',
            'hard_limit': 1,
            'project_id': 'be24b6fba2ed4476b2bd01fa8f0ba74e',
            'id': 10,
            'name': 'fake-quota',
        }

        quota_info.update(attrs)
        quota = osc_fakes.FakeResource(info=copy.deepcopy(quota_info),
                                       loaded=True)
        return quota
Exemple #2
0
    def create_one_cluster_template(attrs=None):
        """Create a fake ClusterTemplate.

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with flavor_id, image_id, and so on
        """

        attrs = attrs or {}

        # set default attributes.
        ct_info = {
            'links': [],
            'insecure_registry': None,
            'labels': None,
            'updated_at': None,
            'floating_ip_enabled': True,
            'fixed_subnet': None,
            'master_flavor_id': None,
            'uuid': uuid.uuid4().hex,
            'no_proxy': None,
            'https_proxy': None,
            'tls_disabled': False,
            'keypair_id': None,
            'public': False,
            'http_proxy': None,
            'docker_volume_size': None,
            'server_type': 'vm',
            'external_network_id': 'public',
            'cluster_distro': 'fedora-atomic',
            'image_id': 'fedora-atomic-latest',
            'volume_driver': None,
            'registry_enabled': False,
            'docker_storage_driver': 'devicemapper',
            'apiserver_port': None,
            'name': 'fake-ct-' + uuid.uuid4().hex,
            'created_at': datetime.datetime.now(),
            'network_driver': 'flannel',
            'fixed_network': None,
            'coe': 'kubernetes',
            'flavor_id': 'm1.medium',
            'master_lb_enabled': False,
            'dns_nameserver': '8.8.8.8',
            'hidden': False
        }

        # Overwrite default attributes.
        ct_info.update(attrs)

        ct = osc_fakes.FakeResource(info=copy.deepcopy(ct_info), loaded=True)
        return ct
    def create_one_cluster(attrs=None):
        """Create a fake Cluster.

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with flavor_id, image_id, and so on
        """

        attrs = attrs or {}

        # set default attributes.
        cluster_info = {
            'status': 'CREATE_IN_PROGRESS',
            'health_status': 'HEALTHY',
            'cluster_template_id': 'fake-ct',
            'node_addresses': [],
            'uuid': '3a369884-b6ba-484f-a206-919b4b718aff',
            'stack_id': 'c4554582-77bd-4734-8f1a-72c3c40e5fb4',
            'status_reason': None,
            'labels': {},
            'labels_overridden': {},
            'labels_added': {},
            'labels_skipped': {},
            'created_at': '2017-03-16T18:40:39+00:00',
            'updated_at': '2017-03-16T18:40:45+00:00',
            'coe_version': None,
            'faults': None,
            'keypair': 'fakekey',
            'api_address': None,
            'master_addresses': [],
            'create_timeout': 60,
            'node_count': 1,
            'discovery_url': 'https://fake.cluster',
            'master_count': 1,
            'container_version': None,
            'name': 'fake-cluster',
            'master_flavor_id': None,
            'flavor_id': 'm1.medium',
            'project_id': None,
            'health_status_reason': {
                'api': 'ok'
            }
        }

        # Overwrite default attributes.
        cluster_info.update(attrs)

        cluster = osc_fakes.FakeResource(info=copy.deepcopy(cluster_info),
                                         loaded=True)
        return cluster
    def create_one_nodegroup(attrs=None):
        """Create a fake NodeGroup.

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A FakeResource object, with flavor_id, image_id, and so on
        """

        attrs = attrs or {}

        # set default attributes.
        nodegroup_info = {
            'created_at': '2017-03-16T18:40:39+00:00',
            'updated_at': '2017-03-16T18:40:45+00:00',
            'uuid': '3a369884-b6ba-484f-a206-919b4b718aff',
            'cluster_id': 'fake-cluster',
            'docker_volume_size': None,
            'node_addresses': [],
            'labels': {},
            'labels_overridden': {},
            'labels_added': {},
            'labels_skipped': {},
            'node_count': 1,
            'name': 'fake-nodegroup',
            'flavor_id': 'm1.medium',
            'image_id': 'fedora-latest',
            'project_id': None,
            'role': 'worker',
            'max_node_count': 10,
            'min_node_count': 1,
            'is_default': False,
            'stack_id': '3a369884-b6ba-484f-fake-stackb718aff',
            'status': 'CREATE_COMPLETE',
            'status_reason': 'None'
        }

        # Overwrite default attributes.
        nodegroup_info.update(attrs)

        nodegroup = osc_fakes.FakeResource(info=copy.deepcopy(nodegroup_info),
                                           loaded=True)
        return nodegroup