Пример #1
0
def stop(**kwargs):
    gcp_config = utils.get_gcp_config()
    name = ctx.instance.runtime_properties.get('name')
    if name:
        cluster = Cluster(gcp_config,
                          ctx.logger,
                          name=name,)
        utils.delete_if_not_external(cluster)
def disable_legacy_abac(**kwargs):
    gcp_config = utils.get_gcp_config()
    cluster_id = ctx.node.properties.get('cluster_id')
    if cluster_id:
        # Before update legacy abac to the cluster we should check the
        # status of the cluster if it is running or not
        legacy_abac = LegacyAbac(gcp_config, ctx.logger,
                                 enabled=False, cluster_id=cluster_id, )
        utils.delete_if_not_external(legacy_abac)
Пример #3
0
    def test_create_delete_resource_external(self, *args):
        self.ctxmock.node.properties['use_external_resource'] = True
        self.ctxmock.node.properties['name'] = 'name-in-properties'

        resource = MagicMock()
        utils.create(resource)
        utils.delete_if_not_external(resource)
        self.assertIsNone(
            self.ctxmock.instance.runtime_properties.get('resource_id'))
    def test_create_delete_resource_external(self, *args):
        self.ctxmock.node.properties['use_external_resource'] = True
        self.ctxmock.node.properties['name'] = 'name-in-properties'

        resource = MagicMock()
        utils.create(resource)
        utils.delete_if_not_external(resource)
        self.assertIsNone(self.ctxmock.instance.runtime_properties.get(
            'resource_id'))
Пример #5
0
def stop(**kwargs):
    gcp_config = utils.get_gcp_config()
    name = ctx.instance.runtime_properties.get(constants.NAME)
    cluster_id = ctx.instance.runtime_properties.get('cluster_id')
    if name:

        node_pool = NodePool(gcp_config, ctx.logger,
                             name=name, cluster_id=cluster_id,)

        utils.delete_if_not_external(node_pool)
Пример #6
0
def stop(**kwargs):
    gcp_config = utils.get_gcp_config()
    name = ctx.instance.runtime_properties.get(constants.NAME)
    if name:
        cluster = Cluster(
            gcp_config,
            ctx.logger,
            name=name,
        )
        utils.delete_if_not_external(cluster)
def unset_monitoring_service(**kwargs):
    gcp_config = utils.get_gcp_config()
    cluster_id = ctx.node.properties.get('cluster_id')
    if cluster_id:
        # Before update monitoring service to the cluster we should check the
        # status of the cluster if it is running or not
        service = MonitoringService(gcp_config, ctx.logger,
                                    service_type='none',
                                    cluster_id=cluster_id, )

        utils.delete_if_not_external(service)
Пример #8
0
def unset_monitoring_service(**kwargs):
    gcp_config = utils.get_gcp_config()
    cluster_id = ctx.node.properties.get('cluster_id')
    if cluster_id:
        # Before update monitoring service to the cluster we should check the
        # status of the cluster if it is running or not
        service = MonitoringService(gcp_config, ctx.logger,
                                    service_type='none',
                                    cluster_id=cluster_id, )

        utils.delete_if_not_external(service)
def delete_network_policy_config(**kwargs):
    gcp_config = utils.get_gcp_config()
    cluster_id = ctx.instance.runtime_properties['cluster_id']
    network_policy_config = {'enabled': False,
                             'provider': 'PROVIDER_UNSPECIFIED'
                             }
    if cluster_id:
        network_policy = \
            NetworkPolicy(gcp_config, ctx.logger,
                          network_policy_config=network_policy_config,
                          cluster_id=cluster_id,)
        utils.delete_if_not_external(network_policy)
Пример #10
0
def disable_legacy_abac(**kwargs):
    gcp_config = utils.get_gcp_config()
    cluster_id = ctx.node.properties.get('cluster_id')
    if cluster_id:
        # Before update legacy abac to the cluster we should check the
        # status of the cluster if it is running or not
        legacy_abac = LegacyAbac(
            gcp_config,
            ctx.logger,
            enabled=False,
            cluster_id=cluster_id,
        )
        utils.delete_if_not_external(legacy_abac)
def stop(**kwargs):
    gcp_config = utils.get_gcp_config()
    name = ctx.instance.runtime_properties.get('name')
    cluster_id = ctx.instance.runtime_properties.get('cluster_id')
    if name:

        node_pool = NodePool(gcp_config, ctx.logger,
                             name=name, cluster_id=cluster_id,)

        remote_mode = get_node(node_pool)
        if remote_mode:
            utils.delete_if_not_external(node_pool)
        else:
            ctx.operation.retry(
                'Node pool {0} stopped'.format(name))