Example #1
0
def delete(**kwargs):
    use_existing, router_dict = common.get_properties('router', kwargs)

    if use_existing:
        nsx_dlr.remove_properties_edges()
        ctx.logger.info("Used pre existed!")
        return

    resource_id = ctx.instance.runtime_properties.get('resource_id')
    if not resource_id:
        nsx_dlr.remove_properties_edges()
        ctx.logger.info("We dont have resource_id")
        return

    # credentials
    client_session = common.nsx_login(kwargs)

    common.attempt_with_rerun(
        nsx_dlr.del_edge,
        client_session=client_session,
        resource_id=resource_id
    )

    ctx.logger.info("deleted %s" % resource_id)

    nsx_dlr.remove_properties_edges()
Example #2
0
def delete(**kwargs):
    use_existing, dynamic_member = common.get_properties(
        'dynamic_member', kwargs)

    if use_existing:
        common.remove_properties('dynamic_member')
        ctx.logger.info("Used existed")
        return

    resource_id = ctx.instance.runtime_properties.get('resource_id')
    if not resource_id:
        common.remove_properties('dynamic_member')
        ctx.logger.info("Not fully created, skip")
        return

    # credentials
    client_session = common.nsx_login(kwargs)

    common.attempt_with_rerun(nsx_security_group.del_dynamic_member,
                              client_session=client_session,
                              security_group_id=resource_id)

    ctx.logger.info("delete %s" % resource_id)

    common.remove_properties('dynamic_member')
Example #3
0
def delete(**kwargs):
    use_existing, interface = common.get_properties('interface', kwargs)

    if use_existing:
        common.remove_properties('interface')
        common.remove_properties('ifindex')
        ctx.logger.info("Used existed")
        return

    resource_id = ctx.instance.runtime_properties.get('resource_id')
    if not resource_id:
        common.remove_properties('interface')
        common.remove_properties('ifindex')
        ctx.logger.info("Not fully created, skip")
        return

    # credentials
    client_session = common.nsx_login(kwargs)

    common.attempt_with_rerun(nsx_esg.esg_clear_interface,
                              client_session=client_session,
                              resource_id=resource_id)

    ctx.logger.info("delete %s" % resource_id)

    common.remove_properties('interface')
    common.remove_properties('ifindex')
Example #4
0
    def test_attempt_with_rerun(self):
        """Check nsx_common.attempt_with_rerun func"""
        self._regen_ctx()

        def func_error(need_error):
            if need_error:
                raise need_error()

        common.attempt_with_rerun(func_error, need_error=False)

        fake_sleep = mock.MagicMock()
        with mock.patch(
            'time.sleep',
            fake_sleep
        ):
            with self.assertRaises(cfy_exc.NonRecoverableError):
                common.attempt_with_rerun(
                    func_error, need_error=cfy_exc.NonRecoverableError
                )
            fake_sleep.assert_not_called()

            with self.assertRaises(cfy_exc.RecoverableError):
                common.attempt_with_rerun(
                    func_error, need_error=cfy_exc.RecoverableError
                )
            fake_sleep.assert_called_with(30)
Example #5
0
def delete(**kwargs):
    use_existing, area = common.get_properties('prefix', kwargs)

    if use_existing:
        common.remove_properties('prefix')
        ctx.logger.info("Used existed")
        return

    resource_id = ctx.instance.runtime_properties.get('resource_id')
    if not resource_id:
        common.remove_properties('prefix')
        ctx.logger.info("Not fully created, skip")
        return

    # credentials
    client_session = common.nsx_login(kwargs)

    common.attempt_with_rerun(cfy_dlr.del_routing_prefix,
                              client_session=client_session,
                              resource_id=resource_id)

    ctx.logger.info("deleted %s" % resource_id)

    common.remove_properties('prefix')